From 394d2e7c06873b828f6ef17f01fb534fad0fb503 Mon Sep 17 00:00:00 2001 From: Pascal Date: Tue, 12 Mar 2024 15:21:33 +0100 Subject: [PATCH] Improve tier handling & recipe generation (#19) * initial work * optimize * last improvements * don't go throw each recipe if gtnh is loaded * spotlessApply * add separated configs & adjust upgrade generation * dark steel is also explosion safe * add missing upgrades * another two missing upgrades * use explosion indicator & remove netherite ugprades expect obsidian * use resistance number * make upgrades configurable * prevent crystal/obsidian to darksteel upgrade beeing added if darksteel is disbaled --- .../cpw/mods/ironchest/BlockIronChest.java | 15 +- .../cpw/mods/ironchest/ChestChangerType.java | 56 ++-- .../java/cpw/mods/ironchest/IronChest.java | 49 ++-- .../cpw/mods/ironchest/IronChestType.java | 276 +++++++++++++----- .../assets/ironchest/lang/de_DE.lang | 6 + .../assets/ironchest/lang/en_US.lang | 6 + .../items/crystalDarkSteelUpgrade.png | Bin 0 -> 269 bytes .../textures/items/ironSilverUpgrade.png | Bin 0 -> 354 bytes .../textures/items/ironSteelUpgrade.png | Bin 0 -> 354 bytes .../items/obsidianDarkSteelUpgrade.png | Bin 0 -> 2921 bytes 10 files changed, 283 insertions(+), 125 deletions(-) create mode 100644 src/main/resources/assets/ironchest/textures/items/crystalDarkSteelUpgrade.png create mode 100644 src/main/resources/assets/ironchest/textures/items/ironSilverUpgrade.png create mode 100644 src/main/resources/assets/ironchest/textures/items/ironSteelUpgrade.png create mode 100644 src/main/resources/assets/ironchest/textures/items/obsidianDarkSteelUpgrade.png diff --git a/src/main/java/cpw/mods/ironchest/BlockIronChest.java b/src/main/java/cpw/mods/ironchest/BlockIronChest.java index 25574f55..676125d6 100644 --- a/src/main/java/cpw/mods/ironchest/BlockIronChest.java +++ b/src/main/java/cpw/mods/ironchest/BlockIronChest.java @@ -7,7 +7,6 @@ ******************************************************************************/ package cpw.mods.ironchest; -import static cpw.mods.ironchest.IronChest.ENABLE_STEEL_CHESTS; import static net.minecraftforge.common.util.ForgeDirection.DOWN; import static net.minecraftforge.common.util.ForgeDirection.UP; @@ -220,26 +219,24 @@ public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List } switch (type) { case STEEL -> { - if (ENABLE_STEEL_CHESTS) { + if (IronChestType.STEEL.isEnabled()) { par3List.add(new ItemStack(this, 1, type.ordinal())); } } case SILVER -> { - if (ENABLE_STEEL_CHESTS) { - continue; + if (IronChestType.SILVER.isEnabled()) { + par3List.add(new ItemStack(this, 1, type.ordinal())); } - par3List.add(new ItemStack(this, 1, type.ordinal())); } case DARKSTEEL -> { - if (IronChest.ENABLE_DARK_STEEL_CHESTS) { + if (IronChestType.DARKSTEEL.isEnabled()) { par3List.add(new ItemStack(this, 1, type.ordinal())); } } case NETHERITE -> { - if (IronChest.ENABLE_DARK_STEEL_CHESTS) { - continue; + if (IronChestType.NETHERITE.isEnabled()) { + par3List.add(new ItemStack(this, 1, type.ordinal())); } - par3List.add(new ItemStack(this, 1, type.ordinal())); } default -> par3List.add(new ItemStack(this, 1, type.ordinal())); } diff --git a/src/main/java/cpw/mods/ironchest/ChestChangerType.java b/src/main/java/cpw/mods/ironchest/ChestChangerType.java index 6e9b1838..249d2666 100644 --- a/src/main/java/cpw/mods/ironchest/ChestChangerType.java +++ b/src/main/java/cpw/mods/ironchest/ChestChangerType.java @@ -7,7 +7,6 @@ ******************************************************************************/ package cpw.mods.ironchest; -import static cpw.mods.ironchest.IronChest.ENABLE_STEEL_CHESTS; import static cpw.mods.ironchest.IronChestType.*; import net.minecraft.init.Blocks; @@ -33,7 +32,13 @@ public enum ChestChangerType { OBSIDIANNETHERITE(OBSIDIAN, NETHERITE, "obsidianNetheriteUpgrade", "Obsidian to Netherite Chest Upgrade", "OOO", "msm", "OOO"), DIAMONDDARKSTEEL(DIAMOND, DARKSTEEL, "diamondDarkSteelUpgrade", "Diamond to Dark Steel Chest Upgrade", "OOO", "msm", - "OOO"); + "OOO"), + CRYSTALDARKSTEEL(CRYSTAL, DARKSTEEL, "crystalDarkSteelUpgrade", "Crystal to Dark Steel Chest Upgrade", "OOO", "msm", + "OOO"), + OBSIDIANDARKSTEEL(OBSIDIAN, DARKSTEEL, "obsidianDarkSteelUpgrade", "Obsidian to Dark Steel Chest Upgrade", "OOO", + "msm", "OOO"), + IRONSTEEL(IRON, STEEL, "ironSteelUpgrade", "Iron to Steel Chest Upgrade", "mGm", "GsG", "mGm"), + IRONSILVER(IRON, SILVER, "ironSilverUpgrade", "Iron to Silver Chest Upgrade", "mGm", "GsG", "mGm"); private final IronChestType source; private final IronChestType target; @@ -59,6 +64,10 @@ public int getTarget() { return this.target.ordinal(); } + public boolean isAllowed() { + return target.allowUpgradeFrom(source); + } + public ItemChestChanger buildItem(Configuration cfg) { item = new ItemChestChanger(this); GameRegistry.registerItem(item, itemName); @@ -81,32 +90,31 @@ public void addRecipes() { public static void buildItems(Configuration cfg) { for (ChestChangerType type : values()) { - switch (type) { - case STEELGOLD, COPPERSTEEL -> { - if (ENABLE_STEEL_CHESTS) { - type.buildItem(cfg); + if (type.isAllowed()) { + switch (type) { + case STEELGOLD, COPPERSTEEL -> { + if (IronChestType.STEEL.isEnabled()) { + type.buildItem(cfg); + } } - } - case SILVERGOLD, COPPERSILVER -> { - if (ENABLE_STEEL_CHESTS) { - continue; + case SILVERGOLD, COPPERSILVER -> { + if (IronChestType.SILVER.isEnabled()) { + type.buildItem(cfg); + } } - type.buildItem(cfg); - } - case DIAMONDDARKSTEEL -> { - if (IronChest.ENABLE_DARK_STEEL_CHESTS) { - type.buildItem(cfg); + case DIAMONDDARKSTEEL, CRYSTALDARKSTEEL, OBSIDIANDARKSTEEL -> { + if (IronChestType.DARKSTEEL.isEnabled()) { + type.buildItem(cfg); + } } - } - case OBSIDIANNETHERITE -> { - if (IronChest.ENABLE_DARK_STEEL_CHESTS) { - continue; + case OBSIDIANNETHERITE -> { + if (IronChestType.NETHERITE.isEnabled()) { + type.buildItem(cfg); + } } - type.buildItem(cfg); + default -> type.buildItem(cfg); } - default -> type.buildItem(cfg); } - } } @@ -115,7 +123,9 @@ public static void generateRecipes() { return; } for (ChestChangerType item : values()) { - item.addRecipes(); + if (item.isAllowed()) { + item.addRecipes(); + } } } } diff --git a/src/main/java/cpw/mods/ironchest/IronChest.java b/src/main/java/cpw/mods/ironchest/IronChest.java index 2b199e4e..814723cf 100644 --- a/src/main/java/cpw/mods/ironchest/IronChest.java +++ b/src/main/java/cpw/mods/ironchest/IronChest.java @@ -45,7 +45,10 @@ public class IronChest { public static boolean TRANSPARENT_RENDER_INSIDE = true; public static double TRANSPARENT_RENDER_DISTANCE = 128D; public static boolean ENABLE_STEEL_CHESTS = true; + public static boolean ENABLE_SILVER_CHESTS = false; public static boolean ENABLE_DARK_STEEL_CHESTS = false; + public static boolean ENABLE_NETHERITE_CHESTS = true; + public static String[] blocklistUpgrades = new String[] {}; public static boolean isGTNHLoaded; @EventHandler @@ -60,16 +63,28 @@ public void preInit(FMLPreInitializationEvent event) { .getBoolean(true); TRANSPARENT_RENDER_DISTANCE = cfg.get(Configuration.CATEGORY_GENERAL, "transparentRenderDistance", 128D) .getDouble(128D); - ENABLE_STEEL_CHESTS = cfg.get( - Configuration.CATEGORY_GENERAL, - "enableSteelChests", - true, - "Enables the steel chest instead of the silver chest.").getBoolean(true); + ENABLE_STEEL_CHESTS = cfg + .get(Configuration.CATEGORY_GENERAL, "enableSteelChests", true, "Enables the steel chest.") + .getBoolean(true); + ENABLE_SILVER_CHESTS = cfg + .get(Configuration.CATEGORY_GENERAL, "enableSilverChests", false, "Enables the silver chest.") + .getBoolean(false); ENABLE_DARK_STEEL_CHESTS = cfg.get( Configuration.CATEGORY_GENERAL, "enableDarkSteelChests", isGTNHLoaded, - "Enables the dark steel chest instead the netherit chest.").getBoolean(isGTNHLoaded); + "Enables the dark steel.").getBoolean(isGTNHLoaded); + ENABLE_NETHERITE_CHESTS = cfg.get( + Configuration.CATEGORY_GENERAL, + "enableNetheriteChests", + !isGTNHLoaded, + "Enables the netherite chest.").getBoolean(!isGTNHLoaded); + blocklistUpgrades = cfg.getStringList( + "blocklistUpgrades", + Configuration.CATEGORY_GENERAL, + new String[] {}, + "Disallowed upgrades. All upgrades listed here will not be registred and no recipes will be generated for it." + + "\nExample: IRON:GOLD"); ChestChangerType.buildItems(cfg); } catch (Exception e) { FMLLog.log(Level.ERROR, e, "IronChest has a problem loading its configuration"); @@ -84,21 +99,7 @@ public void preInit(FMLPreInitializationEvent event) { @EventHandler public void load(FMLInitializationEvent evt) { for (IronChestType typ : IronChestType.values()) { - if (typ.name().equals("STEEL") && ENABLE_STEEL_CHESTS) { - GameRegistry.registerTileEntityWithAlternatives( - typ.clazz, - "IronChest." + typ.name(), - typ.name(), - "SILVER", - "IronChest.SILVER"); - } else if (typ.name().equals("SILVER")) { - if (ENABLE_STEEL_CHESTS) { - continue; - } - GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name()); - } else { - GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name()); - } + GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name()); proxy.registerTileEntitySpecialRenderer(typ); } OreDictionary.registerOre("chestWood", Blocks.chest); @@ -120,7 +121,7 @@ public void modsLoaded(FMLPostInitializationEvent evt) {} @Mod.EventHandler public void missingMapping(FMLMissingMappingsEvent event) { for (FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()) { - if (ENABLE_STEEL_CHESTS) { + if (IronChestType.STEEL.isEnabled()) { if (mapping.type == GameRegistry.Type.BLOCK) { switch (mapping.name) { case "IronChest:copperSilverUpgrade": @@ -143,7 +144,7 @@ public void missingMapping(FMLMissingMappingsEvent event) { } } } - if (ENABLE_DARK_STEEL_CHESTS) { + if (IronChestType.DARKSTEEL.isEnabled()) { if (mapping.name.equals("IronChest:obsidianNetheriteUpgrade")) { if (mapping.type == GameRegistry.Type.BLOCK) { mapping.remap(GameRegistry.findBlock("IronChest", "diamondDarkSteelUpgrade")); @@ -151,7 +152,7 @@ public void missingMapping(FMLMissingMappingsEvent event) { mapping.remap(GameRegistry.findItem("IronChest", "diamondDarkSteelUpgrade")); } } - } else { + } else if (IronChestType.NETHERITE.isEnabled()) { if (mapping.name.equals("IronChest:diamondDarkSteelUpgrade")) { if (mapping.type == GameRegistry.Type.BLOCK) { mapping.remap(GameRegistry.findBlock("IronChest", "obsidianNetheriteUpgrade")); diff --git a/src/main/java/cpw/mods/ironchest/IronChestType.java b/src/main/java/cpw/mods/ironchest/IronChestType.java index ef9d22dd..294a7ec0 100644 --- a/src/main/java/cpw/mods/ironchest/IronChestType.java +++ b/src/main/java/cpw/mods/ironchest/IronChestType.java @@ -9,6 +9,9 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,59 +30,79 @@ public enum IronChestType { - IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), - TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"), - GOLD(81, 9, true, "Gold Chest", "goldchest.png", 1, Arrays.asList("ingotGold"), TileEntityGoldChest.class, - "mmmmPmmmm", "mGmG4GmGm"), - DIAMOND(108, 12, true, "Diamond Chest", "diamondchest.png", 2, Arrays.asList("gemDiamond"), - TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"), - COPPER(45, 9, false, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), - TileEntityCopperChest.class, "mmmmCmmmm"), - STEEL(72, 9, false, "Steel Chest", "silverchest.png", 4, Arrays.asList("ingotSteel"), TileEntitySteelChest.class, - "mmmm3mmmm", "mGmG0GmGm"), - CRYSTAL(108, 12, false, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), - TileEntityCrystalChest.class, "GGGGPGGGG"), - OBSIDIAN(108, 12, false, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), - TileEntityObsidianChest.class, "mmmm2mmmm"), - DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "dirtchest.png", 7, Arrays.asList("dirt"), TileEntityDirtChest.class, - Item.getItemFromBlock(Blocks.dirt), "mmmmCmmmm"), - NETHERITE(135, 15, true, "Netherite Chest", "netheritechest.png", 2, Arrays.asList("ingotNetherite"), - TileEntityNetheriteChest.class, "OOOmPmOOO", "OOOO6Ommm"), - DARKSTEEL(135, 15, true, "Dark Steel Chest", "darksteelchest.png", 2, Arrays.asList("ingotDarkSteel"), - TileEntityDarkSteelChest.class, "OOOmPmOOO", "OOOO4Ommm"), - SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), - TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"), - WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null); + IRON(54, 9, 2, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), + TileEntityIronChest.class, null, "mGmGPGmGm", "mmmmPmmmm", 0), + GOLD(81, 9, 4, "Gold Chest", "goldchest.png", 1, Arrays.asList("ingotGold"), TileEntityGoldChest.class, null, + "mGmGPGmGm", "mmmmPmmmm", 0), + DIAMOND(108, 12, 5, "Diamond Chest", "diamondchest.png", 2, Arrays.asList("gemDiamond"), + TileEntityDiamondChest.class, null, "GGGmPmGGG", "GGGGPGmmm", 0), + COPPER(45, 9, 1, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, + null, "mmmmPmmmm", "mGmGPGmGm", 0), + STEEL(72, 9, 3, "Steel Chest", "silverchest.png", 4, Arrays.asList("ingotSteel"), TileEntitySteelChest.class, null, + "mGmGPGmGm", "mmmmPmmmm", 0), + CRYSTAL(108, 12, 5, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), + TileEntityCrystalChest.class, "mmmmPmmmm", null, null, 0), + OBSIDIAN(108, 12, 5, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), + TileEntityObsidianChest.class, "mmmmPmmmm", null, null, 1), + DIRTCHEST9000(1, 1, -1, "Dirt Chest 9000", "dirtchest.png", 7, Arrays.asList("dirt"), TileEntityDirtChest.class, + Item.getItemFromBlock(Blocks.dirt), "mmmmCmmmm", null, null, 0), + NETHERITE(135, 15, 6, "Netherite Chest", "netheritechest.png", 2, Arrays.asList("ingotNetherite"), + TileEntityNetheriteChest.class, null, "OOOmPmOOO", "OOOOPOmmm", 1), + DARKSTEEL(135, 15, 6, "Dark Steel Chest", "darksteelchest.png", 2, Arrays.asList("ingotDarkSteel"), + TileEntityDarkSteelChest.class, null, "OOOmPmOOO", "OOOOPOmmm", 0), + SILVER(72, 9, 3, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, + null, "mGmGPGmGm", "mmmmPmmmm", 0), + WOOD(0, 0, -1, "", "", -1, Arrays.asList("plankWood"), null, null, null, null, 0); final int size; private final int rowLength; public final String friendlyName; - private final boolean tieredChest; + private final Integer tier; private final String modelTexture; private final int textureRow; public final Class clazz; - private final String[] recipes; + private final String recipeDirect; + private final String recipeUpgradeOneTier; + private final String recipeUpgradeTwoTiers; private final ArrayList matList; private final Item itemFilter; - - IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, - int textureRow, List mats, Class clazz, String... recipes) { - this(size, rowLength, tieredChest, friendlyName, modelTexture, textureRow, mats, clazz, (Item) null, recipes); + private final int resistance; + + IronChestType(int size, int rowLength, int tier, String friendlyName, String modelTexture, int textureRow, + List mats, Class clazz, String recipeDirect, + String recipeUpgradeOneTier, String recipeUpgradeTwoTiers, int resistance) { + this( + size, + rowLength, + tier, + friendlyName, + modelTexture, + textureRow, + mats, + clazz, + (Item) null, + recipeDirect, + recipeUpgradeOneTier, + recipeUpgradeTwoTiers, + resistance); } - IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, - int textureRow, List mats, Class clazz, Item itemFilter, - String... recipes) { + IronChestType(int size, int rowLength, int tier, String friendlyName, String modelTexture, int textureRow, + List mats, Class clazz, Item itemFilter, String recipeDirect, + String recipeUpgradeOneTier, String recipeUpgradeTwoTiers, int resistance) { this.size = size; this.rowLength = rowLength; - this.tieredChest = tieredChest; + this.tier = tier; this.friendlyName = friendlyName; this.modelTexture = modelTexture; this.textureRow = textureRow; this.clazz = clazz; this.itemFilter = itemFilter; - this.recipes = recipes; + this.recipeDirect = recipeDirect; + this.recipeUpgradeOneTier = recipeUpgradeOneTier; + this.recipeUpgradeTwoTiers = recipeUpgradeTwoTiers; this.matList = new ArrayList(); + this.resistance = resistance; matList.addAll(mats); } @@ -91,6 +114,31 @@ public int getTextureRow() { return textureRow; } + public boolean isEnabled() { + if (this == STEEL) { + return IronChest.ENABLE_STEEL_CHESTS; + } else if (this == SILVER) { + return IronChest.ENABLE_SILVER_CHESTS; + } else if (this == DARKSTEEL) { + return IronChest.ENABLE_DARK_STEEL_CHESTS; + } else if (this == NETHERITE) { + return IronChest.ENABLE_NETHERITE_CHESTS; + } + return true; + } + + public boolean allowUpgradeFrom(IronChestType typ) { + var name = typ.name() + ":" + this.name(); + + for (String blocked : IronChest.blocklistUpgrades) { + if (blocked.equals(name)) { + return false; + } + } + + return true; + } + public static TileEntityIronChest makeEntity(int metadata) { // Compatibility int chesttype = validateMeta(metadata); @@ -105,52 +153,109 @@ public static TileEntityIronChest makeEntity(int metadata) { return null; } - public static void registerBlocksAndRecipes(BlockIronChest blockResult) { - Object previous = "chestWood"; + public static IronChestType[] getAll() { + return values(); + } + + public static IronChestType[] getAllSortedByTier() { + IronChestType[] vals = getAll(); + + Arrays.sort(vals, new Comparator() { + + public int compare(IronChestType a, IronChestType b) { + return a.tier.compareTo(b.tier); + } + }); + + return vals; + } + + public static IronChestType[] getAllByTier(int i) { + HashSet vals = new HashSet(); + for (IronChestType typ : values()) { - if ((typ == NETHERITE) && IronChest.ENABLE_DARK_STEEL_CHESTS) { - continue; + if (typ.tier == i) { + vals.add(typ); } + } + + return vals.toArray(new IronChestType[vals.size()]); + } - generateRecipesForType(blockResult, previous, typ); - ItemStack chest = new ItemStack(blockResult, 1, typ.ordinal()); - if (typ.isValidForCreativeMode()) { - GameRegistry.registerCustomItemStack(typ.friendlyName, chest); + public static void registerBlocksAndRecipes(BlockIronChest blockResult) { + IronChestType[] vals = getAllSortedByTier(); + + for (IronChestType typ : vals) { + if (typ.isEnabled()) { + ItemStack chest = new ItemStack(blockResult, 1, typ.ordinal()); + registerChest(typ, chest); + if (typ.isValidForCreativeMode()) { + GameRegistry.registerCustomItemStack(typ.friendlyName, chest); + } } - if (typ.tieredChest) { - previous = chest; + } + + if (!IronChest.isGTNHLoaded) { + for (IronChestType typ : vals) { + if (typ.isEnabled()) { + generateRecipesForType(typ); + } } } } - public static void generateRecipesForType(BlockIronChest blockResult, Object previousTier, IronChestType type) { - if (IronChest.isGTNHLoaded) { - return; - } - for (String recipe : type.recipes) { - String[] recipeSplit = new String[] { recipe.substring(0, 3), recipe.substring(3, 6), - recipe.substring(6, 9) }; - Object mainMaterial = null; - for (String mat : type.matList) { - mainMaterial = translateOreName(mat); - // spotless:off - addRecipe(new ItemStack(blockResult, 1, type.ordinal()), recipeSplit, - 'm', mainMaterial, 'P', previousTier, /* previous tier of chest */ - 'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian, - '0', new ItemStack(blockResult, 1, 0), /* Iron Chest */ - '1', new ItemStack(blockResult, 1, 1), /* Gold Chest */ - '2', new ItemStack(blockResult, 1, 2), /* Diamond Chest */ - '3', new ItemStack(blockResult, 1, 3), /* Copper Chest */ - '4', new ItemStack(blockResult, 1, 4), /* Silver Chest */ - '5', new ItemStack(blockResult, 1, 10), /* Netherite Chest */ - '6', new ItemStack(blockResult, 1, 7) /* Obsidian Chest */ - - ); - // spotless:on + public static void generateRecipesForType(IronChestType typ) { + ItemStack chest = getRegistredChest(typ); + + for (String mat : typ.matList) { + Object mainMaterial = translateOreName(mat); + + // spotless:off + if (typ.recipeDirect != null) { + Object[] curTiers = getRegistredChestsByTier(typ, typ.tier, typ.resistance - 1); + if (curTiers.length > 1) { + for (Object curTier : curTiers) { /* mainly meant for crystal and obsidian chests */ + if (curTier != chest) { + addRecipe(chest, getRecipeSplitted(typ.recipeDirect), + 'm', mainMaterial, 'P', curTier, + 'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian + ); + } + } + } + else { + addRecipe(chest, getRecipeSplitted(typ.recipeDirect), + 'm', mainMaterial, + 'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian + ); + } + } + if (typ.recipeUpgradeOneTier != null) { + Object[] prevTiers = getRegistredChestsByTier(typ, typ.tier - 1, typ.resistance); + for (Object prevTier : prevTiers) { + addRecipe(chest, getRecipeSplitted(typ.recipeUpgradeOneTier), + 'm', mainMaterial, 'P', prevTier, /* previous tier of chest */ + 'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian + ); + } } + if (typ.recipeUpgradeTwoTiers != null) { + Object[] prevPrevTiers = getRegistredChestsByTier(typ, typ.tier - 2, typ.resistance); + for (Object prevTier : prevPrevTiers) { + addRecipe(chest, getRecipeSplitted(typ.recipeUpgradeTwoTiers), + 'm', mainMaterial, 'P', prevTier, /* previous tier of chest */ + 'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian + ); + } + } + // spotless:on } } + public static String[] getRecipeSplitted(String recipe) { + return new String[] { recipe.substring(0, 3), recipe.substring(3, 6), recipe.substring(6, 9) }; + } + public static Object translateOreName(String mat) { if (mat.equals("obsidian")) { return Blocks.obsidian; @@ -194,7 +299,7 @@ public boolean isValidForCreativeMode() { } public boolean isExplosionResistant() { - return this == OBSIDIAN || this == NETHERITE; + return this.resistance >= 1; } @SideOnly(Side.CLIENT) @@ -222,6 +327,7 @@ public IIcon getIcon(int side) { return icons[sideMapping[side]]; } + private static final HashMap registredChests = new HashMap(); private static final String[] sideNames = { "top", "front", "side" }; private static final int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 }; @@ -238,4 +344,36 @@ public void adornItemDrop(ItemStack item) { item.setTagInfo("dirtchest", new NBTTagByte((byte) 1)); } } + + private static void registerChest(IronChestType typ, ItemStack stack) { + registredChests.put(typ, stack); + } + + public static ItemStack getRegistredChest(IronChestType typ) { + return registredChests.getOrDefault(typ, null); + } + + public static Object[] getRegistredChestsByTier(IronChestType parentMaterial, int tier, int resistance) { + if (tier < 0) { + return new Object[0]; + } + + if (tier == 0) { + return new Object[] { "chestWood" }; + } + + IronChestType[] allTyps = getAllByTier(tier); + HashSet result = new HashSet(); + + for (IronChestType typ : allTyps) { + if (typ.tier == tier && typ.resistance >= resistance && parentMaterial.allowUpgradeFrom(typ)) { + ItemStack itemStack = getRegistredChest(typ); + if (itemStack != null) { + result.add(itemStack); + } + } + } + + return result.toArray(new Object[result.size()]); + } } diff --git a/src/main/resources/assets/ironchest/lang/de_DE.lang b/src/main/resources/assets/ironchest/lang/de_DE.lang index daae348d..56e4717e 100644 --- a/src/main/resources/assets/ironchest/lang/de_DE.lang +++ b/src/main/resources/assets/ironchest/lang/de_DE.lang @@ -23,6 +23,12 @@ item.ironchest:WOODCOPPER.name=Holz-zu-Kupfertruhen-Upgrade item.ironchest:DIAMONDOBSIDIAN.name=Diamant-zu-Obsidiantruhen-Upgrade item.ironchest:OBSIDIANNETHERITE.name=Obsidian-zu-Netherittruhen-Upgrade item.ironchest:DIAMONDDARKSTEEL.name=Diamant-zu-Dunkelstahltruhen-Upgrade +item.ironchest:DIAMONDNETHERITE.name=Diamant-zu-Netherittruhen-Upgrade +item.ironchest:CRYSTALNETHERITE.name=Kristall-zu-Netherittruhen-Upgrade +item.ironchest:CRYSTALDARKSTEEL.name=Kristall-zu-Dunkelstahltruhen-Upgrade +item.ironchest:OBSIDIANDARKSTEEL.name=Obsidian-zu-Dunkelstahltruhen-Upgrade +item.ironchest:IRONSTEEL.name=Eisen-zu-Stahltruhen-Upgrade +item.ironchest:IRONSILVER.name=Eisen-zu-Silbertruhen-Upgrade book.ironchest:dirtchest9000.title=Wie du deine neue DirtChest 9000 nutzt! book.ironchest:dirtchest9000.page1=Willkommen zu Ihrer neuen DirtChest 9000! Wir hoffen, dass Sie viele freudige Jahre genießen werden, wenn Sie Ihre Erd-Stacks in unserem nützlichen Speichergerät lagern. diff --git a/src/main/resources/assets/ironchest/lang/en_US.lang b/src/main/resources/assets/ironchest/lang/en_US.lang index 8dc63281..e23b27e3 100644 --- a/src/main/resources/assets/ironchest/lang/en_US.lang +++ b/src/main/resources/assets/ironchest/lang/en_US.lang @@ -23,6 +23,12 @@ item.ironchest:WOODCOPPER.name=Wood to Copper Chest Upgrade item.ironchest:DIAMONDOBSIDIAN.name=Diamond to Obsidian Chest Upgrade item.ironchest:OBSIDIANNETHERITE.name=Obsidian to Netherite Chest Upgrade item.ironchest:DIAMONDDARKSTEEL.name=Diamond to Dark Steel Chest Upgrade +item.ironchest:DIAMONDNETHERITE.name=Diamond to Netherite Chest Upgrade +item.ironchest:CRYSTALNETHERITE.name=Crystal to Netherite Chest Upgrade +item.ironchest:CRYSTALDARKSTEEL.name=Crystal to Dark Steel Chest Upgrade +item.ironchest:OBSIDIANDARKSTEEL.name=Obsidian to Dark Steel Chest Upgrade +item.ironchest:IRONSTEEL.name=Iron to Steel Chest Upgrade +item.ironchest:IRONSILVER.name=Iron to Silver Chest Upgrade book.ironchest:dirtchest9000.title=How to use your DirtChest 9000! book.ironchest:dirtchest9000.page1=Welcome to your new DirtChest 9000! We hope you will enjoy many happy years of storing your stack of dirt in our storage utility. diff --git a/src/main/resources/assets/ironchest/textures/items/crystalDarkSteelUpgrade.png b/src/main/resources/assets/ironchest/textures/items/crystalDarkSteelUpgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..12b9f232e0a4fa3da8d784ed1e8af7b88403e18b GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|&0G|+7UQQtiAt`xDc}+zP2TS|Vpb+Il&m?x+gUHeWsc$ z08%_9L4Lvi5r9GH{<(8Nan1sd$YKTtZeb8+WSBKa0w@^e>Ealo5uAE1kney32XjE+ zoV+{#_i1aK*iBtqOiKcQ3vWgkDraf{vle4L@>ODgT^F%$7*3(8j1*|u$<7Y_b xrP%#f|H$9IYAI(x=OvaC7nGZQ8-xWXit9gMfA{8Jwk^;W22WQ%mvv4FO#ryHTXg^c literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/ironchest/textures/items/ironSilverUpgrade.png b/src/main/resources/assets/ironchest/textures/items/ironSilverUpgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..c4c663ef9455b0a2f497474f367a91b22c557cf2 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%LhJ0G|-onR8}7eev|c;|I6y-nxD7_T_7ruUx-!`rPR==g(Blo>$O6>F}|` zhmIb)_2d7^r>}SI-F4~hmrd(e9lG^!)7DKJPhVWT`{1gzs}?U?ylCm7xeMmbnLh_; z@TK^`I3Oic666>BA2(nS-}LA@P#tH1M`SSr1Gg{;GcwGYBLNi5_jGX#(FhJb6E4)C zz~g#R{l3+*Ur*dbg$p1sEu*TuIu6xVyl@nmOiOqusXl>nKo0`rU?@mR=k>} z-n=vGLfPBD?Jt)yUc1FUr}#0;``VV7(&8-wcKUZ(N~8a8cz;}eiGBg^eNGkOhrJyy ZSju7qRr~K8N&s5T;OXk;vd$@?2>@<8si6P> literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/ironchest/textures/items/ironSteelUpgrade.png b/src/main/resources/assets/ironchest/textures/items/ironSteelUpgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..c4c663ef9455b0a2f497474f367a91b22c557cf2 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%LhJ0G|-onR8}7eev|c;|I6y-nxD7_T_7ruUx-!`rPR==g(Blo>$O6>F}|` zhmIb)_2d7^r>}SI-F4~hmrd(e9lG^!)7DKJPhVWT`{1gzs}?U?ylCm7xeMmbnLh_; z@TK^`I3Oic666>BA2(nS-}LA@P#tH1M`SSr1Gg{;GcwGYBLNi5_jGX#(FhJb6E4)C zz~g#R{l3+*Ur*dbg$p1sEu*TuIu6xVyl@nmOiOqusXl>nKo0`rU?@mR=k>} z-n=vGLfPBD?Jt)yUc1FUr}#0;``VV7(&8-wcKUZ(N~8a8cz;}eiGBg^eNGkOhrJyy ZSju7qRr~K8N&s5T;OXk;vd$@?2>@<8si6P> literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/ironchest/textures/items/obsidianDarkSteelUpgrade.png b/src/main/resources/assets/ironchest/textures/items/obsidianDarkSteelUpgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..cf413f33443c9cf06a5d2c3f1f0af9cf80065e97 GIT binary patch literal 2921 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 Tw^8CJ00000NkvXXu0mjfNXcn~ literal 0 HcmV?d00001