aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0462-Add-PlayerShearBlockEvent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0462-Add-PlayerShearBlockEvent.patch')
-rw-r--r--patches/server/0462-Add-PlayerShearBlockEvent.patch30
1 files changed, 18 insertions, 12 deletions
diff --git a/patches/server/0462-Add-PlayerShearBlockEvent.patch b/patches/server/0462-Add-PlayerShearBlockEvent.patch
index 140bb100a4..e8a864c69f 100644
--- a/patches/server/0462-Add-PlayerShearBlockEvent.patch
+++ b/patches/server/0462-Add-PlayerShearBlockEvent.patch
@@ -39,10 +39,10 @@ index 44e72176a0da08a77fa192ee31c0fcd53f0dc22d..27f1c1ac12251f1438ee8bf14f4afb5f
entityhuman1.broadcastBreakEvent(hand);
});
diff --git a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
-index df11efd22682c2ed799dabf15d2cfa5973e8dca9..cc13b74fa37b5df6fe6f1423496b9fb03d71d083 100644
+index d9c4e0cf178b9a1eed230dc7b8cfbd8f3f49c7bb..c67ee44d49693bfcb92cbbf0ed44929bf0034f13 100644
--- a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
-@@ -35,13 +35,24 @@ public class PumpkinBlock extends Block {
+@@ -35,21 +35,30 @@ public class PumpkinBlock extends Block {
ItemStack itemStack = player.getItemInHand(hand);
if (itemStack.is(Items.SHEARS)) {
if (!world.isClientSide) {
@@ -55,16 +55,22 @@ index df11efd22682c2ed799dabf15d2cfa5973e8dca9..cc13b74fa37b5df6fe6f1423496b9fb0
+ // Paper end - Add PlayerShearBlockEvent
Direction direction = hit.getDirection();
Direction direction2 = direction.getAxis() == Direction.Axis.Y ? player.getDirection().getOpposite() : direction;
- world.playSound((Player)null, pos, SoundEvents.PUMPKIN_CARVE, SoundSource.BLOCKS, 1.0F, 1.0F);
+ world.playSound(null, pos, SoundEvents.PUMPKIN_CARVE, SoundSource.BLOCKS, 1.0F, 1.0F);
world.setBlock(pos, Blocks.CARVED_PUMPKIN.defaultBlockState().setValue(CarvedPumpkinBlock.FACING, direction2), 11);
-- ItemEntity itemEntity = new ItemEntity(world, (double)pos.getX() + 0.5D + (double)direction2.getStepX() * 0.65D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D + (double)direction2.getStepZ() * 0.65D, new ItemStack(Items.PUMPKIN_SEEDS, 4));
-+ // Paper start - Add PlayerShearBlockEvent
-+ for (org.bukkit.inventory.ItemStack item : event.getDrops()) {
-+ ItemEntity itemEntity = new ItemEntity(world, (double) pos.getX() + 0.5D + (double) direction2.getStepX() * 0.65D, (double) pos.getY() + 0.1D, (double) pos.getZ() + 0.5D + (double) direction2.getStepZ() * 0.65D, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item));
-+ // Paper end - Add PlayerShearBlockEvent
- itemEntity.setDeltaMovement(0.05D * (double)direction2.getStepX() + world.random.nextDouble() * 0.02D, 0.05D, 0.05D * (double)direction2.getStepZ() + world.random.nextDouble() * 0.02D);
++ for (org.bukkit.inventory.ItemStack item : event.getDrops()) { // Paper - Add PlayerShearBlockEvent
+ ItemEntity itemEntity = new ItemEntity(
+ world,
+ pos.getX() + 0.5 + direction2.getStepX() * 0.65,
+ pos.getY() + 0.1,
+ pos.getZ() + 0.5 + direction2.getStepZ() * 0.65,
+- new ItemStack(Items.PUMPKIN_SEEDS, 4)
++ org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item) // Paper - Add PlayerShearBlockEvent
+ );
+ itemEntity.setDeltaMovement(
+ 0.05 * direction2.getStepX() + world.random.nextDouble() * 0.02, 0.05, 0.05 * direction2.getStepZ() + world.random.nextDouble() * 0.02
+ );
world.addFreshEntity(itemEntity);
+ } // Paper - Add PlayerShearBlockEvent
- itemStack.hurtAndBreak(1, player, (playerx) -> {
- playerx.broadcastBreakEvent(hand);
- });
+ itemStack.hurtAndBreak(1, player, playerx -> playerx.broadcastBreakEvent(hand));
+ world.gameEvent(player, GameEvent.SHEAR, pos);
+ player.awardStat(Stats.ITEM_USED.get(Items.SHEARS));