Skip to content

Commit

Permalink
Fix CustomLeavesBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Jan 20, 2025
1 parent 3091f2b commit 6c49ca8
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ protected boolean isLogValid(BlockState state) {
return state.isIn(BlockTags.LOGS);
}

protected boolean hasSeparatedLeaves() {
return false;
protected boolean areLeavesValid(BlockState state) {
return state.isOf(this);
}

protected boolean areLeavesConnected() {
return true;
}

@Override
Expand Down Expand Up @@ -99,7 +103,7 @@ private BlockState updateDistanceFromLogs(BlockState state, WorldAccess world, B
int distance = this.getMaxDistance();
BlockPos.Mutable mutable = new BlockPos.Mutable();

if (this.hasSeparatedLeaves()) {
if (!this.areLeavesConnected()) {
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
Expand Down Expand Up @@ -129,7 +133,7 @@ private int getDistanceFromLog(BlockState state) {
if (this.isLogValid(state)) {
return 0;
}
else if (state.isOf(this)) {
else if (this.areLeavesValid(state)) {
return state.get(this.getDistanceProperty());
}
else {
Expand All @@ -150,7 +154,7 @@ public BlockState getPlacementState(ItemPlacementContext ctx) {
.getFluidState(ctx.getBlockPos());

BlockState blockState = this.getDefaultState()
.with(CustomLeavesBlock.PERSISTENT, false)
.with(CustomLeavesBlock.PERSISTENT, true)
.with(CustomLeavesBlock.WATERLOGGED, fluidState.getFluid() == Fluids.WATER);

return this.updateDistanceFromLogs(blockState, ctx.getWorld(), ctx.getBlockPos());
Expand Down

0 comments on commit 6c49ca8

Please sign in to comment.