2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/level/block/BlockFire.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockFire.java
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -27,6 +27,14 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapes;
|
2014-11-26 08:32:16 +11:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2018-07-15 10:00:00 +10:00
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
2021-09-29 18:56:16 +10:00
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlockStates;
|
2014-11-26 08:32:16 +11:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.block.BlockBurnEvent;
|
2018-07-15 10:00:00 +10:00
|
|
|
+import org.bukkit.event.block.BlockFadeEvent;
|
2014-11-26 08:32:16 +11:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2020-06-25 10:00:00 +10:00
|
|
|
public class BlockFire extends BlockFireAbstract {
|
2014-11-26 08:32:16 +11:00
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
public static final int MAX_AGE = 15;
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -92,7 +100,24 @@
|
2018-07-15 10:00:00 +10:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
@Override
|
2021-11-22 09:00:00 +11:00
|
|
|
public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
|
|
|
- return this.canSurvive(iblockdata, generatoraccess, blockposition) ? this.getStateWithAge(generatoraccess, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)) : Blocks.AIR.defaultBlockState();
|
2018-07-15 10:00:00 +10:00
|
|
|
+ // CraftBukkit start
|
2021-11-22 09:00:00 +11:00
|
|
|
+ if (!this.canSurvive(iblockdata, generatoraccess, blockposition)) {
|
2020-06-27 08:41:54 +10:00
|
|
|
+ // Suppress during worldgen
|
|
|
|
+ if (!(generatoraccess instanceof World)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ return Blocks.AIR.defaultBlockState();
|
2020-06-27 08:41:54 +10:00
|
|
|
+ }
|
2021-09-29 18:56:16 +10:00
|
|
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition);
|
2021-11-22 09:00:00 +11:00
|
|
|
+ blockState.setData(Blocks.AIR.defaultBlockState());
|
2018-07-15 10:00:00 +10:00
|
|
|
+
|
|
|
|
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
2021-06-11 21:33:49 +10:00
|
|
|
+ ((World) generatoraccess).getCraftServer().getPluginManager().callEvent(event);
|
2018-07-15 10:00:00 +10:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ return blockState.getHandle();
|
|
|
|
+ }
|
|
|
|
+ }
|
2021-11-22 09:00:00 +11:00
|
|
|
+ return this.getStateWithAge(generatoraccess, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE));
|
2018-07-15 10:00:00 +10:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2020-06-25 10:00:00 +10:00
|
|
|
@Override
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -141,7 +166,7 @@
|
|
|
|
worldserver.scheduleTick(blockposition, (Block) this, getFireTickDelay(worldserver.random));
|
2021-06-11 15:00:00 +10:00
|
|
|
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
if (!iblockdata.canSurvive(worldserver, blockposition)) {
|
|
|
|
- worldserver.removeBlock(blockposition, false);
|
2019-12-11 09:00:00 +11:00
|
|
|
+ fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location
|
2014-11-26 08:32:16 +11:00
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
IBlockData iblockdata1 = worldserver.getBlockState(blockposition.below());
|
|
|
|
@@ -149,7 +174,7 @@
|
|
|
|
int i = (Integer) iblockdata.getValue(BlockFire.AGE);
|
2014-11-26 08:32:16 +11:00
|
|
|
|
2022-06-08 02:00:00 +10:00
|
|
|
if (!flag && worldserver.isRaining() && this.isNearRain(worldserver, blockposition) && randomsource.nextFloat() < 0.2F + (float) i * 0.03F) {
|
2021-11-22 09:00:00 +11:00
|
|
|
- worldserver.removeBlock(blockposition, false);
|
2019-12-11 09:00:00 +11:00
|
|
|
+ fireExtinguished(worldserver, blockposition); // CraftBukkit - extinguished by rain
|
2014-11-26 08:32:16 +11:00
|
|
|
} else {
|
2022-06-08 02:00:00 +10:00
|
|
|
int j = Math.min(15, i + randomsource.nextInt(3) / 2);
|
2018-07-15 10:00:00 +10:00
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -163,14 +188,14 @@
|
|
|
|
BlockPosition blockposition1 = blockposition.below();
|
2019-04-23 12:00:00 +10:00
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
if (!worldserver.getBlockState(blockposition1).isFaceSturdy(worldserver, blockposition1, EnumDirection.UP) || i > 3) {
|
|
|
|
- worldserver.removeBlock(blockposition, false);
|
2019-12-11 09:00:00 +11:00
|
|
|
+ fireExtinguished(worldserver, blockposition); // CraftBukkit
|
2015-02-17 14:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-08 02:00:00 +10:00
|
|
|
if (i == 15 && randomsource.nextInt(4) == 0 && !this.canBurn(worldserver.getBlockState(blockposition.below()))) {
|
2021-11-22 09:00:00 +11:00
|
|
|
- worldserver.removeBlock(blockposition, false);
|
2019-12-11 09:00:00 +11:00
|
|
|
+ fireExtinguished(worldserver, blockposition); // CraftBukkit
|
2015-02-17 14:06:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -178,12 +203,14 @@
|
|
|
|
boolean flag1 = worldserver.isHumidAt(blockposition);
|
2018-07-15 10:00:00 +10:00
|
|
|
int k = flag1 ? -50 : 0;
|
2017-03-08 14:20:24 -08:00
|
|
|
|
2022-06-08 02:00:00 +10:00
|
|
|
- this.checkBurnOut(worldserver, blockposition.east(), 300 + k, randomsource, i);
|
|
|
|
- this.checkBurnOut(worldserver, blockposition.west(), 300 + k, randomsource, i);
|
|
|
|
- this.checkBurnOut(worldserver, blockposition.below(), 250 + k, randomsource, i);
|
|
|
|
- this.checkBurnOut(worldserver, blockposition.above(), 250 + k, randomsource, i);
|
|
|
|
- this.checkBurnOut(worldserver, blockposition.north(), 300 + k, randomsource, i);
|
|
|
|
- this.checkBurnOut(worldserver, blockposition.south(), 300 + k, randomsource, i);
|
2017-03-08 14:20:24 -08:00
|
|
|
+ // CraftBukkit start - add source blockposition to burn calls
|
2022-06-08 02:00:00 +10:00
|
|
|
+ this.trySpread(worldserver, blockposition.east(), 300 + k, randomsource, i, blockposition);
|
|
|
|
+ this.trySpread(worldserver, blockposition.west(), 300 + k, randomsource, i, blockposition);
|
|
|
|
+ this.trySpread(worldserver, blockposition.below(), 250 + k, randomsource, i, blockposition);
|
|
|
|
+ this.trySpread(worldserver, blockposition.above(), 250 + k, randomsource, i, blockposition);
|
|
|
|
+ this.trySpread(worldserver, blockposition.north(), 300 + k, randomsource, i, blockposition);
|
|
|
|
+ this.trySpread(worldserver, blockposition.south(), 300 + k, randomsource, i, blockposition);
|
2017-03-08 14:20:24 -08:00
|
|
|
+ // CraftBukkit end
|
2018-07-15 10:00:00 +10:00
|
|
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
2017-03-08 14:20:24 -08:00
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
for (int l = -1; l <= 1; ++l) {
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -209,7 +236,15 @@
|
2022-06-08 02:00:00 +10:00
|
|
|
if (i2 > 0 && randomsource.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.isNearRain(worldserver, blockposition_mutableblockposition))) {
|
|
|
|
int j2 = Math.min(15, i + randomsource.nextInt(5) / 4);
|
2014-11-26 08:32:16 +11:00
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
- worldserver.setBlock(blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3);
|
2014-11-26 08:32:16 +11:00
|
|
|
+ // CraftBukkit start - Call to stop spread of fire
|
2021-11-22 09:00:00 +11:00
|
|
|
+ if (worldserver.getBlockState(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) {
|
2019-12-11 09:00:00 +11:00
|
|
|
+ if (CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition_mutableblockposition, blockposition).isCancelled()) {
|
2014-11-26 08:32:16 +11:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
2021-11-22 09:00:00 +11:00
|
|
|
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit
|
2014-11-26 08:32:16 +11:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -233,12 +268,24 @@
|
2022-06-08 02:00:00 +10:00
|
|
|
return iblockdata.hasProperty(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockProperties.WATERLOGGED) ? 0 : this.igniteOdds.getInt(iblockdata.getBlock());
|
2017-03-08 14:20:24 -08:00
|
|
|
}
|
|
|
|
|
2022-06-08 02:00:00 +10:00
|
|
|
- private void checkBurnOut(World world, BlockPosition blockposition, int i, RandomSource randomsource, int j) {
|
|
|
|
+ private void trySpread(World world, BlockPosition blockposition, int i, RandomSource randomsource, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition
|
|
|
|
int k = this.getBurnOdds(world.getBlockState(blockposition));
|
2017-03-08 14:20:24 -08:00
|
|
|
|
2022-06-08 02:00:00 +10:00
|
|
|
if (randomsource.nextInt(i) < k) {
|
2021-11-22 09:00:00 +11:00
|
|
|
IBlockData iblockdata = world.getBlockState(blockposition);
|
2015-02-26 22:41:06 +00:00
|
|
|
|
2014-11-26 08:32:16 +11:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
2017-03-08 14:20:24 -08:00
|
|
|
+ org.bukkit.block.Block sourceBlock = world.getWorld().getBlockAt(sourceposition.getX(), sourceposition.getY(), sourceposition.getZ());
|
2014-11-26 08:32:16 +11:00
|
|
|
+
|
2017-03-08 14:20:24 -08:00
|
|
|
+ BlockBurnEvent event = new BlockBurnEvent(theBlock, sourceBlock);
|
2021-06-11 21:33:49 +10:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-26 08:32:16 +11:00
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 22:41:06 +00:00
|
|
|
+
|
2022-06-08 02:00:00 +10:00
|
|
|
if (randomsource.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
|
|
|
|
int l = Math.min(j + randomsource.nextInt(5) / 4, 15);
|
2014-11-26 08:32:16 +11:00
|
|
|
|