RegistryNamespaced .java

net.minecraft.util.RegistryNamespaced (class, 71 lines): members: inverseObjectRegistry, underlyingIntegerMap, getNameForObject, getIDForObject, register.

net.minecraft.utilclass71 linescommonextends RegistrySimple<K1.6 KB

Implements

API Surface (8)

void register(int id, K key, V value)
Map<K, V> createUnderlyingMap()
V getObject(K name)
K getNameForObject(V value)
boolean containsKey(K key)
int getIDForObject(V value)
V getObjectById(int id)
Iterator<V> iterator()

Fields & Constants (2)

underlyingIntegerMap
inverseObjectRegistry

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RegistryNamespaced.java71 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.util;
2
3
import com.google.common.collect.BiMap;
4
import com.google.common.collect.HashBiMap;
5
import java.util.Iterator;
6
import java.util.Map;
7
8
public class RegistryNamespaced<K, V> extends RegistrySimple<K, V> implements IObjectIntIterable<V>
9
{
10
    protected final ObjectIntIdentityMap<V> underlyingIntegerMap = new ObjectIntIdentityMap();
11
    protected final Map<V, K> inverseObjectRegistry;
12
13
    public RegistryNamespaced()
14
    {
15
        this.inverseObjectRegistry = ((BiMap)this.registryObjects).inverse();
16
    }
17
18
    public void register(int id, K key, V value)
19
    {
20
        this.underlyingIntegerMap.put(value, id);
21
        this.putObject(key, value);
22
    }
23
24
    protected Map<K, V> createUnderlyingMap()
25
    {
26
        return HashBiMap.<K, V>create();
27
    }
28
29
    public V getObject(K name)
30
    {
31
        return super.getObject(name);
32
    }
33
34
    /**
35
     * Gets the name we use to identify the given object.
36
     */
37
    public K getNameForObject(V value)
38
    {
39
        return (K)this.inverseObjectRegistry.get(value);
40
    }
41
42
    /**
43
     * Does this registry contain an entry for the given key?
44
     */
45
    public boolean containsKey(K key)
46
    {
47
        return super.containsKey(key);
48
    }
49
50
    /**
51
     * Gets the integer ID we use to identify the given object.
52
     */
53
    public int getIDForObject(V value)
54
    {
55
        return this.underlyingIntegerMap.get(value);
56
    }
57
58
    /**
59
     * Gets the object identified by the given ID.
60
     */
61
    public V getObjectById(int id)
62
    {
63
        return (V)this.underlyingIntegerMap.getByValue(id);
64
    }
65
66
    public Iterator<V> iterator()
67
    {
68
        return this.underlyingIntegerMap.iterator();
69
    }
70
}
71

Deobfuscated MCP 1.8.9 source of RegistryNamespaced from Marcelektro/MavenMCP-1.8.9 (net/minecraft/util/RegistryNamespaced.java), stored verbatim.