Fix custom names in 1.9

This commit is contained in:
git 2016-03-08 16:11:12 +13:00
parent 280d03daa7
commit 0f752fb7e3
2 changed files with 69 additions and 30 deletions

View File

@ -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)
{
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,30 +539,39 @@ 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);
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;
@ -553,17 +579,29 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
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);
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];
@ -571,6 +609,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
UtilPlayer.sendPacket(owner, vehiclePacket);
}
}
else
{
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();

View File

@ -917,7 +917,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> 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);