From 9851947a2b6260f05f1632b2422119aecafaa9df Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Sun, 8 Oct 2023 03:39:37 -0600 Subject: [PATCH 1/5] Further improved modded woodtype compatibility Fixed Snifferplus and Cluttered wood type sets. --- .../pfm/blocks/models/ModelHelper.java | 62 +++++++++++++++---- .../basicTable/UnbakedBasicTableModel.java | 16 +++-- .../UnbakedClassicNightstandModel.java | 18 +++--- .../UnbakedClassicTableModel.java | 16 +++-- .../dinnerTable/UnbakedDinnerTableModel.java | 16 +++-- .../UnbakedKitchenCabinetModel.java | 16 +++-- .../UnbakedKitchenCounterModel.java | 16 +++-- .../UnbakedKitchenCounterOvenModel.java | 16 +++-- .../UnbakedKitchenDrawerModel.java | 16 +++-- .../UnbakedKitchenWallCounterModel.java | 17 +++-- .../UnbakedKitchenWallDrawerModel.java | 16 +++-- .../models/logTable/UnbakedLogTableModel.java | 45 +++++--------- .../UnbakedModernDinnerTableModel.java | 16 +++-- .../data/materials/DynamicBlockRegistry.java | 12 ++++ .../data/materials/VariantRegistryBase.java | 4 +- .../pfm/data/materials/WoodVariant.java | 52 +++++++++++----- .../data/materials/WoodVariantRegistry.java | 23 ++++++- .../unlikepaladin/pfm/runtime/PFMDataGen.java | 7 ++- 18 files changed, 223 insertions(+), 161 deletions(-) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java index 18da18663..c8cafef50 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java @@ -6,6 +6,7 @@ import com.unlikepaladin.pfm.runtime.PFMDataGen; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.client.texture.MissingSprite; import net.minecraft.data.client.model.Texture; import net.minecraft.resource.ResourcePack; import net.minecraft.resource.ResourceType; @@ -14,6 +15,7 @@ import net.minecraft.util.Pair; import net.minecraft.util.StringIdentifiable; import net.minecraft.util.registry.Registry; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashMap; @@ -45,38 +47,41 @@ public static BlockType getBlockType(Identifier identifier) { public static VariantBase getVariant(Identifier identifier) { VariantBase var = getExtraCounterType(identifier); - if (var == ExtraCounterVariant.DEEPSLATE_TILE && !identifier.getPath().contains("deepslate_tile")) { + if (var == null) { var = getStoneType(identifier); } - if ((var == StoneVariant.STONE && !identifier.getPath().contains("stone")) || (var == ExtraCounterVariant.DEEPSLATE_TILE && !identifier.getPath().contains("deepslate_tile"))) { + if (var == null) { var = getWoodType(identifier); } return var; } + @Nullable public static ExtraCounterVariant getExtraCounterType(Identifier identifier) { for (ExtraCounterVariant variant: ExtraCounterVariant.values()) { - if (identifier.getPath().contains(variant.getPath())) { + if (identifier.getPath().contains(variant.getPath()) && getBlockType(identifier) == BlockType.BLOCK) { return variant; } } - return ExtraCounterVariant.DEEPSLATE_TILE; + return null; } + + @Nullable public static StoneVariant getStoneType(Identifier identifier) { for (StoneVariant variant: StoneVariant.values()) { - if (identifier.getPath().contains(variant.getPath())) { + if (identifier.getPath().contains(variant.getPath()) && getBlockType(identifier) == BlockType.BLOCK) { return variant; } } - return StoneVariant.STONE; + return null; } public static WoodVariant getWoodType(Identifier identifier){ WoodVariant selectedVariant = null; for (WoodVariant woodVariant : WoodVariantRegistry.getVariants()) if (identifier.getPath().contains(woodVariant.identifier.getPath())) { - if (identifier.getPath().contains("dark") && !woodVariant.identifier.getPath().contains("dark")) + if (identifier.getPath().contains("dark") && !woodVariant.identifier.getPath().contains("dark") || (!identifier.getPath().contains(woodVariant.getNamespace()) && !woodVariant.isVanilla())) continue; selectedVariant = woodVariant; } @@ -169,7 +174,7 @@ else if(idExists(getLogId(block, "_bottom"), ResourceType.CLIENT_RESOURCES, IdLo } else { PFMDataGen.LOGGER.warn("Couldn't find texture for, {}", block); - id = Texture.getId(Blocks.BEDROCK); + id = MissingSprite.getMissingSpriteId(); } blockToTextureMap.put(pair, id); return id; @@ -179,15 +184,30 @@ else if(idExists(getLogId(block, "_bottom"), ResourceType.CLIENT_RESOURCES, IdLo public static Identifier getPlankId(Block block) { Identifier identifier = Registry.BLOCK.getId(block); String namespace = identifier.getNamespace(); - String path = identifier.getPath(); + String path = identifier.getPath().replace("luphie_", ""); if (path.contains("planks")) { path = path.replace("_planks", ""); path = "planks_" + path; - Identifier id = new Identifier(namespace, "block/wood/" + path); - path = path.replace("mining", "mine").replace("sorting", "sort").replace("transformation", "trans").replace("dark", "darkwood"); + Identifier id = new Identifier(namespace, "block/" + path); + path = path.replace("mining", "mine").replace("sorting", "sort").replace("transformation", "trans").replace("dark", "darkwood").replace("alpha_", "alpha_oak_").replace("flowering_pink", "flowerypink").replace("flowering_purple", "floweringpurple"); + Identifier id2 = new Identifier(namespace, "block/wood/" + path); + Identifier id3 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "planks"); + Identifier id4 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "_planks"); + Identifier id5 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "plankstext"); + Identifier id6 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "plankretext"); if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) return id; + else if (idExists(id2, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) + return id2; + else if (idExists(id3, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) + return id3; + else if (idExists(id4, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) + return id4; + else if (idExists(id5, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) + return id5; + else if (idExists(id6, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) + return id6; else return new Identifier(namespace, "block/wood/" + path+ "_0"); } @@ -198,8 +218,14 @@ public static Identifier getPlankId(Block block) { public static Identifier getLogId(Block block, String postFix) { Identifier identifier = Registry.BLOCK.getId(block); String namespace = identifier.getNamespace(); - String path = identifier.getPath(); + String path = identifier.getPath().replace("luphie_", ""); + if (namespace.contains("luphieclutteredmod") && path.contains("flowering_log")) { + path = path.replace("flowering_log", "flowering_yellow_log"); + } if (path.contains("log")) { + if (!path.contains("_log")) { + path = path.replace("log", "_log"); + } path = path.replace("log", "bark"); path += postFix; Identifier id = new Identifier(namespace, "block/" + path); @@ -250,6 +276,18 @@ public static Identifier getLogId(Block block, String postFix) { return id; } } + if (path.contains("alpha_")) { + path = path.replace("alpha", "alpha_oak"); + Identifier id = new Identifier(namespace, "block/" + path); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)){ + return id; + } + path += postFix; + id = new Identifier(namespace, "block/" + path); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { + return id; + } + } return new Identifier(namespace, "block/" + path); } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/UnbakedBasicTableModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/UnbakedBasicTableModel.java index 5c56c07c1..6c21757ca 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/UnbakedBasicTableModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/UnbakedBasicTableModel.java @@ -48,9 +48,8 @@ public class UnbakedBasicTableModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_basic/" + variant.asString() + "_table_basic")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_basic/stripped_" + variant.asString() + "_table_basic")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_basic/stripped_" + variant.asString() + "_table_basic")); } for(StoneVariant variant : StoneVariant.values()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_basic/" + variant.asString() + "_table_basic")); @@ -65,12 +64,11 @@ public class UnbakedBasicTableModel implements UnbakedModel { String newPart = part.replaceAll("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : BASIC_MODEL_PARTS_BASE) { - String newPart = part.replaceAll("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : BASIC_MODEL_PARTS_BASE) { + String newPart = part.replaceAll("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ for (String part : BASIC_MODEL_PARTS_BASE) { diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicNightstand/UnbakedClassicNightstandModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicNightstand/UnbakedClassicNightstandModel.java index a879f3d66..e9f6292bc 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicNightstand/UnbakedClassicNightstandModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicNightstand/UnbakedClassicNightstandModel.java @@ -52,10 +52,8 @@ public UnbakedClassicNightstandModel(VariantBase variant, List modelP for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/classic_nightstand/" + variant.asString() + "_classic_nightstand")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/classic_nightstand/stripped_" + variant.asString() + "_classic_nightstand")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/classic_nightstand/stripped_" + variant.asString() + "_classic_nightstand")); } for(StoneVariant variant : StoneVariant.values()){ @@ -72,13 +70,11 @@ public UnbakedClassicNightstandModel(VariantBase variant, List modelP String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - - for (String part : NIGHTSTAND_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : NIGHTSTAND_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/UnbakedClassicTableModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/UnbakedClassicTableModel.java index 6257fbc7b..f84c669b3 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/UnbakedClassicTableModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/UnbakedClassicTableModel.java @@ -37,9 +37,8 @@ public class UnbakedClassicTableModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_classic/" + variant.asString() + "_table_classic")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_classic/stripped_" + variant.asString() + "_table_classic")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_classic/stripped_" + variant.asString() + "_table_classic")); } for(StoneVariant variant : StoneVariant.values()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_classic/" + variant.asString() + "_table_classic")); @@ -54,12 +53,11 @@ public class UnbakedClassicTableModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : CLASSIC_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : CLASSIC_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/dinnerTable/UnbakedDinnerTableModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/dinnerTable/UnbakedDinnerTableModel.java index 7ad91e822..5b0e70d5b 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/dinnerTable/UnbakedDinnerTableModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/dinnerTable/UnbakedDinnerTableModel.java @@ -34,9 +34,8 @@ public class UnbakedDinnerTableModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/dinner_table/" + variant.asString() + "_dinner_table")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/dinner_table/stripped_" + variant.asString() + "_dinner_table")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/dinner_table/stripped_" + variant.asString() + "_dinner_table")); } for(StoneVariant variant : StoneVariant.values()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/dinner_table/" + variant.asString() + "_dinner_table")); @@ -51,12 +50,11 @@ public class UnbakedDinnerTableModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : DINNER_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : DINNER_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ for (String part : DINNER_MODEL_PARTS_BASE) { diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCabinet/UnbakedKitchenCabinetModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCabinet/UnbakedKitchenCabinetModel.java index 5f39f6883..ead9c97a7 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCabinet/UnbakedKitchenCabinetModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCabinet/UnbakedKitchenCabinetModel.java @@ -40,9 +40,8 @@ public class UnbakedKitchenCabinetModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_cabinet/" + variant.asString() + "_kitchen_cabinet")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_cabinet/stripped_" + variant.asString() + "_kitchen_cabinet")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_cabinet/stripped_" + variant.asString() + "_kitchen_cabinet")); } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) @@ -62,12 +61,11 @@ public class UnbakedKitchenCabinetModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : CABINET_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : CABINET_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounter/UnbakedKitchenCounterModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounter/UnbakedKitchenCounterModel.java index 1eeff2e54..aaeb12756 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounter/UnbakedKitchenCounterModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounter/UnbakedKitchenCounterModel.java @@ -37,9 +37,8 @@ public class UnbakedKitchenCounterModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_counter/" + variant.asString() + "_kitchen_counter")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_counter/stripped_" + variant.asString() + "_kitchen_counter")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_counter/stripped_" + variant.asString() + "_kitchen_counter")); } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) @@ -59,12 +58,11 @@ public class UnbakedKitchenCounterModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : COUNTER_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : COUNTER_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounterOven/UnbakedKitchenCounterOvenModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounterOven/UnbakedKitchenCounterOvenModel.java index 849b60251..577373614 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounterOven/UnbakedKitchenCounterOvenModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenCounterOven/UnbakedKitchenCounterOvenModel.java @@ -36,9 +36,8 @@ public class UnbakedKitchenCounterOvenModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_counter_oven/" + variant.asString() + "_kitchen_counter_oven")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_counter_oven/stripped_" + variant.asString() + "_kitchen_counter_oven")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_counter_oven/stripped_" + variant.asString() + "_kitchen_counter_oven")); } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) @@ -58,12 +57,11 @@ public class UnbakedKitchenCounterOvenModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : OVEN_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : OVEN_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenDrawer/UnbakedKitchenDrawerModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenDrawer/UnbakedKitchenDrawerModel.java index 4267ba0d5..51c2e4dde 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenDrawer/UnbakedKitchenDrawerModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenDrawer/UnbakedKitchenDrawerModel.java @@ -44,9 +44,8 @@ public class UnbakedKitchenDrawerModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_drawer/" + variant.asString() + "_kitchen_drawer")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_drawer/stripped_" + variant.asString() + "_kitchen_drawer")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_drawer/stripped_" + variant.asString() + "_kitchen_drawer")); } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) @@ -66,12 +65,11 @@ public class UnbakedKitchenDrawerModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : COUNTER_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : COUNTER_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallCounter/UnbakedKitchenWallCounterModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallCounter/UnbakedKitchenWallCounterModel.java index 9458b8380..434ee5e2f 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallCounter/UnbakedKitchenWallCounterModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallCounter/UnbakedKitchenWallCounterModel.java @@ -35,9 +35,8 @@ public class UnbakedKitchenWallCounterModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_wall_counter/" + variant.asString() + "_kitchen_wall_counter")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_wall_counter/stripped_" + variant.asString() + "_kitchen_wall_counter")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_wall_counter/stripped_" + variant.asString() + "_kitchen_wall_counter")); } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) @@ -57,13 +56,13 @@ public class UnbakedKitchenWallCounterModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } + if (variant.hasStripped()) + for (String part : COUNTER_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : COUNTER_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } - } + for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) continue; diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallDrawer/UnbakedKitchenWallDrawerModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallDrawer/UnbakedKitchenWallDrawerModel.java index e43ca424e..83a21d7a9 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallDrawer/UnbakedKitchenWallDrawerModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/kitchenWallDrawer/UnbakedKitchenWallDrawerModel.java @@ -40,9 +40,8 @@ public class UnbakedKitchenWallDrawerModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_wall_drawer/" + variant.asString() + "_kitchen_wall_drawer")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_wall_drawer/stripped_" + variant.asString() + "_kitchen_wall_drawer")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/kitchen_wall_drawer/stripped_" + variant.asString() + "_kitchen_wall_drawer")); } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) @@ -62,12 +61,11 @@ public class UnbakedKitchenWallDrawerModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : COUNTER_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : COUNTER_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ if (variant.equals(StoneVariant.QUARTZ)) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/logTable/UnbakedLogTableModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/logTable/UnbakedLogTableModel.java index 3e139fc06..a610e4322 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/logTable/UnbakedLogTableModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/logTable/UnbakedLogTableModel.java @@ -35,18 +35,11 @@ public class UnbakedLogTableModel implements UnbakedModel { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ String logType = variant.isNetherWood() ? "stem" : "log"; add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/" + variant.asString() + "_" + logType+ "_table")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - String logType = variant.isNetherWood() ? "stem" : "log"; add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/" + variant.asString() + "_raw_" + logType+ "_table")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - String logType = variant.isNetherWood() ? "stem" : "log"; - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/stripped_" + variant.asString() + "_" + logType+ "_table")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - String logType = variant.isNetherWood() ? "stem" : "log"; - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/stripped_" + variant.asString() + "_raw_" + logType+ "_table")); + if (variant.hasStripped()) { + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/stripped_" + variant.asString() + "_" + logType+ "_table")); + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/stripped_" + variant.asString() + "_raw_" + logType+ "_table")); + } } for(StoneVariant variant : StoneVariant.values()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/log_table/" + variant.asString() + "_natural_table")); @@ -63,29 +56,25 @@ public class UnbakedLogTableModel implements UnbakedModel { newPart = newPart.replace(variant.asString() + "_log", variant.asString() + "_stem"); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ for (String part : LOG_MODEL_PARTS_BASE) { String newPart = part.replace("template", variant.asString() + "_raw"); if (variant.isNetherWood()) newPart = newPart.replace(variant.asString() + "_raw_log", variant.asString() + "_raw_stem"); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : LOG_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString() + "_raw"); - if (variant.isNetherWood()) - newPart = newPart.replace(variant.asString() + "_raw_log", variant.asString() + "_raw_stem"); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : LOG_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - if (variant.isNetherWood()) - newPart = newPart.replace(variant.asString() + "_log", variant.asString() + "_stem"); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + if (variant.hasStripped()) { + for (String part : LOG_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString() + "_raw"); + if (variant.isNetherWood()) + newPart = newPart.replace(variant.asString() + "_raw_log", variant.asString() + "_raw_stem"); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } + for (String part : LOG_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + if (variant.isNetherWood()) + newPart = newPart.replace(variant.asString() + "_log", variant.asString() + "_stem"); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } } for(StoneVariant variant : StoneVariant.values()){ diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/modernDinnerTable/UnbakedModernDinnerTableModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/modernDinnerTable/UnbakedModernDinnerTableModel.java index 8c63b2ffa..79f1f596a 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/modernDinnerTable/UnbakedModernDinnerTableModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/modernDinnerTable/UnbakedModernDinnerTableModel.java @@ -34,9 +34,8 @@ public class UnbakedModernDinnerTableModel implements UnbakedModel { { for(WoodVariant variant : WoodVariantRegistry.getVariants()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_modern_dinner/" + variant.asString() + "_table_modern_dinner")); - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_modern_dinner/stripped_" + variant.asString() + "_table_modern_dinner")); + if (variant.hasStripped()) + add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_modern_dinner/stripped_" + variant.asString() + "_table_modern_dinner")); } for(StoneVariant variant : StoneVariant.values()){ add(new Identifier(PaladinFurnitureMod.MOD_ID, "block/table_modern_dinner/" + variant.asString() + "_table_modern_dinner")); @@ -51,12 +50,11 @@ public class UnbakedModernDinnerTableModel implements UnbakedModel { String newPart = part.replace("template", variant.asString()); add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); } - } - for(WoodVariant variant : WoodVariantRegistry.getVariants()){ - for (String part : MODERN_DINNER_MODEL_PARTS_BASE) { - String newPart = part.replace("template", "stripped_" + variant.asString()); - add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); - } + if (variant.hasStripped()) + for (String part : MODERN_DINNER_MODEL_PARTS_BASE) { + String newPart = part.replace("template", "stripped_" + variant.asString()); + add(new Identifier(PaladinFurnitureMod.MOD_ID, newPart)); + } } for(StoneVariant variant : StoneVariant.values()){ for (String part : MODERN_DINNER_MODEL_PARTS_BASE) { diff --git a/common/src/main/java/com/unlikepaladin/pfm/data/materials/DynamicBlockRegistry.java b/common/src/main/java/com/unlikepaladin/pfm/data/materials/DynamicBlockRegistry.java index d2ba0f6dc..ebd700575 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/data/materials/DynamicBlockRegistry.java +++ b/common/src/main/java/com/unlikepaladin/pfm/data/materials/DynamicBlockRegistry.java @@ -129,6 +129,18 @@ public static void compatInit() { "betternether", "nether_reed", "nether_reed_planks", "nether_reed_roof"); addBlockTypeFinder(WoodVariant.class, netherReed); + + WoodVariant.Finder clutteredFloweringYellow = WoodVariant.Finder.simple( + "luphieclutteredmod", "luphie_flowering_yellow", "luphie_flowering_yellow_planks", "luphie_flowering_yellow_log"); + clutteredFloweringYellow.addChild("wood", "luphie_flowering_yellow_wood"); + clutteredFloweringYellow.addChild("stripped_log", "stripped_luphie_flowering_log"); + clutteredFloweringYellow.addChild("stripped_wood", "stripped_luphie_flowering_wood"); + clutteredFloweringYellow.addChild("slab", "luphie_flowering_yellow_slab"); + clutteredFloweringYellow.addChild("fence", "luphie_flowering_yellow_fence"); + clutteredFloweringYellow.addChild("fence_gate", "luphie_flowering_yellow_fence_gate"); + clutteredFloweringYellow.addChild("button", "luphie_flowering_yellow_button"); + + addBlockTypeFinder(WoodVariant.class, clutteredFloweringYellow); } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/data/materials/VariantRegistryBase.java b/common/src/main/java/com/unlikepaladin/pfm/data/materials/VariantRegistryBase.java index 1bd697aaa..0a6cf6850 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/data/materials/VariantRegistryBase.java +++ b/common/src/main/java/com/unlikepaladin/pfm/data/materials/VariantRegistryBase.java @@ -45,7 +45,7 @@ public void registerBlockType(T newType) { builder.add(newType); } - public abstract Optional geVariantFromBlock(Block baseBlock, Identifier blockId); + public abstract Optional getVariantFromBlock(Block baseBlock, Identifier blockId); public void buildAll() { //adds default @@ -53,7 +53,7 @@ public void buildAll() { //adds finders finders.stream().map(VariantBase.SetFinder::get).forEach(f -> f.ifPresent(this::registerBlockType)); for (Block block : Registry.BLOCK) { - this.geVariantFromBlock(block, Registry.BLOCK.getId(block)).ifPresent(this::registerBlockType); + this.getVariantFromBlock(block, Registry.BLOCK.getId(block)).ifPresent(this::registerBlockType); } this.finalizeAndFreeze(); } diff --git a/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariant.java b/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariant.java index 13d84779a..78adac3a4 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariant.java +++ b/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariant.java @@ -14,10 +14,7 @@ import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.Nullable; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import java.util.function.Supplier; public class WoodVariant extends VariantBase { @@ -71,23 +68,45 @@ public String getPath() { @Nullable protected Block findLogRelatedBlock(String append, String postpend) { - if (this.isNetherWood() && postpend.equals("log") || postpend.equals("wood")) { - switch (postpend) { - case "log" -> postpend = "stem"; - case "wood" -> postpend = "hyphae"; - } - } String post = postpend.isEmpty() ? "" : "_" + postpend; - var id = this.getIdentifier(); + Identifier id = this.getIdentifier(); String logN = Registry.BLOCK.getId(this.logBlock).getPath(); Identifier[] targets = { new Identifier(id.getNamespace(), logN + "_" + append + post), + new Identifier(id.getNamespace(), logN + "_" + append + post.replace("_", "")), new Identifier(id.getNamespace(), append + "_" + logN + post), + new Identifier(id.getNamespace(), append + "_" + logN + post.replace("_", "")), new Identifier(id.getNamespace(), id.getPath() + "_" + append + post), - new Identifier(id.getNamespace(), append + "_" + id.getPath() + post) + new Identifier(id.getNamespace(), id.getPath() + "_" + append + post.replace("_", "")), + new Identifier(id.getNamespace(), append + "_" + id.getPath() + post), + new Identifier(id.getNamespace(), append + "_" + id.getPath() + post.replace("_", "")) }; + String postNether = ""; + switch (postpend) { + case "log" -> postNether = "stem"; + case "wood" -> postNether = "hyphae"; + } + postNether = postpend.isEmpty() ? "" : "_" + postNether; Block found = null; - for (var r : targets) { + if (!postNether.isEmpty()) { + Identifier[] nether_targets = { + new Identifier(id.getNamespace(), logN + "_" + append + postNether), + new Identifier(id.getNamespace(), logN + "_" + append + postNether.replace("_", "")), + new Identifier(id.getNamespace(), append + "_" + logN + postNether), + new Identifier(id.getNamespace(), append + "_" + logN + postNether.replace("_", "")), + new Identifier(id.getNamespace(), id.getPath() + "_" + append + postNether), + new Identifier(id.getNamespace(), id.getPath() + "_" + append + postNether.replace("_", "")), + new Identifier(id.getNamespace(), append + "_" + id.getPath() + postNether), + new Identifier(id.getNamespace(), append + "_" + id.getPath() + postNether.replace("_", "")) + }; + for (Identifier r : nether_targets) { + if (Registry.BLOCK.containsId(r)) { + found = Registry.BLOCK.get(r); + break; + } + } + } + for (Identifier r : targets) { if (Registry.BLOCK.containsId(r)) { found = Registry.BLOCK.get(r); break; @@ -157,7 +176,8 @@ public void initializeChildrenItems() { } public boolean hasStripped() { - return this.getChild("stripped_log") != null; + Object child = this.getChild("stripped_log"); + return child != null && child != this.getBaseBlock(); } @Override public Block mainChild() { @@ -203,6 +223,10 @@ public Optional get() { Block d = Registry.BLOCK.get(new Identifier("minecraft","air")); if (plank != d && log != d && plank != null && log != null) { WoodVariant w = new WoodVariant(id, plank, log); + for (Map.Entry entry : childNames.entrySet()){ + Object child = Registry.BLOCK.getOrEmpty(entry.getValue()).isPresent() ? Registry.BLOCK.get(entry.getValue()) : Registry.ITEM.get(entry.getValue()); + w.addChild(entry.getKey(), child); + } return Optional.of(w); } } catch (Exception ignored) { diff --git a/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java b/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java index 7a0663799..64c226f66 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java +++ b/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java @@ -7,10 +7,15 @@ import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.stream.Collectors; public class WoodVariantRegistry extends VariantRegistryBase { public static final WoodVariant OAK = new WoodVariant(new Identifier("oak"), Blocks.OAK_PLANKS, Blocks.OAK_LOG, BoatEntity.Type.OAK); public static final WoodVariantRegistry INSTANCE = new WoodVariantRegistry(); + public static Collection getNamespaces() { + return INSTANCE.variants.values().stream().map(VariantBase::getNamespace).collect(Collectors.toUnmodifiableList()); + }; + public static Collection getVariants() { return Collections.unmodifiableCollection(INSTANCE.variants.values()); } @@ -20,7 +25,7 @@ public static WoodVariant getVariant(Identifier name) { } @Nullable - public static WoodVariant getVariantFromVanillaWoodType(BoatEntity.Type type) { + public static WoodVariant getVariantFromVanillaWoodType(BoatEntity.Type type) { for (WoodVariant woodVariant : INSTANCE.variants.values()) { if (woodVariant.getVanillaWoodType() == type) return woodVariant; @@ -30,10 +35,20 @@ public static WoodVariant getVariantFromVanillaWoodType(BoatEntity.Type type) { /** * Simplified Wood/Block detection based on MoonlightLib... */ - public Optional geVariantFromBlock(Block baseBlock, Identifier blockId) { + public Optional getVariantFromBlock(Block baseBlock, Identifier blockId) { String name = null; String path = blockId.getPath(); - + if (blockId.getNamespace().equals("tfc")) { + if (path.contains("wood/planks/")) { + Optional log = Registry.BLOCK.getOrEmpty( + new Identifier(blockId.getNamespace(), path.replace("planks", "log"))); + if (log.isPresent()) { + Identifier id = new Identifier(blockId.getNamespace(), path.replace("wood/planks/", "")); + return Optional.of(new WoodVariant(id, baseBlock, log.get())); + } + } + return Optional.empty(); + } if (path.endsWith("_planks")) { name = path.substring(0, path.length() - "_planks".length()); } else if (path.startsWith("planks_")) { @@ -83,8 +98,10 @@ private static Block findLog(Identifier id) { Identifier[] test = { new Identifier(id.getNamespace(), id.getPath() + "_log"), new Identifier(id.getNamespace(), "log_" + id.getPath()), + new Identifier(id.getNamespace(), id.getPath() + "log"), new Identifier(id.getPath() + "_log"), new Identifier("log_" + id.getPath()), + new Identifier(id.getPath() + "log"), new Identifier(id.getNamespace(), id.getPath() + "_stem"), new Identifier(id.getNamespace(), "stem_" + id.getPath()), new Identifier(id.getPath() + "_stem"), diff --git a/common/src/main/java/com/unlikepaladin/pfm/runtime/PFMDataGen.java b/common/src/main/java/com/unlikepaladin/pfm/runtime/PFMDataGen.java index f09900bad..ac4aaede8 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/runtime/PFMDataGen.java +++ b/common/src/main/java/com/unlikepaladin/pfm/runtime/PFMDataGen.java @@ -156,7 +156,12 @@ private static void collectFiles(File directory, List hashList, collectFiles(file, hashList, includeHiddenFiles); } else { FileInputStream stream = new FileInputStream(file); - hashList.add(HashCode.fromBytes(stream.readAllBytes()).toString()); + try { + HashCode code = HashCode.fromBytes(stream.readAllBytes()); + hashList.add(code.toString()); + } catch (Exception e) { + LOGGER.warn("File {} was less than 1 byte or invalid, skipping, {}", file.getName(), e); + } stream.close(); } } From c410ef0cf3c6c3948db18d859ab3b92c04eafa96 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:54:26 -0600 Subject: [PATCH 2/5] Fix variants with multiple words in their name not being translated properly. --- .../com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java b/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java index 72735cef1..9b145598f 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java +++ b/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java @@ -222,7 +222,7 @@ public String getTranslatedVariantName(VariantBase variant) { String baseBlockName = translate(variant.getBaseBlock().getTranslationKey()); List common = findCommonWords(variantName.get(), baseBlockName); variantName.set(""); - common.forEach(s -> variantName.set(String.join(!variantName.get().isEmpty() ? variantName.get() + " " : variantName.get(), s))); + variantName.set(String.join(" ", common)); return variantName.get(); } From 25c0f98983a8922de959dcf3d696e0fd8a3c1153 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Sun, 15 Oct 2023 16:21:48 -0600 Subject: [PATCH 3/5] Fix Texture detection for BYG --- .../pfm/blocks/models/ModelHelper.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java index c8cafef50..e4c50b866 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java @@ -186,9 +186,13 @@ public static Identifier getPlankId(Block block) { String namespace = identifier.getNamespace(); String path = identifier.getPath().replace("luphie_", ""); if (path.contains("planks")) { - path = path.replace("_planks", ""); + path = path.replace("_planks", "").replace("plank_", ""); + Identifier id = new Identifier(namespace, "block/" + path +"/planks"); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) + return id; + path = "planks_" + path; - Identifier id = new Identifier(namespace, "block/" + path); + id = new Identifier(namespace, "block/" + path); path = path.replace("mining", "mine").replace("sorting", "sort").replace("transformation", "trans").replace("dark", "darkwood").replace("alpha_", "alpha_oak_").replace("flowering_pink", "flowerypink").replace("flowering_purple", "floweringpurple"); Identifier id2 = new Identifier(namespace, "block/wood/" + path); Identifier id3 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "planks"); @@ -222,11 +226,13 @@ public static Identifier getLogId(Block block, String postFix) { if (namespace.contains("luphieclutteredmod") && path.contains("flowering_log")) { path = path.replace("flowering_log", "flowering_yellow_log"); } - if (path.contains("log")) { + if (namespace.equals("byg") && path.contains("pedu")) + path = path.replace("pedu", "log"); + if (path.contains("log") || path.contains("stem")) { if (!path.contains("_log")) { path = path.replace("log", "_log"); } - path = path.replace("log", "bark"); + path = path.replace("stem", "log").replace("log", "bark"); path += postFix; Identifier id = new Identifier(namespace, "block/" + path); if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { @@ -260,6 +266,26 @@ public static Identifier getLogId(Block block, String postFix) { if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { return id; } + String loc = identifier.getPath().contains("stripped") || identifier.getPath().contains("striped") ? "stripped_log" : "log"; + path = path.replace("striped_", "").replace(postFix, "").replace("_log", ""); + if (!identifier.getPath().contains("stripped") && namespace.equals("byg")) + System.out.println("paused"); + id = new Identifier(namespace, "block/" + path+ "/" + loc + postFix); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { + return id; + } + id = new Identifier(namespace, "block/" + path+ "/" + loc.replace("log", "stem") + postFix); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { + return id; + } + id = new Identifier(namespace, "block/" + path+ "/" + loc); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { + return id; + } + id = new Identifier(namespace, "block/" + path+ "/" + loc.replace("log", "stem")); + if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) { + return id; + } } else if (path.contains("reed")) { path = path.replace("nether_", "").replace("reed", "reeds"); Identifier id = new Identifier(namespace, "block/" + path); From 9449ea7c7baba1e528f64037330b9fa1cd81ddfd Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Sun, 15 Oct 2023 16:48:04 -0600 Subject: [PATCH 4/5] Bump mod version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 898f86b82..9955a805a 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.17.1 enabled_platforms=fabric,forge archives_base_name=paladin-furniture-mod -mod_version=1.2.0-rc3 +mod_version=1.2.0-rc4 maven_group=com.unlikepaladin architectury_version=2.10.12 From 6b8b136044f3556f564ecadae6efddf170d3c5a7 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:17:08 -0600 Subject: [PATCH 5/5] Fix Patchouli Book template --- .../guide_book/en_us/templates/freezingrecipetemplate.json | 2 +- .../guide_book/en_us/templates/furniturerecipetemplate.json | 2 +- .../guide_book/en_us/templates/stoverecipetemplate.json | 2 +- .../guide_book/zh_cn/templates/freezingrecipetemplate.json | 2 +- .../guide_book/zh_cn/templates/furniturerecipetemplate.json | 2 +- .../guide_book/zh_cn/templates/stoverecipetemplate.json | 2 +- .../guide_book/en_us/templates/freezingrecipetemplate.json | 2 +- .../guide_book/en_us/templates/furniturerecipetemplate.json | 2 +- .../guide_book/en_us/templates/stoverecipetemplate.json | 2 +- .../guide_book/zh_cn/templates/freezingrecipetemplate.json | 2 +- .../guide_book/zh_cn/templates/furniturerecipetemplate.json | 2 +- .../guide_book/zh_cn/templates/stoverecipetemplate.json | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json index 80e3886fe..84ca6a0de 100644 --- a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json +++ b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.fabric.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json index b28973c53..a77ed3258 100644 --- a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json +++ b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.fabric.patchouli.FurnitureRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FurnitureRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json index 8d5f20a7b..446ad8157 100644 --- a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json +++ b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.fabric.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json index 80e3886fe..84ca6a0de 100755 --- a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json +++ b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.fabric.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json index b28973c53..a77ed3258 100755 --- a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json +++ b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.fabric.patchouli.FurnitureRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FurnitureRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json index 8d5f20a7b..446ad8157 100755 --- a/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json +++ b/fabric/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.fabric.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json index a135cdcb9..84ca6a0de 100644 --- a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json +++ b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/freezingrecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.forge.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json index a113b2182..a77ed3258 100644 --- a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json +++ b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/furniturerecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.forge.patchouli.FurnitureRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FurnitureRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json index 79907bea7..446ad8157 100644 --- a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json +++ b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/en_us/templates/stoverecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.forge.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json index a135cdcb9..84ca6a0de 100755 --- a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json +++ b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/freezingrecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.forge.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json index a113b2182..a77ed3258 100755 --- a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json +++ b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/furniturerecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.forge.patchouli.FurnitureRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FurnitureRecipeProcessor", "include": [ { "template": "pfm:namenumber", diff --git a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json index 79907bea7..446ad8157 100755 --- a/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json +++ b/forge/src/main/resources/data/pfm/patchouli_books/guide_book/zh_cn/templates/stoverecipetemplate.json @@ -1,5 +1,5 @@ { - "processor": "com.unlikepaladin.pfm.compat.forge.patchouli.FreezingRecipeProcessor", + "processor": "com.unlikepaladin.pfm.compat.patchouli.FreezingRecipeProcessor", "include": [ { "template": "pfm:namenumber",