Import necessary nms and fix decompile errors
This commit is contained in:
148
sources/src/main/java/net/minecraft/server/RegistryID.java
Normal file
148
sources/src/main/java/net/minecraft/server/RegistryID.java
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
import com.google.common.collect.Iterators;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class RegistryID<K> implements Registry {
|
||||||
|
|
||||||
|
private static final Object a = null;
|
||||||
|
private K[] b;
|
||||||
|
private int[] c;
|
||||||
|
private K[] d;
|
||||||
|
private int e;
|
||||||
|
private int f;
|
||||||
|
|
||||||
|
public RegistryID(int i) {
|
||||||
|
i = (int) ((float) i / 0.8F);
|
||||||
|
this.b = (K[]) (new Object[i]);
|
||||||
|
this.c = new int[i];
|
||||||
|
this.d = (K[]) (new Object[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId(@Nullable K k0) {
|
||||||
|
return this.c(this.b(k0, this.d(k0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public K fromId(int i) {
|
||||||
|
return i >= 0 && i < this.d.length ? this.d[i] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int c(int i) {
|
||||||
|
return i == -1 ? -1 : this.c[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int c(K k0) {
|
||||||
|
int i = this.c();
|
||||||
|
|
||||||
|
this.a(k0, i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int c() {
|
||||||
|
while (this.e < this.d.length && this.d[this.e] != null) {
|
||||||
|
++this.e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.e;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void d(int i) {
|
||||||
|
K[] aobject = this.b;
|
||||||
|
int[] aint = this.c;
|
||||||
|
|
||||||
|
this.b = (K[]) (new Object[i]);
|
||||||
|
this.c = new int[i];
|
||||||
|
this.d = (K[]) (new Object[i]);
|
||||||
|
this.e = 0;
|
||||||
|
this.f = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < aobject.length; ++j) {
|
||||||
|
if (aobject[j] != null) {
|
||||||
|
this.a(aobject[j], aint[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(K k0, int i) {
|
||||||
|
int j = Math.max(i, this.f + 1);
|
||||||
|
int k;
|
||||||
|
|
||||||
|
if ((float) j >= (float) this.b.length * 0.8F) {
|
||||||
|
for (k = this.b.length << 1; k < i; k <<= 1) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.d(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
k = this.e(this.d(k0));
|
||||||
|
this.b[k] = k0;
|
||||||
|
this.c[k] = i;
|
||||||
|
this.d[i] = k0;
|
||||||
|
++this.f;
|
||||||
|
if (i == this.e) {
|
||||||
|
++this.e;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int d(@Nullable K k0) {
|
||||||
|
return (MathHelper.f(System.identityHashCode(k0)) & Integer.MAX_VALUE) % this.b.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int b(@Nullable K k0, int i) {
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (j = i; j < this.b.length; ++j) {
|
||||||
|
if (this.b[j] == k0) {
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.b[j] == RegistryID.a) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < i; ++j) {
|
||||||
|
if (this.b[j] == k0) {
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.b[j] == RegistryID.a) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int e(int i) {
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (j = i; j < this.b.length; ++j) {
|
||||||
|
if (this.b[j] == RegistryID.a) {
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < i; ++j) {
|
||||||
|
if (this.b[j] == RegistryID.a) {
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Overflowed :(");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<K> iterator() {
|
||||||
|
return Iterators.filter(Iterators.forArray(this.d), Predicates.notNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int b() {
|
||||||
|
return this.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user