Fire EntityChangeBlockEvent in more places
Co-authored-by: ChristopheG <61288881+chrisgdt@users.noreply.github.com> Co-authored-by: maxcom1 <46265094+maxcom1@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/item/AxeItem.java
|
||||
+++ b/net/minecraft/world/item/AxeItem.java
|
||||
@@ -67,6 +67,11 @@
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
ItemStack itemStack = context.getItemInHand();
|
||||
+ // Paper start - EntityChangeBlockEvent
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, optional.get())) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (player instanceof ServerPlayer) {
|
||||
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack);
|
||||
}
|
||||
@@ -1,6 +1,18 @@
|
||||
--- a/net/minecraft/world/item/EnderEyeItem.java
|
||||
+++ b/net/minecraft/world/item/EnderEyeItem.java
|
||||
@@ -62,7 +62,27 @@
|
||||
@@ -45,6 +45,11 @@
|
||||
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)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, world, blockposition);
|
||||
world.setBlock(blockposition, iblockdata1, 2);
|
||||
@@ -62,7 +67,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +41,7 @@
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
@@ -99,7 +119,11 @@
|
||||
@@ -99,7 +124,11 @@
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.signalTo(blockposition);
|
||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.Context.of((Entity) user));
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/world/item/HoneycombItem.java
|
||||
+++ b/net/minecraft/world/item/HoneycombItem.java
|
||||
@@ -74,6 +74,14 @@
|
||||
return getWaxed(blockState).map(state -> {
|
||||
Player player = context.getPlayer();
|
||||
ItemStack itemStack = context.getItemInHand();
|
||||
+ // Paper start - EntityChangeBlockEvent
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, state)) {
|
||||
+ if (!player.isCreative()) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(serverPlayer, blockPos, itemStack);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/world/item/PotionItem.java
|
||||
+++ b/net/minecraft/world/item/PotionItem.java
|
||||
@@ -42,6 +42,12 @@
|
||||
PotionContents potionContents = itemStack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
|
||||
BlockState blockState = level.getBlockState(blockPos);
|
||||
if (context.getClickedFace() != Direction.DOWN && blockState.is(BlockTags.CONVERTABLE_TO_MUD) && potionContents.is(Potions.WATER)) {
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, Blocks.MUD.defaultBlockState())) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
level.playSound(null, blockPos, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
player.setItemInHand(context.getHand(), ItemUtils.createFilledResult(itemStack, player, new ItemStack(Items.GLASS_BOTTLE)));
|
||||
player.awardStat(Stats.ITEM_USED.get(itemStack.getItem()));
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/world/item/ShovelItem.java
|
||||
+++ b/net/minecraft/world/item/ShovelItem.java
|
||||
@@ -46,20 +46,29 @@
|
||||
Player player = context.getPlayer();
|
||||
BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
|
||||
BlockState blockState3 = null;
|
||||
+ Runnable afterAction = null; // Paper
|
||||
if (blockState2 != null && level.getBlockState(blockPos.above()).isAir()) {
|
||||
- level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ afterAction = () -> level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
|
||||
blockState3 = blockState2;
|
||||
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
|
||||
+ afterAction = () -> { // Paper
|
||||
if (!level.isClientSide()) {
|
||||
level.levelEvent(null, 1009, blockPos, 0);
|
||||
}
|
||||
|
||||
CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
|
||||
+ }; // Paper
|
||||
blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
if (blockState3 != null) {
|
||||
if (!level.isClientSide) {
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), blockPos, blockState3)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ afterAction.run();
|
||||
+ // Paper end
|
||||
level.setBlock(blockPos, blockState3, 11);
|
||||
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(player, blockState3));
|
||||
if (player != null) {
|
||||
Reference in New Issue
Block a user