Skip to content

Commit

Permalink
fixed leaves of the wrong type growing over others
Browse files Browse the repository at this point in the history
  • Loading branch information
supermassimo committed Aug 6, 2024
1 parent a772920 commit 9b43a92
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 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
modVersion=1.3.0-BETA13

group=com.ferreusveritas.dynamictrees

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
Expand Down Expand Up @@ -510,8 +509,9 @@ public int getHydrationLevelFromNeighbors(LevelAccessor level, BlockPos pos, Lea
}

@Override
public Cell getHydrationCell(BlockGetter level, BlockPos pos, BlockState state, Direction dir, LeavesProperties leavesProperties) {
return dir != null ? leavesProperties.getCellKit().getCellForLeaves(state.getValue(LeavesBlock.DISTANCE)) : CellNull.NULL_CELL;
public Cell getHydrationCell(BlockGetter level, BlockPos pos, BlockState state, Direction dir, LeavesProperties otherProperties) {
LeavesProperties thisProperties = getProperties(state);
return thisProperties.isCompatibleLeaves(otherProperties) ? thisProperties.getCellKit().getCellForLeaves(state.getValue(LeavesBlock.DISTANCE)) : CellNull.NULL_CELL;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ public void generateLangData(DTLangProvider provider) {
//this.langGenerator.get().generate(provider, this);
}

public boolean isCompatibleLeaves(LeavesProperties leaves){
return this.getFamily() == leaves.getFamily();
}

///////////////////////////////////////////
// LEAVES COLORS
///////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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.material.Fluids;
import net.minecraft.world.level.storage.loot.LootDataManager;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
Expand Down Expand Up @@ -965,6 +964,9 @@ public Species generateSapling() {
this.setSapling(RegistryHandler.addBlock(this.getSaplingRegName(), () -> new DynamicSaplingBlock(this)));
}

/**
* @return the sapling block. Empty Optional if none is present.
*/
public Optional<DynamicSaplingBlock> getSapling() {
return Optional.ofNullable(this.saplingBlock == null ? null : this.saplingBlock.get());
}
Expand Down Expand Up @@ -997,12 +999,8 @@ public boolean shouldUseLocationOverride() {
* @return true if the planting was successful
*/
public boolean plantSapling(LevelAccessor level, BlockPos pos, boolean locationOverride) {

Species saplingSpecies = this;
while (saplingSpecies.isMegaSpecies()){
saplingSpecies = getPreMegaSpecies();
}
final DynamicSaplingBlock sapling = saplingSpecies.getSapling().orElse(null);
DynamicSaplingBlock commonSapling = getCommonSpecies().getSapling().orElse(null);
final DynamicSaplingBlock sapling = locationOverride ? commonSapling : getSapling().orElse(commonSapling);

if (sapling == null || !level.getBlockState(pos).canBeReplaced() ||
!DynamicSaplingBlock.canSaplingStay(level, this, pos)) {
Expand Down

0 comments on commit 9b43a92

Please sign in to comment.