diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FireBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FireBlock.java.patch | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FireBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FireBlock.java.patch new file mode 100644 index 0000000000..2fa5e5c3d2 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FireBlock.java.patch @@ -0,0 +1,182 @@ +--- a/net/minecraft/world/level/block/FireBlock.java ++++ b/net/minecraft/world/level/block/FireBlock.java +@@ -29,6 +28,13 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.craftbukkit.block.CraftBlockStates; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.event.block.BlockBurnEvent; ++import org.bukkit.event.block.BlockFadeEvent; ++// CraftBukkit end + + public class FireBlock extends BaseFireBlock { + public static final MapCodec<FireBlock> CODEC = simpleCodec(FireBlock::new); +@@ -113,8 +106,25 @@ + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { +- return this.canSurvive(state, level, currentPos) ? this.getStateWithAge(level, currentPos, state.getValue(AGE)) : Blocks.AIR.defaultBlockState(); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ // CraftBukkit start ++ if (!this.canSurvive(state, level, currentPos)) { ++ // Suppress during worldgen ++ if (!(level instanceof Level)) { ++ return Blocks.AIR.defaultBlockState(); ++ } ++ CraftBlockState blockState = CraftBlockStates.getBlockState(level, currentPos); ++ blockState.setData(Blocks.AIR.defaultBlockState()); ++ ++ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); ++ ((Level) level).getCraftServer().getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ return blockState.getHandle(); ++ } ++ } ++ return this.getStateWithAge(level, currentPos, (Integer) state.getValue(FireBlock.AGE)); ++ // CraftBukkit end + } + + @Override +@@ -157,14 +173,15 @@ + level.scheduleTick(pos, this, getFireTickDelay(level.random)); + if (level.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { + if (!state.canSurvive(level, pos)) { +- level.removeBlock(pos, false); ++ fireExtinguished(level, pos); // CraftBukkit - invalid place location + } + +- BlockState blockState = level.getBlockState(pos.below()); +- boolean isTag = blockState.is(level.dimensionType().infiniburn()); +- int i = state.getValue(AGE); +- if (!isTag && level.isRaining() && this.isNearRain(level, pos) && random.nextFloat() < 0.2F + (float)i * 0.03F) { +- level.removeBlock(pos, false); ++ IBlockData iblockdata1 = level.getBlockState(pos.below()); ++ boolean flag = iblockdata1.is(level.dimensionType().infiniburn()); ++ int i = (Integer) state.getValue(FireBlock.AGE); ++ ++ if (!flag && level.isRaining() && this.isNearRain(level, pos) && random.nextFloat() < 0.2F + (float) i * 0.03F) { ++ fireExtinguished(level, pos); // CraftBukkit - extinguished by rain + } else { + int min = Math.min(15, i + random.nextInt(3) / 2); + if (i != min) { +@@ -174,16 +192,17 @@ + + if (!isTag) { + if (!this.isValidFireLocation(level, pos)) { +- BlockPos blockPos = pos.below(); +- if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || i > 3) { +- level.removeBlock(pos, false); ++ BlockPos blockposition1 = pos.below(); ++ ++ if (!level.getBlockState(blockposition1).isFaceSturdy(level, blockposition1, Direction.UP) || i > 3) { ++ fireExtinguished(level, pos); // CraftBukkit + } + + return; + } + + if (i == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { +- level.removeBlock(pos, false); ++ fireExtinguished(level, pos); // CraftBukkit + return; + } + } +@@ -198,13 +210,24 @@ + this.checkBurnOut(level, pos.south(), 300 + i1, random, i); + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + +- for (int i2 = -1; i2 <= 1; i2++) { +- for (int i3 = -1; i3 <= 1; i3++) { +- for (int i4 = -1; i4 <= 4; i4++) { +- if (i2 != 0 || i4 != 0 || i3 != 0) { +- int i5 = 100; +- if (i4 > 1) { +- i5 += (i4 - 1) * 100; ++ // CraftBukkit start - add source blockposition to burn calls ++ this.trySpread(level, pos.east(), 300 + k, random, i, pos); ++ this.trySpread(level, pos.west(), 300 + k, random, i, pos); ++ this.trySpread(level, pos.below(), 250 + k, random, i, pos); ++ this.trySpread(level, pos.above(), 250 + k, random, i, pos); ++ this.trySpread(level, pos.north(), 300 + k, random, i, pos); ++ this.trySpread(level, pos.south(), 300 + k, random, i, pos); ++ // CraftBukkit end ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); ++ ++ for (int l = -1; l <= 1; ++l) { ++ for (int i1 = -1; i1 <= 1; ++i1) { ++ for (int j1 = -1; j1 <= 4; ++j1) { ++ if (l != 0 || j1 != 0 || i1 != 0) { ++ int k1 = 100; ++ ++ if (j1 > 1) { ++ k1 += (j1 - 1) * 100; + } + + mutableBlockPos.setWithOffset(pos, i2, i4, i3); +@@ -215,9 +240,18 @@ + i6 /= 2; + } + +- if (i6 > 0 && random.nextInt(i5) <= i6 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { +- int min1 = Math.min(15, i + random.nextInt(5) / 4); +- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); ++ if (i2 > 0 && random.nextInt(k1) <= i2 && (!level.isRaining() || !this.isNearRain(level, blockposition_mutableblockposition))) { ++ int j2 = Math.min(15, i + random.nextInt(5) / 4); ++ ++ // CraftBukkit start - Call to stop spread of fire ++ if (level.getBlockState(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) { ++ if (CraftEventFactory.callBlockIgniteEvent(level, blockposition_mutableblockposition, pos).isCancelled()) { ++ continue; ++ } ++ ++ CraftEventFactory.handleBlockSpreadEvent(level, pos, blockposition_mutableblockposition, this.getStateWithAge(level, blockposition_mutableblockposition, j2), 3); // CraftBukkit ++ } ++ // CraftBukkit end + } + } + } +@@ -248,13 +275,32 @@ + : this.igniteOdds.getInt(state.getBlock()); + } + +- private void checkBurnOut(Level level, BlockPos pos, int chance, RandomSource random, int age) { +- int burnOdds = this.getBurnOdds(level.getBlockState(pos)); +- if (random.nextInt(chance) < burnOdds) { +- BlockState blockState = level.getBlockState(pos); +- if (random.nextInt(age + 10) < 5 && !level.isRainingAt(pos)) { +- int min = Math.min(age + random.nextInt(5) / 4, 15); +- level.setBlock(pos, this.getStateWithAge(level, pos, min), 3); ++ private void trySpread(Level world, BlockPos blockposition, int i, RandomSource randomsource, int j, BlockPos sourceposition) { // CraftBukkit add sourceposition ++ int k = this.getBurnOdds(world.getBlockState(blockposition)); ++ ++ if (randomsource.nextInt(i) < k) { ++ IBlockData iblockdata = world.getBlockState(blockposition); ++ ++ // CraftBukkit start ++ org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.block.Block sourceBlock = world.getWorld().getBlockAt(sourceposition.getX(), sourceposition.getY(), sourceposition.getZ()); ++ ++ BlockBurnEvent event = new BlockBurnEvent(theBlock, sourceBlock); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ ++ if (iblockdata.getBlock() instanceof TntBlock && !CraftEventFactory.callTNTPrimeEvent(world, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.FIRE, null, sourceposition)) { ++ return; ++ } ++ // CraftBukkit end ++ ++ if (randomsource.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) { ++ int l = Math.min(j + randomsource.nextInt(5) / 4, 15); ++ ++ world.setBlock(blockposition, this.getStateWithAge(world, blockposition, l), 3); + } else { + level.removeBlock(pos, false); + } |