From 91775aff41aa2aa0b0fe24cd720e608409f2b9e3 Mon Sep 17 00:00:00 2001 From: FortressNebula Date: Wed, 19 Jan 2022 19:14:34 +0000 Subject: [PATCH] Allow copper block set to use different root directories CopperBlockSet has many useful functionalities that addons could use for their own metals that also oxidize. It'd be nicer and more intuitive for anyone going through our github, however, if they could be in their own separate directory. --- .../foundation/block/CopperBlockSet.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/block/CopperBlockSet.java b/src/main/java/com/simibubi/create/foundation/block/CopperBlockSet.java index be2127af8..fe3dc7ceb 100644 --- a/src/main/java/com/simibubi/create/foundation/block/CopperBlockSet.java +++ b/src/main/java/com/simibubi/create/foundation/block/CopperBlockSet.java @@ -55,18 +55,28 @@ public class CopperBlockSet { new Variant[] { BlockVariant.INSTANCE, SlabVariant.INSTANCE, StairVariant.INSTANCE }; protected final String name; + protected final String generalDirectory; // Leave empty for root folder protected final Variant[] variants; protected final Map, BlockEntry[]> entries = new HashMap<>(); protected final NonNullBiConsumer, RegistrateRecipeProvider> mainBlockRecipe; protected final String endTextureName; public CopperBlockSet(AbstractRegistrate registrate, String name, String endTextureName, Variant[] variants) { - this(registrate, name, endTextureName, variants, NonNullBiConsumer.noop()); + this(registrate, name, endTextureName, variants, NonNullBiConsumer.noop(), "copper/"); + } + + public CopperBlockSet(AbstractRegistrate registrate, String name, String endTextureName, Variant[] variants, String generalDirectory) { + this(registrate, name, endTextureName, variants, NonNullBiConsumer.noop(), generalDirectory); + } + + public CopperBlockSet(AbstractRegistrate registrate, String name, String endTextureName, Variant[] variants, NonNullBiConsumer, RegistrateRecipeProvider> mainBlockRecipe) { + this(registrate, name, endTextureName, variants, mainBlockRecipe, "copper/"); } public CopperBlockSet(AbstractRegistrate registrate, String name, String endTextureName, Variant[] variants, - NonNullBiConsumer, RegistrateRecipeProvider> mainBlockRecipe) { + NonNullBiConsumer, RegistrateRecipeProvider> mainBlockRecipe, String generalDirectory) { this.name = name; + this.generalDirectory = generalDirectory; this.endTextureName = endTextureName; this.variants = variants; this.mainBlockRecipe = mainBlockRecipe; @@ -129,7 +139,7 @@ public class CopperBlockSet { .requires(Items.HONEYCOMB) .unlockedBy("has_unwaxed", RegistrateRecipeProvider.has(unwaxed)) .save(prov, new ResourceLocation(ctx.getId() - .getNamespace(), "crafting/copper/" + ctx.getName() + "_from_honeycomb")); + .getNamespace(), "crafting/" + generalDirectory + ctx.getName() + "_from_honeycomb")); }); } @@ -217,7 +227,7 @@ public class CopperBlockSet { Block block = ctx.get(); String path = block.getRegistryName() .getPath(); - String baseLoc = ModelProvider.BLOCK_FOLDER + "/copper/" + getWeatherStatePrefix(state); + String baseLoc = ModelProvider.BLOCK_FOLDER + "/" + blocks.generalDirectory + getWeatherStatePrefix(state); ResourceLocation texture = prov.modLoc(baseLoc + blocks.getName()); ResourceLocation endTexture = prov.modLoc(baseLoc + blocks.getEndTextureName()); prov.simpleBlock(block, prov.models() @@ -262,7 +272,7 @@ public class CopperBlockSet { ResourceLocation fullModel = prov.modLoc(ModelProvider.BLOCK_FOLDER + "/" + getWeatherStatePrefix(state) + blocks.getName()); - String baseLoc = ModelProvider.BLOCK_FOLDER + "/copper/" + getWeatherStatePrefix(state); + String baseLoc = ModelProvider.BLOCK_FOLDER + "/" + blocks.generalDirectory + getWeatherStatePrefix(state); ResourceLocation texture = prov.modLoc(baseLoc + blocks.getName()); ResourceLocation endTexture = prov.modLoc(baseLoc + blocks.getEndTextureName()); @@ -317,7 +327,7 @@ public class CopperBlockSet { @Override public void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, CopperBlockSet blocks, WeatherState state, boolean waxed) { - String baseLoc = ModelProvider.BLOCK_FOLDER + "/copper/" + getWeatherStatePrefix(state); + String baseLoc = ModelProvider.BLOCK_FOLDER + "/" + blocks.generalDirectory + getWeatherStatePrefix(state); ResourceLocation texture = prov.modLoc(baseLoc + blocks.getName()); ResourceLocation endTexture = prov.modLoc(baseLoc + blocks.getEndTextureName()); prov.stairsBlock(ctx.get(), texture, endTexture, endTexture);