From 7d3548956eb121f501f0af3d7997ccc526f505a5 Mon Sep 17 00:00:00 2001 From: Matsv Date: Sat, 1 Oct 2016 20:56:14 +0200 Subject: [PATCH] Fix 16w39c --- .../api/entities/Entity1_11Types.java | 12 ++--- .../MetadataRewriter.java | 51 ++++++++++--------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_11Types.java b/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_11Types.java index a04c8fe25..d091f9ba0 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_11Types.java +++ b/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_11Types.java @@ -160,10 +160,6 @@ public class Entity1_11Types { return Optional.absent(); } - public boolean is(EntityType type) { - return this == type; - } - public boolean is(EntityType... types) { for (EntityType type : types) if (is(type)) @@ -171,14 +167,18 @@ public class Entity1_11Types { return false; } + public boolean is(EntityType type) { + return this == type; + } + public boolean isOrHasParent(EntityType type) { EntityType parent = this; do { - if (parent == type) + if (parent.equals(type)) return true; - parent = type.getParent(); + parent = parent.getParent(); } while (parent != null); return false; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/MetadataRewriter.java index 4d382f9eb..e4aa98f6f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/MetadataRewriter.java @@ -161,32 +161,32 @@ public class MetadataRewriter { } } } - if (type.is(EntityType.ARMOR_STAND) && Via.getConfig().isHologramPatch()) { - Optional flags = getById(metadatas, 11); - Optional customName = getById(metadatas, 2); - Optional customNameVisible = getById(metadatas, 3); - if (metadata.getId() == 0 && flags.isPresent() && customName.isPresent() && customNameVisible.isPresent()) { - Metadata meta = flags.get(); - byte data = (byte) metadata.getValue(); - // Check invisible | Check small | Check if custom name is empty | Check if custom name visible is true - if ((data & 0x20) == 0x20 && ((byte) meta.getValue() & 0x01) == 0x01 - && ((String) customName.get().getValue()).length() != 0 && (boolean) customNameVisible.get().getValue()) { - EntityTracker tracker = connection.get(EntityTracker.class); - if (!tracker.isHologram(entityId)) { - tracker.addHologram(entityId); - try { - // Send movement - PacketWrapper wrapper = new PacketWrapper(0x25, null, connection); - wrapper.write(Type.VAR_INT, entityId); - wrapper.write(Type.SHORT, (short) 0); - wrapper.write(Type.SHORT, (short) (128D * (-Via.getConfig().getHologramYOffset() * 32D))); - wrapper.write(Type.SHORT, (short) 0); - wrapper.write(Type.BOOLEAN, true); + } + if (type.is(EntityType.ARMOR_STAND) && Via.getConfig().isHologramPatch()) { + Optional flags = getById(metadatas, 11); + Optional customName = getById(metadatas, 2); + Optional customNameVisible = getById(metadatas, 3); + if (metadata.getId() == 0 && flags.isPresent() && customName.isPresent() && customNameVisible.isPresent()) { + Metadata meta = flags.get(); + byte data = (byte) metadata.getValue(); + // Check invisible | Check small | Check if custom name is empty | Check if custom name visible is true + if ((data & 0x20) == 0x20 && ((byte) meta.getValue() & 0x01) == 0x01 + && ((String) customName.get().getValue()).length() != 0 && (boolean) customNameVisible.get().getValue()) { + EntityTracker tracker = connection.get(EntityTracker.class); + if (!tracker.isHologram(entityId)) { + tracker.addHologram(entityId); + try { + // Send movement + PacketWrapper wrapper = new PacketWrapper(0x25, null, connection); + wrapper.write(Type.VAR_INT, entityId); + wrapper.write(Type.SHORT, (short) 0); + wrapper.write(Type.SHORT, (short) (128D * (-Via.getConfig().getHologramYOffset() * 32D))); + wrapper.write(Type.SHORT, (short) 0); + wrapper.write(Type.BOOLEAN, true); - wrapper.send(ProtocolSnapshotTo1_10.class); - } catch (Exception e) { - e.printStackTrace(); - } + wrapper.send(ProtocolSnapshotTo1_10.class); + } catch (Exception e) { + e.printStackTrace(); } } } @@ -201,6 +201,7 @@ public class MetadataRewriter { } } } + } public static Optional getById(List metadatas, int id) {