diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch index 3ccec446ad..066bfd1863 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -32,7 +32,7 @@ Block block1 = world.getBlockState(this.aboveFarmlandPos.below()).getBlock(); if (block instanceof CropBlock && ((CropBlock) block).isMaxAge(iblockdata)) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState())) { // CraftBukkit ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, this.aboveFarmlandPos, iblockdata.getFluidState().createLegacyBlock())) { // CraftBukkit // Paper - fix wrong block state world.destroyBlock(this.aboveFarmlandPos, true, entity); + } // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index fd9157bdd7..6dda582ccb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -5,7 +5,7 @@ if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos, this.mob.level().getFluidState(this.doorPos).createLegacyBlock()).isCancelled()) { // Paper - fix wrong block state + this.start(); + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index 9f774f6e06..0dd16a1ddc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -11,21 +11,24 @@ public class EatBlockGoal extends Goal { private static final int EAT_ANIMATION_TICKS = 40; -@@ -64,7 +68,7 @@ +@@ -63,8 +67,9 @@ + if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockposition = this.mob.blockPosition(); - if (EatBlockGoal.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { +- if (EatBlockGoal.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit ++ final BlockState blockState = this.level.getBlockState(blockposition); // Paper - fix wrong block state ++ if (EatBlockGoal.IS_TALL_GRASS.test(blockState)) { // Paper - fix wrong block state ++ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - fix wrong block state this.level.destroyBlock(blockposition, false); } -@@ -73,7 +77,7 @@ +@@ -73,7 +78,7 @@ BlockPos blockposition1 = blockposition.below(); if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit ++ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - Fix wrong block state this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch index 636fd21d1e..1f8f84be30 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -23,7 +23,7 @@ if (i == 0) { + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.defaultBlockState())) { ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index b321572366..38a819cef3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -110,7 +110,7 @@ if (WitherBoss.canDestroy(iblockdata)) { + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) { ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + continue; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 2af4387665..512e3e45cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -138,7 +138,7 @@ boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); if (iblockdata.is(BlockTags.ENDERMAN_HOLDABLE) && flag) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState())) { // CraftBukkit - Place event ++ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // CraftBukkit - Place event // Paper - fix wrong block state world.removeBlock(blockposition, false); world.gameEvent((Holder) GameEvent.BLOCK_DESTROY, blockposition, GameEvent.Context.of(this.enderman, iblockdata)); this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch index d67051c461..1cbab8cd90 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch @@ -15,7 +15,7 @@ if (block instanceof LeavesBlock) { + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) { ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + continue; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch index 799778d522..b031571b09 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -20,19 +20,20 @@ } } -@@ -160,6 +164,11 @@ +@@ -160,6 +164,12 @@ Block block = iblockdata.getBlock(); if (block instanceof InfestedBlock) { + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) { ++ BlockState afterState = getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? iblockdata.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(world.getBlockState(blockposition1)); // Paper - fix wrong block state ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, afterState)) { // Paper - fix wrong block state + continue; + } + // CraftBukkit end if (getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { world.destroyBlock(blockposition1, true, this.silverfish); } else { -@@ -229,9 +238,14 @@ +@@ -229,9 +239,14 @@ BlockState iblockdata = world.getBlockState(blockposition); if (InfestedBlock.isCompatibleHostBlock(iblockdata)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch index bb959fb39c..0f9ff86f46 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch @@ -288,7 +288,7 @@ if (iblockdata.is(BlockTags.FIRE)) { - this.level().destroyBlock(pos, false, this); + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(this, pos, Blocks.AIR.defaultBlockState())) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this, pos, iblockdata.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + this.level().destroyBlock(pos, false, this); + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index 3737ab608e..88160b2d20 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -64,7 +64,7 @@ if (world instanceof ServerLevel worldserver) { if (projectile.mayInteract(worldserver, blockposition) && projectile.mayBreak(worldserver)) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState())) { ++ if (!CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 14cd920419..c6ccc94ddb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -5,7 +5,7 @@ if (projectile.mayInteract(worldserver, blockposition) && projectile.mayBreak(worldserver) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6D) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState())) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch index d7d7fcb2c8..42cf7a6881 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch @@ -87,7 +87,7 @@ if (projectile.isOnFire() && projectile.mayInteract(worldserver, blockposition)) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState()) || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, projectile, null)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, state.getFluidState().createLegacyBlock()) || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, projectile, null)) { // Paper - fix wrong block state + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch index 75c6ca22ea..279e050da1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch @@ -18,7 +18,7 @@ super.entityInside(state, world, pos, entity); if (world instanceof ServerLevel && entity instanceof AbstractBoat) { + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState())) { ++ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, pos, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + return; + } + // CraftBukkit end diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index ca094e393d..fcc9fe8f5f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1378,11 +1378,11 @@ public class CraftEventFactory { return event; } - public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, BlockPos pos) { + public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, BlockPos pos, net.minecraft.world.level.block.state.BlockState newState) { // Paper org.bukkit.entity.Entity entity1 = entity.getBukkitEntity(); Block block = CraftBlock.at(entity.level(), pos); - EntityBreakDoorEvent event = new EntityBreakDoorEvent((LivingEntity) entity1, block); + EntityBreakDoorEvent event = new EntityBreakDoorEvent((LivingEntity) entity1, block, newState.createCraftBlockData()); // Paper entity1.getServer().getPluginManager().callEvent(event); return event;