Update to Minecraft 1.21.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-10-23 02:15:00 +11:00
parent 2c4beb962b
commit d3a23f42c3
522 changed files with 8501 additions and 6477 deletions

View File

@@ -16,62 +16,60 @@
public abstract class FluidTypeFlowing extends FluidType {
public static final BlockStateBoolean FALLING = BlockProperties.FALLING;
@@ -132,6 +141,15 @@
Fluid fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);
@@ -135,6 +144,15 @@
FluidType fluidtype = fluid2.getType();
if (this.canSpreadTo(world, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
+ // CraftBukkit start
+ org.bukkit.block.Block source = CraftBlock.at(world, blockposition);
+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+ world.getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.spreadTo(world, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1);
if (this.sourceNeighborCount(world, blockposition) >= 3) {
this.spreadToSides(world, blockposition, fluid, iblockdata);
@@ -162,6 +180,15 @@
IBlockData iblockdata1 = world.getBlockState(blockposition1);
if (this.canSpreadTo(world, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
if (fluid1.canBeReplacedWith(worldserver, blockposition1, fluidtype, EnumDirection.DOWN) && canHoldSpecificFluid(worldserver, blockposition1, iblockdata1, fluidtype)) {
+ // CraftBukkit start
+ org.bukkit.block.Block source = CraftBlock.at(world, blockposition);
+ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection));
+ world.getCraftServer().getPluginManager().callEvent(event);
+ org.bukkit.block.Block source = CraftBlock.at(worldserver, blockposition);
+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ continue;
+ return;
+ }
+ // CraftBukkit end
this.spreadTo(world, blockposition1, iblockdata1, enumdirection, fluid1);
}
}
@@ -436,12 +463,23 @@
this.spreadTo(worldserver, blockposition1, iblockdata1, EnumDirection.DOWN, fluid2);
if (this.sourceNeighborCount(worldserver, blockposition) >= 3) {
this.spreadToSides(worldserver, blockposition, fluid, iblockdata);
@@ -168,6 +186,15 @@
Fluid fluid1 = (Fluid) entry.getValue();
BlockPosition blockposition1 = blockposition.relative(enumdirection);
+ // CraftBukkit start
+ org.bukkit.block.Block source = CraftBlock.at(worldserver, blockposition);
+ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection));
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
this.spreadTo(worldserver, blockposition1, worldserver.getBlockState(blockposition1), enumdirection, fluid1);
}
@@ -444,10 +471,24 @@
if (fluid1.isEmpty()) {
fluid = fluid1;
- world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3);
iblockdata = Blocks.AIR.defaultBlockState();
+ // CraftBukkit start
+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, Blocks.AIR.defaultBlockState());
+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(worldserver, blockposition, iblockdata);
+ if (event.isCancelled()) {
+ return;
+ }
+ world.setBlock(blockposition, ((CraftBlockData) event.getNewData()).getState(), 3);
+ iblockdata = ((CraftBlockData) event.getNewData()).getState();
+ // CraftBukkit end
worldserver.setBlock(blockposition, iblockdata, 3);
} else if (!fluid1.equals(fluid)) {
fluid = fluid1;
IBlockData iblockdata = fluid1.createLegacyBlock();
-
- world.setBlock(blockposition, iblockdata, 2);
iblockdata = fluid1.createLegacyBlock();
+ // CraftBukkit start
+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, iblockdata);
+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(worldserver, blockposition, iblockdata);
+ if (event.isCancelled()) {
+ return;
+ }
+ world.setBlock(blockposition, ((CraftBlockData) event.getNewData()).getState(), 2);
+ iblockdata = ((CraftBlockData) event.getNewData()).getState();
+ // CraftBukkit end
world.scheduleTick(blockposition, fluid1.getType(), i);
world.updateNeighborsAt(blockposition, iblockdata.getBlock());
worldserver.setBlock(blockposition, iblockdata, 3);
worldserver.scheduleTick(blockposition, fluid1.getType(), i);
}

View File

@@ -1,35 +1,35 @@
--- a/net/minecraft/world/level/material/FluidTypeLava.java
+++ b/net/minecraft/world/level/material/FluidTypeLava.java
@@ -84,6 +84,13 @@
@@ -85,6 +85,13 @@
if (iblockdata.isAir()) {
if (this.hasFlammableNeighbours(world, blockposition1)) {
if (this.hasFlammableNeighbours(worldserver, blockposition1)) {
+ // CraftBukkit start - Prevent lava putting something on fire
+ if (world.getBlockState(blockposition1).getBlock() != Blocks.FIRE) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, blockposition).isCancelled()) {
+ if (worldserver.getBlockState(blockposition1).getBlock() != Blocks.FIRE) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition1, blockposition).isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
world.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(world, blockposition1));
worldserver.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(worldserver, blockposition1));
return;
}
@@ -100,6 +107,14 @@
@@ -101,6 +108,14 @@
}
if (world.isEmptyBlock(blockposition2.above()) && this.isFlammable(world, blockposition2)) {
if (worldserver.isEmptyBlock(blockposition2.above()) && this.isFlammable(worldserver, blockposition2)) {
+ // CraftBukkit start - Prevent lava putting something on fire
+ BlockPosition up = blockposition2.above();
+ if (world.getBlockState(up).getBlock() != Blocks.FIRE) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, up, blockposition).isCancelled()) {
+ if (worldserver.getBlockState(up).getBlock() != Blocks.FIRE) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, up, blockposition).isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
world.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(world, blockposition2));
worldserver.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(worldserver, blockposition2));
}
}
@@ -195,7 +210,11 @@
@@ -196,7 +211,11 @@
if (this.is(TagsFluid.LAVA) && fluid1.is(TagsFluid.WATER)) {
if (iblockdata.getBlock() instanceof BlockFluids) {