Skip to content

Commit

Permalink
Allowed all leaves to handle particles
Browse files Browse the repository at this point in the history
  • Loading branch information
supermassimo committed Jul 23, 2024
1 parent 517ed56 commit 7e55a27
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 5 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.3.0-BETA12.006
modVersion=1.3.0-BETA12

group=com.ferreusveritas.dynamictrees

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

import javax.annotation.Nonnull;

/**
* Use 'has_tick_particles' property instead
*/
@Deprecated
public class CherryLeavesProperties extends LeavesProperties {

public static final TypedRegistry.EntryType<LeavesProperties> TYPE = TypedRegistry.newType(CherryLeavesProperties::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ public boolean isRandomlyTicking(BlockState state) {
return !state.getValue(PERSISTENT);
}


@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
if (properties.hasTickParticles && properties.getPrimitiveLeavesBlock().isPresent()) {
properties.getPrimitiveLeavesBlock().ifPresent((b)->b.animateTick(state,level,pos,random));
} else {
super.animateTick(state, level, pos, random);
}
}

public void setProperties(LeavesProperties properties) {
this.properties = properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public boolean updateTick(Level level, BlockPos pos, BlockState state, RandomSou
protected AgeingConfiguration ageingConfiguration = AgeingConfiguration.ALWAYS;
protected boolean connectAnyRadius = false;
protected boolean requiresShears = true;
protected boolean hasTickParticles = false;

private LeavesProperties() {
this.blockLootTableSupplier = new LootTableSupplier("null/", DTTrees.NULL);
Expand Down Expand Up @@ -600,6 +601,10 @@ public void setRequiresShears(boolean requiresShears) {
this.requiresShears = requiresShears;
}

public void setHasTickParticles(boolean hasTickParticles) {
this.hasTickParticles = hasTickParticles;
}

public List<TagKey<Block>> defaultLeavesTags() {
return Collections.singletonList(DTBlockTags.LEAVES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void registerLeavesPropertiesTypes(final TypeRegistryEvent<LeavesP
event.registerType(DynamicTrees.location("wart"), WartProperties.TYPE);
event.registerType(DynamicTrees.location("palm"), PalmLeavesProperties.TYPE);
event.registerType(DynamicTrees.location("scruffy"), ScruffyLeavesProperties.TYPE);
event.registerType(DynamicTrees.location("cherry"), CherryLeavesProperties.TYPE);
//event.registerType(DynamicTrees.location("cherry"), CherryLeavesProperties.TYPE);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void registerAppliers() {
.register("does_age", String.class, (Applier<LeavesProperties, String>) this::readDoesAge)
.register("ageing_configuration", LeavesProperties.AgeingConfiguration.class, LeavesProperties::setAgeingConfiguration)
.register("can_grow_on_ground", Boolean.class, LeavesProperties::setCanGrowOnGround)
.register("has_tick_particles", Boolean.class, LeavesProperties::setHasTickParticles)
.register("scruffy_leaf_chance", ScruffyLeavesProperties.class, Float.class, ScruffyLeavesProperties::setLeafChance)
.register("scruffy_max_hydro", ScruffyLeavesProperties.class, Integer.class, ScruffyLeavesProperties::setMaxHydro);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "dynamictrees:cherry",
"primitive_leaves": "minecraft:cherry_leaves",
"smother": 5,
"light_requirement": 14
"light_requirement": 14,
"has_tick_particles": true
}

0 comments on commit 7e55a27

Please sign in to comment.