From 43ecb00e6b8ec80a54ff0d9953f26860e4d8d651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Massimo=20Cant=C3=BA?= Date: Tue, 14 May 2024 15:11:22 -0300 Subject: [PATCH] Added texture overrides to soil properties also fixed mega spruce sapling being created --- gradle.properties | 2 +- .../06c8634dbcb9eb0304a95e1ace9f06130b969502 | 8 +-- .../82dbd4df3226a8f2ebd864eec8c96cc5d0540266 | 31 +++++++--- .../blockstates/mega_spruce_sapling.json | 7 --- .../models/block/saplings/crimson.json | 2 +- .../models/block/saplings/mega_spruce.json | 8 --- .../models/block/saplings/warped.json | 2 +- .../dynamictrees/tags/blocks/foliage.json | 7 +-- .../api/data/SaplingStateGenerator.java | 2 +- .../api/data/SeedItemModelGenerator.java | 4 +- .../api/data/SoilStateGenerator.java | 4 +- .../block/DynamicSaplingBlock.java | 2 +- .../block/leaves/LeavesProperties.java | 2 - .../block/rooty/SoilProperties.java | 24 +++++++- .../loader/FamilyResourceLoader.java | 3 +- .../loader/SoilPropertiesResourceLoader.java | 8 ++- .../loader/SpeciesResourceLoader.java | 1 + .../dynamictrees/tree/family/Family.java | 17 ++++-- .../dynamictrees/tree/species/Species.java | 60 ++++++++++++------- .../trees/dynamictrees/families/oak.json | 6 +- .../dynamictrees/species/mega_spruce.json | 1 - 21 files changed, 122 insertions(+), 79 deletions(-) delete mode 100644 src/generated/resources/assets/dynamictrees/blockstates/mega_spruce_sapling.json delete mode 100644 src/generated/resources/assets/dynamictrees/models/block/saplings/mega_spruce.json diff --git a/gradle.properties b/gradle.properties index e73ad274f..aa33b762a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ modName=DynamicTrees modId=dynamictrees -modVersion=1.2.0-BETA2.006 +modVersion=1.2.0-BETA2 group=com.ferreusveritas.dynamictrees mcVersion=1.19.2 diff --git a/src/generated/resources/.cache/06c8634dbcb9eb0304a95e1ace9f06130b969502 b/src/generated/resources/.cache/06c8634dbcb9eb0304a95e1ace9f06130b969502 index c2515cc17..e35088650 100644 --- a/src/generated/resources/.cache/06c8634dbcb9eb0304a95e1ace9f06130b969502 +++ b/src/generated/resources/.cache/06c8634dbcb9eb0304a95e1ace9f06130b969502 @@ -1,4 +1,4 @@ -// 1.19.2 2023-12-23T21:59:27.6837076 Block States: dynamictrees +// 1.19.2 2024-05-14T14:52:28.0361511 Block States: dynamictrees ba3df68d28fba8cf21f652ea60b7575c7915d267 assets/dynamictrees/blockstates/acacia_branch.json 2606791521eac27fa77ebbeeea442b8073802a51 assets/dynamictrees/blockstates/acacia_leaves.json 28a0cd7b38e1a854acd4f0c477573a9460811d82 assets/dynamictrees/blockstates/acacia_sapling.json @@ -26,7 +26,6 @@ a82f9fc1c2378f77e75442eb41b6eff31ae0c687 assets/dynamictrees/blockstates/jungle_ e8323999fd52df15a0a4a6644543902710c6192a assets/dynamictrees/blockstates/mangrove_leaves.json 8322563ee7870806d6140a71f0f9875d31929701 assets/dynamictrees/blockstates/mangrove_roots.json ec8ab110c9a7deb973ad5c223fa05d2391f77c44 assets/dynamictrees/blockstates/mangrove_sapling.json -530b13d53b4adfb7b9463d6c40054223433d8f30 assets/dynamictrees/blockstates/mega_spruce_sapling.json 0dec9ba9d981a4b67a72b307630c1deaed9eaf7f assets/dynamictrees/blockstates/oak_branch.json 9b73d2419e07259eb9681640ac018a6aeb7e7e93 assets/dynamictrees/blockstates/oak_leaves.json 1128f60fc8e5148d030661dbf3893731dd50f56d assets/dynamictrees/blockstates/oak_sapling.json @@ -99,16 +98,15 @@ fcdb9bc5efbdbb4e4fafca3defa3324afb1ecbfc assets/dynamictrees/models/block/rooty_ b465c30f23ed200e7d6b139fa4ba3e6ce2e66ca6 assets/dynamictrees/models/block/saplings/azalea.json e85b6b5fb75c35a7306993653ed1e0e73cc9d566 assets/dynamictrees/models/block/saplings/birch.json 62beaa82e8dcb5cbc3652ef27ac4bd8138abce43 assets/dynamictrees/models/block/saplings/cocoa.json -99421b3c9731c1525176aea40ea9ed488c19fa91 assets/dynamictrees/models/block/saplings/crimson.json +6a456a252ed88c03154add1de4fb1846230ae872 assets/dynamictrees/models/block/saplings/crimson.json 4a57237782717c8e918a299847aacd892ca6f5e6 assets/dynamictrees/models/block/saplings/dark_oak.json 62beaa82e8dcb5cbc3652ef27ac4bd8138abce43 assets/dynamictrees/models/block/saplings/jungle.json 2a2d629109caa470b63e0d2aae0c1150a69baa69 assets/dynamictrees/models/block/saplings/mangrove.json -82e19945531fbcaf8d88a55bd21673f281be1f2c assets/dynamictrees/models/block/saplings/mega_spruce.json 7a849487d3813ef0bcd33e55299ef4e396af2777 assets/dynamictrees/models/block/saplings/oak.json 82e19945531fbcaf8d88a55bd21673f281be1f2c assets/dynamictrees/models/block/saplings/spruce.json 667dbf2ab02554d282492a618b4b4a010b290965 assets/dynamictrees/models/block/saplings/swamp_oak.json e85b6b5fb75c35a7306993653ed1e0e73cc9d566 assets/dynamictrees/models/block/saplings/tall_birch.json -92fbb577a5ca69bbf76612f9b7b2dc199604e12c assets/dynamictrees/models/block/saplings/warped.json +9b88a62e798839ac0b6a013d0ce20f7722865ee8 assets/dynamictrees/models/block/saplings/warped.json 3d7345ca6a2c779ace87986dd18b0749ce3cf468 assets/dynamictrees/models/block/spruce_branch.json fc187504c387a51112afb087392b611f8f37b02f assets/dynamictrees/models/block/stripped_acacia_branch.json e11e6857ff8da1632bd5d7261150a150cefb12da assets/dynamictrees/models/block/stripped_birch_branch.json diff --git a/src/generated/resources/.cache/82dbd4df3226a8f2ebd864eec8c96cc5d0540266 b/src/generated/resources/.cache/82dbd4df3226a8f2ebd864eec8c96cc5d0540266 index 8a353329a..2e064fb3e 100644 --- a/src/generated/resources/.cache/82dbd4df3226a8f2ebd864eec8c96cc5d0540266 +++ b/src/generated/resources/.cache/82dbd4df3226a8f2ebd864eec8c96cc5d0540266 @@ -1,7 +1,24 @@ -// 1.19.2 2024-02-07T21:28:25.6424484 dynamictrees DT Block Tags -0852fd1f90777eeab7126995157c4b1242a44700 data/dynamictrees/tags/items/branches.json -c16c437c51cfaa61f8cec19b3f2c9af858cf2e3e data/dynamictrees/tags/items/branches_that_burn.json -265c9a52b7eb0cfd09154318ed7e17789980c9a6 data/dynamictrees/tags/items/fungus_branches.json -80f707272ee43de5e1e0d5897629cdd2798eb9dd data/dynamictrees/tags/items/fungus_caps.json -bc9fc83554c6581be3209e99ddfd16c3af8d6d27 data/dynamictrees/tags/items/seeds.json -40d8c97822466372474dc35e9087e3f6ac034207 data/minecraft/tags/items/saplings.json +// 1.19.2 2024-05-14T15:06:51.3208872 dynamictrees DT Block Tags +89563876084509cc93d596004b67e412d78ebf3b data/dynamictrees/tags/blocks/aerial_roots_rooty_soil.json +0852fd1f90777eeab7126995157c4b1242a44700 data/dynamictrees/tags/blocks/branches.json +c16c437c51cfaa61f8cec19b3f2c9af858cf2e3e data/dynamictrees/tags/blocks/branches_that_burn.json +f7b3d15cfb12f4c543a75050f694ba0609d1d209 data/dynamictrees/tags/blocks/foliage.json +265c9a52b7eb0cfd09154318ed7e17789980c9a6 data/dynamictrees/tags/blocks/fungus_branches.json +a86aa6fa2f09d162f8300475ee0d944102f6334c data/dynamictrees/tags/blocks/fungus_caps.json +9b5ab09c1aee5e896642d4ae3ffaa2afdbbe5c72 data/dynamictrees/tags/blocks/leaves.json +40de46457ac325dc281c1862bf4d99eb12daec0f data/dynamictrees/tags/blocks/roots.json +52baa924e0817cb9cbaca436202fd66c846258b1 data/dynamictrees/tags/blocks/rooty_soil.json +9462bb62d2969d2f7b136e237b2456b4554e324a data/dynamictrees/tags/blocks/saplings.json +ef507377a99fc5ec5cc3ca9cdd35486ea719a119 data/dynamictrees/tags/blocks/stripped_branches.json +9cc41779f2e3f981b1883b1fda538c83cb43afca data/dynamictrees/tags/blocks/stripped_branches_that_burn.json +3e34ca7dcdebfeae6d9931c582ba2243275afd6c data/dynamictrees/tags/blocks/stripped_fungus_branches.json +df7ab2d6211815d5441e432477abca88841b501c data/dynamictrees/tags/blocks/wart_blocks.json +4458fce0a5d1dbd6e884e4a581f15f4df9def5fb data/minecraft/tags/blocks/enderman_holdable.json +bb90442c6cad4ad25a29f41c20d4540e8bd80799 data/minecraft/tags/blocks/flower_pots.json +478c83611465564e2ad9f75d9a1f60369b13b8da data/minecraft/tags/blocks/hoglin_repellents.json +5d45d3e56c20aa5b2eacc4ae25a9815459a664ef data/minecraft/tags/blocks/leaves.json +c6cbc2390b831eca0a8a61bd1a5faee1cf798f13 data/minecraft/tags/blocks/logs.json +bc2b505c9efcae8fad28abd2638a512645158332 data/minecraft/tags/blocks/logs_that_burn.json +54774cb7e6ab420204d58ad3c265d6ac24eb1046 data/minecraft/tags/blocks/mineable/axe.json +b1d094064f3a9f87563f9c43b97ddd084255a7d1 data/minecraft/tags/blocks/saplings.json +145d07f74a6f711d7e0f71365129d520a3d65269 data/minecraft/tags/blocks/wart_blocks.json diff --git a/src/generated/resources/assets/dynamictrees/blockstates/mega_spruce_sapling.json b/src/generated/resources/assets/dynamictrees/blockstates/mega_spruce_sapling.json deleted file mode 100644 index 0cbfd0675..000000000 --- a/src/generated/resources/assets/dynamictrees/blockstates/mega_spruce_sapling.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "variants": { - "": { - "model": "dynamictrees:block/saplings/mega_spruce" - } - } -} \ No newline at end of file diff --git a/src/generated/resources/assets/dynamictrees/models/block/saplings/crimson.json b/src/generated/resources/assets/dynamictrees/models/block/saplings/crimson.json index bda715d88..a7b262559 100644 --- a/src/generated/resources/assets/dynamictrees/models/block/saplings/crimson.json +++ b/src/generated/resources/assets/dynamictrees/models/block/saplings/crimson.json @@ -3,6 +3,6 @@ "render_type": "minecraft:cutout_mipped", "textures": { "cap": "dynamictrees:block/crimson_cap", - "stem": "minecraft:block/crimson_stem" + "stem": "dynamictrees:block/crimson_cap" } } \ No newline at end of file diff --git a/src/generated/resources/assets/dynamictrees/models/block/saplings/mega_spruce.json b/src/generated/resources/assets/dynamictrees/models/block/saplings/mega_spruce.json deleted file mode 100644 index e37197ac0..000000000 --- a/src/generated/resources/assets/dynamictrees/models/block/saplings/mega_spruce.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "dynamictrees:block/smartmodel/sapling", - "render_type": "minecraft:cutout_mipped", - "textures": { - "leaves": "minecraft:block/spruce_leaves", - "log": "minecraft:block/spruce_log" - } -} \ No newline at end of file diff --git a/src/generated/resources/assets/dynamictrees/models/block/saplings/warped.json b/src/generated/resources/assets/dynamictrees/models/block/saplings/warped.json index b3504e387..76b82dd1d 100644 --- a/src/generated/resources/assets/dynamictrees/models/block/saplings/warped.json +++ b/src/generated/resources/assets/dynamictrees/models/block/saplings/warped.json @@ -3,6 +3,6 @@ "render_type": "minecraft:cutout_mipped", "textures": { "cap": "dynamictrees:block/warped_cap", - "stem": "minecraft:block/warped_stem" + "stem": "dynamictrees:block/warped_cap" } } \ No newline at end of file diff --git a/src/generated/resources/data/dynamictrees/tags/blocks/foliage.json b/src/generated/resources/data/dynamictrees/tags/blocks/foliage.json index 87d7be151..42e11f2db 100644 --- a/src/generated/resources/data/dynamictrees/tags/blocks/foliage.json +++ b/src/generated/resources/data/dynamictrees/tags/blocks/foliage.json @@ -1,8 +1,7 @@ { "values": [ - "minecraft:grass", - "minecraft:tall_grass", - "minecraft:fern", - "minecraft:lily_pad" + "minecraft:lily_pad", + "#minecraft:flowers", + "#minecraft:replaceable_plants" ] } \ No newline at end of file diff --git a/src/main/java/com/ferreusveritas/dynamictrees/api/data/SaplingStateGenerator.java b/src/main/java/com/ferreusveritas/dynamictrees/api/data/SaplingStateGenerator.java index 888941faf..53e159807 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/api/data/SaplingStateGenerator.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/api/data/SaplingStateGenerator.java @@ -26,7 +26,7 @@ public void generate(DTBlockStateProvider provider, Species input, Dependencies .map(primitiveLeaves -> provider.block(Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(primitiveLeaves)))); final ResourceLocation primitiveLogLocation = Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(dependencies.get(PRIMITIVE_LOG))); - final BlockModelBuilder builder = provider.models().getBuilder("block/saplings/" + input.getRegistryName().getPath()) + final BlockModelBuilder builder = provider.models().getBuilder(input.getSaplingModelName()) .parent(provider.models().getExistingFile(input.getSaplingSmartModelLocation())) .renderType("cutout_mipped"); input.addSaplingTextures(builder::texture, leavesTextureLocation.orElse(primitiveLogLocation), provider.block(primitiveLogLocation)); diff --git a/src/main/java/com/ferreusveritas/dynamictrees/api/data/SeedItemModelGenerator.java b/src/main/java/com/ferreusveritas/dynamictrees/api/data/SeedItemModelGenerator.java index 4e07fcf92..bdf1a7bb4 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/api/data/SeedItemModelGenerator.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/api/data/SeedItemModelGenerator.java @@ -15,8 +15,8 @@ public class SeedItemModelGenerator implements Generator textureOverrides) public void setModelOverrides(Map modelOverrides) { this.modelOverrides.putAll(modelOverrides); } - public Optional getTexturePath(String key) { return Optional.ofNullable(textureOverrides.getOrDefault(key, null)); } diff --git a/src/main/java/com/ferreusveritas/dynamictrees/block/rooty/SoilProperties.java b/src/main/java/com/ferreusveritas/dynamictrees/block/rooty/SoilProperties.java index 5c0e2ee55..acbdd41e2 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/block/rooty/SoilProperties.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/block/rooty/SoilProperties.java @@ -25,6 +25,8 @@ import net.minecraft.world.level.material.MaterialColor; import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.function.Supplier; @@ -225,7 +227,26 @@ public void generateStateData(DTBlockStateProvider provider) { this.soilStateGenerator.get().generate(provider, this); } - public ResourceLocation getRootsOverlayLocation() { + protected HashMap textureOverrides = new HashMap<>(); + protected HashMap modelOverrides = new HashMap<>(); + public static final String ROOTS = "roots"; + public static final String SOIL_BLOCK = "soil_block"; + + public void setTextureOverrides(Map textureOverrides) { + this.textureOverrides.putAll(textureOverrides); + } + public Optional getTexturePath(String key) { + return Optional.ofNullable(textureOverrides.getOrDefault(key, null)); + } + public void setModelOverrides(Map modelOverrides) { + this.modelOverrides.putAll(modelOverrides); + } + public Optional getModelPath(String key) { + return Optional.ofNullable(modelOverrides.getOrDefault(key, null)); + } + + public ResourceLocation getRootsOverlayModelLocation() { + if (modelOverrides.containsKey(ROOTS)) return modelOverrides.get(ROOTS); return DynamicTrees.location("block/roots"); } @@ -237,4 +258,5 @@ public ResourceLocation getRootsOverlayLocation() { public String toString() { return getRegistryName().toString(); } + } diff --git a/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/FamilyResourceLoader.java b/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/FamilyResourceLoader.java index d4f8ae32d..4f4ee32b9 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/FamilyResourceLoader.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/FamilyResourceLoader.java @@ -48,7 +48,8 @@ public void registerAppliers() { this.gatherDataAppliers .register("primitive_log", Block.class, Family::setPrimitiveLog) .register("primitive_stripped_log", Block.class, Family::setPrimitiveStrippedLog) - .registerMapApplier("texture_overrides", ResourceLocation.class, Family::setTextureOverrides); + .registerMapApplier("texture_overrides", ResourceLocation.class, Family::setTextureOverrides) + .registerMapApplier("model_overrides", ResourceLocation.class, Family::setModelOverrides); this.setupAppliers .register("primitive_log", Block.class, Family::setPrimitiveLog) diff --git a/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SoilPropertiesResourceLoader.java b/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SoilPropertiesResourceLoader.java index 7e9cd0bbb..9bc6612c0 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SoilPropertiesResourceLoader.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SoilPropertiesResourceLoader.java @@ -9,8 +9,10 @@ import com.ferreusveritas.dynamictrees.deserialisation.JsonHelper; import com.ferreusveritas.dynamictrees.deserialisation.ResourceLocationDeserialiser; import com.ferreusveritas.dynamictrees.deserialisation.result.JsonResult; +import com.ferreusveritas.dynamictrees.tree.species.Species; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraftforge.registries.ForgeRegistries; @@ -32,7 +34,11 @@ public void registerAppliers() { ); // Primitive soil is needed before gathering data. - this.gatherDataAppliers.register("primitive_soil", Block.class, SoilProperties::setPrimitiveSoilBlock); + this.gatherDataAppliers + .register("primitive_soil", Block.class, SoilProperties::setPrimitiveSoilBlock) + .registerMapApplier("model_overrides", ResourceLocation.class, SoilProperties::setModelOverrides) + .registerMapApplier("texture_overrides", ResourceLocation.class, SoilProperties::setTextureOverrides); + ; this.setupAppliers.register("primitive_soil", Block.class, SoilProperties::setPrimitiveSoilBlock); diff --git a/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SpeciesResourceLoader.java b/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SpeciesResourceLoader.java index db5faf9d8..9e62ee206 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SpeciesResourceLoader.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/resources/loader/SpeciesResourceLoader.java @@ -107,6 +107,7 @@ public void registerAppliers() { .register("mega_species", ResourceLocation.class, this::setMegaSpecies) .register("seed", Seed.class, (species, seed) -> species.setSeed(() -> seed)) .register("seed_composter_chance", Float.class, this.composterChanceCache::put) + .register("tint_sapling", Boolean.class, Species::setTintSapling) .register("sapling_grows_naturally", Boolean.class, Species::setCanSaplingGrowNaturally) .register("primitive_sapling", SeedSaplingRecipe.class, Species::addPrimitiveSaplingRecipe) .registerArrayApplier("primitive_saplings", SeedSaplingRecipe.class, Species::addPrimitiveSaplingRecipe) diff --git a/src/main/java/com/ferreusveritas/dynamictrees/tree/family/Family.java b/src/main/java/com/ferreusveritas/dynamictrees/tree/family/Family.java index fb152707b..010bddca1 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/tree/family/Family.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/tree/family/Family.java @@ -62,7 +62,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.generators.BlockModelBuilder; import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -851,7 +850,9 @@ public ResourceLocation getRootItemParentLocation() { protected final MutableLazyValue> branchItemModelGenerator = MutableLazyValue.supplied(BranchItemModelGenerator::new); + //Texture overrides protected HashMap textureOverrides = new HashMap<>(); + protected HashMap modelOverrides = new HashMap<>(); public static final String BRANCH = "branch"; public static final String BRANCH_TOP = "branch_top"; public static final String STRIPPED_BRANCH = "stripped_branch"; @@ -862,6 +863,16 @@ public ResourceLocation getRootItemParentLocation() { public void setTextureOverrides(Map textureOverrides) { this.textureOverrides.putAll(textureOverrides); } + public Optional getTexturePath(String key) { + return Optional.ofNullable(textureOverrides.getOrDefault(key, null)); + } + //There are no models to override but this is here for future-proofing. + public void setModelOverrides(Map modelOverrides) { + this.modelOverrides.putAll(textureOverrides); + } + public Optional getModelPath(String key) { + return Optional.ofNullable(modelOverrides.getOrDefault(key, null)); + } /** * @deprecated Use method with that includes the Block parameter @@ -898,10 +909,6 @@ public void addRootTextures(BiConsumer textureConsumer textureConsumer.accept("rings", rings); } - public Optional getTexturePath(String key) { - return Optional.ofNullable(textureOverrides.getOrDefault(key, null)); - } - @Override public void generateItemModelData(DTItemModelProvider provider) { // Generate branch item models. diff --git a/src/main/java/com/ferreusveritas/dynamictrees/tree/species/Species.java b/src/main/java/com/ferreusveritas/dynamictrees/tree/species/Species.java index a4870bcb6..08f5773b6 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/tree/species/Species.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/tree/species/Species.java @@ -118,7 +118,6 @@ import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.feature.TreeFeature; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.LootTables; @@ -131,17 +130,7 @@ import org.apache.logging.log4j.LogManager; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiConsumer; import java.util.function.BiPredicate; @@ -322,6 +311,11 @@ private static DataResult read(ResourceLocation name) { */ protected Supplier saplingBlock; + /** + * Wether the sapling block should be tinted with the leaves' tint index/ + */ + protected Boolean tintSapling = true; + //WorldGen /** * A map of environmental biome factors that change a tree's suitability @@ -1021,7 +1015,9 @@ public boolean shouldUseLocationOverride() { */ public boolean plantSapling(LevelAccessor level, BlockPos pos, boolean locationOverride) { - final DynamicSaplingBlock sapling = this.getSapling().or(() -> this.getCommonSpecies().getSapling()).orElse(null); + final DynamicSaplingBlock sapling = this.getSapling().or(() -> + isMegaSpecies() ? getPreMegaSpecies().getSapling() : this.getCommonSpecies().getSapling() + ).orElse(null); if (sapling == null || !level.getBlockState(pos).getMaterial().isReplaceable() || !DynamicSaplingBlock.canSaplingStay(level, this, pos)) { @@ -1135,16 +1131,27 @@ public ResourceLocation getSaplingRegName() { } } + public String getSaplingModelName() { + return "block/saplings/" + Objects.requireNonNullElseGet(saplingName, () -> this.getRegistryName().getPath()); + } + public void setSaplingName(String name) { saplingName = name; } + public void setTintSapling(Boolean tintSapling) { + this.tintSapling = tintSapling; + } + public int saplingColorMultiplier(BlockState state, BlockAndTintGetter level, BlockPos pos, int tintIndex) { - if (tintIndex == 0) - return getLeavesProperties().foliageColorMultiplier(state, level, pos); - if (tintIndex == 1) - return family.getRootColor(state, true); - return -1; + if (tintSapling){ + if (tintIndex == 0) + return getLeavesProperties().foliageColorMultiplier(state, level, pos); + if (tintIndex == 1) + return family.getRootColor(state, true); + return -1; + } else return 0xFFFFFFFF; + } private SoundType saplingSound = SoundType.GRASS; @@ -1961,19 +1968,23 @@ public boolean showSpeciesOnWaila() { /////////////////////////////////////////// private Species megaSpecies = Species.NULL_SPECIES; - private boolean isMegaSpecies = false; + private Species preMegaSpecies = Species.NULL_SPECIES; public Species getMegaSpecies() { return this.megaSpecies; } + public Species getPreMegaSpecies() { + return this.preMegaSpecies; + } + public boolean isMegaSpecies() { - return isMegaSpecies; + return preMegaSpecies.isValid(); } public void setMegaSpecies(final Species megaSpecies) { this.megaSpecies = megaSpecies; - megaSpecies.isMegaSpecies = true; + megaSpecies.preMegaSpecies = this; } /////////////////////////////////////////// @@ -2284,6 +2295,9 @@ public List> defaultSeedTags() { protected HashMap textureOverrides = new HashMap<>(); protected HashMap modelOverrides = new HashMap<>(); public static final String SAPLING = "sapling"; + public static final String SEED_PARENT = "seed_parent"; + public static final String SEED = "seed"; + public void setModelOverrides(Map modelOverrides) { this.modelOverrides.putAll(modelOverrides); @@ -2298,7 +2312,6 @@ public Optional getModelPath(String key) { public Optional getTexturePath(String key) { return Optional.ofNullable(textureOverrides.getOrDefault(key, null)); } - /** * @return the location of the dynamic sapling smartmodel for this type of species */ @@ -2327,7 +2340,8 @@ public void generateStateData(DTBlockStateProvider provider) { /** * @return the location of the parent model of the seed item model */ - public ResourceLocation getSeedParentLocation() { + public ResourceLocation getSeedParentModelLocation() { + if (modelOverrides.containsKey(SEED_PARENT)) return modelOverrides.get(SEED_PARENT); return DynamicTrees.location("item/standard_seed"); } diff --git a/src/main/resources/trees/dynamictrees/families/oak.json b/src/main/resources/trees/dynamictrees/families/oak.json index 48ca1c581..a5404687d 100644 --- a/src/main/resources/trees/dynamictrees/families/oak.json +++ b/src/main/resources/trees/dynamictrees/families/oak.json @@ -3,9 +3,5 @@ "common_species": "oak", "primitive_log": "oak_log", "primitive_stripped_log": "stripped_oak_log", - "max_branch_radius": 8, - "texture_overrides": { - "branch": "block/dirt", - "branch_top": "block/grass_block_top" - } + "max_branch_radius": 8 } \ No newline at end of file diff --git a/src/main/resources/trees/dynamictrees/species/mega_spruce.json b/src/main/resources/trees/dynamictrees/species/mega_spruce.json index 59102b4c7..5d9de622d 100644 --- a/src/main/resources/trees/dynamictrees/species/mega_spruce.json +++ b/src/main/resources/trees/dynamictrees/species/mega_spruce.json @@ -21,7 +21,6 @@ }, "perfect_biomes": { "name": "minecraft:old_growth_(pine|spruce)_taiga" }, "common_override": { "name": "minecraft:old_growth_(pine|spruce)_taiga" }, - "generate_sapling": true, "features" : [ "conifer_topper", {