Files
Purpur/patches/server/0122-Farmland-trampling-changes.patch
granny 639bcbd780 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@f9c7f2a Begin switching to JSpecify annotations (#11448)
PaperMC/Paper@e3c8a8e Add PlayerInsertLecternBookEvent [1.20 port] (#7305)
PaperMC/Paper@b410fe8 Configurable per-world void damage offset/damage(#11436)
PaperMC/Paper@ea00be3 Do not NPE on uuid resolution in player profile (#11449)
PaperMC/Paper@ba3c29b Finish converting all events to jspecify annotations
PaperMC/Paper@e7e1ab5 Finish converting most of the undeprecated api to jspecify
PaperMC/Paper@69ffbec Fix hex color check
PaperMC/Paper@709f0f2 Use components properly in ProfileWhitelistVerifyEvent (#11456)
PaperMC/Paper@fb76840 [ci skip] Add section on nullability annotations (#11461)
PaperMC/Paper@7cd4f2c Check if leash tag has a uuid
2024-10-03 17:08:59 -07:00

60 lines
3.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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 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.
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index 99798220b6e0ad06db2ba5c9b74bfb72af185fee..12a0c69f8fec30fad64cbb00af2ca1bbf0ea5153 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -126,12 +126,20 @@ public class FarmBlock extends Block {
}
// Purpur start
+ if (world.purpurConfig.farmlandTramplingDisabled) return;
+ if (world.purpurConfig.farmlandTramplingOnlyPlayers && !(entity instanceof Player)) return;
if (world.purpurConfig.farmlandAlpha) {
Block block = world.getBlockState(pos.below()).getBlock();
if (block instanceof FenceBlock || block instanceof WallBlock) {
return;
}
}
+ if (world.purpurConfig.farmlandTramplingFeatherFalling) {
+ Iterator<net.minecraft.world.item.ItemStack> armor = ((LivingEntity) entity).getArmorSlots().iterator();
+ if (armor.hasNext() && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.FEATHER_FALLING, armor.next()) >= (int) entity.fallDistance) {
+ return;
+ }
+ }
// Purpur end
if (!CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.DIRT.defaultBlockState())) {
return;
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index ec3d6553f3ab84078878e6e423b45b944efb299e..4319f30cc1287fa557de5ab281f285d38d311d87 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -451,10 +451,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);
}
public boolean furnaceUseLavaFromUnderneath = false;