All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.RegistryID Maven / Gradle / Ivy

package net.minecraft.server;

import com.google.common.base.Predicates;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;

public class RegistryID implements Registry {
  public final IdentityHashMap a = new IdentityHashMap<>(512); // ChestMC - private -> public.
  private final List b = Lists.newArrayList();

  public RegistryID() {}

  public void a(T t0, int i) {
    this.a.put(t0, i);

    while (this.b.size() <= i) {
      this.b.add(null);
    }

    this.b.set(i, t0);
  }

  public int b(T element) {
    Integer integer = this.a.get(element);
    return integer != null ? integer : -1;
  }

  public final T a(int i) {
    return i >= 0 && i < this.b.size() ? this.b.get(i) : null;
  }

  public Iterator iterator() {
    return Iterators.filter(this.b.iterator(), Predicates.notNull());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy