Store bed colors in Object2ByteOpenHashMap

This commit is contained in:
BuildTools 2020-03-26 18:34:54 -04:00
parent 22908c4de7
commit e5766ef96a
2 changed files with 9 additions and 2 deletions

View file

@ -48,6 +48,12 @@
<version>8.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-byte-maps</artifactId>
<version>8.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.steveice10</groupId>
<artifactId>opennbt</artifactId>

View file

@ -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<BlockState> BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>();
private static final Map<String, BlockState> JAVA_ID_BLOCK_MAP = new HashMap<>();
private static final IntSet WATERLOGGED = new IntOpenHashSet();
private static final Map<BlockState, Byte> BEDCOLORS = new HashMap<>();
private static final Object2ByteOpenHashMap<BlockState> BEDCOLORS = new Object2ByteOpenHashMap<>();
private static final Map<BlockState, String> 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;
}