Configurable farmland trample height

This is _not_ in block height or an exact science. During my testing I found very inconsistent values for the fallDistance variable. Here are the results of those tests (https://imgur.com/BojltJF):

Value set -> Actual fall distance needed to trample
   1.0 -> 1.25
   1.5 -> 1.75
   2.0 -> 2.25
   2.5 -> 2.87
   3.0 -> 3.5
   3.5 -> 4.25
   4.0 -> 4.25
   4.5 -> 5.0
   5.0 -> 5.87
   5.5 -> 5.87
This commit is contained in:
BillyGalbreath
2025-01-12 14:15:15 -08:00
committed by granny
parent 3507102ce2
commit 17faace258
3 changed files with 11 additions and 56 deletions

View File

@@ -1,5 +1,14 @@
--- a/net/minecraft/world/level/block/FarmBlock.java
+++ b/net/minecraft/world/level/block/FarmBlock.java
@@ -112,7 +_,7 @@
public void fallOn(Level level, BlockState 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 instanceof ServerLevel serverLevel
- && level.random.nextFloat() < fallDistance - 0.5F
+ && (serverLevel.purpurConfig.farmlandTrampleHeight >= 0D ? fallDistance >= serverLevel.purpurConfig.farmlandTrampleHeight : level.random.nextFloat() < fallDistance - 0.5F) // // Purpur - Configurable farmland trample height
&& entity instanceof LivingEntity
&& (entity instanceof Player || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))
&& entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) {
@@ -129,6 +_,27 @@
return;
}

View File

@@ -935,6 +935,7 @@ public class PurpurWorldConfig {
public boolean farmlandTramplingDisabled = false;
public boolean farmlandTramplingOnlyPlayers = false;
public boolean farmlandTramplingFeatherFalling = false;
public double farmlandTrampleHeight = -1D;
private void farmlandSettings() {
farmlandBypassMobGriefing = getBoolean("blocks.farmland.bypass-mob-griefing", farmlandBypassMobGriefing);
farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);
@@ -942,6 +943,7 @@ public class PurpurWorldConfig {
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);
farmlandTrampleHeight = getDouble("blocks.farmland.trample-height", farmlandTrampleHeight);
}
public double floweringAzaleaGrowthChance = 0.0D;