From e5766ef96a8197045fe03a9e611517ca83bfc482 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 26 Mar 2020 18:34:54 -0400 Subject: [PATCH] Store bed colors in Object2ByteOpenHashMap --- connector/pom.xml | 6 ++++++ .../network/translators/block/BlockTranslator.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/connector/pom.xml b/connector/pom.xml index 6d56fbcad..0258e9a30 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -48,6 +48,12 @@ 8.1.1 compile + + com.nukkitx.fastutil + fastutil-object-byte-maps + 8.3.1 + compile + com.github.steveice10 opennbt 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 f0c474104..d38211541 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 @@ -35,6 +35,7 @@ import com.nukkitx.nbt.tag.ListTag; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; import it.unimi.dsi.fastutil.ints.*; +import it.unimi.dsi.fastutil.objects.*; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.utils.Toolbox; @@ -50,7 +51,7 @@ public class BlockTranslator { private static final Int2ObjectMap BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>(); private static final Map JAVA_ID_BLOCK_MAP = new HashMap<>(); private static final IntSet WATERLOGGED = new IntOpenHashSet(); - private static final Map BEDCOLORS = new HashMap<>(); + private static final Object2ByteOpenHashMap BEDCOLORS = new Object2ByteOpenHashMap<>(); private static final Map JAVA_ID_TO_BLOCK_ENTITY_MAP = new HashMap<>(); @@ -244,7 +245,7 @@ public class BlockTranslator { public static byte getBedColor(BlockState state) { if (BEDCOLORS.containsKey(state)) { - return BEDCOLORS.get(state); + return BEDCOLORS.getByte(state); } return -1; }