diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/CaveVines.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/CaveVines.java.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/CaveVines.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CaveVines.java.patch new file mode 100644 index 0000000000..0735fcda12 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CaveVines.java.patch @@ -0,0 +1,84 @@ +--- a/net/minecraft/world/level/block/CaveVines.java ++++ b/net/minecraft/world/level/block/CaveVines.java +@@ -8,38 +8,68 @@ + import net.minecraft.util.Mth; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.player.Player; + 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.0, 0.0, 1.0, 15.0, 16.0, 15.0); ++ ++ 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 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)); +- level.setBlock(pos, blockState, 2); +- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState)); ++ ++ 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(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 state) { +- return state.hasProperty(BERRIES) && state.getValue(BERRIES); ++ static boolean hasGlowBerries(IBlockData state) { ++ return state.hasProperty(CaveVines.BERRIES) && (Boolean) state.getValue(CaveVines.BERRIES); + } + +- static ToIntFunction<BlockState> emission(int berries) { +- return state -> state.getValue(BlockStateProperties.BERRIES) ? berries : 0; ++ static ToIntFunction<IBlockData> emission(int berries) { ++ return (iblockdata) -> { ++ return (Boolean) iblockdata.getValue(BlockStateProperties.BERRIES) ? berries : 0; ++ }; + } + } |