From e830b9a2d8a57ba69ac52cbff5e204d47a86968d Mon Sep 17 00:00:00 2001 From: Samsuik Date: Thu, 5 Dec 2024 22:23:07 +0000 Subject: [PATCH] Add lava flow speed api --- .../api/0013-Add-lava-flow-speed-api.patch | 21 ++++++++++++++++++ ...4-Local-Config-and-Value-Storage-API.patch | 8 +++++-- .../server/0081-Add-lava-flow-speed-api.patch | 22 +++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 patches/api/0013-Add-lava-flow-speed-api.patch create mode 100644 patches/server/0081-Add-lava-flow-speed-api.patch diff --git a/patches/api/0013-Add-lava-flow-speed-api.patch b/patches/api/0013-Add-lava-flow-speed-api.patch new file mode 100644 index 0000000..0e78e75 --- /dev/null +++ b/patches/api/0013-Add-lava-flow-speed-api.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Thu, 5 Dec 2024 22:27:38 +0000 +Subject: [PATCH] Add lava flow speed api + + +diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKey.java b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java +index 741e5466f00b34832ac69ff01503146278e952a9..3ae1e31a11921282ac6e293e8fe5c231e71ad770 100644 +--- a/src/main/java/me/samsuik/sakura/local/LocalValueKey.java ++++ b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java +@@ -33,6 +33,10 @@ public record LocalValueKey(NamespacedKey key, Supplier defaultSupplier) { + new NamespacedKey("sakura", "redstone-cache"), () -> false + ); + ++ public static final LocalValueKey LAVA_FLOW_SPEED = new LocalValueKey<>( ++ new NamespacedKey("sakura", "lava-flow-speed"), () -> -1 ++ ); ++ + @Override + public boolean equals(Object o) { + if (this == o) return true; diff --git a/patches/server/0004-Local-Config-and-Value-Storage-API.patch b/patches/server/0004-Local-Config-and-Value-Storage-API.patch index 7454494..8371614 100644 --- a/patches/server/0004-Local-Config-and-Value-Storage-API.patch +++ b/patches/server/0004-Local-Config-and-Value-Storage-API.patch @@ -153,10 +153,10 @@ index 0000000000000000000000000000000000000000..58e2bada4d9120a4802def5caece906f +} diff --git a/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..5b3e2cca7ee16bc6ecfa0f29438fa6588fa39a99 +index 0000000000000000000000000000000000000000..86a5964e7dea512da0a54ae675394bded91c5e0e --- /dev/null +++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java -@@ -0,0 +1,69 @@ +@@ -0,0 +1,73 @@ +package me.samsuik.sakura.local.config; + +import io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation; @@ -179,6 +179,7 @@ index 0000000000000000000000000000000000000000..5b3e2cca7ee16bc6ecfa0f29438fa658 + public RedstoneImplementation redstoneImplementation; + public boolean consistentRadius; + public boolean redstoneCache; ++ public int lavaFlowSpeed = -1; + + LocalValueConfig(Expiry expiry) { + this.expiry = expiry; @@ -220,6 +221,9 @@ index 0000000000000000000000000000000000000000..5b3e2cca7ee16bc6ecfa0f29438fa658 + + // redstone cache + this.redstoneCache = storage.getOrDefault(LocalValueKey.REDSTONE_CACHE, this.redstoneCache); ++ ++ // lava flow speed ++ this.lavaFlowSpeed = storage.getOrDefault(LocalValueKey.LAVA_FLOW_SPEED, this.lavaFlowSpeed); + } + + Expiry expiry() { diff --git a/patches/server/0081-Add-lava-flow-speed-api.patch b/patches/server/0081-Add-lava-flow-speed-api.patch new file mode 100644 index 0000000..d925d06 --- /dev/null +++ b/patches/server/0081-Add-lava-flow-speed-api.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Thu, 5 Dec 2024 22:21:39 +0000 +Subject: [PATCH] Add lava flow speed api + + +diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java +index ce34bbe57c524964300b6086358fa456f9e6d3ca..1a6fd2c638f04c92a2fb39331054e6c07371ce6f 100644 +--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java ++++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java +@@ -189,7 +189,10 @@ public abstract class LavaFluid extends FlowingFluid { + + @Override + public int getSpreadDelay(Level world, BlockPos pos, FluidState oldState, FluidState newState) { +- int i = this.getTickDelay(world); ++ // Sakura start - lava flow speed api ++ final int flowSpeed = world.localConfig().config(pos).lavaFlowSpeed; ++ int i = flowSpeed >= 0 ? flowSpeed : this.getTickDelay(world); ++ // Sakura end - lava flow speed api + + if (!oldState.isEmpty() && !newState.isEmpty() && !(Boolean) oldState.getValue(LavaFluid.FALLING) && !(Boolean) newState.getValue(LavaFluid.FALLING) && newState.getHeight(world, pos) > oldState.getHeight(world, pos) && world.getRandom().nextInt(4) != 0) { + i *= 4;