From 5013b4b3808d1e7d799fa54e483d4308238992bd Mon Sep 17 00:00:00 2001
From: SupremeMortal <6178101+SupremeMortal@users.noreply.github.com>
Date: Fri, 13 Mar 2020 20:16:17 +0000
Subject: [PATCH] Use new fastutil dependencies and remove Trove.
---
bedrock/bedrock-common/pom.xml | 12 ++-
.../protocol/bedrock/BedrockPacketCodec.java | 22 ++--
.../protocol/bedrock/data/ContainerType.java | 6 +-
.../protocol/bedrock/data/EntityFlags.java | 10 +-
.../bedrock/data/InventorySource.java | 6 +-
.../packet/AdventureSettingsPacket.java | 4 +-
.../bedrock/packet/UpdateBlockPacket.java | 3 +-
.../protocol/bedrock/v291/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v291.java | 8 +-
.../serializer/AnimateSerializer_v291.java | 4 +-
.../AvailableCommandsSerializer_v291.java | 18 ++--
.../serializer/BookEditSerializer_v291.java | 4 +-
...ClientboundMapItemDataSerializer_v291.java | 2 +-
.../ContainerSetDataSerializer_v291.java | 1 -
.../EntityEventSerializer_v291.java | 4 +-
.../GameRulesChangedSerializer_v291.java | 7 +-
.../serializer/LevelEventSerializer_v291.java | 4 +-
.../LevelSoundEventSerializer_v291.java | 4 +-
.../protocol/bedrock/v313/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v313.java | 8 +-
.../serializer/AnimateSerializer_v313.java | 4 +-
.../AvailableCommandsSerializer_v313.java | 18 ++--
.../serializer/BookEditSerializer_v313.java | 4 +-
...ClientboundMapItemDataSerializer_v313.java | 2 +-
.../ContainerSetDataSerializer_v313.java | 1 -
.../EntityEventSerializer_v313.java | 4 +-
.../GameRulesChangedSerializer_v313.java | 7 +-
.../serializer/LevelEventSerializer_v313.java | 4 +-
.../LevelSoundEvent1Serializer_v313.java | 4 +-
.../protocol/bedrock/v332/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v332.java | 8 +-
.../serializer/AnimateSerializer_v332.java | 4 +-
.../AvailableCommandsSerializer_v332.java | 18 ++--
.../serializer/BookEditSerializer_v332.java | 4 +-
...ClientboundMapItemDataSerializer_v332.java | 2 +-
.../ContainerSetDataSerializer_v332.java | 1 -
.../EntityEventSerializer_v332.java | 4 +-
.../GameRulesChangedSerializer_v332.java | 7 +-
.../serializer/LevelEventSerializer_v332.java | 4 +-
.../LevelSoundEvent1Serializer_v332.java | 4 +-
.../protocol/bedrock/v340/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v340.java | 8 +-
.../serializer/AnimateSerializer_v340.java | 4 +-
.../AvailableCommandsSerializer_v340.java | 18 ++--
.../serializer/BookEditSerializer_v340.java | 4 +-
...ClientboundMapItemDataSerializer_v340.java | 2 +-
.../ContainerSetDataSerializer_v340.java | 1 -
.../EntityEventSerializer_v340.java | 4 +-
.../GameRulesChangedSerializer_v340.java | 7 +-
.../serializer/LevelEventSerializer_v340.java | 4 +-
.../LevelSoundEvent1Serializer_v340.java | 4 +-
.../protocol/bedrock/v354/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v354.java | 8 +-
.../serializer/AnimateSerializer_v354.java | 4 +-
.../AvailableCommandsSerializer_v354.java | 18 ++--
.../serializer/BookEditSerializer_v354.java | 4 +-
...ClientboundMapItemDataSerializer_v354.java | 2 +-
.../ContainerSetDataSerializer_v354.java | 1 -
.../EntityEventSerializer_v354.java | 4 +-
.../GameRulesChangedSerializer_v354.java | 7 +-
.../serializer/LevelEventSerializer_v354.java | 4 +-
.../LevelSoundEvent1Serializer_v354.java | 4 +-
.../protocol/bedrock/v361/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v361.java | 8 +-
.../serializer/AnimateSerializer_v361.java | 4 +-
.../AvailableCommandsSerializer_v361.java | 18 ++--
.../serializer/BookEditSerializer_v361.java | 4 +-
...ClientboundMapItemDataSerializer_v361.java | 2 +-
.../ContainerSetDataSerializer_v361.java | 1 -
.../EntityEventSerializer_v361.java | 4 +-
.../GameRulesChangedSerializer_v361.java | 7 +-
.../serializer/LevelChunkSerializer_v361.java | 5 +-
.../serializer/LevelEventSerializer_v361.java | 4 +-
.../LevelSoundEvent1Serializer_v361.java | 4 +-
.../ResourcePackDataInfoSerializer_v361.java | 4 +-
.../protocol/bedrock/v388/BedrockUtils.java | 8 +-
.../AdventureSettingsSerializer_v388.java | 8 +-
.../serializer/AnimateSerializer_v388.java | 4 +-
.../AvailableCommandsSerializer_v388.java | 18 ++--
.../serializer/BookEditSerializer_v388.java | 4 +-
...ClientboundMapItemDataSerializer_v388.java | 2 +-
.../EntityEventSerializer_v388.java | 4 +-
.../GameRulesChangedSerializer_v388.java | 7 +-
.../serializer/LevelChunkSerializer_v388.java | 5 +-
.../serializer/LevelEventSerializer_v388.java | 4 +-
.../LevelSoundEvent1Serializer_v388.java | 4 +-
.../ResourcePackDataInfoSerializer_v388.java | 4 +-
common/pom.xml | 12 ++-
.../protocol/util/Int2ObjectBiMap.java | 100 ++++++++++++++++++
.../nukkitx/protocol/util/TIntHashBiMap.java | 100 ------------------
90 files changed, 388 insertions(+), 352 deletions(-)
create mode 100644 common/src/main/java/com/nukkitx/protocol/util/Int2ObjectBiMap.java
delete mode 100644 common/src/main/java/com/nukkitx/protocol/util/TIntHashBiMap.java
diff --git a/bedrock/bedrock-common/pom.xml b/bedrock/bedrock-common/pom.xml
index 17f25507a..a9733f396 100644
--- a/bedrock/bedrock-common/pom.xml
+++ b/bedrock/bedrock-common/pom.xml
@@ -31,9 +31,15 @@
compile
- com.nukkitx
- fastutil-lite
- 8.1.1
+ com.nukkitx.fastutil
+ fastutil-long-common
+ 8.3.1
+ compile
+
+
+ com.nukkitx.fastutil
+ fastutil-long-object-maps
+ 8.3.1
compile
diff --git a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/BedrockPacketCodec.java b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/BedrockPacketCodec.java
index fa4420fdc..c08bd4ad9 100644
--- a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/BedrockPacketCodec.java
+++ b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/BedrockPacketCodec.java
@@ -5,15 +5,14 @@
import com.nukkitx.protocol.bedrock.packet.PacketHeader;
import com.nukkitx.protocol.bedrock.packet.UnknownPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
-import gnu.trove.iterator.TIntObjectIterator;
-import gnu.trove.map.TIntObjectMap;
-import gnu.trove.map.hash.TIntObjectHashMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -33,7 +32,7 @@ public final class BedrockPacketCodec {
@Getter
private final String minecraftVersion;
private final PacketSerializer[] serializers;
- private final TIntHashBiMap> idBiMap;
+ private final Int2ObjectBiMap> idBiMap;
private final PacketSerializer headerSerializer;
public static Builder builder() {
@@ -104,8 +103,8 @@ public int getId(Class extends BedrockPacket> clazz) {
@SuppressWarnings("unchecked")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class Builder {
- private final TIntObjectMap> serializers = new TIntObjectHashMap<>();
- private final TIntHashBiMap> idBiMap = new TIntHashBiMap<>((Class) UnknownPacket.class);
+ private final Int2ObjectMap> serializers = new Int2ObjectOpenHashMap<>();
+ private final Int2ObjectBiMap> idBiMap = new Int2ObjectBiMap<>(UnknownPacket.class);
private int protocolVersion = -1;
private String minecraftVersion = null;
private PacketSerializer headerSerializer = null;
@@ -146,7 +145,7 @@ public BedrockPacketCodec build() {
Preconditions.checkNotNull(minecraftVersion, "No Minecraft version defined");
Preconditions.checkNotNull(headerSerializer, "headerSerializer cannot be null");
int largestId = -1;
- for (int id : serializers.keys()) {
+ for (int id : serializers.keySet()) {
if (id > largestId) {
largestId = id;
}
@@ -154,11 +153,8 @@ public BedrockPacketCodec build() {
Preconditions.checkArgument(largestId > -1, "Must have at least one packet registered");
PacketSerializer[] serializers = new PacketSerializer[largestId + 1];
- TIntObjectIterator> iterator = this.serializers.iterator();
-
- while (iterator.hasNext()) {
- iterator.advance();
- serializers[iterator.key()] = iterator.value();
+ for (Int2ObjectMap.Entry> entry : this.serializers.int2ObjectEntrySet()) {
+ serializers[entry.getIntKey()] = entry.getValue();
}
return new BedrockPacketCodec(protocolVersion, minecraftVersion, serializers, idBiMap, headerSerializer);
}
diff --git a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/ContainerType.java b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/ContainerType.java
index c33d7f7a4..856252f59 100644
--- a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/ContainerType.java
+++ b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/ContainerType.java
@@ -1,7 +1,7 @@
package com.nukkitx.protocol.bedrock.data;
-import gnu.trove.map.TIntObjectMap;
-import gnu.trove.map.hash.TIntObjectHashMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public enum ContainerType {
UNTRACKED_UI_INTERACTION(-9),
@@ -29,7 +29,7 @@ public enum ContainerType {
MATERIAL_REDUCER(22),
LAB_TABLE(23);
- public static final TIntObjectMap BY_ID = new TIntObjectHashMap<>();
+ public static final Int2ObjectMap BY_ID = new Int2ObjectOpenHashMap<>();
static {
for (ContainerType type : values()) {
diff --git a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/EntityFlags.java b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/EntityFlags.java
index 32a7e40ba..4cbd1b93e 100644
--- a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/EntityFlags.java
+++ b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/EntityFlags.java
@@ -1,20 +1,20 @@
package com.nukkitx.protocol.bedrock.data;
import com.nukkitx.network.util.Preconditions;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.ToString;
import javax.annotation.Nonnull;
-import java.util.HashSet;
import java.util.Set;
@ToString
public class EntityFlags {
private static final InternalLogger log = InternalLoggerFactory.getInstance(EntityFlags.class);
- private final Set flags = new HashSet<>();
+ private final Set flags = new ObjectOpenHashSet<>();
/**
* Set {@link EntityFlag} value
@@ -47,7 +47,7 @@ public boolean getFlag(@Nonnull EntityFlag flag) {
return flags.contains(flag);
}
- public long get(int index, TIntHashBiMap flagMappings) {
+ public long get(int index, Int2ObjectBiMap flagMappings) {
long value = 0;
final int lower = index * 64;
final int upper = lower + 64;
@@ -60,7 +60,7 @@ public long get(int index, TIntHashBiMap flagMappings) {
return value;
}
- public void set(long value, int index, TIntHashBiMap flagMappings) {
+ public void set(long value, int index, Int2ObjectBiMap flagMappings) {
final int lower = index * 64;
final int upper = lower + 64;
for (int i = lower; i < upper; i++) {
diff --git a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/InventorySource.java b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/InventorySource.java
index b9755f009..dcedd5db1 100644
--- a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/InventorySource.java
+++ b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/InventorySource.java
@@ -1,8 +1,8 @@
package com.nukkitx.protocol.bedrock.data;
import com.nukkitx.network.util.Preconditions;
-import gnu.trove.map.TIntObjectMap;
-import gnu.trove.map.hash.TIntObjectHashMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.Value;
@@ -60,7 +60,7 @@ public enum Type {
UNTRACKED_INTERACTION_UI(100),
NON_IMPLEMENTED_TODO(99999);
- private static final TIntObjectMap BY_ID = new TIntObjectHashMap<>(6);
+ private static final Int2ObjectMap BY_ID = new Int2ObjectOpenHashMap<>(6);
static {
for (Type type : values()) {
diff --git a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/AdventureSettingsPacket.java b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/AdventureSettingsPacket.java
index 9951e5233..eaa1300c8 100644
--- a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/AdventureSettingsPacket.java
+++ b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/AdventureSettingsPacket.java
@@ -5,16 +5,16 @@
import com.nukkitx.protocol.bedrock.data.CommandPermission;
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import java.util.HashSet;
import java.util.Set;
@Data
@EqualsAndHashCode(doNotUseGetters = true, callSuper = false)
public class AdventureSettingsPacket extends BedrockPacket {
- private final Set flags = new HashSet<>();
+ private final Set flags = new ObjectOpenHashSet<>();
private CommandPermission commandPermission;
private PlayerPermission playerPermission;
private long uniqueEntityId;
diff --git a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/UpdateBlockPacket.java b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/UpdateBlockPacket.java
index ec30e6c7b..ebc78fecb 100644
--- a/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/UpdateBlockPacket.java
+++ b/bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/packet/UpdateBlockPacket.java
@@ -4,6 +4,7 @@
import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.BedrockPacketType;
import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -19,7 +20,7 @@ public class UpdateBlockPacket extends BedrockPacket {
new HashSet<>(Arrays.asList(Flag.NEIGHBORS, Flag.NETWORK)));
public static final Set FLAG_ALL_PRIORITY = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(Flag.NEIGHBORS, Flag.NETWORK, Flag.PRIORITY)));
- private final Set flags = new HashSet<>();
+ private final Set flags = new ObjectOpenHashSet<>();
private Vector3i blockPosition;
private int runtimeId;
private int dataLayer;
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/BedrockUtils.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/BedrockUtils.java
index 8d036d11e..c97278569 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/BedrockUtils.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/BedrockUtils.java
@@ -15,7 +15,7 @@
import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
import com.nukkitx.protocol.bedrock.util.LittleEndianByteBufOutputStream;
import com.nukkitx.protocol.bedrock.v291.serializer.GameRulesChangedSerializer_v291;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.util.AsciiString;
@@ -34,9 +34,9 @@
@UtilityClass
public final class BedrockUtils {
private static final InternalLogger log = InternalLoggerFactory.getInstance(BedrockUtils.class);
- private static final TIntHashBiMap METADATAS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_FLAGS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_TYPES = new TIntHashBiMap<>(9);
+ private static final Int2ObjectBiMap METADATAS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_FLAGS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_TYPES = new Int2ObjectBiMap<>(9);
static {
METADATAS.put(0, FLAGS);
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AdventureSettingsSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AdventureSettingsSerializer_v291.java
index 01c6aaa0f..b3a88287d 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AdventureSettingsSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AdventureSettingsSerializer_v291.java
@@ -5,9 +5,9 @@
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -25,8 +25,8 @@ public class AdventureSettingsSerializer_v291 implements PacketSerializer FLAGS_TO_BIT_1 = new TObjectIntHashMap<>();
- private static final TObjectIntMap FLAGS_TO_BIT_2 = new TObjectIntHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_1 = new Object2IntOpenHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_2 = new Object2IntOpenHashMap<>();
static {
FLAGS_TO_BIT_1.put(IMMUTABLE_WORLD, 0x1);
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AnimateSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AnimateSerializer_v291.java
index 8b4ba0f86..5d93bb4ab 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AnimateSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AnimateSerializer_v291.java
@@ -3,7 +3,7 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AnimateSerializer_v291 implements PacketSerializer {
public static final AnimateSerializer_v291 INSTANCE = new AnimateSerializer_v291();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.NO_ACTION);
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AvailableCommandsSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AvailableCommandsSerializer_v291.java
index 1d6779bce..d36985145 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AvailableCommandsSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/AvailableCommandsSerializer_v291.java
@@ -9,12 +9,16 @@
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
import com.nukkitx.protocol.bedrock.v291.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -29,7 +33,7 @@ public class AvailableCommandsSerializer_v291 implements PacketSerializer READ_BYTE = ByteBuf::readUnsignedByte;
private static final ToIntFunction READ_SHORT = ByteBuf::readUnsignedShortLE;
private static final ToIntFunction READ_INT = ByteBuf::readIntLE;
- private static final TIntHashBiMap PARAM_TYPES = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap PARAM_TYPES = new Int2ObjectBiMap<>();
static {
PARAM_TYPES.put(1, INT);
@@ -51,10 +55,10 @@ public class AvailableCommandsSerializer_v291 implements PacketSerializer enumValuesSet = new HashSet<>();
- Set postfixSet = new HashSet<>();
- Set enumsSet = new HashSet<>();
- Set softEnumsSet = new HashSet<>();
+ Set enumValuesSet = new ObjectOpenHashSet<>();
+ Set postfixSet = new ObjectOpenHashSet<>();
+ Set enumsSet = new ObjectOpenHashSet<>();
+ Set softEnumsSet = new ObjectOpenHashSet<>();
// Get all enum values
for (CommandData data : packet.getCommands()) {
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/BookEditSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/BookEditSerializer_v291.java
index 51166ec8a..f5af375b2 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/BookEditSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/BookEditSerializer_v291.java
@@ -3,7 +3,7 @@
import com.nukkitx.protocol.bedrock.packet.BookEditPacket;
import com.nukkitx.protocol.bedrock.v291.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BookEditSerializer_v291 implements PacketSerializer {
public static final BookEditSerializer_v291 INSTANCE = new BookEditSerializer_v291();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.REPLACE_PAGE);
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ClientboundMapItemDataSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ClientboundMapItemDataSerializer_v291.java
index 68f8d4f5b..b3660dcf2 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ClientboundMapItemDataSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ClientboundMapItemDataSerializer_v291.java
@@ -41,7 +41,7 @@ public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) {
if ((type & 0x8) != 0) {
VarInts.writeUnsignedInt(buffer, trackedEntityIds.size());
- for (long trackedEntityId : trackedEntityIds.toArray()) {
+ for (long trackedEntityId : trackedEntityIds) {
VarInts.writeLong(buffer, trackedEntityId);
}
}
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ContainerSetDataSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ContainerSetDataSerializer_v291.java
index 56680128e..c2cc5f2ad 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ContainerSetDataSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/ContainerSetDataSerializer_v291.java
@@ -3,7 +3,6 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/EntityEventSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/EntityEventSerializer_v291.java
index e02f2a7a2..e60ea0b0b 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/EntityEventSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/EntityEventSerializer_v291.java
@@ -4,7 +4,7 @@
import com.nukkitx.protocol.bedrock.data.EntityEventType;
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -16,7 +16,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class EntityEventSerializer_v291 implements PacketSerializer {
public static final EntityEventSerializer_v291 INSTANCE = new EntityEventSerializer_v291();
- private static final TIntHashBiMap events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
private static final InternalLogger log = InternalLoggerFactory.getInstance(EntityEventSerializer_v291.class);
static {
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/GameRulesChangedSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/GameRulesChangedSerializer_v291.java
index 104ed4330..80df3d217 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/GameRulesChangedSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/GameRulesChangedSerializer_v291.java
@@ -3,9 +3,9 @@
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
import com.nukkitx.protocol.bedrock.v291.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,9 +13,10 @@
public class GameRulesChangedSerializer_v291 implements PacketSerializer {
public static final GameRulesChangedSerializer_v291 INSTANCE = new GameRulesChangedSerializer_v291();
- public static final TObjectIntMap RULE_TYPES = new TObjectIntHashMap<>(3, 0.5f, -1);
+ public static final Object2IntMap> RULE_TYPES = new Object2IntOpenHashMap<>(3, 0.5f);
static {
+ RULE_TYPES.defaultReturnValue(-1);
RULE_TYPES.put(Boolean.class, 1);
RULE_TYPES.put(Integer.class, 2);
RULE_TYPES.put(Float.class, 3);
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelEventSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelEventSerializer_v291.java
index 43896448d..05a264b39 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelEventSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelEventSerializer_v291.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.v291.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -19,7 +19,7 @@ public class LevelEventSerializer_v291 implements PacketSerializer events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
static {
events.put(1000, SOUND_CLICK);
diff --git a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelSoundEventSerializer_v291.java b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelSoundEventSerializer_v291.java
index ffe2e128c..b8b17ab11 100644
--- a/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelSoundEventSerializer_v291.java
+++ b/bedrock/bedrock-v291/src/main/java/com/nukkitx/protocol/bedrock/v291/serializer/LevelSoundEventSerializer_v291.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelSoundEvent1Packet;
import com.nukkitx.protocol.bedrock.v291.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -16,7 +16,7 @@
public class LevelSoundEventSerializer_v291 implements PacketSerializer {
public static final LevelSoundEventSerializer_v291 INSTANCE = new LevelSoundEventSerializer_v291();
- private static final TIntHashBiMap sounds = new TIntHashBiMap<>(2, 0.5F, 214, UNDEFINED);
+ private static final Int2ObjectBiMap sounds = new Int2ObjectBiMap<>(2, 0.5F, 214, UNDEFINED);
static {
sounds.put(0, ITEM_USE_ON);
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/BedrockUtils.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/BedrockUtils.java
index c0d724652..2ac50c5b5 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/BedrockUtils.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/BedrockUtils.java
@@ -15,7 +15,7 @@
import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
import com.nukkitx.protocol.bedrock.util.LittleEndianByteBufOutputStream;
import com.nukkitx.protocol.bedrock.v313.serializer.GameRulesChangedSerializer_v313;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.util.AsciiString;
@@ -34,9 +34,9 @@
@UtilityClass
public final class BedrockUtils {
private static final InternalLogger log = InternalLoggerFactory.getInstance(BedrockUtils.class);
- private static final TIntHashBiMap METADATAS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_FLAGS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_TYPES = new TIntHashBiMap<>(9);
+ private static final Int2ObjectBiMap METADATAS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_FLAGS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_TYPES = new Int2ObjectBiMap<>(9);
private static final byte[] EMPTY = new byte[0];
static {
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AdventureSettingsSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AdventureSettingsSerializer_v313.java
index 2ab28121d..4c2bbe2c1 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AdventureSettingsSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AdventureSettingsSerializer_v313.java
@@ -5,9 +5,9 @@
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -25,8 +25,8 @@ public class AdventureSettingsSerializer_v313 implements PacketSerializer FLAGS_TO_BIT_1 = new TObjectIntHashMap<>();
- private static final TObjectIntMap FLAGS_TO_BIT_2 = new TObjectIntHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_1 = new Object2IntOpenHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_2 = new Object2IntOpenHashMap<>();
static {
FLAGS_TO_BIT_1.put(IMMUTABLE_WORLD, 0x1);
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AnimateSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AnimateSerializer_v313.java
index 2ece5eb4e..7b84ff1c5 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AnimateSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AnimateSerializer_v313.java
@@ -3,7 +3,7 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AnimateSerializer_v313 implements PacketSerializer {
public static final AnimateSerializer_v313 INSTANCE = new AnimateSerializer_v313();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.NO_ACTION);
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AvailableCommandsSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AvailableCommandsSerializer_v313.java
index dba04d65a..24e6bb0e2 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AvailableCommandsSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/AvailableCommandsSerializer_v313.java
@@ -9,12 +9,16 @@
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
import com.nukkitx.protocol.bedrock.v313.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -29,7 +33,7 @@ public class AvailableCommandsSerializer_v313 implements PacketSerializer READ_BYTE = ByteBuf::readUnsignedByte;
private static final ToIntFunction READ_SHORT = ByteBuf::readUnsignedShortLE;
private static final ToIntFunction READ_INT = ByteBuf::readIntLE;
- private static final TIntHashBiMap PARAM_TYPES = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap PARAM_TYPES = new Int2ObjectBiMap<>();
static {
PARAM_TYPES.put(1, INT);
@@ -51,10 +55,10 @@ public class AvailableCommandsSerializer_v313 implements PacketSerializer enumValuesSet = new HashSet<>();
- Set postfixSet = new HashSet<>();
- Set enumsSet = new HashSet<>();
- Set softEnumsSet = new HashSet<>();
+ Set enumValuesSet = new ObjectOpenHashSet<>();
+ Set postfixSet = new ObjectOpenHashSet<>();
+ Set enumsSet = new ObjectOpenHashSet<>();
+ Set softEnumsSet = new ObjectOpenHashSet<>();
// Get all enum values
for (CommandData data : packet.getCommands()) {
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/BookEditSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/BookEditSerializer_v313.java
index daaff19da..c1fbb8dd9 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/BookEditSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/BookEditSerializer_v313.java
@@ -3,7 +3,7 @@
import com.nukkitx.protocol.bedrock.packet.BookEditPacket;
import com.nukkitx.protocol.bedrock.v313.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BookEditSerializer_v313 implements PacketSerializer {
public static final BookEditSerializer_v313 INSTANCE = new BookEditSerializer_v313();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.REPLACE_PAGE);
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ClientboundMapItemDataSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ClientboundMapItemDataSerializer_v313.java
index 2aeac1a52..d398c6de3 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ClientboundMapItemDataSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ClientboundMapItemDataSerializer_v313.java
@@ -41,7 +41,7 @@ public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) {
if ((type & 0x8) != 0) {
VarInts.writeUnsignedInt(buffer, trackedEntityIds.size());
- for (long trackedEntityId : trackedEntityIds.toArray()) {
+ for (long trackedEntityId : trackedEntityIds) {
VarInts.writeLong(buffer, trackedEntityId);
}
}
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ContainerSetDataSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ContainerSetDataSerializer_v313.java
index c5f040340..8e2530872 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ContainerSetDataSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/ContainerSetDataSerializer_v313.java
@@ -3,7 +3,6 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/EntityEventSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/EntityEventSerializer_v313.java
index 44325f16a..8d8da24c6 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/EntityEventSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/EntityEventSerializer_v313.java
@@ -4,7 +4,7 @@
import com.nukkitx.protocol.bedrock.data.EntityEventType;
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -16,7 +16,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class EntityEventSerializer_v313 implements PacketSerializer {
public static final EntityEventSerializer_v313 INSTANCE = new EntityEventSerializer_v313();
- private static final TIntHashBiMap events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
private static final InternalLogger log = InternalLoggerFactory.getInstance(EntityEventSerializer_v313.class);
static {
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/GameRulesChangedSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/GameRulesChangedSerializer_v313.java
index 5a65b69e1..52e41f758 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/GameRulesChangedSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/GameRulesChangedSerializer_v313.java
@@ -3,9 +3,9 @@
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
import com.nukkitx.protocol.bedrock.v313.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,9 +13,10 @@
public class GameRulesChangedSerializer_v313 implements PacketSerializer {
public static final GameRulesChangedSerializer_v313 INSTANCE = new GameRulesChangedSerializer_v313();
- public static final TObjectIntMap RULE_TYPES = new TObjectIntHashMap<>(3, 0.5f, -1);
+ public static final Object2IntMap> RULE_TYPES = new Object2IntOpenHashMap<>(3, 0.5f);
static {
+ RULE_TYPES.defaultReturnValue(-1);
RULE_TYPES.put(Boolean.class, 1);
RULE_TYPES.put(Integer.class, 2);
RULE_TYPES.put(Float.class, 3);
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelEventSerializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelEventSerializer_v313.java
index 186d44388..f6451bd83 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelEventSerializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelEventSerializer_v313.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.v313.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -19,7 +19,7 @@ public class LevelEventSerializer_v313 implements PacketSerializer events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
static {
events.put(1000, SOUND_CLICK);
diff --git a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelSoundEvent1Serializer_v313.java b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelSoundEvent1Serializer_v313.java
index d35bb72d0..df6d3ed77 100644
--- a/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelSoundEvent1Serializer_v313.java
+++ b/bedrock/bedrock-v313/src/main/java/com/nukkitx/protocol/bedrock/v313/serializer/LevelSoundEvent1Serializer_v313.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelSoundEvent1Packet;
import com.nukkitx.protocol.bedrock.v313.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -17,7 +17,7 @@
public class LevelSoundEvent1Serializer_v313 implements PacketSerializer {
public static final LevelSoundEvent1Serializer_v313 INSTANCE = new LevelSoundEvent1Serializer_v313();
- static final TIntHashBiMap SOUNDS = new TIntHashBiMap<>(2, 0.5F, 255, UNDEFINED);
+ static final Int2ObjectBiMap SOUNDS = new Int2ObjectBiMap<>(2, 0.5F, 255, UNDEFINED);
static {
SOUNDS.put(0, ITEM_USE_ON);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/BedrockUtils.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/BedrockUtils.java
index 5d1c2d014..e75f89988 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/BedrockUtils.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/BedrockUtils.java
@@ -14,7 +14,7 @@
import com.nukkitx.protocol.bedrock.packet.ResourcePackStackPacket;
import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
import com.nukkitx.protocol.bedrock.v332.serializer.GameRulesChangedSerializer_v332;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
@@ -34,9 +34,9 @@
@UtilityClass
public final class BedrockUtils {
private static final InternalLogger log = InternalLoggerFactory.getInstance(BedrockUtils.class);
- private static final TIntHashBiMap METADATAS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_FLAGS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_TYPES = new TIntHashBiMap<>(9);
+ private static final Int2ObjectBiMap METADATAS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_FLAGS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_TYPES = new Int2ObjectBiMap<>(9);
static {
METADATAS.put(0, FLAGS);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AdventureSettingsSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AdventureSettingsSerializer_v332.java
index eeb0b42e1..8b76be3a3 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AdventureSettingsSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AdventureSettingsSerializer_v332.java
@@ -5,9 +5,9 @@
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -25,8 +25,8 @@ public class AdventureSettingsSerializer_v332 implements PacketSerializer FLAGS_TO_BIT_1 = new TObjectIntHashMap<>();
- private static final TObjectIntMap FLAGS_TO_BIT_2 = new TObjectIntHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_1 = new Object2IntOpenHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_2 = new Object2IntOpenHashMap<>();
static {
FLAGS_TO_BIT_1.put(IMMUTABLE_WORLD, 0x1);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AnimateSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AnimateSerializer_v332.java
index 88b7d8aa3..5bec887a0 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AnimateSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AnimateSerializer_v332.java
@@ -3,7 +3,7 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AnimateSerializer_v332 implements PacketSerializer {
public static final AnimateSerializer_v332 INSTANCE = new AnimateSerializer_v332();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.NO_ACTION);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AvailableCommandsSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AvailableCommandsSerializer_v332.java
index 769a84656..ed07079e2 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AvailableCommandsSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/AvailableCommandsSerializer_v332.java
@@ -9,12 +9,16 @@
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
import com.nukkitx.protocol.bedrock.v332.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -29,7 +33,7 @@ public class AvailableCommandsSerializer_v332 implements PacketSerializer READ_BYTE = ByteBuf::readUnsignedByte;
private static final ToIntFunction READ_SHORT = ByteBuf::readUnsignedShortLE;
private static final ToIntFunction READ_INT = ByteBuf::readIntLE;
- private static final TIntHashBiMap PARAM_TYPES = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap PARAM_TYPES = new Int2ObjectBiMap<>();
static {
PARAM_TYPES.put(1, INT);
@@ -51,10 +55,10 @@ public class AvailableCommandsSerializer_v332 implements PacketSerializer enumValuesSet = new HashSet<>();
- Set postfixSet = new HashSet<>();
- Set enumsSet = new HashSet<>();
- Set softEnumsSet = new HashSet<>();
+ Set enumValuesSet = new ObjectOpenHashSet<>();
+ Set postfixSet = new ObjectOpenHashSet<>();
+ Set enumsSet = new ObjectOpenHashSet<>();
+ Set softEnumsSet = new ObjectOpenHashSet<>();
// Get all enum values
for (CommandData data : packet.getCommands()) {
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/BookEditSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/BookEditSerializer_v332.java
index bbbd13068..12f95b797 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/BookEditSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/BookEditSerializer_v332.java
@@ -3,7 +3,7 @@
import com.nukkitx.protocol.bedrock.packet.BookEditPacket;
import com.nukkitx.protocol.bedrock.v332.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BookEditSerializer_v332 implements PacketSerializer {
public static final BookEditSerializer_v332 INSTANCE = new BookEditSerializer_v332();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.REPLACE_PAGE);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ClientboundMapItemDataSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ClientboundMapItemDataSerializer_v332.java
index a3914f1a0..9316e9d1e 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ClientboundMapItemDataSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ClientboundMapItemDataSerializer_v332.java
@@ -41,7 +41,7 @@ public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) {
if ((type & 0x8) != 0) {
VarInts.writeUnsignedInt(buffer, trackedEntityIds.size());
- for (long trackedEntityId : trackedEntityIds.toArray()) {
+ for (long trackedEntityId : trackedEntityIds) {
VarInts.writeLong(buffer, trackedEntityId);
}
}
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ContainerSetDataSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ContainerSetDataSerializer_v332.java
index 38b773876..66e4a5618 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ContainerSetDataSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/ContainerSetDataSerializer_v332.java
@@ -3,7 +3,6 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/EntityEventSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/EntityEventSerializer_v332.java
index d4f057349..ab0a3f3fa 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/EntityEventSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/EntityEventSerializer_v332.java
@@ -4,7 +4,7 @@
import com.nukkitx.protocol.bedrock.data.EntityEventType;
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -16,7 +16,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class EntityEventSerializer_v332 implements PacketSerializer {
public static final EntityEventSerializer_v332 INSTANCE = new EntityEventSerializer_v332();
- private static final TIntHashBiMap events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
private static final InternalLogger log = InternalLoggerFactory.getInstance(EntityEventSerializer_v332.class);
static {
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/GameRulesChangedSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/GameRulesChangedSerializer_v332.java
index 8079cb4c7..9692f4c46 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/GameRulesChangedSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/GameRulesChangedSerializer_v332.java
@@ -3,9 +3,9 @@
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
import com.nukkitx.protocol.bedrock.v332.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,9 +13,10 @@
public class GameRulesChangedSerializer_v332 implements PacketSerializer {
public static final GameRulesChangedSerializer_v332 INSTANCE = new GameRulesChangedSerializer_v332();
- public static final TObjectIntMap> RULE_TYPES = new TObjectIntHashMap<>(3, 0.5f, -1);
+ public static final Object2IntMap> RULE_TYPES = new Object2IntOpenHashMap<>(3, 0.5f);
static {
+ RULE_TYPES.defaultReturnValue(-1);
RULE_TYPES.put(Boolean.class, 1);
RULE_TYPES.put(Integer.class, 2);
RULE_TYPES.put(Float.class, 3);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelEventSerializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelEventSerializer_v332.java
index 44634671c..710ecc314 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelEventSerializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelEventSerializer_v332.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.v332.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -19,7 +19,7 @@ public class LevelEventSerializer_v332 implements PacketSerializer events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
static {
events.put(1000, SOUND_CLICK);
diff --git a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelSoundEvent1Serializer_v332.java b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelSoundEvent1Serializer_v332.java
index d30947122..b8e941c5a 100644
--- a/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelSoundEvent1Serializer_v332.java
+++ b/bedrock/bedrock-v332/src/main/java/com/nukkitx/protocol/bedrock/v332/serializer/LevelSoundEvent1Serializer_v332.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelSoundEvent1Packet;
import com.nukkitx.protocol.bedrock.v332.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -17,7 +17,7 @@
public class LevelSoundEvent1Serializer_v332 implements PacketSerializer {
public static final LevelSoundEvent1Serializer_v332 INSTANCE = new LevelSoundEvent1Serializer_v332();
- static final TIntHashBiMap SOUNDS = new TIntHashBiMap<>(2, 0.5F, 255, UNDEFINED);
+ static final Int2ObjectBiMap SOUNDS = new Int2ObjectBiMap<>(2, 0.5F, 255, UNDEFINED);
static {
SOUNDS.put(0, ITEM_USE_ON);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/BedrockUtils.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/BedrockUtils.java
index b0c54bf96..1ba0d0bd3 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/BedrockUtils.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/BedrockUtils.java
@@ -14,7 +14,7 @@
import com.nukkitx.protocol.bedrock.packet.ResourcePackStackPacket;
import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
import com.nukkitx.protocol.bedrock.v340.serializer.GameRulesChangedSerializer_v340;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
@@ -34,9 +34,9 @@
@UtilityClass
public final class BedrockUtils {
private static final InternalLogger log = InternalLoggerFactory.getInstance(BedrockUtils.class);
- private static final TIntHashBiMap METADATAS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_FLAGS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_TYPES = new TIntHashBiMap<>(9);
+ private static final Int2ObjectBiMap METADATAS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_FLAGS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_TYPES = new Int2ObjectBiMap<>(9);
static {
METADATAS.put(0, FLAGS);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AdventureSettingsSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AdventureSettingsSerializer_v340.java
index ec282ed1b..db9d25314 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AdventureSettingsSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AdventureSettingsSerializer_v340.java
@@ -5,9 +5,9 @@
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -25,8 +25,8 @@ public class AdventureSettingsSerializer_v340 implements PacketSerializer FLAGS_TO_BIT_1 = new TObjectIntHashMap<>();
- private static final TObjectIntMap FLAGS_TO_BIT_2 = new TObjectIntHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_1 = new Object2IntOpenHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_2 = new Object2IntOpenHashMap<>();
static {
FLAGS_TO_BIT_1.put(IMMUTABLE_WORLD, 0x1);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AnimateSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AnimateSerializer_v340.java
index e4b94cdc2..e5d7d6dfe 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AnimateSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AnimateSerializer_v340.java
@@ -3,7 +3,7 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AnimateSerializer_v340 implements PacketSerializer {
public static final AnimateSerializer_v340 INSTANCE = new AnimateSerializer_v340();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.NO_ACTION);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AvailableCommandsSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AvailableCommandsSerializer_v340.java
index f2b824a0d..f387e67b7 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AvailableCommandsSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/AvailableCommandsSerializer_v340.java
@@ -9,12 +9,16 @@
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
import com.nukkitx.protocol.bedrock.v340.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -29,7 +33,7 @@ public class AvailableCommandsSerializer_v340 implements PacketSerializer READ_BYTE = ByteBuf::readUnsignedByte;
private static final ToIntFunction READ_SHORT = ByteBuf::readUnsignedShortLE;
private static final ToIntFunction READ_INT = ByteBuf::readIntLE;
- private static final TIntHashBiMap PARAM_TYPES = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap PARAM_TYPES = new Int2ObjectBiMap<>();
static {
PARAM_TYPES.put(1, INT);
@@ -51,10 +55,10 @@ public class AvailableCommandsSerializer_v340 implements PacketSerializer enumValuesSet = new HashSet<>();
- Set postfixSet = new HashSet<>();
- Set enumsSet = new HashSet<>();
- Set softEnumsSet = new HashSet<>();
+ Set enumValuesSet = new ObjectOpenHashSet<>();
+ Set postfixSet = new ObjectOpenHashSet<>();
+ Set enumsSet = new ObjectOpenHashSet<>();
+ Set softEnumsSet = new ObjectOpenHashSet<>();
// Get all enum values
for (CommandData data : packet.getCommands()) {
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/BookEditSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/BookEditSerializer_v340.java
index e6fde2831..5061c65d1 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/BookEditSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/BookEditSerializer_v340.java
@@ -3,7 +3,7 @@
import com.nukkitx.protocol.bedrock.packet.BookEditPacket;
import com.nukkitx.protocol.bedrock.v340.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BookEditSerializer_v340 implements PacketSerializer {
public static final BookEditSerializer_v340 INSTANCE = new BookEditSerializer_v340();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.REPLACE_PAGE);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ClientboundMapItemDataSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ClientboundMapItemDataSerializer_v340.java
index 022726c6e..dcafd896b 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ClientboundMapItemDataSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ClientboundMapItemDataSerializer_v340.java
@@ -41,7 +41,7 @@ public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) {
if ((type & 0x8) != 0) {
VarInts.writeUnsignedInt(buffer, trackedEntityIds.size());
- for (long trackedEntityId : trackedEntityIds.toArray()) {
+ for (long trackedEntityId : trackedEntityIds) {
VarInts.writeLong(buffer, trackedEntityId);
}
}
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ContainerSetDataSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ContainerSetDataSerializer_v340.java
index b84b5e11a..b662942db 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ContainerSetDataSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/ContainerSetDataSerializer_v340.java
@@ -3,7 +3,6 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/EntityEventSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/EntityEventSerializer_v340.java
index 213c662b6..3c5a30bc0 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/EntityEventSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/EntityEventSerializer_v340.java
@@ -4,7 +4,7 @@
import com.nukkitx.protocol.bedrock.data.EntityEventType;
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -16,7 +16,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class EntityEventSerializer_v340 implements PacketSerializer {
public static final EntityEventSerializer_v340 INSTANCE = new EntityEventSerializer_v340();
- private static final TIntHashBiMap events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
private static final InternalLogger log = InternalLoggerFactory.getInstance(EntityEventSerializer_v340.class);
static {
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/GameRulesChangedSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/GameRulesChangedSerializer_v340.java
index df9bb9062..47f0eb620 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/GameRulesChangedSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/GameRulesChangedSerializer_v340.java
@@ -3,9 +3,9 @@
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
import com.nukkitx.protocol.bedrock.v340.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,9 +13,10 @@
public class GameRulesChangedSerializer_v340 implements PacketSerializer {
public static final GameRulesChangedSerializer_v340 INSTANCE = new GameRulesChangedSerializer_v340();
- public static final TObjectIntMap RULE_TYPES = new TObjectIntHashMap<>(3, 0.5f, -1);
+ public static final Object2IntMap> RULE_TYPES = new Object2IntOpenHashMap<>(3, 0.5f);
static {
+ RULE_TYPES.defaultReturnValue(-1);
RULE_TYPES.put(Boolean.class, 1);
RULE_TYPES.put(Integer.class, 2);
RULE_TYPES.put(Float.class, 3);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelEventSerializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelEventSerializer_v340.java
index 2bec603b6..35320a1a5 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelEventSerializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelEventSerializer_v340.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.v340.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -19,7 +19,7 @@ public class LevelEventSerializer_v340 implements PacketSerializer events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
static {
events.put(1000, SOUND_CLICK);
diff --git a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelSoundEvent1Serializer_v340.java b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelSoundEvent1Serializer_v340.java
index 9aed73c5f..9ea89576a 100644
--- a/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelSoundEvent1Serializer_v340.java
+++ b/bedrock/bedrock-v340/src/main/java/com/nukkitx/protocol/bedrock/v340/serializer/LevelSoundEvent1Serializer_v340.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelSoundEvent1Packet;
import com.nukkitx.protocol.bedrock.v340.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -17,7 +17,7 @@
public class LevelSoundEvent1Serializer_v340 implements PacketSerializer {
public static final LevelSoundEvent1Serializer_v340 INSTANCE = new LevelSoundEvent1Serializer_v340();
- static final TIntHashBiMap SOUNDS = new TIntHashBiMap<>(2, 0.5F, 255, UNDEFINED);
+ static final Int2ObjectBiMap SOUNDS = new Int2ObjectBiMap<>(2, 0.5F, 255, UNDEFINED);
static {
SOUNDS.put(0, ITEM_USE_ON);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/BedrockUtils.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/BedrockUtils.java
index a0a419441..06ba69328 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/BedrockUtils.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/BedrockUtils.java
@@ -14,7 +14,7 @@
import com.nukkitx.protocol.bedrock.packet.ResourcePackStackPacket;
import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
import com.nukkitx.protocol.bedrock.v354.serializer.GameRulesChangedSerializer_v354;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
@@ -34,9 +34,9 @@
@UtilityClass
public final class BedrockUtils {
private static final InternalLogger log = InternalLoggerFactory.getInstance(BedrockUtils.class);
- private static final TIntHashBiMap METADATAS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_FLAGS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_TYPES = new TIntHashBiMap<>(9);
+ private static final Int2ObjectBiMap METADATAS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_FLAGS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_TYPES = new Int2ObjectBiMap<>(9);
static {
METADATAS.put(0, FLAGS);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AdventureSettingsSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AdventureSettingsSerializer_v354.java
index 215e9f513..0e7bc26ae 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AdventureSettingsSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AdventureSettingsSerializer_v354.java
@@ -5,9 +5,9 @@
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -25,8 +25,8 @@ public class AdventureSettingsSerializer_v354 implements PacketSerializer FLAGS_TO_BIT_1 = new TObjectIntHashMap<>();
- private static final TObjectIntMap FLAGS_TO_BIT_2 = new TObjectIntHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_1 = new Object2IntOpenHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_2 = new Object2IntOpenHashMap<>();
static {
FLAGS_TO_BIT_1.put(IMMUTABLE_WORLD, 0x1);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AnimateSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AnimateSerializer_v354.java
index fa268487a..e0c0d88e8 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AnimateSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AnimateSerializer_v354.java
@@ -3,7 +3,7 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AnimateSerializer_v354 implements PacketSerializer {
public static final AnimateSerializer_v354 INSTANCE = new AnimateSerializer_v354();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.NO_ACTION);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AvailableCommandsSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AvailableCommandsSerializer_v354.java
index 4a2aa54d7..e5cdd80a1 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AvailableCommandsSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/AvailableCommandsSerializer_v354.java
@@ -9,14 +9,18 @@
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
import com.nukkitx.protocol.bedrock.v354.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -32,7 +36,7 @@ public class AvailableCommandsSerializer_v354 implements PacketSerializer READ_BYTE = ByteBuf::readUnsignedByte;
private static final ToIntFunction READ_SHORT = ByteBuf::readUnsignedShortLE;
private static final ToIntFunction READ_INT = ByteBuf::readIntLE;
- private static final TIntHashBiMap PARAM_TYPES = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap PARAM_TYPES = new Int2ObjectBiMap<>();
static {
PARAM_TYPES.put(1, INT);
@@ -54,10 +58,10 @@ public class AvailableCommandsSerializer_v354 implements PacketSerializer enumValuesSet = new HashSet<>();
- Set postfixSet = new HashSet<>();
- Set enumsSet = new HashSet<>();
- Set softEnumsSet = new HashSet<>();
+ Set enumValuesSet = new ObjectOpenHashSet<>();
+ Set postfixSet = new ObjectOpenHashSet<>();
+ Set enumsSet = new ObjectOpenHashSet<>();
+ Set softEnumsSet = new ObjectOpenHashSet<>();
// Get all enum values
for (CommandData data : packet.getCommands()) {
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/BookEditSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/BookEditSerializer_v354.java
index b4aa4e475..9140fc7fe 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/BookEditSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/BookEditSerializer_v354.java
@@ -3,7 +3,7 @@
import com.nukkitx.protocol.bedrock.packet.BookEditPacket;
import com.nukkitx.protocol.bedrock.v354.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BookEditSerializer_v354 implements PacketSerializer {
public static final BookEditSerializer_v354 INSTANCE = new BookEditSerializer_v354();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.REPLACE_PAGE);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ClientboundMapItemDataSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ClientboundMapItemDataSerializer_v354.java
index 339270476..6d5b0e154 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ClientboundMapItemDataSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ClientboundMapItemDataSerializer_v354.java
@@ -42,7 +42,7 @@ public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) {
if ((type & 0x8) != 0) {
VarInts.writeUnsignedInt(buffer, trackedEntityIds.size());
- for (long trackedEntityId : trackedEntityIds.toArray()) {
+ for (long trackedEntityId : trackedEntityIds) {
VarInts.writeLong(buffer, trackedEntityId);
}
}
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ContainerSetDataSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ContainerSetDataSerializer_v354.java
index 84d16785b..f3931d8b8 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ContainerSetDataSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/ContainerSetDataSerializer_v354.java
@@ -3,7 +3,6 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/EntityEventSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/EntityEventSerializer_v354.java
index b6520692e..7981fdd69 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/EntityEventSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/EntityEventSerializer_v354.java
@@ -4,7 +4,7 @@
import com.nukkitx.protocol.bedrock.data.EntityEventType;
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -16,7 +16,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class EntityEventSerializer_v354 implements PacketSerializer {
public static final EntityEventSerializer_v354 INSTANCE = new EntityEventSerializer_v354();
- private static final TIntHashBiMap events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
private static final InternalLogger log = InternalLoggerFactory.getInstance(EntityEventSerializer_v354.class);
static {
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/GameRulesChangedSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/GameRulesChangedSerializer_v354.java
index e9bbfbd39..c53a88b7a 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/GameRulesChangedSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/GameRulesChangedSerializer_v354.java
@@ -3,9 +3,9 @@
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
import com.nukkitx.protocol.bedrock.v354.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,9 +13,10 @@
public class GameRulesChangedSerializer_v354 implements PacketSerializer {
public static final GameRulesChangedSerializer_v354 INSTANCE = new GameRulesChangedSerializer_v354();
- public static final TObjectIntMap RULE_TYPES = new TObjectIntHashMap<>(3, 0.5f, -1);
+ public static final Object2IntMap> RULE_TYPES = new Object2IntOpenHashMap<>(3, 0.5f);
static {
+ RULE_TYPES.defaultReturnValue(-1);
RULE_TYPES.put(Boolean.class, 1);
RULE_TYPES.put(Integer.class, 2);
RULE_TYPES.put(Float.class, 3);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelEventSerializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelEventSerializer_v354.java
index 1d526d129..84c4bec2b 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelEventSerializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelEventSerializer_v354.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.v354.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -19,7 +19,7 @@ public class LevelEventSerializer_v354 implements PacketSerializer events = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap events = new Int2ObjectBiMap<>();
static {
events.put(1000, SOUND_CLICK);
diff --git a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelSoundEvent1Serializer_v354.java b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelSoundEvent1Serializer_v354.java
index 2a8d490f4..a9a343ca3 100644
--- a/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelSoundEvent1Serializer_v354.java
+++ b/bedrock/bedrock-v354/src/main/java/com/nukkitx/protocol/bedrock/v354/serializer/LevelSoundEvent1Serializer_v354.java
@@ -5,7 +5,7 @@
import com.nukkitx.protocol.bedrock.packet.LevelSoundEvent1Packet;
import com.nukkitx.protocol.bedrock.v354.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -17,7 +17,7 @@
public class LevelSoundEvent1Serializer_v354 implements PacketSerializer {
public static final LevelSoundEvent1Serializer_v354 INSTANCE = new LevelSoundEvent1Serializer_v354();
- static final TIntHashBiMap SOUNDS = new TIntHashBiMap<>(2, 0.5F, 255, UNDEFINED);
+ static final Int2ObjectBiMap SOUNDS = new Int2ObjectBiMap<>(2, 0.5F, 255, UNDEFINED);
static {
SOUNDS.put(0, ITEM_USE_ON);
diff --git a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/BedrockUtils.java b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/BedrockUtils.java
index cb5c0b654..a56d45ae0 100644
--- a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/BedrockUtils.java
+++ b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/BedrockUtils.java
@@ -15,7 +15,7 @@
import com.nukkitx.protocol.bedrock.packet.ResourcePackStackPacket;
import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
import com.nukkitx.protocol.bedrock.v361.serializer.GameRulesChangedSerializer_v361;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
@@ -35,9 +35,9 @@
@UtilityClass
public final class BedrockUtils {
private static final InternalLogger log = InternalLoggerFactory.getInstance(BedrockUtils.class);
- private static final TIntHashBiMap METADATAS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_FLAGS = new TIntHashBiMap<>();
- private static final TIntHashBiMap METADATA_TYPES = new TIntHashBiMap<>(9);
+ private static final Int2ObjectBiMap METADATAS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_FLAGS = new Int2ObjectBiMap<>();
+ private static final Int2ObjectBiMap METADATA_TYPES = new Int2ObjectBiMap<>(9);
static {
METADATAS.put(0, FLAGS);
diff --git a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AdventureSettingsSerializer_v361.java b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AdventureSettingsSerializer_v361.java
index 6cf12c2fd..933d70c4a 100644
--- a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AdventureSettingsSerializer_v361.java
+++ b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AdventureSettingsSerializer_v361.java
@@ -5,9 +5,9 @@
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import gnu.trove.map.TObjectIntMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
import io.netty.buffer.ByteBuf;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -25,8 +25,8 @@ public class AdventureSettingsSerializer_v361 implements PacketSerializer FLAGS_TO_BIT_1 = new TObjectIntHashMap<>();
- private static final TObjectIntMap FLAGS_TO_BIT_2 = new TObjectIntHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_1 = new Object2IntOpenHashMap<>();
+ private static final Object2IntMap FLAGS_TO_BIT_2 = new Object2IntOpenHashMap<>();
static {
FLAGS_TO_BIT_1.put(IMMUTABLE_WORLD, 0x1);
diff --git a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AnimateSerializer_v361.java b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AnimateSerializer_v361.java
index b8e809eed..a045f786b 100644
--- a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AnimateSerializer_v361.java
+++ b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AnimateSerializer_v361.java
@@ -3,7 +3,7 @@
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AnimateSerializer_v361 implements PacketSerializer {
public static final AnimateSerializer_v361 INSTANCE = new AnimateSerializer_v361();
- private static final TIntHashBiMap types = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap types = new Int2ObjectBiMap<>();
static {
types.put(0, Action.NO_ACTION);
diff --git a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AvailableCommandsSerializer_v361.java b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AvailableCommandsSerializer_v361.java
index 71a1697aa..8bdad8868 100644
--- a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AvailableCommandsSerializer_v361.java
+++ b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/AvailableCommandsSerializer_v361.java
@@ -9,14 +9,18 @@
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
import com.nukkitx.protocol.bedrock.v361.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -32,7 +36,7 @@ public class AvailableCommandsSerializer_v361 implements PacketSerializer READ_BYTE = ByteBuf::readUnsignedByte;
private static final ToIntFunction READ_SHORT = ByteBuf::readUnsignedShortLE;
private static final ToIntFunction READ_INT = ByteBuf::readIntLE;
- private static final TIntHashBiMap PARAM_TYPES = new TIntHashBiMap<>();
+ private static final Int2ObjectBiMap PARAM_TYPES = new Int2ObjectBiMap<>();
static {
PARAM_TYPES.put(1, INT);
@@ -54,10 +58,10 @@ public class AvailableCommandsSerializer_v361 implements PacketSerializer enumValuesSet = new HashSet<>();
- Set postfixSet = new HashSet<>();
- Set enumsSet = new HashSet<>();
- Set softEnumsSet = new HashSet<>();
+ Set enumValuesSet = new ObjectOpenHashSet<>();
+ Set postfixSet = new ObjectOpenHashSet<>();
+ Set enumsSet = new ObjectOpenHashSet<>();
+ Set softEnumsSet = new ObjectOpenHashSet<>();
// Get all enum values
for (CommandData data : packet.getCommands()) {
diff --git a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/BookEditSerializer_v361.java b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/BookEditSerializer_v361.java
index 61da3840c..44516ef78 100644
--- a/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/BookEditSerializer_v361.java
+++ b/bedrock/bedrock-v361/src/main/java/com/nukkitx/protocol/bedrock/v361/serializer/BookEditSerializer_v361.java
@@ -3,7 +3,7 @@
import com.nukkitx.protocol.bedrock.packet.BookEditPacket;
import com.nukkitx.protocol.bedrock.v361.BedrockUtils;
import com.nukkitx.protocol.serializer.PacketSerializer;
-import com.nukkitx.protocol.util.TIntHashBiMap;
+import com.nukkitx.protocol.util.Int2ObjectBiMap;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BookEditSerializer_v361 implements PacketSerializer