diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/CaveVines.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/CaveVines.java.patch | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CaveVines.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CaveVines.java.patch new file mode 100644 index 0000000000..b1687f0e9d --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CaveVines.java.patch @@ -0,0 +1,80 @@ +--- a/net/minecraft/world/level/block/CaveVines.java ++++ b/net/minecraft/world/level/block/CaveVines.java +@@ -12,40 +12,64 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.Items; + import net.minecraft.world.level.Level; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.BooleanProperty; + 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.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); + BooleanProperty BERRIES = BlockStateProperties.BERRIES; + +- static InteractionResult use(@Nullable Entity entity, BlockState blockstate, Level level, BlockPos blockpos) { +- if ((Boolean) blockstate.getValue(CaveVines.BERRIES)) { +- Block.popResource(level, blockpos, 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((Player) null, blockpos, SoundEvents.CAVE_VINES_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, f); +- BlockState blockstate1 = (BlockState) blockstate.setValue(CaveVines.BERRIES, false); ++ level.playSound((Player) null, pos, SoundEvents.CAVE_VINES_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, f); ++ IBlockData iblockdata1 = (IBlockData) state.setValue(CaveVines.BERRIES, false); + +- level.setBlock(blockpos, blockstate1, 2); +- level.gameEvent(GameEvent.BLOCK_CHANGE, blockpos, GameEvent.Context.of(entity, blockstate1)); ++ level.setBlock(pos, iblockdata1, 2); ++ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, iblockdata1)); + return InteractionResult.sidedSuccess(level.isClientSide); + } else { + return InteractionResult.PASS; + } + } + +- static boolean hasGlowBerries(BlockState blockstate) { +- return blockstate.hasProperty(CaveVines.BERRIES) && (Boolean) blockstate.getValue(CaveVines.BERRIES); ++ static boolean hasGlowBerries(IBlockData state) { ++ return state.hasProperty(CaveVines.BERRIES) && (Boolean) state.getValue(CaveVines.BERRIES); + } + +- static ToIntFunction<BlockState> emission(int i) { +- return (blockstate) -> { +- return (Boolean) blockstate.getValue(BlockStateProperties.BERRIES) ? i : 0; ++ static ToIntFunction<IBlockData> emission(int berries) { ++ return (iblockdata) -> { ++ return (Boolean) iblockdata.getValue(BlockStateProperties.BERRIES) ? berries : 0; + }; + } + } |