diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/FarmBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/FarmBlock.java.patch | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/FarmBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/FarmBlock.java.patch new file mode 100644 index 0000000000..22094a8a3d --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/FarmBlock.java.patch @@ -0,0 +1,213 @@ +--- a/net/minecraft/world/level/block/FarmBlock.java ++++ b/net/minecraft/world/level/block/FarmBlock.java +@@ -20,14 +20,18 @@ + import net.minecraft.world.level.LevelReader; + import net.minecraft.world.level.block.piston.MovingPistonBlock; + 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.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.IntegerProperty; + import net.minecraft.world.level.gameevent.GameEvent; +-import net.minecraft.world.level.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; ++// CraftBukkit start ++import org.bukkit.event.entity.EntityInteractEvent; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end + + public class FarmBlock extends Block { + +@@ -37,124 +41,136 @@ + public static final int MAX_MOISTURE = 7; + + @Override +- @Override + public MapCodec<FarmBlock> codec() { + return FarmBlock.CODEC; + } + +- protected FarmBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any()).setValue(FarmBlock.MOISTURE, 0)); ++ protected FarmBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(FarmBlock.MOISTURE, 0)); + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- if (direction == Direction.UP && !blockstate.canSurvive(levelaccessor, blockpos)) { +- levelaccessor.scheduleTick(blockpos, (Block) this, 1); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ if (facing == Direction.UP && !state.canSurvive(level, currentPos)) { ++ level.scheduleTick(currentPos, (Block) this, 1); + } + +- return super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1); ++ return super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + + @Override +- @Override +- public boolean canSurvive(BlockState blockstate, LevelReader levelreader, BlockPos blockpos) { +- BlockState blockstate1 = levelreader.getBlockState(blockpos.above()); ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ IBlockData iblockdata1 = level.getBlockState(pos.above()); + +- return !blockstate1.isSolid() || blockstate1.getBlock() instanceof FenceGateBlock || blockstate1.getBlock() instanceof MovingPistonBlock; ++ return !iblockdata1.isSolid() || iblockdata1.getBlock() instanceof FenceGateBlock || iblockdata1.getBlock() instanceof MovingPistonBlock; + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- return !this.defaultBlockState().canSurvive(blockplacecontext.getLevel(), blockplacecontext.getClickedPos()) ? Blocks.DIRT.defaultBlockState() : super.getStateForPlacement(blockplacecontext); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return !this.defaultBlockState().canSurvive(context.getLevel(), context.getClickedPos()) ? Blocks.DIRT.defaultBlockState() : super.getStateForPlacement(context); + } + + @Override +- @Override +- public boolean useShapeForLightOcclusion(BlockState blockstate) { ++ public boolean useShapeForLightOcclusion(IBlockData state) { + return true; + } + + @Override +- @Override +- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { + return FarmBlock.SHAPE; + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if (!blockstate.canSurvive(serverlevel, blockpos)) { +- turnToDirt((Entity) null, blockstate, serverlevel, blockpos); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if (!state.canSurvive(level, pos)) { ++ turnToDirt((Entity) null, state, level, pos); + } + + } + + @Override +- @Override +- public void randomTick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- int i = (Integer) blockstate.getValue(FarmBlock.MOISTURE); ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ int i = (Integer) state.getValue(FarmBlock.MOISTURE); + +- if (!isNearWater(serverlevel, blockpos) && !serverlevel.isRainingAt(blockpos.above())) { ++ if (!isNearWater(level, pos) && !level.isRainingAt(pos.above())) { + if (i > 0) { +- serverlevel.setBlock(blockpos, (BlockState) blockstate.setValue(FarmBlock.MOISTURE, i - 1), 2); +- } else if (!shouldMaintainFarmland(serverlevel, blockpos)) { +- turnToDirt((Entity) null, blockstate, serverlevel, blockpos); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, (IBlockData) state.setValue(FarmBlock.MOISTURE, i - 1), 2); // CraftBukkit ++ } else if (!shouldMaintainFarmland(level, pos)) { ++ turnToDirt((Entity) null, state, level, pos); + } + } else if (i < 7) { +- serverlevel.setBlock(blockpos, (BlockState) blockstate.setValue(FarmBlock.MOISTURE, 7), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, (IBlockData) state.setValue(FarmBlock.MOISTURE, 7), 2); // CraftBukkit + } + + } + + @Override +- @Override +- public void fallOn(Level level, BlockState blockstate, BlockPos blockpos, Entity entity, float f) { +- if (!level.isClientSide && level.random.nextFloat() < f - 0.5F && entity instanceof LivingEntity && (entity instanceof Player || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { +- turnToDirt(entity, blockstate, level, blockpos); ++ public void fallOn(Level level, IBlockData state, BlockPos pos, Entity entity, float fallDistance) { ++ super.fallOn(level, state, pos, entity, fallDistance); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. ++ if (!level.isClientSide && level.random.nextFloat() < fallDistance - 0.5F && entity instanceof LivingEntity && (entity instanceof Player || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { ++ // CraftBukkit start - Interact soil ++ org.bukkit.event.Cancellable cancellable; ++ if (entity instanceof Player) { ++ cancellable = CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); ++ } else { ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ level.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); ++ } ++ ++ if (cancellable.isCancelled()) { ++ return; ++ } ++ ++ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.DIRT.defaultBlockState())) { ++ return; ++ } ++ // CraftBukkit end ++ turnToDirt(entity, state, level, pos); + } + +- super.fallOn(level, blockstate, blockpos, entity, f); ++ // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up + } + +- public static void turnToDirt(@Nullable Entity entity, BlockState blockstate, Level level, BlockPos blockpos) { +- BlockState blockstate1 = pushEntitiesUp(blockstate, Blocks.DIRT.defaultBlockState(), level, blockpos); ++ public static void turnToDirt(@Nullable Entity entity, IBlockData state, Level level, BlockPos pos) { ++ // CraftBukkit start ++ if (CraftEventFactory.callBlockFadeEvent(level, pos, Blocks.DIRT.defaultBlockState()).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end ++ IBlockData iblockdata1 = pushEntitiesUp(state, Blocks.DIRT.defaultBlockState(), level, pos); + +- level.setBlockAndUpdate(blockpos, blockstate1); +- level.gameEvent(GameEvent.BLOCK_CHANGE, blockpos, GameEvent.Context.of(entity, blockstate1)); ++ level.setBlockAndUpdate(pos, iblockdata1); ++ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, iblockdata1)); + } + +- private static boolean shouldMaintainFarmland(BlockGetter blockgetter, BlockPos blockpos) { +- return blockgetter.getBlockState(blockpos.above()).is(BlockTags.MAINTAINS_FARMLAND); ++ private static boolean shouldMaintainFarmland(BlockGetter level, BlockPos pos) { ++ return level.getBlockState(pos.above()).is(BlockTags.MAINTAINS_FARMLAND); + } + +- private static boolean isNearWater(LevelReader levelreader, BlockPos blockpos) { +- Iterator iterator = BlockPos.betweenClosed(blockpos.offset(-4, 0, -4), blockpos.offset(4, 1, 4)).iterator(); ++ private static boolean isNearWater(LevelReader level, BlockPos pos) { ++ Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 1, 4)).iterator(); + +- BlockPos blockpos1; ++ BlockPos blockposition1; + + do { + if (!iterator.hasNext()) { + return false; + } + +- blockpos1 = (BlockPos) iterator.next(); +- } while (!levelreader.getFluidState(blockpos1).is(FluidTags.WATER)); ++ blockposition1 = (BlockPos) iterator.next(); ++ } while (!level.getFluidState(blockposition1).is(FluidTags.WATER)); + + return true; + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(FarmBlock.MOISTURE); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(FarmBlock.MOISTURE); + } + + @Override +- @Override +- public boolean isPathfindable(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, PathComputationType pathcomputationtype) { ++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) { + return false; + } + } |