From 0f752fb7e3ea53df4a8dbd3f1115b58434190724 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 8 Mar 2016 16:11:12 +1300 Subject: [PATCH] Fix custom names in 1.9 --- .../src/mineplex/core/CustomTagFix.java | 97 +++++++++++++------ .../mineplex/core/bonuses/BonusManager.java | 2 +- 2 files changed, 69 insertions(+), 30 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 6f14c0810..a4285980f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -28,6 +28,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; @@ -67,9 +68,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { super("Custom Tag Fix", plugin); - packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, - PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, - PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class); + packetHandler.addPacketHandler(this, true, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class, + PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class, + PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class, PacketPlayOutNewAttachEntity.class); // NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); // NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); @@ -452,9 +453,25 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } } } - else if (packet instanceof PacketPlayOutAttachEntity) + else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity) { - PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; + int vech = -1; + int rider = -1; + + if (packet instanceof PacketPlayOutAttachEntity) + { + PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; + vech = attachPacket.b; + rider = attachPacket.c; + } + else if (packet instanceof PacketPlayOutNewAttachEntity) + { + PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet; + vech = attachPacket.a; + + if (attachPacket.b.length > 0) + rider = attachPacket.b[0]; + } // c = rider, b = ridden // When detaching, c is sent, b is -1 @@ -473,27 +490,27 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook int vehicleId = -1; - if (_entityRiding.get(owner.getName()).containsKey(attachPacket.b)) + if (_entityRiding.get(owner.getName()).containsKey(vech)) { - vehicleId = _entityRiding.get(owner.getName()).get(attachPacket.b); + vehicleId = _entityRiding.get(owner.getName()).get(vech); } - if (attachPacket.c == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId)) + if (rider == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId)) { Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId); - _entityRiding.get(owner.getName()).remove(attachPacket.b); + _entityRiding.get(owner.getName()).remove(vech); sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true, ids); } else { - Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c); + Integer[] ids = _entityMap.get(owner.getName()).get(rider); - if (ids != null && ids[1] != attachPacket.b) + if (ids != null && ids[1] != vech) { - _entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c); + _entityRiding.get(owner.getName()).put(vech, rider); int[] newIds = new int[ids.length]; @@ -522,54 +539,76 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); - watcher.a(0, (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5)); // Invisible + watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); // Invisible watcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 0); watcher.a(2, finalEntityName, Entity.META_CUSTOMNAME, finalEntityName); watcher.a(3, (byte) 1, Entity.META_CUSTOMNAME_VISIBLE, true); - watcher.a(10, (byte) (0 | 0x1), EntityArmorStand.META_ARMOR_OPTION, (byte) (0 | 0x1)); // Small + watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); // Small if (newPacket) { { - watcher.watch(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); - DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); - squidWatcher.a(0, (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5)); + squidWatcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); spawnPacket.a = entityIds[1]; spawnPacket.b = (byte) EntityType.SQUID.getTypeId(); - spawnPacket.c = 1000000; + spawnPacket.c = owner.getLocation().getBlockX() * 32; + spawnPacket.d = -150; + spawnPacket.e = owner.getLocation().getBlockZ() * 32; spawnPacket.l = squidWatcher; spawnPacket.uuid = UUID.randomUUID(); UtilPlayer.sendPacket(owner, spawnPacket); - PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); - vehiclePacket.a = 0; - vehiclePacket.b = spawnPacket.a; - vehiclePacket.c = entityId; + if (UtilPlayer.is1_9(owner)) + { + UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[] + { + entityIds[1] + })); + } + else + { + PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); + vehiclePacket.a = 0; + vehiclePacket.b = spawnPacket.a; + vehiclePacket.c = entityId; - UtilPlayer.sendPacket(owner, vehiclePacket); + UtilPlayer.sendPacket(owner, vehiclePacket); + } } PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); spawnPacket.a = entityIds[0]; spawnPacket.b = (byte) 30; - spawnPacket.c = 1000000; + spawnPacket.c = owner.getLocation().getBlockX() * 32; + spawnPacket.d = -150; + spawnPacket.e = owner.getLocation().getBlockZ() * 32; spawnPacket.l = watcher; spawnPacket.uuid = UUID.randomUUID(); UtilPlayer.sendPacket(owner, spawnPacket); - PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); - vehiclePacket.a = 0; - vehiclePacket.b = entityIds[0]; - vehiclePacket.c = entityIds[1]; + if (UtilPlayer.is1_9(owner)) + { + UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[] + { + entityIds[0] + })); + } + else + { + PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); + vehiclePacket.a = 0; + vehiclePacket.b = entityIds[0]; + vehiclePacket.c = entityIds[1]; - UtilPlayer.sendPacket(owner, vehiclePacket); + UtilPlayer.sendPacket(owner, vehiclePacket); + } } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index be8ddbe84..9410fb7a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -917,7 +917,7 @@ public class BonusManager extends MiniClientPlugin implements I if (client.getHologram() == null) { - double yAdd = 2.18; + double yAdd = 2.3; hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), ""); hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); hologram.addPlayer(player);