aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch
diff options
context:
space:
mode:
authorMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
committerMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
commitbee74680e607c2e29b038329f62181238911cd83 (patch)
tree708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch
parent0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff)
downloadPaper-softspoon.tar.gz
Paper-softspoon.zip
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch b/patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch
new file mode 100644
index 0000000000..e370f14b57
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/level/block/BlockSoil.patch
@@ -0,0 +1,67 @@
+--- a/net/minecraft/world/level/block/BlockSoil.java
++++ b/net/minecraft/world/level/block/BlockSoil.java
+@@ -29,6 +29,11 @@
+ import net.minecraft.world.phys.shapes.VoxelShape;
+ import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+
++// CraftBukkit start
++import org.bukkit.event.entity.EntityInteractEvent;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++// CraftBukkit end
++
+ public class BlockSoil extends Block {
+
+ public static final MapCodec<BlockSoil> CODEC = simpleCodec(BlockSoil::new);
+@@ -91,26 +96,49 @@
+
+ if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) {
+ if (i > 0) {
+- 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
+ } else if (!shouldMaintainFarmland(worldserver, blockposition)) {
+ turnToDirt((Entity) null, iblockdata, worldserver, blockposition);
+ }
+ } else if (i < 7) {
+- 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
+ }
+
+ }
+
+ @Override
+ 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.
+ 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) {
++ // CraftBukkit start - Interact soil
++ org.bukkit.event.Cancellable cancellable;
++ if (entity instanceof EntityHuman) {
++ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
++ } else {
++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
++ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
++ }
++
++ if (cancellable.isCancelled()) {
++ return;
++ }
++
++ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState())) {
++ return;
++ }
++ // CraftBukkit end
+ turnToDirt(entity, iblockdata, world, blockposition);
+ }
+
+- super.fallOn(world, iblockdata, blockposition, entity, f);
++ // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up
+ }
+
+ public static void turnToDirt(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
++ // CraftBukkit start
++ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ IBlockData iblockdata1 = pushEntitiesUp(iblockdata, Blocks.DIRT.defaultBlockState(), world, blockposition);
+
+ world.setBlockAndUpdate(blockposition, iblockdata1);