diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch new file mode 100644 index 0000000000..fb71d103ab --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/world/level/block/CaveVines.java ++++ b/net/minecraft/world/level/block/CaveVines.java +@@ -17,13 +18,37 @@ + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.shapes.VoxelShape; + ++// CraftBukkit start ++import java.util.Collections; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.player.PlayerHarvestBlockEvent; ++// CraftBukkit end ++ + public interface CaveVines { + VoxelShape SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 16.0, 15.0); + BooleanProperty BERRIES = BlockStateProperties.BERRIES; + +- static InteractionResult use(@Nullable Entity entity, BlockState state, Level level, BlockPos pos) { +- if (state.getValue(BERRIES)) { +- Block.popResource(level, pos, new ItemStack(Items.GLOW_BERRIES, 1)); ++ static InteractionResult use(@Nullable Entity entity, IBlockData state, Level level, BlockPos pos) { ++ if ((Boolean) state.getValue(CaveVines.BERRIES)) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, (IBlockData) state.setValue(CaveVines.BERRIES, false))) { ++ return InteractionResult.SUCCESS; ++ } ++ ++ if (entity instanceof Player) { ++ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(level, pos, (Player) entity, net.minecraft.world.EnumHand.MAIN_HAND, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1))); ++ 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()) { ++ Block.popResource(level, pos, CraftItemStack.asNMSCopy(itemStack)); ++ } ++ } else { ++ Block.popResource(level, pos, new ItemStack(Items.GLOW_BERRIES, 1)); ++ } ++ // CraftBukkit end ++ + float f = Mth.randomBetween(level.random, 0.8F, 1.2F); + level.playSound(null, pos, SoundEvents.CAVE_VINES_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, f); + BlockState blockState = state.setValue(BERRIES, Boolean.valueOf(false)); |