From 03dad8f20a6ea25c5de06cef3b52cc45a161354e Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 17 Dec 2022 19:20:14 +0100 Subject: [PATCH] Add missing EntityChangeBlockEvent (#8696) * Add missing EntityChangeBlockEvent * Fix duplicate empty bottle when canceled for creative player * Use native update impl instead of craftbukkit -> nms --- ...ntityChangeBlockEvent-in-more-places.patch | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch b/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch index e3c0963d2f..60c7a74433 100644 --- a/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch +++ b/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch @@ -94,6 +94,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (player instanceof ServerPlayer) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack); } +diff --git a/src/main/java/net/minecraft/world/item/EnderEyeItem.java b/src/main/java/net/minecraft/world/item/EnderEyeItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/EnderEyeItem.java ++++ b/src/main/java/net/minecraft/world/item/EnderEyeItem.java +@@ -0,0 +0,0 @@ public class EnderEyeItem extends Item { + return InteractionResult.SUCCESS; + } else { + BlockState iblockdata1 = (BlockState) iblockdata.setValue(EndPortalFrameBlock.HAS_EYE, true); ++ // Paper start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), blockposition, iblockdata1).isCancelled()) { ++ return InteractionResult.PASS; ++ } ++ // Paper end + + Block.pushEntitiesUp(iblockdata, iblockdata1, world, blockposition); + world.setBlock(blockposition, iblockdata1, 2); diff --git a/src/main/java/net/minecraft/world/item/HoneycombItem.java b/src/main/java/net/minecraft/world/item/HoneycombItem.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/HoneycombItem.java @@ -110,6 +126,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (player instanceof ServerPlayer) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack); } +diff --git a/src/main/java/net/minecraft/world/item/PotionItem.java b/src/main/java/net/minecraft/world/item/PotionItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/PotionItem.java ++++ b/src/main/java/net/minecraft/world/item/PotionItem.java +@@ -0,0 +0,0 @@ public class PotionItem extends Item { + BlockState iblockdata = world.getBlockState(blockposition); + + if (context.getClickedFace() != Direction.DOWN && iblockdata.is(BlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(itemstack) == Potions.WATER) { ++ // Paper start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityhuman, blockposition, Blocks.MUD.defaultBlockState()).isCancelled()) { ++ entityhuman.containerMenu.sendAllDataToRemote(); ++ return InteractionResult.PASS; ++ } ++ // Paper end + world.playSound((Player) null, blockposition, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 1.0F, 1.0F); + entityhuman.setItemInHand(context.getHand(), ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); + entityhuman.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/ShovelItem.java