Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 17faace

Browse files
BillyGalbreathgranny
authored andcommitted
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
1 parent 3507102 commit 17faace

3 files changed

Lines changed: 11 additions & 56 deletions

File tree

patches/server/0224-Configurable-farmland-trample-height.patch

Lines changed: 0 additions & 56 deletions
This file was deleted.

purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
--- a/net/minecraft/world/level/block/FarmBlock.java
22
+++ b/net/minecraft/world/level/block/FarmBlock.java
3+
@@ -112,7 +_,7 @@
4+
public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) {
5+
super.fallOn(level, state, pos, entity, fallDistance); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
6+
if (level instanceof ServerLevel serverLevel
7+
- && level.random.nextFloat() < fallDistance - 0.5F
8+
+ && (serverLevel.purpurConfig.farmlandTrampleHeight >= 0D ? fallDistance >= serverLevel.purpurConfig.farmlandTrampleHeight : level.random.nextFloat() < fallDistance - 0.5F) // // Purpur - Configurable farmland trample height
9+
&& entity instanceof LivingEntity
10+
&& (entity instanceof Player || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))
11+
&& entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) {
312
@@ -129,6 +_,27 @@
413
return;
514
}

purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,13 +935,15 @@ private void endCrystalSettings() {
935935
public boolean farmlandTramplingDisabled = false;
936936
public boolean farmlandTramplingOnlyPlayers = false;
937937
public boolean farmlandTramplingFeatherFalling = false;
938+
public double farmlandTrampleHeight = -1D;
938939
private void farmlandSettings() {
939940
farmlandBypassMobGriefing = getBoolean("blocks.farmland.bypass-mob-griefing", farmlandBypassMobGriefing);
940941
farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);
941942
farmlandAlpha = getBoolean("blocks.farmland.use-alpha-farmland", farmlandAlpha);
942943
farmlandTramplingDisabled = getBoolean("blocks.farmland.disable-trampling", farmlandTramplingDisabled);
943944
farmlandTramplingOnlyPlayers = getBoolean("blocks.farmland.only-players-trample", farmlandTramplingOnlyPlayers);
944945
farmlandTramplingFeatherFalling = getBoolean("blocks.farmland.feather-fall-distance-affects-trampling", farmlandTramplingFeatherFalling);
946+
farmlandTrampleHeight = getDouble("blocks.farmland.trample-height", farmlandTrampleHeight);
945947
}
946948

947949
public double floweringAzaleaGrowthChance = 0.0D;

0 commit comments

Comments
 (0)