aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch
diff options
context:
space:
mode:
authorMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
committerMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
commitbee74680e607c2e29b038329f62181238911cd83 (patch)
tree708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch
parent0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff)
downloadPaper-softspoon.tar.gz
Paper-softspoon.zip
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch
new file mode 100644
index 0000000000..803ce226a9
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/level/block/BlockSweetBerryBush.patch
@@ -0,0 +1,53 @@
+--- a/net/minecraft/world/level/block/BlockSweetBerryBush.java
++++ b/net/minecraft/world/level/block/BlockSweetBerryBush.java
+@@ -28,6 +28,14 @@
+ import net.minecraft.world.phys.shapes.VoxelShape;
+ import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+
++// CraftBukkit start
++import java.util.Collections;
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.event.player.PlayerHarvestBlockEvent;
++// CraftBukkit end
++
+ public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement {
+
+ public static final MapCodec<BlockSweetBerryBush> CODEC = simpleCodec(BlockSweetBerryBush::new);
+@@ -69,7 +77,7 @@
+ if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) {
+ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1);
+
+- worldserver.setBlock(blockposition, iblockdata1, 2);
++ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2)) return; // CraftBukkit
+ worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1));
+ }
+
+@@ -84,7 +92,9 @@
+ double d1 = Math.abs(entity.getZ() - entity.zOld);
+
+ if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) {
++ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit
+ entity.hurt(world.damageSources().sweetBerryBush(), 1.0F);
++ CraftEventFactory.blockDamage = null; // CraftBukkit
+ }
+ }
+
+@@ -101,7 +111,15 @@
+ } else if (i > 1) {
+ int j = 1 + world.random.nextInt(2);
+
+- popResource(world, blockposition, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0)));
++ // CraftBukkit start
++ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, entityhuman, enumhand, Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))));
++ if (event.isCancelled()) {
++ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
++ }
++ for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) {
++ popResource(world, blockposition, CraftItemStack.asNMSCopy(itemStack));
++ }
++ // CraftBukkit end
+ world.playSound((EntityHuman) null, blockposition, SoundEffects.SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);
+ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
+