Changes plates registration

This commit is contained in:
drcrazy 2018-08-23 14:05:22 +03:00
parent c86f3dc2f4
commit 45d6317d12
3 changed files with 20 additions and 55 deletions

View file

@ -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) {

View file

@ -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");

View file

@ -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;