From 08eb99fa9492b455e8286c804b3d31383b50ad2a Mon Sep 17 00:00:00 2001 From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com> Date: Tue, 14 Apr 2020 18:33:55 -0400 Subject: [PATCH 1/6] Implement skulls and heads --- .../translators/block/BlockTranslator.java | 180 ++++++++++++++++++ .../entity/SkullBlockEntityTranslator.java | 49 +++++ .../java/world/JavaChunkDataTranslator.java | 4 + .../geysermc/connector/utils/ChunkUtils.java | 8 + 4 files changed, 241 insertions(+) create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java 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 1ffaa3bd7..14a821c0d 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 @@ -67,6 +67,8 @@ public class BlockTranslator { private static final Map JAVA_ID_TO_BLOCK_ENTITY_MAP = new HashMap<>(); private static final Object2ByteMap BED_COLORS = new Object2ByteOpenHashMap<>(); + private static final Object2ByteMap SKULL_VARIANTS = new Object2ByteOpenHashMap<>(); + private static final Object2ByteMap SKULL_ROTATIONS = new Object2ByteOpenHashMap<>(); public static final Int2DoubleMap JAVA_RUNTIME_ID_TO_HARDNESS = new Int2DoubleOpenHashMap(); public static final Int2BooleanMap JAVA_RUNTIME_ID_TO_CAN_HARVEST_WITH_HAND = new Int2BooleanOpenHashMap(); @@ -147,6 +149,170 @@ 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)); + } + 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); + } + // If the Java ID is bed, signal that it needs a tag to show color // The color is in the namespace ID in Java Edition but it's a tag in Bedrock. JsonNode bedColor = entry.getValue().get("bed_color"); @@ -268,6 +434,20 @@ public class BlockTranslator { return -1; } + public static byte getSkullVariant(BlockState state) { + if (SKULL_VARIANTS.containsKey(state)) { + return SKULL_VARIANTS.getByte(state); + } + return 0; + } + + public static byte getSkullRotation(BlockState state) { + if (SKULL_ROTATIONS.containsKey(state)) { + return SKULL_ROTATIONS.getByte(state); + } + return 0; + } + public static BlockState getJavaWaterloggedState(int bedrockId) { return BEDROCK_TO_JAVA_BLOCK_MAP.get(1 << 31 | bedrockId); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java new file mode 100644 index 000000000..e4ace6e35 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java @@ -0,0 +1,49 @@ +package org.geysermc.connector.network.translators.block.entity; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; +import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; +import com.github.steveice10.mc.protocol.data.message.Message; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.nukkitx.math.vector.Vector3i; +import com.nukkitx.nbt.CompoundTagBuilder; +import com.nukkitx.nbt.tag.StringTag; +import com.nukkitx.nbt.tag.Tag; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.block.BlockTranslator; +import org.geysermc.connector.utils.BlockEntityUtils; +import org.geysermc.connector.utils.MessageUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +public class SkullBlockEntityTranslator { + + public static void checkForSkullVariant(GeyserSession session, BlockState blockState, Vector3i position) { + byte skullVariant = BlockTranslator.getSkullVariant(blockState); + byte rotation = BlockTranslator.getSkullRotation(blockState); + // If Bed Color is not -1 then it is indeed a bed with a color. + if (skullVariant > 0) { + Position pos = new Position(position.getX(), position.getY(), position.getZ()); + com.nukkitx.nbt.tag.CompoundTag finalSkullTag = getSkullTag(skullVariant, pos, rotation); + // Delay needed, otherwise newly placed beds will not get their color + // Delay is not needed for beds already placed on login + session.getConnector().getGeneralThreadPool().schedule(() -> + BlockEntityUtils.updateBlockEntity(session, finalSkullTag, pos), + 500, + TimeUnit.MILLISECONDS + ); + } + } + + public static com.nukkitx.nbt.tag.CompoundTag getSkullTag(byte skullvariant, Position pos, byte rotation) { + CompoundTagBuilder tagBuilder = CompoundTagBuilder.builder() + .intTag("x", pos.getX()) + .intTag("y", pos.getY()) + .intTag("z", pos.getZ()) + .stringTag("id", "Skull") + .floatTag("Rotation", rotation * 22.5f); + tagBuilder.byteTag("SkullType", skullvariant); + return tagBuilder.buildRootTag(); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java index 4f6d1bc6b..9309ca758 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java @@ -120,9 +120,13 @@ public class JavaChunkDataTranslator extends PacketTranslator blockEntityEntry: chunkData.beds.entrySet()) { ChunkUtils.updateBlock(session, blockEntityEntry.getValue(), blockEntityEntry.getKey()); } + for (Map.Entry blockEntityEntry: chunkData.skulls.entrySet()) { + ChunkUtils.updateBlock(session, blockEntityEntry.getValue(), blockEntityEntry.getKey()); + } chunkData.signs.clear(); chunkData.gateways.clear(); chunkData.beds.clear(); + chunkData.skulls.clear(); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index c6851770c..737dfd738 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -42,6 +42,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator; +import org.geysermc.connector.network.translators.block.entity.SkullBlockEntityTranslator; import org.geysermc.connector.world.chunk.ChunkPosition; import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.block.BlockTranslator; @@ -86,6 +87,11 @@ public class ChunkUtils { // Beds need to be updated separately to add the bed color tag // Previously this was done by matching block state but this resulted in only one bed per color+orientation showing chunkData.beds.put(pos, blockState); + } else if (BlockTranslator.getSkullVariant(blockState) > 0) { + Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z); + // Beds need to be updated separately to add the bed color tag + // Previously this was done by matching block state but this resulted in only one bed per color+orientation showing + chunkData.skulls.put(pos, blockState); } else { section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id); } @@ -160,6 +166,7 @@ public class ChunkUtils { // Since Java stores bed colors as part of the namespaced ID and Bedrock stores it as a tag // This is the only place I could find that interacts with the Java block state and block updates BedBlockEntityTranslator.checkForBedColor(session, blockState, position); + SkullBlockEntityTranslator.checkForSkullVariant(session, blockState, position); } public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius, boolean forceUpdate) { @@ -194,5 +201,6 @@ public class ChunkUtils { public Object2IntMap signs = new Object2IntOpenHashMap<>(); public Object2IntMap gateways = new Object2IntOpenHashMap<>(); public Map beds = new HashMap<>(); + public Map skulls = new HashMap<>(); } } From 3972cc7f873358958fdfb632ae6b9bcb70f64e9e Mon Sep 17 00:00:00 2001 From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com> Date: Tue, 14 Apr 2020 18:40:05 -0400 Subject: [PATCH 2/6] Fix comments --- .../block/entity/SkullBlockEntityTranslator.java | 7 +++---- .../main/java/org/geysermc/connector/utils/ChunkUtils.java | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java index e4ace6e35..e7fd3a3de 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java @@ -22,12 +22,11 @@ public class SkullBlockEntityTranslator { public static void checkForSkullVariant(GeyserSession session, BlockState blockState, Vector3i position) { byte skullVariant = BlockTranslator.getSkullVariant(blockState); byte rotation = BlockTranslator.getSkullRotation(blockState); - // If Bed Color is not -1 then it is indeed a bed with a color. - if (skullVariant > 0) { + if (skullVariant > -1) { Position pos = new Position(position.getX(), position.getY(), position.getZ()); com.nukkitx.nbt.tag.CompoundTag finalSkullTag = getSkullTag(skullVariant, pos, rotation); - // Delay needed, otherwise newly placed beds will not get their color - // Delay is not needed for beds already placed on login + // Delay needed, otherwise newly placed skulls will not appear + // Delay is not needed for skulls already placed on login session.getConnector().getGeneralThreadPool().schedule(() -> BlockEntityUtils.updateBlockEntity(session, finalSkullTag, pos), 500, diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index 737dfd738..c75664b8f 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -89,8 +89,7 @@ public class ChunkUtils { chunkData.beds.put(pos, blockState); } else if (BlockTranslator.getSkullVariant(blockState) > 0) { Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z); - // Beds need to be updated separately to add the bed color tag - // Previously this was done by matching block state but this resulted in only one bed per color+orientation showing + //Doing the same stuff as beds chunkData.skulls.put(pos, blockState); } else { section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id); 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 3/6] 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 From 9bd1c0fc702bb4f2b0fbdcfb2b6a6123c78a27da Mon Sep 17 00:00:00 2001 From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com> Date: Tue, 14 Apr 2020 20:08:48 -0400 Subject: [PATCH 4/6] Cleanup some code --- .../network/translators/block/BlockTranslator.java | 10 +++++----- .../block/entity/SkullBlockEntityTranslator.java | 12 +++--------- 2 files changed, 8 insertions(+), 14 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 a495a8224..2a6b3c98d 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 @@ -151,13 +151,13 @@ public class BlockTranslator { JsonNode skullVariation = entry.getValue().get("variation"); - if(skullVariation != null) { - SKULL_VARIANTS.put(javaBlockState, (byte) skullVariation.intValue()); - } + if(skullVariation != null) { + SKULL_VARIANTS.put(javaBlockState, (byte) skullVariation.intValue()); + } JsonNode skullRotation = entry.getValue().get("skull_rotation"); - if (skullRotation != null) { - SKULL_ROTATIONS.put(javaBlockState, (byte) skullRotation.intValue()); + 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 diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java index e7fd3a3de..67bcdddda 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java @@ -2,19 +2,13 @@ package org.geysermc.connector.network.translators.block.entity; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; -import com.github.steveice10.mc.protocol.data.message.Message; -import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.nukkitx.math.vector.Vector3i; import com.nukkitx.nbt.CompoundTagBuilder; -import com.nukkitx.nbt.tag.StringTag; -import com.nukkitx.nbt.tag.Tag; +import com.nukkitx.nbt.tag.CompoundTag; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.utils.BlockEntityUtils; -import org.geysermc.connector.utils.MessageUtils; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.TimeUnit; public class SkullBlockEntityTranslator { @@ -24,7 +18,7 @@ public class SkullBlockEntityTranslator { byte rotation = BlockTranslator.getSkullRotation(blockState); if (skullVariant > -1) { Position pos = new Position(position.getX(), position.getY(), position.getZ()); - com.nukkitx.nbt.tag.CompoundTag finalSkullTag = getSkullTag(skullVariant, pos, rotation); + CompoundTag finalSkullTag = getSkullTag(skullVariant, pos, rotation); // Delay needed, otherwise newly placed skulls will not appear // Delay is not needed for skulls already placed on login session.getConnector().getGeneralThreadPool().schedule(() -> @@ -35,7 +29,7 @@ public class SkullBlockEntityTranslator { } } - public static com.nukkitx.nbt.tag.CompoundTag getSkullTag(byte skullvariant, Position pos, byte rotation) { + public static CompoundTag getSkullTag(byte skullvariant, Position pos, byte rotation) { CompoundTagBuilder tagBuilder = CompoundTagBuilder.builder() .intTag("x", pos.getX()) .intTag("y", pos.getY()) From 60b65e4be6b45d3a7f5e79f93eef229be912844f Mon Sep 17 00:00:00 2001 From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com> Date: Wed, 15 Apr 2020 10:11:32 -0400 Subject: [PATCH 5/6] Add copyright notice --- .../entity/SkullBlockEntityTranslator.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java index 67bcdddda..0d792288c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + package org.geysermc.connector.network.translators.block.entity; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; From 80a7f3a57889f22671f78b20568e174b3fcc5049 Mon Sep 17 00:00:00 2001 From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com> Date: Wed, 15 Apr 2020 15:38:17 -0400 Subject: [PATCH 6/6] It's not 2019 anymore? --- .../translators/block/entity/SkullBlockEntityTranslator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java index 0d792288c..12526d8e5 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 GeyserMC. http://geysermc.org + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal