aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch
new file mode 100644
index 0000000000..96f4c6b00e
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch
@@ -0,0 +1,79 @@
+--- a/net/minecraft/world/level/block/SweetBerryBushBlock.java
++++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java
+@@ -27,6 +27,13 @@
+ import net.minecraft.world.phys.Vec3;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.VoxelShape;
++// 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 SweetBerryBushBlock extends BushBlock implements BonemealableBlock {
+ public static final MapCodec<SweetBerryBushBlock> CODEC = simpleCodec(SweetBerryBushBlock::new);
+@@ -69,21 +74,25 @@
+ public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
+ int i = state.getValue(AGE);
+ if (i < 3 && random.nextInt(5) == 0 && level.getRawBrightness(pos.above(), 0) >= 9) {
+- BlockState blockState = state.setValue(AGE, Integer.valueOf(i + 1));
+- level.setBlock(pos, blockState, 2);
+- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState));
++ IBlockData iblockdata1 = (IBlockData) state.setValue(SweetBerryBushBlock.AGE, i + 1);
++
++ if (!CraftEventFactory.handleBlockGrowEvent(level, pos, iblockdata1, 2)) return; // CraftBukkit
++ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(iblockdata1));
+ }
+ }
+
+ @Override
+ public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
+ if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) {
+- entity.makeStuckInBlock(state, new Vec3(0.8F, 0.75, 0.8F));
+- if (!level.isClientSide && state.getValue(AGE) > 0 && (entity.xOld != entity.getX() || entity.zOld != entity.getZ())) {
+- double abs = Math.abs(entity.getX() - entity.xOld);
+- double abs1 = Math.abs(entity.getZ() - entity.zOld);
+- if (abs >= 0.003F || abs1 >= 0.003F) {
++ entity.makeStuckInBlock(state, new Vec3(0.800000011920929D, 0.75D, 0.800000011920929D));
++ if (!level.isClientSide && (Integer) state.getValue(SweetBerryBushBlock.AGE) > 0 && (entity.xOld != entity.getX() || entity.zOld != entity.getZ())) {
++ double d0 = Math.abs(entity.getX() - entity.xOld);
++ double d1 = Math.abs(entity.getZ() - entity.zOld);
++
++ if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) {
++ CraftEventFactory.blockDamage = CraftBlock.at(level, pos); // CraftBukkit
+ entity.hurt(level.damageSources().sweetBerryBush(), 1.0F);
++ CraftEventFactory.blockDamage = null; // CraftBukkit
+ }
+ }
+ }
+@@ -96,12 +108,22 @@
+ if (!flag && player.getItemInHand(hand).is(Items.BONE_MEAL)) {
+ return InteractionResult.PASS;
+ } else if (i > 1) {
+- int i1 = 1 + level.random.nextInt(2);
+- popResource(level, pos, new ItemStack(Items.SWEET_BERRIES, i1 + (flag ? 1 : 0)));
+- level.playSound(null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, 0.8F + level.random.nextFloat() * 0.4F);
+- BlockState blockState = state.setValue(AGE, Integer.valueOf(1));
+- level.setBlock(pos, blockState, 2);
+- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, blockState));
++ int j = 1 + level.random.nextInt(2);
++
++ // CraftBukkit start
++ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(level, pos, player, hand, Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))));
++ if (event.isCancelled()) {
++ return InteractionResult.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(level, pos, CraftItemStack.asNMSCopy(itemStack));
++ }
++ // CraftBukkit end
++ level.playSound((Player) null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, 0.8F + level.random.nextFloat() * 0.4F);
++ IBlockData iblockdata1 = (IBlockData) state.setValue(SweetBerryBushBlock.AGE, 1);
++
++ level.setBlock(pos, iblockdata1, 2);
++ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, iblockdata1));
+ return InteractionResult.sidedSuccess(level.isClientSide);
+ } else {
+ return super.use(state, level, pos, player, hand, hit);