Skip to content

Commit

Permalink
Fixed fire not burning trees properly
Browse files Browse the repository at this point in the history
  • Loading branch information
supermassimo committed Sep 8, 2024
1 parent d27bf04 commit 2992aa6
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -576,19 +577,28 @@ public void onRemove(BlockState state, Level level, BlockPos pos, BlockState new
return;
}

if (toBlock == Blocks.AIR) { // Block was set to air improperly.
level.setBlock(pos, state, 0); // Set the block back and attempt a proper breaking.
this.sloppyBreak(level, pos, DestroyType.VOID);
this.setBlockStateIgnored(level, pos, BlockStates.AIR, 2); // Set back to air in case the sloppy break failed to do so.
return;
boolean foundFire = false;
for (Direction offset : Direction.values()){
BlockPos offPos = pos.offset(offset.getNormal());
if (level.getBlockState(offPos).is(BlockTags.FIRE)){
foundFire = true;
break;
}
}
if (toBlock == Blocks.FIRE) { // Block has burned.

if (foundFire) { // Block has burned.
level.setBlock(pos, state, 0); // Set the branch block back and attempt a proper breaking.
this.sloppyBreak(level, pos, DestroyType.FIRE); // Applies fire effects to falling branches.
//this.setBlockStateIgnored(level, pos, Blocks.FIRE.getDefaultState(), 2); // Disabled because the fire is too aggressive.
this.setBlockStateIgnored(level, pos, BlockStates.AIR, 2); // Set back to air instead.
return;
} else if (toBlock == Blocks.AIR){
level.setBlock(pos, state, 0); // Set the block back and attempt a proper breaking.
this.sloppyBreak(level, pos, DestroyType.VOID);
this.setBlockStateIgnored(level, pos, BlockStates.AIR, 2); // Set back to air in case the sloppy break failed to do so.
return;
}

if (/*!toBlock.entity(toBlockState) && */level.getBlockEntity(pos) == null) { // Block seems to be a pure BlockState based block.
level.setBlock(pos, state, 0); // Set the branch block back and attempt a proper breaking.
this.sloppyBreak(level, pos, DestroyType.VOID);
Expand Down

0 comments on commit 2992aa6

Please sign in to comment.