From 03b4271d725b1815f3d7be8c79f813d7a350f329 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 12 Jan 2025 11:43:00 -0800 Subject: [PATCH] Big dripleaf tilt delay Makes the tilt delays configurable. There are only 3 types of tilts used by this setting. When an entity steps on a big_dripleaf with no tilt it will immediately change to an UNSTABLE tilt. Each change after that is on a tick timer: UNSTABLE: big_dripleaf with UNSTABLE tilt will change to PARTIAL tilt after 10 ticks PARTIAL: big_dripleaf with PARTIAL tilt will change to FULL tilt after 10 ticks UNSTABLE: big_dripleaf with FULL tilt will change back to no tilt after 100 ticks --- .../server/0184-Big-dripleaf-tilt-delay.patch | 52 ------------------- .../level/block/BigDripleafBlock.java.patch | 11 ++++ .../purpurmc/purpur/PurpurWorldConfig.java | 17 ++++++ 3 files changed, 28 insertions(+), 52 deletions(-) delete mode 100644 patches/server/0184-Big-dripleaf-tilt-delay.patch create mode 100644 purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch diff --git a/patches/server/0184-Big-dripleaf-tilt-delay.patch b/patches/server/0184-Big-dripleaf-tilt-delay.patch deleted file mode 100644 index 71b7011bb..000000000 --- a/patches/server/0184-Big-dripleaf-tilt-delay.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Fri, 16 Jul 2021 22:47:29 -0500 -Subject: [PATCH] Big dripleaf tilt delay - -Makes the tilt delays configurable. There are only 3 types of tilts used by this setting. When an entity steps on a -big_dripleaf with no tilt it will immediately change to an UNSTABLE tilt. Each change after that is on a tick timer: - -UNSTABLE: big_dripleaf with UNSTABLE tilt will change to PARTIAL tilt after 10 ticks -PARTIAL: big_dripleaf with PARTIAL tilt will change to FULL tilt after 10 ticks -UNSTABLE: big_dripleaf with FULL tilt will change back to no tilt after 100 ticks - -diff --git a/net/minecraft/world/level/block/BigDripleafBlock.java b/net/minecraft/world/level/block/BigDripleafBlock.java -index 9e3f1441d62128535112621bf259c24f1a90595b..2535e6d71b690f8dfde41a7d9cb76b6f010f5aa7 100644 ---- a/net/minecraft/world/level/block/BigDripleafBlock.java -+++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -246,7 +246,7 @@ public class BigDripleafBlock extends HorizontalDirectionalBlock implements Bone - BigDripleafBlock.playTiltSound(world, blockposition, soundeffect); - } - -- int i = BigDripleafBlock.DELAY_UNTIL_NEXT_TILT_STATE.getInt(tilt); -+ int i = world.purpurConfig.bigDripleafTiltDelay.getOrDefault(tilt, -1); // Purpur - - if (i != -1) { - world.scheduleTick(blockposition, (Block) this, i); -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index f62de466c50287ecbe364f74bd715cbdf02808ea..20d4021d6222c58e97062756cf8c66b4f819d666 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -787,6 +787,22 @@ public class PurpurWorldConfig { - } - } - -+ public Map bigDripleafTiltDelay = new HashMap<>(); -+ private void bigDripleafSettings() { -+ bigDripleafTiltDelay.clear(); -+ getMap("blocks.big_dripleaf.tilt-delay", Map.ofEntries( -+ Map.entry("UNSTABLE", 10), -+ Map.entry("PARTIAL", 10), -+ Map.entry("FULL", 100)) -+ ).forEach((tilt, delay) -> { -+ try { -+ bigDripleafTiltDelay.put(Tilt.valueOf(tilt), (int) delay); -+ } catch (IllegalArgumentException e) { -+ PurpurConfig.log(Level.SEVERE, "Invalid big_dripleaf tilt key: " + tilt); -+ } -+ }); -+ } -+ - public boolean chestOpenWithBlockOnTop = false; - private void chestSettings() { - chestOpenWithBlockOnTop = getBoolean("blocks.chest.open-with-solid-block-on-top", chestOpenWithBlockOnTop); diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch new file mode 100644 index 000000000..45532dcb8 --- /dev/null +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/BigDripleafBlock.java ++++ b/net/minecraft/world/level/block/BigDripleafBlock.java +@@ -261,7 +_,7 @@ + playTiltSound(level, pos, sound); + } + +- int _int = DELAY_UNTIL_NEXT_TILT_STATE.getInt(tilt); ++ int _int = level.purpurConfig.bigDripleafTiltDelay.getOrDefault(tilt, -1); // Purpur - Big dripleaf tilt delay + if (_int != -1) { + level.scheduleTick(pos, this, _int); + } diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 2d6f2d981..c4d66bfa0 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -13,6 +13,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.properties.Tilt; import org.apache.commons.lang.BooleanUtils; import org.bukkit.ChatColor; import org.bukkit.World; @@ -785,6 +786,22 @@ public class PurpurWorldConfig { } } + public Map bigDripleafTiltDelay = new HashMap<>(); + private void bigDripleafSettings() { + bigDripleafTiltDelay.clear(); + getMap("blocks.big_dripleaf.tilt-delay", Map.ofEntries( + Map.entry("UNSTABLE", 10), + Map.entry("PARTIAL", 10), + Map.entry("FULL", 100)) + ).forEach((tilt, delay) -> { + try { + bigDripleafTiltDelay.put(Tilt.valueOf(tilt), (int) delay); + } catch (IllegalArgumentException e) { + PurpurConfig.log(Level.SEVERE, "Invalid big_dripleaf tilt key: " + tilt); + } + }); + } + public boolean chestOpenWithBlockOnTop = false; private void chestSettings() { chestOpenWithBlockOnTop = getBoolean("blocks.chest.open-with-solid-block-on-top", chestOpenWithBlockOnTop);