From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Sat, 9 Jan 2021 16:06:40 +0100 Subject: [PATCH] Farmland trampling changes This lets us choose if only players may trample farmland. This lets us choose if entities can stop trampling if they fall a distance equal to their feather falling level, plus the extra block necessary to trample in the first place. Feather Falling 1 requires you to fall over 3+ blocks to trample. FF 2 requires 4+, etc. diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java index 73dc0f499c456c21d298013fbab8c79ebcdecd6b..6b65a4b1845c6770f92ceebd04827595725632b5 100644 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ b/src/main/java/net/minecraft/server/BlockSoil.java @@ -97,6 +97,12 @@ public class BlockSoil extends Block { return; } } + if (world.purpurConfig.farmlandTramplingOnlyPlayers && !(entity instanceof EntityPlayer)) return; + if (world.purpurConfig.farmlandTramplingFeatherFalling) { + Iterator armor = entity.getArmorItems().iterator(); + if (armor.hasNext() && EnchantmentManager.getEnchantmentLevel(Enchantments.PROTECTION_FALL, armor.next()) >= (int) entity.fallDistance) + return; + } // Purpur end if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { return; diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 4d1851d23f27f58299f72f4bc14e7c99c69245d2..5699d54d9ffd1f194a22fe03ad4d144d3ad5a007 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -413,10 +413,14 @@ public class PurpurWorldConfig { public boolean farmlandBypassMobGriefing = false; public boolean farmlandGetsMoistFromBelow = false; public boolean farmlandAlpha = false; + public boolean farmlandTramplingOnlyPlayers = false; + public boolean farmlandTramplingFeatherFalling = false; private void farmlandSettings() { farmlandBypassMobGriefing = getBoolean("blocks.farmland.bypass-mob-griefing", farmlandBypassMobGriefing); farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow); farmlandAlpha = getBoolean("blocks.farmland.use-alpha-farmland", farmlandAlpha); + farmlandTramplingOnlyPlayers = getBoolean("blocks.farmland.only-players-trample", farmlandTramplingOnlyPlayers); + farmlandTramplingFeatherFalling = getBoolean("blocks.farmland.feather-fall-distance-affects-trampling", farmlandTramplingFeatherFalling); } public boolean furnaceInfiniteFuel = false;