Skip to content

Commit

Permalink
Added texture overrides to soil properties
Browse files Browse the repository at this point in the history
also fixed mega spruce sapling being created
  • Loading branch information
supermassimo committed May 14, 2024
1 parent 27b2a55 commit 43ecb00
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 79 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"values": [
"minecraft:grass",
"minecraft:tall_grass",
"minecraft:fern",
"minecraft:lily_pad"
"minecraft:lily_pad",
"#minecraft:flowers",
"#minecraft:replaceable_plants"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class SeedItemModelGenerator implements Generator<DTItemModelProvider, Sp
@Override
public void generate(DTItemModelProvider provider, Species input, Dependencies dependencies) {
final Seed seed = dependencies.get(SEED);
provider.withExistingParent(String.valueOf(ForgeRegistries.ITEMS.getKey(seed)), seed.getSpecies().getSeedParentLocation())
.texture("layer0", provider.item(ForgeRegistries.ITEMS.getKey(seed)));
provider.withExistingParent(String.valueOf(ForgeRegistries.ITEMS.getKey(seed)), seed.getSpecies().getSeedParentModelLocation())
.texture("layer0", seed.getSpecies().getTexturePath(Species.SEED).orElse(provider.item(ForgeRegistries.ITEMS.getKey(seed))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class SoilStateGenerator implements Generator<DTBlockStateProvider, SoilP
public void generate(DTBlockStateProvider provider, SoilProperties input, Dependencies dependencies) {
provider.getMultipartBuilder(dependencies.get(SOIL))
.part().modelFile(provider.models().getExistingFile(
provider.block(Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(dependencies.get(PRIMITIVE_SOIL))))
input.getModelPath(SoilProperties.SOIL_BLOCK).orElse(provider.block(Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(dependencies.get(PRIMITIVE_SOIL)))))
)).addModel().end()
.part().modelFile(provider.models().getExistingFile(input.getRootsOverlayLocation())).addModel().end();
.part().modelFile(provider.models().getExistingFile(input.getRootsOverlayModelLocation())).addModel().end();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
@Override
public void performBonemeal(@Nonnull ServerLevel level, @Nonnull RandomSource rand, @Nonnull BlockPos pos, @Nonnull BlockState state) {
if (this.canSurvive(state, level, pos)) {
final Species species = this.getSpecies();
final Species species = this.getSpecies().selfOrLocationOverride(level, pos);;
if (species.canSaplingGrow(level, pos)) {
species.transitionToTree(level, pos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public boolean updateTick(Level level, BlockPos pos, BlockState state, RandomSou
protected AgeingConfiguration ageingConfiguration = AgeingConfiguration.ALWAYS;
protected boolean connectAnyRadius = false;
protected boolean requiresShears = true;
protected ResourceLocation texturePath;

private LeavesProperties() {
this.blockLootTableSupplier = new LootTableSupplier("null/", DTTrees.NULL);
Expand Down Expand Up @@ -316,7 +315,6 @@ public void setTextureOverrides(Map<String, ResourceLocation> textureOverrides)
public void setModelOverrides(Map<String, ResourceLocation> modelOverrides) {
this.modelOverrides.putAll(modelOverrides);
}

public Optional<ResourceLocation> getTexturePath(String key) {
return Optional.ofNullable(textureOverrides.getOrDefault(key, null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -225,7 +227,26 @@ public void generateStateData(DTBlockStateProvider provider) {
this.soilStateGenerator.get().generate(provider, this);
}

public ResourceLocation getRootsOverlayLocation() {
protected HashMap<String, ResourceLocation> textureOverrides = new HashMap<>();
protected HashMap<String, ResourceLocation> modelOverrides = new HashMap<>();
public static final String ROOTS = "roots";
public static final String SOIL_BLOCK = "soil_block";

public void setTextureOverrides(Map<String, ResourceLocation> textureOverrides) {
this.textureOverrides.putAll(textureOverrides);
}
public Optional<ResourceLocation> getTexturePath(String key) {
return Optional.ofNullable(textureOverrides.getOrDefault(key, null));
}
public void setModelOverrides(Map<String, ResourceLocation> modelOverrides) {
this.modelOverrides.putAll(modelOverrides);
}
public Optional<ResourceLocation> 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");
}

Expand All @@ -237,4 +258,5 @@ public ResourceLocation getRootsOverlayLocation() {
public String toString() {
return getRegistryName().toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -851,7 +850,9 @@ public ResourceLocation getRootItemParentLocation() {
protected final MutableLazyValue<Generator<DTItemModelProvider, Family>> branchItemModelGenerator =
MutableLazyValue.supplied(BranchItemModelGenerator::new);

//Texture overrides
protected HashMap<String, ResourceLocation> textureOverrides = new HashMap<>();
protected HashMap<String, ResourceLocation> 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";
Expand All @@ -862,6 +863,16 @@ public ResourceLocation getRootItemParentLocation() {
public void setTextureOverrides(Map<String, ResourceLocation> textureOverrides) {
this.textureOverrides.putAll(textureOverrides);
}
public Optional<ResourceLocation> 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<String, ResourceLocation> modelOverrides) {
this.modelOverrides.putAll(textureOverrides);
}
public Optional<ResourceLocation> getModelPath(String key) {
return Optional.ofNullable(modelOverrides.getOrDefault(key, null));
}

/**
* @deprecated Use method with that includes the Block parameter
Expand Down Expand Up @@ -898,10 +909,6 @@ public void addRootTextures(BiConsumer<String, ResourceLocation> textureConsumer
textureConsumer.accept("rings", rings);
}

public Optional<ResourceLocation> getTexturePath(String key) {
return Optional.ofNullable(textureOverrides.getOrDefault(key, null));
}

@Override
public void generateItemModelData(DTItemModelProvider provider) {
// Generate branch item models.
Expand Down
Loading

0 comments on commit 43ecb00

Please sign in to comment.