From 2992aa61ed27c55c9d19bd9ba805a0fbbc85a5b8 Mon Sep 17 00:00:00 2001 From: Max Hyper Date: Sun, 8 Sep 2024 16:45:16 -0300 Subject: [PATCH] Fixed fire not burning trees properly --- .../block/branch/BranchBlock.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ferreusveritas/dynamictrees/block/branch/BranchBlock.java b/src/main/java/com/ferreusveritas/dynamictrees/block/branch/BranchBlock.java index 8d646d864..c9b3d10e7 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/block/branch/BranchBlock.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/block/branch/BranchBlock.java @@ -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; @@ -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);