Skip to content

Commit

Permalink
Call EntityChangeBlockEvent for cake eating
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Jan 1, 2024
1 parent 1281f4f commit ab16f40
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ index db507638a97b5a33df712c54daff35b21922c0dd..2e75fd06e9e379eb95ebfe55086ffc32
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 1fddc9025a9e5079f05dd6c86f6ca43c5d51d9c3..6d45e3ebea6721b9c168fea572e9bd610eb54431 100644
index 1977e702f6af39ebf100c1f2f2edc2d1c4d003b0..cfcd1778b5ae66395400221879dde3575591b23d 100644
--- a/src/main/java/net/minecraft/world/item/EnderEyeItem.java
+++ b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
@@ -43,6 +43,11 @@ public class EnderEyeItem extends Item {
Expand Down Expand Up @@ -198,6 +198,35 @@ index 32995cb5efdad0bc34ecacacb78cccd21220ba8d..21212462e6b415e96536a27b2c009d15
level.setBlock(blockPos, blockState3, 11);
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(player, blockState3));
if (player != null) {
diff --git a/src/main/java/net/minecraft/world/level/block/CakeBlock.java b/src/main/java/net/minecraft/world/level/block/CakeBlock.java
index 49fe91a8eaeb2580c8ad0166e72540168af605f6..5d23ef9a3607a5c0724b1a91cb9b012af8bdb04b 100644
--- a/src/main/java/net/minecraft/world/level/block/CakeBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CakeBlock.java
@@ -66,6 +66,11 @@ public class CakeBlock extends Block {
itemstack.shrink(1);
}

+ // Paper start - call change block event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, CandleCakeBlock.byCandle(block))) {
+ return InteractionResult.PASS;
+ }
+ // Paper end - call change block event
world.playSound((Player) null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F);
world.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(block));
world.gameEvent((Entity) player, GameEvent.BLOCK_CHANGE, pos);
@@ -107,6 +112,12 @@ public class CakeBlock extends Block {
int i = (Integer) state.getValue(CakeBlock.BITES);

world.gameEvent((Entity) player, GameEvent.EAT, pos);
+ // Paper start - call change block event
+ final BlockState newState = i < MAX_BITES ? state.setValue(CakeBlock.BITES, i + 1) : world.getFluidState(pos).createLegacyBlock();
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) {
+ return InteractionResult.PASS; // return a non-consume result to cake blocks don't drop their candles
+ }
+ // Paper end - call change block event
if (i < 6) {
world.setBlock(pos, (BlockState) state.setValue(CakeBlock.BITES, i + 1), 3);
} else {
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
index 6cccdd1d19488275ff3fe90838cf1c31e844d517..413b307acaad5823b9e06f49fa2faf561f5f7b9a 100644
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
Expand Down

0 comments on commit ab16f40

Please sign in to comment.