diff --git a/src/main/java/net/minecraftforge/advancements/critereon/ItemPredicates.java b/src/main/java/net/minecraftforge/advancements/critereon/ItemPredicates.java index ff551e0a9..c2e6abe27 100644 --- a/src/main/java/net/minecraftforge/advancements/critereon/ItemPredicates.java +++ b/src/main/java/net/minecraftforge/advancements/critereon/ItemPredicates.java @@ -20,17 +20,18 @@ package net.minecraftforge.advancements.critereon; import com.google.gson.JsonObject; -import gnu.trove.map.hash.THashMap; + import net.minecraft.advancements.critereon.ItemPredicate; import net.minecraft.util.ResourceLocation; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Function; public class ItemPredicates { - private static final Map> predicates = new THashMap<>(); + private static final Map> predicates = new HashMap<>(); static { diff --git a/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java b/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java index a2f61f77c..9263d396b 100644 --- a/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java +++ b/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java @@ -23,7 +23,9 @@ import java.util.Map; import com.google.common.collect.Maps; -import gnu.trove.map.hash.TIntObjectHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + import net.minecraft.client.renderer.ItemModelMesher; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ModelManager; @@ -36,8 +38,8 @@ import net.minecraftforge.registries.IRegistryDelegate; */ public class ItemModelMesherForge extends ItemModelMesher { - Map, TIntObjectHashMap> locations = Maps.newHashMap(); - Map, TIntObjectHashMap> models = Maps.newHashMap(); + final Map, Int2ObjectMap> locations = Maps.newHashMap(); + final Map, Int2ObjectMap> models = Maps.newHashMap(); public ItemModelMesherForge(ModelManager manager) { @@ -47,7 +49,7 @@ public class ItemModelMesherForge extends ItemModelMesher @Override protected IBakedModel getItemModel(Item item, int meta) { - TIntObjectHashMap map = models.get(item.delegate); + Int2ObjectMap map = models.get(item.delegate); return map == null ? null : map.get(meta); } @@ -55,16 +57,16 @@ public class ItemModelMesherForge extends ItemModelMesher public void register(Item item, int meta, ModelResourceLocation location) { IRegistryDelegate key = item.delegate; - TIntObjectHashMap locs = locations.get(key); - TIntObjectHashMap mods = models.get(key); + Int2ObjectMap locs = locations.get(key); + Int2ObjectMap mods = models.get(key); if (locs == null) { - locs = new TIntObjectHashMap(); + locs = new Int2ObjectOpenHashMap<>(); locations.put(key, locs); } if (mods == null) { - mods = new TIntObjectHashMap(); + mods = new Int2ObjectOpenHashMap<>(); models.put(key, mods); } locs.put(meta, location); @@ -75,24 +77,22 @@ public class ItemModelMesherForge extends ItemModelMesher public void rebuildCache() { final ModelManager manager = this.getModelManager(); - for (Map.Entry, TIntObjectHashMap> e : locations.entrySet()) + for (Map.Entry, Int2ObjectMap> e : locations.entrySet()) { - TIntObjectHashMap mods = models.get(e.getKey()); + Int2ObjectMap mods = models.get(e.getKey()); if (mods != null) { mods.clear(); } else { - mods = new TIntObjectHashMap(); + mods = new Int2ObjectOpenHashMap<>(); models.put(e.getKey(), mods); } - final TIntObjectHashMap map = mods; - e.getValue().forEachEntry((meta, location) -> - { - map.put(meta, manager.getModel(location)); - return true; - }); + final Int2ObjectMap map = mods; + e.getValue().int2ObjectEntrySet().forEach(entry -> + map.put(entry.getIntKey(), manager.getModel(entry.getValue())) + ); } } } diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java b/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java index 17e9d09a5..77213b0b2 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java @@ -19,8 +19,6 @@ package net.minecraftforge.fml.common.network; -import gnu.trove.map.hash.TByteObjectHashMap; -import gnu.trove.map.hash.TObjectByteHashMap; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler.Sharable; @@ -31,14 +29,20 @@ import io.netty.util.AttributeKey; import java.lang.ref.WeakReference; import java.util.List; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ByteMap; +import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap; + import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; @Sharable -public abstract class FMLIndexedMessageToMessageCodec extends MessageToMessageCodec { - private TByteObjectHashMap> discriminators = new TByteObjectHashMap>(); - private TObjectByteHashMap> types = new TObjectByteHashMap>(); +public abstract class FMLIndexedMessageToMessageCodec extends MessageToMessageCodec +{ + private final Byte2ObjectMap> discriminators = new Byte2ObjectOpenHashMap<>(); + private final Object2ByteMap> types = new Object2ByteOpenHashMap<>(); /** * Make this accessible to subclasses @@ -71,7 +75,7 @@ public abstract class FMLIndexedMessageToMessageCodec extends MessageToMessag { throw new RuntimeException("Undefined discriminator for message type " + clazz.getSimpleName() + " in channel " + channel); } - byte discriminator = types.get(clazz); + byte discriminator = types.getByte(clazz); PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); buffer.writeByte(discriminator); encodeInto(ctx, msg, buffer);