From 631251a913ba4e86ec027fdb226f3d252a058efb Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 4 Mar 2023 23:35:26 +0100 Subject: [PATCH] Take in account waterlogged block for the event (#8623) There's some inconsistencies between the EntityChangeBlockEvent and the BlockDestroyEvent. The destroy event has always the right final type but the change block event has always air even for waterlogged blocks. This fix this behavior only for possible case to avoid a bigger patch. --- ...lock-data-for-EntityChangeBlockEvent.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch b/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch index e8a5d635bf..0695e9eff7 100644 --- a/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch +++ b/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch @@ -18,6 +18,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2); } +diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java ++++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob + + if (WitherBoss.canDestroy(iblockdata)) { + // CraftBukkit start +- if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) { // Paper + continue; + } + // CraftBukkit end +diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java ++++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java +@@ -0,0 +0,0 @@ public class Ravager extends Raider { + BlockState iblockdata = this.level.getBlockState(blockposition); + Block block = iblockdata.getBlock(); + +- if (block instanceof LeavesBlock && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit ++ if (block instanceof LeavesBlock && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit // Paper + flag = this.level.destroyBlock(blockposition, true, this) || flag; + } + } diff --git a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java @@ -35,3 +61,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 continue; } // CraftBukkit end +diff --git a/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java b/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java +@@ -0,0 +0,0 @@ public class PointedDripstoneBlock extends Block implements Fallable, SimpleWate + + if (!world.isClientSide && projectile.mayInteract(world, blockposition) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6D) { + // CraftBukkit start +- if (CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, state.getFluidState().createLegacyBlock()).isCancelled()) { // Paper + return; + } + // CraftBukkit end