mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 00:50:41 +01:00
116 lines
7.8 KiB
Diff
116 lines
7.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Josh Roy <10731363+JRoy@users.noreply.github.com>
|
|
Date: Thu, 27 Aug 2020 15:02:48 -0400
|
|
Subject: [PATCH] Add PlayerShearBlockEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
|
|
@@ -0,0 +0,0 @@
|
|
package net.minecraft.world.level.block;
|
|
|
|
+import io.papermc.paper.event.block.PlayerShearBlockEvent; // Paper - PlayerShearBlockEvent namespace conflicts
|
|
+
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.nbt.Tag;
|
|
+import net.minecraft.server.MCUtil;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
@@ -0,0 +0,0 @@ public class BeehiveBlock extends BaseEntityBlock {
|
|
|
|
if (i >= 5) {
|
|
if (itemstack.getItem() == Items.SHEARS) {
|
|
+ // Paper start - Add PlayerShearBlockEvent
|
|
+ PlayerShearBlockEvent event = new PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
|
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.HONEYCOMB, 3)));
|
|
+ if (!event.callEvent()) {
|
|
+ return InteractionResult.PASS;
|
|
+ }
|
|
+ // Paper end
|
|
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
|
- dropHoneycomb(world, pos);
|
|
+ // Paper start - Add PlayerShearBlockEvent
|
|
+ for (org.bukkit.inventory.ItemStack item : event.getDrops()) {
|
|
+ dropItem(world, pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item));
|
|
+ }
|
|
+ // Paper end
|
|
itemstack.hurtAndBreak(1, player, (entityhuman1) -> {
|
|
entityhuman1.broadcastBreakEvent(hand);
|
|
});
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -0,0 +0,0 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
|
|
}
|
|
|
|
- public static void popResource(Level world, BlockPos pos, ItemStack stack) {
|
|
- if (!world.isClientSide && !stack.isEmpty() && world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) {
|
|
+ public static void popResource(Level world, BlockPos pos, ItemStack stack) { dropItem(world, pos, stack); } public static void dropItem(Level world, BlockPos blockposition, ItemStack itemstack) { // Paper - OBFHELPER
|
|
+ if (!world.isClientSide && !itemstack.isEmpty() && world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) {
|
|
float f = 0.5F;
|
|
double d0 = (double) (world.random.nextFloat() * 0.5F) + 0.25D;
|
|
double d1 = (double) (world.random.nextFloat() * 0.5F) + 0.25D;
|
|
double d2 = (double) (world.random.nextFloat() * 0.5F) + 0.25D;
|
|
- ItemEntity entityitem = new ItemEntity(world, (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, stack);
|
|
+ ItemEntity entityitem = new ItemEntity(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
|
|
|
|
entityitem.setDefaultPickUpDelay();
|
|
// CraftBukkit start
|
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
|
|
@@ -0,0 +0,0 @@ package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
+import net.minecraft.server.MCUtil;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.world.InteractionHand;
|
|
@@ -0,0 +0,0 @@ import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
+import io.papermc.paper.event.block.PlayerShearBlockEvent; // Paper - PlayerShearBlockEvent namespace conflicts
|
|
|
|
public class PumpkinBlock extends StemGrownBlock {
|
|
|
|
@@ -0,0 +0,0 @@ public class PumpkinBlock extends StemGrownBlock {
|
|
|
|
if (itemstack.getItem() == Items.SHEARS) {
|
|
if (!world.isClientSide) {
|
|
+ // Paper start - Add PlayerShearBlockEvent
|
|
+ PlayerShearBlockEvent event = new PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
|
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4)));
|
|
+ if (!event.callEvent()) {
|
|
+ return InteractionResult.PASS;
|
|
+ }
|
|
+ // Paper end
|
|
Direction enumdirection = hit.getDirection();
|
|
Direction enumdirection1 = enumdirection.getAxis() == Direction.Axis.Y ? player.getDirection().getOpposite() : enumdirection;
|
|
|
|
world.playSound((Player) null, pos, SoundEvents.PUMPKIN_CARVE, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
world.setBlock(pos, (BlockState) Blocks.CARVED_PUMPKIN.defaultBlockState().setValue(CarvedPumpkinBlock.FACING, enumdirection1), 11);
|
|
- ItemEntity entityitem = new ItemEntity(world, (double) pos.getX() + 0.5D + (double) enumdirection1.getStepX() * 0.65D, (double) pos.getY() + 0.1D, (double) pos.getZ() + 0.5D + (double) enumdirection1.getStepZ() * 0.65D, new ItemStack(Items.PUMPKIN_SEEDS, 4));
|
|
+ // Paper start - Add PlayerShearBlockEvent
|
|
+ for (org.bukkit.inventory.ItemStack item : event.getDrops()) {
|
|
+ ItemEntity entityitem = new ItemEntity(world, (double) pos.getX() + 0.5D + (double) enumdirection1.getStepX() * 0.65D, (double) pos.getY() + 0.1D, (double) pos.getZ() + 0.5D + (double) enumdirection1.getStepZ() * 0.65D, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item));
|
|
+ // Paper end
|
|
|
|
entityitem.setDeltaMovement(0.05D * (double) enumdirection1.getStepX() + world.random.nextDouble() * 0.02D, 0.05D, 0.05D * (double) enumdirection1.getStepZ() + world.random.nextDouble() * 0.02D);
|
|
world.addFreshEntity(entityitem);
|
|
+ } // Paper - Add PlayerShearBlockEvent
|
|
itemstack.hurtAndBreak(1, player, (entityhuman1) -> {
|
|
entityhuman1.broadcastBreakEvent(hand);
|
|
});
|