Files
Purpur/patches/server/0162-Farmland-trampling-changes.patch
BillyGalbreath cb72751f80 Updated Upstream (Tuinity)
Upstream has released updates that appear to apply and compile correctly

Tuinity Changes:
901ac3525 Optimise BlockSoil nearby water lookup
2021-06-11 09:34:50 -05:00

77 lines
4.3 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/BlockSoil.java b/src/main/java/net/minecraft/world/level/block/BlockSoil.java
index 386641173bb758c1ba1e80071f68813fec012a93..0c7422d9b041341b12f1b8796236b8728b93ff2f 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockSoil.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockSoil.java
@@ -4,13 +4,17 @@ import java.util.Iterator;
import java.util.Random;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
+import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.WorldServer;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagsFluid;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityLiving;
import net.minecraft.world.entity.player.EntityHuman;
+import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockActionContext;
+import net.minecraft.world.item.enchantment.EnchantmentManager;
+import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.IBlockAccess;
@@ -114,12 +118,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.farmlandTramplingFeatherFalling) {
+ Iterator<ItemStack> 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 c8b510a49ba5c299ec38ea1a56f5245ec6161b55..e639519a78bababc5d8034841e9ab2c20d34e4f7 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -471,10 +471,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 furnaceInfiniteFuel = false;