diff options
| author | Giovanni Harting <539@idlegandalf.com> | 2018-02-08 19:37:21 +0100 |
|---|---|---|
| committer | Giovanni Harting <539@idlegandalf.com> | 2018-02-08 19:37:21 +0100 |
| commit | 17ae55c35992829bf377ac5bc0741b234cb90bda (patch) | |
| tree | 3608c15d29184573dd7dc562d62f26bb9a8de385 /src/main/java/com/sosnitzka/taiga/Items.java | |
| parent | 1c07cfc5ee463bf7b95e7d4814526c15007f9c87 (diff) | |
1.12.2; not well tested; book integration still broken
Diffstat (limited to 'src/main/java/com/sosnitzka/taiga/Items.java')
| -rw-r--r-- | src/main/java/com/sosnitzka/taiga/Items.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/java/com/sosnitzka/taiga/Items.java b/src/main/java/com/sosnitzka/taiga/Items.java index 4655d73..de28c36 100644 --- a/src/main/java/com/sosnitzka/taiga/Items.java +++ b/src/main/java/com/sosnitzka/taiga/Items.java @@ -4,7 +4,8 @@ package com.sosnitzka.taiga; import com.google.common.base.Joiner; import com.sosnitzka.taiga.generic.BasicItem; import net.minecraft.item.Item; -import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.StringUtils; @@ -173,32 +174,36 @@ public class Items { * Gets the ingots declared in the class (fields and reflection) and iterates through them: <br> * Checks that the field is static, registers the field (item), and adds an oreDict entry if needed */ - + @SubscribeEvent public static void register() { Field[] declaredFields = Items.class.getDeclaredFields(); // Gets the fields (ingots) declared above for (Field field : declaredFields) { // Iterates through the fields declared above if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { // Checks that the fields are static Class<?> targetType = field.getType(); try { - Item item = (Item) field.get(targetType); // Gets the field as a BasicItem which is then casted to an Item + Item item = (Item) field.get(targetType); // Gets the field as a BasicItem which is then casted + // to an Item if (item.equals(ironNugget) && OreDictionary.doesOreNameExist("nuggetIron")) { System.out.println("TAIGA: Skipped registration of nuggetIron which already exists."); continue; } item.setCreativeTab(CreativeTab.tabTaigaItem); - GameRegistry.register(item); // Registers the item into the game + ForgeRegistries.ITEMS.register(item); // Registers the item into the game if (item instanceof BasicItem) { // Checks that the item is a BasicItem - if (((BasicItem) item).isOreDict()) { // Checks if this item should be registered into the oreDict and registers it + if (((BasicItem) item).isOreDict()) { // Checks if this item should be registered into the + // oreDict and registers it String oreDictName; String[] nameParts = item.getUnlocalizedName().replace("item.", "").split("_"); if (nameParts.length > 2) { - oreDictName = Joiner.on("_").join(Arrays.copyOfRange(nameParts, 0, nameParts.length - 1)); + oreDictName = Joiner.on("_").join(Arrays.copyOfRange(nameParts, 0, nameParts.length - + 1)); } else { oreDictName = nameParts[0]; } - OreDictionary.registerOre(((BasicItem) item).getOreDictPrefix() + StringUtils.capitalize(oreDictName), item); // Registers into oreDict + OreDictionary.registerOre(((BasicItem) item).getOreDictPrefix() + StringUtils.capitalize + (oreDictName), item); // Registers into oreDict } } } catch (IllegalAccessException e) { |
