diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/DoublePlantBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/DoublePlantBlock.java.patch | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/DoublePlantBlock.java.patch new file mode 100644 index 0000000000..beb5457fbb --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -0,0 +1,181 @@ +--- a/net/minecraft/world/level/block/DoublePlantBlock.java ++++ b/net/minecraft/world/level/block/DoublePlantBlock.java +@@ -14,117 +14,121 @@ + import net.minecraft.world.level.LevelReader; + import net.minecraft.world.level.block.entity.BlockEntity; + import net.minecraft.world.level.block.state.BlockBehaviour; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.block.state.StateDefinition; ++import net.minecraft.world.level.block.state.properties.BlockPropertyDoubleBlockHalf; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; +-import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; + import net.minecraft.world.level.block.state.properties.EnumProperty; ++import net.minecraft.world.level.material.Fluid; + import net.minecraft.world.level.material.Fluids; + + public class DoublePlantBlock extends BushBlock { ++ + public static final MapCodec<DoublePlantBlock> CODEC = simpleCodec(DoublePlantBlock::new); +- public static final EnumProperty<DoubleBlockHalf> HALF = BlockStateProperties.DOUBLE_BLOCK_HALF; ++ public static final EnumProperty<BlockPropertyDoubleBlockHalf> HALF = BlockStateProperties.DOUBLE_BLOCK_HALF; + + @Override + public MapCodec<? extends DoublePlantBlock> codec() { +- return CODEC; ++ return DoublePlantBlock.CODEC; + } + + public DoublePlantBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState(this.stateDefinition.any().setValue(HALF, DoubleBlockHalf.LOWER)); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(DoublePlantBlock.HALF, BlockPropertyDoubleBlockHalf.LOWER)); + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { +- DoubleBlockHalf doubleBlockHalf = state.getValue(HALF); +- if (facing.getAxis() != Direction.Axis.Y +- || doubleBlockHalf == DoubleBlockHalf.LOWER != (facing == Direction.UP) +- || facingState.is(this) && facingState.getValue(HALF) != doubleBlockHalf) { +- return doubleBlockHalf == DoubleBlockHalf.LOWER && facing == Direction.DOWN && !state.canSurvive(level, currentPos) +- ? Blocks.AIR.defaultBlockState() +- : super.updateShape(state, facing, facingState, level, currentPos, facingPos); +- } else { +- return Blocks.AIR.defaultBlockState(); +- } ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) state.getValue(DoublePlantBlock.HALF); ++ ++ return facing.getAxis() == Direction.Axis.Y && blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER == (facing == Direction.UP) && (!facingState.is((Block) this) || facingState.getValue(DoublePlantBlock.HALF) == blockpropertydoubleblockhalf) ? Blocks.AIR.defaultBlockState() : (blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER && facing == Direction.DOWN && !state.canSurvive(level, currentPos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, facing, facingState, level, currentPos, facingPos)); + } + + @Nullable + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- BlockPos clickedPos = context.getClickedPos(); +- Level level = context.getLevel(); +- return clickedPos.getY() < level.getMaxBuildHeight() - 1 && level.getBlockState(clickedPos.above()).canBeReplaced(context) +- ? super.getStateForPlacement(context) +- : null; ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ BlockPos blockposition = context.getClickedPos(); ++ Level world = context.getLevel(); ++ ++ return blockposition.getY() < world.getMaxBuildHeight() - 1 && world.getBlockState(blockposition.above()).canBeReplaced(context) ? super.getStateForPlacement(context) : null; + } + + @Override +- public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { +- BlockPos blockPos = pos.above(); +- level.setBlock(blockPos, copyWaterloggedFrom(level, blockPos, this.defaultBlockState().setValue(HALF, DoubleBlockHalf.UPPER)), 3); ++ public void setPlacedBy(Level level, BlockPos pos, IBlockData state, LivingEntity placer, ItemStack stack) { ++ BlockPos blockposition1 = pos.above(); ++ ++ level.setBlock(blockposition1, copyWaterloggedFrom(level, blockposition1, (IBlockData) this.defaultBlockState().setValue(DoublePlantBlock.HALF, BlockPropertyDoubleBlockHalf.UPPER)), 3); + } + + @Override +- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { +- if (state.getValue(HALF) != DoubleBlockHalf.UPPER) { ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ if (state.getValue(DoublePlantBlock.HALF) != BlockPropertyDoubleBlockHalf.UPPER) { + return super.canSurvive(state, level, pos); + } else { +- BlockState blockState = level.getBlockState(pos.below()); +- return blockState.is(this) && blockState.getValue(HALF) == DoubleBlockHalf.LOWER; ++ IBlockData iblockdata1 = level.getBlockState(pos.below()); ++ ++ return iblockdata1.is((Block) this) && iblockdata1.getValue(DoublePlantBlock.HALF) == BlockPropertyDoubleBlockHalf.LOWER; + } + } + +- public static void placeAt(LevelAccessor level, BlockState state, BlockPos pos, int flags) { +- BlockPos blockPos = pos.above(); +- level.setBlock(pos, copyWaterloggedFrom(level, pos, state.setValue(HALF, DoubleBlockHalf.LOWER)), flags); +- level.setBlock(blockPos, copyWaterloggedFrom(level, blockPos, state.setValue(HALF, DoubleBlockHalf.UPPER)), flags); ++ public static void placeAt(LevelAccessor level, IBlockData state, BlockPos pos, int flags) { ++ BlockPos blockposition1 = pos.above(); ++ ++ level.setBlock(pos, copyWaterloggedFrom(level, pos, (IBlockData) state.setValue(DoublePlantBlock.HALF, BlockPropertyDoubleBlockHalf.LOWER)), flags); ++ level.setBlock(blockposition1, copyWaterloggedFrom(level, blockposition1, (IBlockData) state.setValue(DoublePlantBlock.HALF, BlockPropertyDoubleBlockHalf.UPPER)), flags); + } + +- public static BlockState copyWaterloggedFrom(LevelReader level, BlockPos pos, BlockState state) { +- return state.hasProperty(BlockStateProperties.WATERLOGGED) +- ? state.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(level.isWaterAt(pos))) +- : state; ++ public static IBlockData copyWaterloggedFrom(LevelReader level, BlockPos pos, IBlockData state) { ++ return state.hasProperty(BlockStateProperties.WATERLOGGED) ? (IBlockData) state.setValue(BlockStateProperties.WATERLOGGED, level.isWaterAt(pos)) : state; + } + + @Override +- public BlockState playerWillDestroy(Level level, BlockPos blockPos, BlockState blockState, Player player) { +- if (!level.isClientSide) { +- if (player.isCreative()) { +- preventDropFromBottomPart(level, blockPos, blockState, player); ++ public IBlockData playerWillDestroy(Level world, BlockPos blockposition, IBlockData iblockdata, Player entityhuman) { ++ if (!world.isClientSide) { ++ if (entityhuman.isCreative()) { ++ preventDropFromBottomPart(world, blockposition, iblockdata, entityhuman); + } else { +- dropResources(blockState, level, blockPos, null, player, player.getMainHandItem()); ++ dropResources(iblockdata, world, blockposition, (BlockEntity) null, entityhuman, entityhuman.getMainHandItem()); + } + } + +- return super.playerWillDestroy(level, blockPos, blockState, player); ++ return super.playerWillDestroy(world, blockposition, iblockdata, entityhuman); + } + + @Override +- public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) { ++ public void playerDestroy(Level level, Player player, BlockPos pos, IBlockData state, @Nullable BlockEntity te, ItemStack stack) { + super.playerDestroy(level, player, pos, Blocks.AIR.defaultBlockState(), te, stack); + } + +- protected static void preventDropFromBottomPart(Level level, BlockPos blockPos, BlockState blockState, Player player) { +- DoubleBlockHalf doubleBlockHalf = blockState.getValue(HALF); +- if (doubleBlockHalf == DoubleBlockHalf.UPPER) { +- BlockPos blockPos1 = blockPos.below(); +- BlockState blockState1 = level.getBlockState(blockPos1); +- if (blockState1.is(blockState.getBlock()) && blockState1.getValue(HALF) == DoubleBlockHalf.LOWER) { +- BlockState blockState2 = blockState1.getFluidState().is(Fluids.WATER) ? Blocks.WATER.defaultBlockState() : Blocks.AIR.defaultBlockState(); +- level.setBlock(blockPos1, blockState2, 35); +- level.levelEvent(player, 2001, blockPos1, Block.getId(blockState1)); ++ protected static void preventDropFromBottomPart(Level world, BlockPos blockposition, IBlockData iblockdata, Player entityhuman) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end ++ BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.getValue(DoublePlantBlock.HALF); ++ ++ if (blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.UPPER) { ++ BlockPos blockposition1 = blockposition.below(); ++ IBlockData iblockdata1 = world.getBlockState(blockposition1); ++ ++ if (iblockdata1.is(iblockdata.getBlock()) && iblockdata1.getValue(DoublePlantBlock.HALF) == BlockPropertyDoubleBlockHalf.LOWER) { ++ IBlockData iblockdata2 = iblockdata1.getFluidState().is((Fluid) Fluids.WATER) ? Blocks.WATER.defaultBlockState() : Blocks.AIR.defaultBlockState(); ++ ++ world.setBlock(blockposition1, iblockdata2, 35); ++ world.levelEvent(entityhuman, 2001, blockposition1, Block.getId(iblockdata1)); + } + } ++ + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(HALF); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(DoublePlantBlock.HALF); + } + + @Override +- public long getSeed(BlockState state, BlockPos pos) { +- return Mth.getSeed(pos.getX(), pos.below(state.getValue(HALF) == DoubleBlockHalf.LOWER ? 0 : 1).getY(), pos.getZ()); ++ public long getSeed(IBlockData state, BlockPos pos) { ++ return Mth.getSeed(pos.getX(), pos.below(state.getValue(DoublePlantBlock.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? 0 : 1).getY(), pos.getZ()); + } + } |