diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch new file mode 100644 index 0000000000..af8d092023 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch @@ -0,0 +1,79 @@ +--- a/net/minecraft/world/level/block/FarmBlock.java ++++ b/net/minecraft/world/level/block/FarmBlock.java +@@ -27,6 +28,10 @@ + import net.minecraft.world.level.pathfinder.PathComputationType; + 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 { + public static final MapCodec<FarmBlock> CODEC = simpleCodec(FarmBlock::new); +@@ -88,32 +95,52 @@ + int i = state.getValue(MOISTURE); + if (!isNearWater(level, pos) && !level.isRainingAt(pos.above())) { + if (i > 0) { +- level.setBlock(pos, state.setValue(MOISTURE, Integer.valueOf(i - 1)), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, (IBlockData) state.setValue(FarmBlock.MOISTURE, i - 1), 2); // CraftBukkit + } else if (!shouldMaintainFarmland(level, pos)) { + turnToDirt(null, state, level, pos); + } + } else if (i < 7) { +- level.setBlock(pos, state.setValue(MOISTURE, Integer.valueOf(7)), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, (IBlockData) state.setValue(FarmBlock.MOISTURE, 7), 2); // CraftBukkit + } + } + + @Override +- public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) { +- 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) { ++ 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, state, pos, entity, fallDistance); ++ // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up + } + +- public static void turnToDirt(@Nullable Entity entity, BlockState state, Level level, BlockPos pos) { +- BlockState blockState = pushEntitiesUp(state, Blocks.DIRT.defaultBlockState(), level, pos); +- level.setBlockAndUpdate(pos, blockState); +- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState)); ++ 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(pos, iblockdata1); ++ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, iblockdata1)); + } + + private static boolean shouldMaintainFarmland(BlockGetter level, BlockPos pos) { |