Allow fully disabling farmland trampling

This commit is contained in:
BillyGalbreath
2021-03-15 15:33:16 -05:00
parent 3aa4f68535
commit a99a83bdf3
17 changed files with 53 additions and 43 deletions

View File

@@ -3,22 +3,30 @@ From: Mariell Hoversholm <proximyst@proximyst.com>
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 farmland trampling is fully disabled or 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.
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
index 73dc0f499c456c21d298013fbab8c79ebcdecd6b..383a6fa1cbc913c492fea341132bfabf412115c6 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 {
@@ -91,12 +91,19 @@ public class BlockSoil extends Block {
}
// Purpur start
+ if (world.purpurConfig.farmlandTramplingDisabled) return;
+ if (world.purpurConfig.farmlandTramplingOnlyPlayers && !(entity instanceof EntityPlayer)) return;
if (world.purpurConfig.farmlandAlpha) {
Block block = world.getType(blockposition.down()).getBlock();
if (block instanceof BlockFence || block instanceof BlockCobbleWall) {
return;
}
}
+ if (world.purpurConfig.farmlandTramplingOnlyPlayers && !(entity instanceof EntityPlayer)) return;
+ if (world.purpurConfig.farmlandTramplingFeatherFalling) {
+ Iterator<ItemStack> armor = entity.getArmorItems().iterator();
+ if (armor.hasNext() && EnchantmentManager.getEnchantmentLevel(Enchantments.PROTECTION_FALL, armor.next()) >= (int) entity.fallDistance)
@@ -28,19 +36,21 @@ index 73dc0f499c456c21d298013fbab8c79ebcdecd6b..6b65a4b1845c6770f92ceebd04827595
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 2391e1ddbe062dde5cb9a240b0a6a85ed793e569..e248681fc8d1c91077e2135a70347bf4c5282686 100644
index 2391e1ddbe062dde5cb9a240b0a6a85ed793e569..16e95a3c6edd65d943ebab5d894dc4c6a84623e3 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 {
@@ -413,10 +413,16 @@ public class PurpurWorldConfig {
public boolean farmlandBypassMobGriefing = false;
public boolean farmlandGetsMoistFromBelow = false;
public boolean farmlandAlpha = false;
+ public boolean farmlandTramplingDisabled = 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);
+ farmlandTramplingDisabled = getBoolean("blocks.farmland.disable-trampling", farmlandTramplingDisabled);
+ farmlandTramplingOnlyPlayers = getBoolean("blocks.farmland.only-players-trample", farmlandTramplingOnlyPlayers);
+ farmlandTramplingFeatherFalling = getBoolean("blocks.farmland.feather-fall-distance-affects-trampling", farmlandTramplingFeatherFalling);
}