blob: fe91b920b82409869cb03d7b165ce42e5d581bf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package moe.nea.morbing;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.registry.Registry;
import java.util.ArrayList;
import java.util.List;
public class ModRegistry<T> {
private Registry<T> registry;
private List<Pair<Identifier, T>> toRegister = new ArrayList<>();
public ModRegistry(Registry<T> registry) {
this.registry = registry;
}
protected <U extends T> U register(String id, U item) {
toRegister.add(new Pair<>(new Identifier(Morbing.MODID, id), item));
return item;
}
public void registerAll() {
toRegister.forEach(it ->
Registry.register(registry, it.getLeft(), it.getRight())
);
}
}
|