From 45d6317d12c24ca8d2c93b8a9be289718dca476a Mon Sep 17 00:00:00 2001 From: drcrazy Date: Thu, 23 Aug 2018 14:05:22 +0300 Subject: [PATCH] Changes plates registration --- .../techreborn/client/RegisterItemJsons.java | 6 +- src/main/java/techreborn/init/ModItems.java | 4 +- src/main/java/techreborn/init/ModPlates.java | 65 +++++-------------- 3 files changed, 20 insertions(+), 55 deletions(-) diff --git a/src/main/java/techreborn/client/RegisterItemJsons.java b/src/main/java/techreborn/client/RegisterItemJsons.java index 8038f1b5c..3bbef1a12 100644 --- a/src/main/java/techreborn/client/RegisterItemJsons.java +++ b/src/main/java/techreborn/client/RegisterItemJsons.java @@ -132,10 +132,8 @@ public class RegisterItemJsons { for (int i = 0; i < ItemGems.types.length; ++i) { registerBlockstate(ModItems.GEMS, i, name[i], "items/materials/"); } - - for (ModPlates plate : ModPlates.values()){ - plate.registerModel(); - } + + ModPlates.registerModel(); name = ItemNuggets.types.clone(); for (int i = 0; i < ItemNuggets.types.length; ++i) { diff --git a/src/main/java/techreborn/init/ModItems.java b/src/main/java/techreborn/init/ModItems.java index c64ea3adb..402f7e50b 100644 --- a/src/main/java/techreborn/init/ModItems.java +++ b/src/main/java/techreborn/init/ModItems.java @@ -165,9 +165,7 @@ public class ModItems { SMALL_DUSTS = new ItemDustsSmall(); registerItem(SMALL_DUSTS, "smallDust"); - for (ModPlates plate : ModPlates.values()){ - plate.register(); - } + ModPlates.register(); NUGGETS = new ItemNuggets(); registerItem(NUGGETS, "nuggets"); diff --git a/src/main/java/techreborn/init/ModPlates.java b/src/main/java/techreborn/init/ModPlates.java index 0dae12abd..ac4c0b401 100644 --- a/src/main/java/techreborn/init/ModPlates.java +++ b/src/main/java/techreborn/init/ModPlates.java @@ -24,6 +24,8 @@ package techreborn.init; +import java.util.Arrays; + import com.google.common.base.CaseFormat; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -38,75 +40,42 @@ import reborncore.RebornRegistry; import techreborn.lib.ModInfo; import techreborn.items.ItemPlates; - /** * @author drcrazy * */ public enum ModPlates implements IStringSerializable { - ADVANCED_ALLOY, - ALUMINUM, - BRASS, - BRONZE, - CARBON, - COAL, - COPPER, - DIAMOND, - ELECTRUM, - EMERALD, - GOLD, - INVAR, - IRIDIUM_ALLOY, - IRIDIUM, - IRON, - LAPIS, - LAZURITE, - LEAD, - MAGNALIUM, - NICKEL, - OBSIDIAN, - PERIDOT, - PLATINUM, - RED_GARNET, - REDSTONE, - REFINED_IRON, - RUBY, - SAPPHIRE, - SILICON, - SILVER, - STEEL, - TIN, - TITANIUM, - TUNGSTEN, - TUNGSTENSTEEL, - WOOD, - YELLOW_GARNET, - ZINC; - + ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CARBON, COAL, COPPER, DIAMOND, ELECTRUM, EMERALD, GOLD, INVAR, + IRIDIUM_ALLOY, IRIDIUM, IRON, LAPIS, LAZURITE, LEAD, MAGNALIUM, NICKEL, OBSIDIAN, PERIDOT, PLATINUM, RED_GARNET, + REDSTONE, REFINED_IRON, RUBY, SAPPHIRE, SILICON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, WOOD, + YELLOW_GARNET, ZINC; + public final String name; public final Item item; - + private ModPlates() { name = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "PLATE_" + this.toString()); item = new ItemPlates(); item.setRegistryName(new ResourceLocation(ModInfo.MOD_ID, name)); item.setTranslationKey(ModInfo.MOD_ID + "." + name); } - + public ItemStack getStack() { return new ItemStack(item); } - public void register() { - RebornRegistry.registerItem(item); + public static void register() { + Arrays.stream(ModPlates.values()).forEach(plate -> RebornRegistry.registerItem(plate.item)); + } - + @SideOnly(Side.CLIENT) - public void registerModel() { + public static void registerModel() { ResourceLocation blockstateJson = new ResourceLocation(ModInfo.MOD_ID, "items/materials/plates"); - ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(blockstateJson, "type=" + name)); + Arrays.stream(ModPlates.values()).forEach(plate -> ModelLoader.setCustomModelResourceLocation(plate.item, 0, + new ModelResourceLocation(blockstateJson, "type=" + plate.name))); } - + @Override public String getName() { return name;