2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockSoil.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockSoil.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -30,6 +30,11 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class BlockSoil extends Block {
|
|
|
|
|
2023-12-05 17:40:00 +01:00
|
|
|
public static final MapCodec<BlockSoil> CODEC = simpleCodec(BlockSoil::new);
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -92,26 +97,49 @@
|
2018-09-09 10:53:38 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) {
|
2020-06-25 02:00:00 +02:00
|
|
|
if (i > 0) {
|
2021-11-21 23:00:00 +01:00
|
|
|
- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit
|
2023-06-07 17:30:00 +02:00
|
|
|
} else if (!shouldMaintainFarmland(worldserver, blockposition)) {
|
2023-03-14 17:30:00 +01:00
|
|
|
turnToDirt((Entity) null, iblockdata, worldserver, blockposition);
|
2018-09-09 10:53:38 +02:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
} else if (i < 7) {
|
2021-11-21 23:00:00 +01:00
|
|
|
- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, 7), 2);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, 7), 2); // CraftBukkit
|
2018-09-09 10:53:38 +02:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
}
|
2015-01-31 00:14:29 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-06-11 07:00:00 +02:00
|
|
|
public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) {
|
|
|
|
+ super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
|
2021-11-21 23:00:00 +01:00
|
|
|
if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - Interact soil
|
|
|
|
+ org.bukkit.event.Cancellable cancellable;
|
|
|
|
+ if (entity instanceof EntityHuman) {
|
2016-03-04 05:24:51 +01:00
|
|
|
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (cancellable.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2023-06-24 09:15:05 +02:00
|
|
|
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState())) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2023-03-14 17:30:00 +01:00
|
|
|
turnToDirt(entity, iblockdata, world, blockposition);
|
2015-01-31 00:14:29 +01:00
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- super.fallOn(world, iblockdata, blockposition, entity, f);
|
|
|
|
+ // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up
|
2015-01-31 00:14:29 +01:00
|
|
|
}
|
|
|
|
|
2023-03-14 17:30:00 +01:00
|
|
|
public static void turnToDirt(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
|
2018-01-03 22:57:01 +01:00
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) {
|
2018-01-03 22:57:01 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2023-03-14 17:30:00 +01:00
|
|
|
IBlockData iblockdata1 = pushEntitiesUp(iblockdata, Blocks.DIRT.defaultBlockState(), world, blockposition);
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2023-03-14 17:30:00 +01:00
|
|
|
world.setBlockAndUpdate(blockposition, iblockdata1);
|