mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 11:09:06 +00:00
NMS Stuff
This commit is contained in:
@@ -21,6 +21,12 @@ package com.volmit.iris.util.nbt.mca.palette;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.minecraft.Util;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -28,11 +34,11 @@ import java.util.List;
|
||||
|
||||
public class MCAIdMapper<T> implements MCAIdMap<T> {
|
||||
public static final int DEFAULT = -1;
|
||||
private final IdentityHashMap<T, Integer> tToId;
|
||||
private final Object2IntMap<T> tToId;
|
||||
private final List<T> idToT;
|
||||
private int nextId;
|
||||
|
||||
public MCAIdMapper(IdentityHashMap<T, Integer> tToId, List<T> idToT, int nextId) {
|
||||
public MCAIdMapper(Object2IntMap<T> tToId, List<T> idToT, int nextId) {
|
||||
this.tToId = tToId;
|
||||
this.idToT = idToT;
|
||||
this.nextId = nextId;
|
||||
@@ -44,7 +50,7 @@ public class MCAIdMapper<T> implements MCAIdMap<T> {
|
||||
|
||||
public MCAIdMapper(int var0) {
|
||||
this.idToT = Lists.newArrayListWithExpectedSize(var0);
|
||||
this.tToId = new IdentityHashMap<>(var0);
|
||||
this.tToId = new Object2IntOpenCustomHashMap<>(var0, IdentityStrategy.INSTANCE);
|
||||
}
|
||||
|
||||
public void addMapping(T var0, int var1) {
|
||||
@@ -82,4 +88,19 @@ public class MCAIdMapper<T> implements MCAIdMap<T> {
|
||||
public int size() {
|
||||
return this.tToId.size();
|
||||
}
|
||||
|
||||
static enum IdentityStrategy implements Hash.Strategy<Object> {
|
||||
INSTANCE;
|
||||
|
||||
private IdentityStrategy() {
|
||||
}
|
||||
|
||||
public int hashCode(Object var0) {
|
||||
return System.identityHashCode(var0);
|
||||
}
|
||||
|
||||
public boolean equals(Object var0, Object var1) {
|
||||
return var0 == var1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user