2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8 KiB
Java

package com.zivilon.cinder_loe;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry;
public class ItemRegistration {
public static FMLControlledNamespacedRegistry<Block> block_registry;
public static FMLControlledNamespacedRegistry<Item> item_registry;
static {
block_registry = GameData.getBlockRegistry();
item_registry = GameData.getItemRegistry();
}
public static List<SimpleEntry<Item, String>> list = new ArrayList<>();
@Deprecated
public static void registerItem(Item item, String item_name, int ordinal) {
while (list.size() <= ordinal) {
list.add(new SimpleEntry<>(null, null));
}
list.set(ordinal, new SimpleEntry<>(item, item_name));
}
// Register items in consistent order that persists through mod updates while enabling us to keep the item lists neatly organized.
// Unknown if this is actually necessary, but might help to prevent item ID shifts
public static void registerItems() {
for (int i = 0; i < list.size(); i++) {
SimpleEntry<Item, String> entry = list.get(i);
if (entry == null || entry.getKey() == null || entry.getValue() == null) {
break;
}
GameRegistry.registerItem(entry.getKey(), entry.getValue());
}
}
public static void register(Item item, String item_name, int id) {
item_registry.addObject(id, item_name, item);
}
public static void register(Block block, String item_name, int id) {
block_registry.addObject(id, item_name, block);
}
}