From 4e4b35b2e77d86faaef3c0d1a06ba9a51c07e003 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Mon, 19 Feb 2018 14:42:54 -0300 Subject: [PATCH] 18w07c - Fix skull handler --- .../providers/blockentities/SkullHandler.java | 35 +++++-------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java index f8fa7db94..1820909a8 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java @@ -8,6 +8,8 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEnt import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage; public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { + private final int SKULL_WALL_START = 4669; + private final int SKULL_END = 4788; @Override public int transform(UserConnection user, CompoundTag tag) { BlockStorage storage = user.get(BlockStorage.class); @@ -18,36 +20,15 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { return -1; } - int data = storage.get(position).getOriginal() & 0xF; + int id = storage.get(position).getOriginal(); - byte type = (Byte) tag.get("SkullType").getValue(); - - int add = 0; - - // wall head start - int blockId = 4669; - - switch (data % 6) { - case 1: - add = (Byte) tag.get("Rot").getValue() + 4; - break; - case 2: - add = 0; - break; - case 3: - add = 2; - break; - case 4: - add = 3; - break; - case 5: - add = 1; - break; + if (id >= SKULL_WALL_START && id <= SKULL_END) { + id += (byte) tag.get("SkullType").getValue() * 20 + (byte) tag.get("Rot").getValue(); + } else { + System.out.println("Why does this block have the skull block entity? :(" + tag); } - blockId += add + type * 20; - - return blockId; + return id; } private long getLong(Tag tag) { return ((Integer) tag.getValue()).longValue();