diff --git a/common/pom.xml b/common/pom.xml
index 4d79ce92a..d190028ee 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -20,12 +20,12 @@
compile
-
+
it.unimi.dsi
fastutil
8.3.1
- provided
+ compile
diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java
index 4d7929359..1880d3ad6 100644
--- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java
+++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java
@@ -2,6 +2,8 @@ package us.myles.ViaVersion.api.protocol;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
@@ -31,8 +33,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3To1_9_1_2;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9To1_9_1;
-import us.myles.ViaVersion.util.fastutil.CollectionUtil;
-import us.myles.ViaVersion.util.fastutil.IntObjectMap;
import java.util.ArrayList;
import java.util.Arrays;
@@ -54,7 +54,7 @@ public class ProtocolRegistry {
public static final Protocol BASE_PROTOCOL = new BaseProtocol();
public static int SERVER_PROTOCOL = -1;
// Input Version -> Output Version & Protocol (Allows fast lookup)
- private static final IntObjectMap> registryMap = CollectionUtil.createIntObjectMap(32);
+ private static final Int2ObjectMap> registryMap = new Int2ObjectOpenHashMap<>(32);
private static final Map, Protocol> protocols = new HashMap<>();
private static final Map, List>> pathCache = new ConcurrentHashMap<>();
private static final Set supportedVersions = new HashSet<>();
@@ -128,7 +128,7 @@ public class ProtocolRegistry {
* @param supported Supported client versions.
* @param output The output server version it converts to.
*/
- public static void registerProtocol(Protocol protocol, List supported, Integer output) {
+ public static void registerProtocol(Protocol protocol, List supported, int output) {
// Clear cache as this may make new routes.
if (!pathCache.isEmpty()) {
pathCache.clear();
@@ -137,9 +137,9 @@ public class ProtocolRegistry {
protocols.put(protocol.getClass(), protocol);
for (int version : supported) {
- IntObjectMap protocolMap = registryMap.get(version);
+ Int2ObjectMap protocolMap = registryMap.get(version);
if (protocolMap == null) {
- protocolMap = CollectionUtil.createIntObjectMap(1);
+ protocolMap = new Int2ObjectOpenHashMap<>(1);
registryMap.put(version, protocolMap);
}
@@ -211,8 +211,8 @@ public class ProtocolRegistry {
* @return True if there is a useful pipe
*/
public static boolean isWorkingPipe() {
- for (IntObjectMap maps : registryMap.getMap().values()) {
- if (maps.containsKey(SERVER_PROTOCOL)) return true;
+ for (Int2ObjectMap map : registryMap.values()) {
+ if (map.containsKey(SERVER_PROTOCOL)) return true;
}
return false; // No destination for protocol
}
@@ -241,7 +241,7 @@ public class ProtocolRegistry {
if (current.size() > 50) return null; // Fail safe, protocol too complicated.
// First check if there is any protocols for this
- IntObjectMap inputMap = registryMap.get(clientVersion);
+ Int2ObjectMap inputMap = registryMap.get(clientVersion);
if (inputMap == null) {
return null; // Not supported
}
@@ -255,24 +255,23 @@ public class ProtocolRegistry {
// There might be a more advanced solution... So we'll see if any of the others can get us there
List> shortest = null;
-
- for (Map.Entry entry : inputMap.getMap().entrySet()) {
+ for (Int2ObjectMap.Entry entry : inputMap.int2ObjectEntrySet()) {
// Ensure it wasn't caught by the other loop
- if (!entry.getKey().equals(serverVersion)) {
- Pair pair = new Pair<>(entry.getKey(), entry.getValue());
- // Ensure no recursion
- if (!current.contains(pair)) {
- // Create a copy
- List> newCurrent = new ArrayList<>(current);
- newCurrent.add(pair);
- // Calculate the rest of the protocol using the current
- newCurrent = getProtocolPath(newCurrent, entry.getKey(), serverVersion);
- if (newCurrent != null) {
- // If it's shorter then choose it
- if (shortest == null || shortest.size() > newCurrent.size()) {
- shortest = newCurrent;
- }
- }
+ if (entry.getIntKey() == (serverVersion)) continue;
+
+ Pair pair = new Pair<>(entry.getIntKey(), entry.getValue());
+ // Ensure no recursion
+ if (current.contains(pair)) continue;
+
+ // Create a copy
+ List> newCurrent = new ArrayList<>(current);
+ newCurrent.add(pair);
+ // Calculate the rest of the protocol using the current
+ newCurrent = getProtocolPath(newCurrent, entry.getKey(), serverVersion);
+ if (newCurrent != null) {
+ // If it's shorter then choose it
+ if (shortest == null || shortest.size() > newCurrent.size()) {
+ shortest = newCurrent;
}
}
}
diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java
index 1590a4eb8..d32532f54 100644
--- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java
+++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java
@@ -1,5 +1,7 @@
package us.myles.ViaVersion.api.rewriters;
+import it.unimi.dsi.fastutil.ints.Int2IntMap;
+import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
@@ -12,8 +14,6 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.storage.EntityTracker;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
-import us.myles.ViaVersion.util.fastutil.CollectionUtil;
-import us.myles.ViaVersion.util.fastutil.IntMap;
import java.util.ArrayList;
import java.util.Collections;
@@ -25,7 +25,7 @@ import java.util.logging.Logger;
public abstract class MetadataRewriter {
private final Class extends EntityTracker> entityTrackerClass;
private final Protocol protocol;
- private IntMap typeMapping;
+ private Int2IntMap typeMapping;
protected MetadataRewriter(Protocol protocol, Class extends EntityTracker> entityTrackerClass) {
this.protocol = protocol;
@@ -184,7 +184,7 @@ public abstract class MetadataRewriter {
}
public & EntityType> void mapTypes(EntityType[] oldTypes, Class newTypeClass) {
- if (typeMapping == null) typeMapping = CollectionUtil.createIntMap(oldTypes.length);
+ if (typeMapping == null) typeMapping = new Int2IntOpenHashMap(oldTypes.length);
for (EntityType oldType : oldTypes) {
try {
T newType = Enum.valueOf(newTypeClass, oldType.name());
@@ -199,7 +199,7 @@ public abstract class MetadataRewriter {
}
public void mapType(EntityType oldType, EntityType newType) {
- if (typeMapping == null) typeMapping = CollectionUtil.createIntMap();
+ if (typeMapping == null) typeMapping = new Int2IntOpenHashMap();
typeMapping.put(oldType.getId(), newType.getId());
}
diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java
index 5aa77d1a4..c2f8ac3a4 100644
--- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java
+++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java
@@ -3,6 +3,10 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntSet;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
@@ -16,9 +20,6 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
-import us.myles.ViaVersion.util.fastutil.CollectionUtil;
-import us.myles.ViaVersion.util.fastutil.IntObjectMap;
-import us.myles.ViaVersion.util.fastutil.IntSet;
import java.util.ArrayList;
import java.util.HashMap;
@@ -30,11 +31,11 @@ import java.util.Map.Entry;
public class ConnectionData {
private static final BlockChangeRecord[] A = new BlockChangeRecord[0];
public static BlockConnectionProvider blockConnectionProvider;
- static IntObjectMap idToKey = CollectionUtil.createIntObjectMap(8582);
+ static Int2ObjectMap idToKey = new Int2ObjectOpenHashMap<>(8582);
static Map keyToId = new HashMap<>(8582);
- static IntObjectMap connectionHandlerMap = CollectionUtil.createIntObjectMap(1);
- static IntObjectMap blockConnectionData = CollectionUtil.createIntObjectMap(1);
- static IntSet occludingStates = CollectionUtil.createIntSet(377);
+ static Int2ObjectMap connectionHandlerMap = new Int2ObjectOpenHashMap<>(1);
+ static Int2ObjectMap blockConnectionData = new Int2ObjectOpenHashMap<>(1);
+ static IntSet occludingStates = new IntOpenHashSet(377);
public static void update(UserConnection user, Position position) {
for (BlockFace face : BlockFace.values()) {
@@ -212,10 +213,10 @@ public class ConnectionData {
keyToId.put(key, id);
}
- connectionHandlerMap = CollectionUtil.createIntObjectMap(3650);
+ connectionHandlerMap = new Int2ObjectOpenHashMap<>(3650);
if (!Via.getConfig().isReduceBlockStorageMemory()) {
- blockConnectionData = CollectionUtil.createIntObjectMap(1146);
+ blockConnectionData = new Int2ObjectOpenHashMap<>(1146);
JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
for (Entry entry : mappingBlockConnections.entrySet()) {
int id = keyToId.get(entry.getKey());
diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java
index 14eac24c9..801a7d63d 100644
--- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java
+++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java
@@ -1,18 +1,17 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
+import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.BlockFace;
import us.myles.ViaVersion.api.minecraft.Position;
-import us.myles.ViaVersion.util.fastutil.CollectionUtil;
-import us.myles.ViaVersion.util.fastutil.IntMap;
import java.util.HashSet;
import java.util.Set;
public class FlowerConnectionHandler extends ConnectionHandler {
- private static final IntMap flowers = CollectionUtil.createIntMap();
+ private static final Int2IntOpenHashMap flowers = new Int2IntOpenHashMap();
static ConnectionData.ConnectorInitAction init() {
final Set baseFlower = new HashSet<>();
diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java
index a09528880..918691470 100644
--- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java
+++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java
@@ -1,18 +1,17 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
+import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.BlockFace;
import us.myles.ViaVersion.api.minecraft.Position;
-import us.myles.ViaVersion.util.fastutil.CollectionUtil;
-import us.myles.ViaVersion.util.fastutil.IntMap;
import java.util.HashSet;
import java.util.Set;
public class RedstoneConnectionHandler extends ConnectionHandler {
private static final Set redstone = new HashSet<>();
- private static final IntMap connectedBlockStates = CollectionUtil.createIntMap(1296);
- private static final IntMap powerMappings = CollectionUtil.createIntMap(1296);
+ private static final Int2IntOpenHashMap connectedBlockStates = new Int2IntOpenHashMap(1296);
+ private static final Int2IntOpenHashMap powerMappings = new Int2IntOpenHashMap(1296);
static ConnectionData.ConnectorInitAction init() {
final RedstoneConnectionHandler connectionHandler = new RedstoneConnectionHandler();
diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java
index 49e2ae9ff..b1e547384 100644
--- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java
+++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java
@@ -2,9 +2,9 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import com.google.common.collect.ObjectArrays;
import com.google.gson.reflect.TypeToken;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import us.myles.ViaVersion.util.GsonUtil;
-import us.myles.ViaVersion.util.fastutil.CollectionUtil;
-import us.myles.ViaVersion.util.fastutil.IntObjectMap;
import java.io.IOException;
import java.io.InputStream;
@@ -15,7 +15,7 @@ import java.util.Map;
public class BlockIdData {
public static Map blockIdMapping;
public static Map fallbackReverseMapping;
- public static IntObjectMap numberIdToString;
+ public static Int2ObjectMap numberIdToString;
public static void init() {
InputStream stream = MappingData.class.getClassLoader()
@@ -47,11 +47,11 @@ public class BlockIdData {
.getResourceAsStream("assets/viaversion/data/blockNumberToString1.12.json");
InputStreamReader blockR = new InputStreamReader(blockS);
try {
- numberIdToString = CollectionUtil.createIntObjectMap(new HashMap<>(GsonUtil.getGson().fromJson(
+ numberIdToString = new Int2ObjectOpenHashMap<>(GsonUtil.getGson().fromJson(
blockR,
new TypeToken