aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch
new file mode 100644
index 0000000000..08770f993f
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/FarmBlock.java.patch
@@ -0,0 +1,75 @@
+--- a/net/minecraft/world/level/block/FarmBlock.java
++++ b/net/minecraft/world/level/block/FarmBlock.java
+@@ -28,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 {
+
+@@ -99,28 +95,50 @@
+
+ if (!isNearWater(serverlevel, blockpos) && !serverlevel.isRainingAt(blockpos.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));