From 87e372ce217c2b595f03503a8cc74512e11db480 Mon Sep 17 00:00:00 2001 From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com> Date: Tue, 14 Apr 2020 19:34:11 -0400 Subject: [PATCH] Put everything into bedrock mapping --- .../translators/block/BlockTranslator.java | 165 +----------------- 1 file changed, 6 insertions(+), 159 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java index 14a821c0d..a495a8224 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java @@ -149,168 +149,15 @@ public class BlockTranslator { JAVA_ID_TO_BLOCK_ENTITY_MAP.put(javaBlockState, javaId); } - int lastIndex = javaId.length() -1; - byte rotation = 0; - if (javaId.contains("skeleton_skull[")) { - if (javaId.indexOf("=") == lastIndex - 2) { - rotation = Byte.parseByte(javaId.substring(lastIndex -1, lastIndex)); - } - else { - rotation = Byte.parseByte(javaId.substring(lastIndex -2, lastIndex)); - } - SKULL_VARIANTS.put(javaBlockState, (byte) 0); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - else if (javaId.contains("skeleton_wall")) { - if (javaId.contains("north")) { - rotation = 0; - } - else if (javaId.contains("east")) { - rotation = 4; - } - else if (javaId.contains("south")) { - rotation = 8; - } - else if(javaId.contains("west")) { - rotation = 12; - } - SKULL_VARIANTS.put(javaBlockState, (byte) 0); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - if (javaId.contains("wither_skeleton_skull[")) { - if (javaId.indexOf("=") == lastIndex - 2) { - rotation = Byte.parseByte(javaId.substring(lastIndex -1, lastIndex)); + JsonNode skullVariation = entry.getValue().get("variation"); + if(skullVariation != null) { + SKULL_VARIANTS.put(javaBlockState, (byte) skullVariation.intValue()); } - else { - rotation = Byte.parseByte(javaId.substring(lastIndex -2, lastIndex)); - } - SKULL_VARIANTS.put(javaBlockState, (byte) 1); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - else if (javaId.contains("wither_skeleton_wall")) { - if (javaId.contains("north")) { - rotation = 0; - } - else if (javaId.contains("east")) { - rotation = 4; - } - else if (javaId.contains("south")) { - rotation = 8; - } - else if(javaId.contains("west")) { - rotation = 12; - } - SKULL_VARIANTS.put(javaBlockState, (byte) 1); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - if (javaId.contains("zombie_head[")) { - if (javaId.indexOf("=") == lastIndex - 2) { - rotation = Byte.parseByte(javaId.substring(lastIndex -1, lastIndex)); - } - else { - rotation = Byte.parseByte(javaId.substring(lastIndex -2, lastIndex)); - } - SKULL_VARIANTS.put(javaBlockState, (byte) 2); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - else if (javaId.contains("zombie_wall")) { - if (javaId.contains("north")) { - rotation = 0; - } - else if (javaId.contains("east")) { - rotation = 4; - } - else if (javaId.contains("south")) { - rotation = 8; - } - else if(javaId.contains("west")) { - rotation = 12; - } - SKULL_VARIANTS.put(javaBlockState, (byte) 2); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - - if (javaId.contains("player_head[")) { - if (javaId.indexOf("=") == lastIndex - 2) { - rotation = Byte.parseByte(javaId.substring(lastIndex -1, lastIndex)); - } - else { - rotation = Byte.parseByte(javaId.substring(lastIndex -2, lastIndex)); - } - SKULL_VARIANTS.put(javaBlockState, (byte) 3); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - else if (javaId.contains("player_wall")) { - if (javaId.contains("north")) { - rotation = 0; - } - else if (javaId.contains("east")) { - rotation = 4; - } - else if (javaId.contains("south")) { - rotation = 8; - } - else if(javaId.contains("west")) { - rotation = 12; - } - SKULL_VARIANTS.put(javaBlockState, (byte) 3); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - - if (javaId.contains("creeper_head[")) { - if (javaId.indexOf("=") == lastIndex - 2) { - rotation = Byte.parseByte(javaId.substring(lastIndex -1, lastIndex)); - } - else { - rotation = Byte.parseByte(javaId.substring(lastIndex -2, lastIndex)); - } - SKULL_VARIANTS.put(javaBlockState, (byte) 4); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - else if (javaId.contains("creeper_wall")) { - if (javaId.contains("north")) { - rotation = 0; - } - else if (javaId.contains("east")) { - rotation = 4; - } - else if (javaId.contains("south")) { - rotation = 8; - } - else if(javaId.contains("west")) { - rotation = 12; - } - SKULL_VARIANTS.put(javaBlockState, (byte) 4); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - - if (javaId.contains("dragon_head[")) { - if (javaId.indexOf("=") == lastIndex - 2) { - rotation = Byte.parseByte(javaId.substring(lastIndex -1, lastIndex)); - } - else { - rotation = Byte.parseByte(javaId.substring(lastIndex -2, lastIndex)); - } - SKULL_VARIANTS.put(javaBlockState, (byte) 5); - SKULL_ROTATIONS.put(javaBlockState, rotation); - } - else if (javaId.contains("dragon_wall")) { - if (javaId.contains("north")) { - rotation = 0; - } - else if (javaId.contains("east")) { - rotation = 4; - } - else if (javaId.contains("south")) { - rotation = 8; - } - else if(javaId.contains("west")) { - rotation = 12; - } - SKULL_VARIANTS.put(javaBlockState, (byte) 5); - SKULL_ROTATIONS.put(javaBlockState, rotation); + JsonNode skullRotation = entry.getValue().get("skull_rotation"); + if (skullRotation != null) { + SKULL_ROTATIONS.put(javaBlockState, (byte) skullRotation.intValue()); } // If the Java ID is bed, signal that it needs a tag to show color