9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-21 15:59:26 +00:00

Add lava flow speed api

This commit is contained in:
Samsuik
2024-12-05 22:23:07 +00:00
parent 7f8d0d086d
commit 82b9fc83ca
4 changed files with 31 additions and 6 deletions

View File

@@ -87,10 +87,10 @@ index 0000000000000000000000000000000000000000..4a1540d4f6125bd2a8a4f6b7e645a3eb
+} +}
diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java b/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java b/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..43070da3fc644e22ef3825301d1d42bba27b945d index 0000000000000000000000000000000000000000..54c3693c97d5049882d7c10e14fc79ef6c76b1fc
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java +++ b/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java
@@ -0,0 +1,24 @@ @@ -0,0 +1,25 @@
+package me.samsuik.sakura.local; +package me.samsuik.sakura.local;
+ +
+import me.samsuik.sakura.physics.PhysicsVersion; +import me.samsuik.sakura.physics.PhysicsVersion;
@@ -110,6 +110,7 @@ index 0000000000000000000000000000000000000000..43070da3fc644e22ef3825301d1d42bb
+ public static final LocalValueKey<RedstoneImplementation> REDSTONE_IMPLEMENTATION = create("redstone-implementation", () -> RedstoneImplementation.VANILLA); + public static final LocalValueKey<RedstoneImplementation> REDSTONE_IMPLEMENTATION = create("redstone-implementation", () -> RedstoneImplementation.VANILLA);
+ public static final LocalValueKey<Boolean> CONSISTENT_EXPLOSION_RADIUS = create("consistent-radius", () -> false); + public static final LocalValueKey<Boolean> CONSISTENT_EXPLOSION_RADIUS = create("consistent-radius", () -> false);
+ public static final LocalValueKey<Boolean> REDSTONE_CACHE = create("redstone-cache", () -> false); + public static final LocalValueKey<Boolean> REDSTONE_CACHE = create("redstone-cache", () -> false);
+ public static final LocalValueKey<Integer> LAVA_FLOW_SPEED = create("lava-flow-speed", () -> -1);
+ +
+ private static <T> LocalValueKey<T> create(String key, Supplier<T> supplier) { + private static <T> LocalValueKey<T> create(String key, Supplier<T> supplier) {
+ return new LocalValueKey<>(new NamespacedKey(NAMESPACE, key), supplier); + return new LocalValueKey<>(new NamespacedKey(NAMESPACE, key), supplier);

View File

@@ -153,10 +153,10 @@ index 0000000000000000000000000000000000000000..2b77b942b1733380c566683ba0516a74
+} +}
diff --git a/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..b445166f38202ec250bcaf124b88746b3559a952 index 0000000000000000000000000000000000000000..53d2c0f3d3c2d857a44c7a993cbd91ea5ce4b099
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java +++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java
@@ -0,0 +1,55 @@ @@ -0,0 +1,57 @@
+package me.samsuik.sakura.local.config; +package me.samsuik.sakura.local.config;
+ +
+import io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation; +import io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation;
@@ -179,6 +179,7 @@ index 0000000000000000000000000000000000000000..b445166f38202ec250bcaf124b88746b
+ public PhysicsVersion physicsVersion; + public PhysicsVersion physicsVersion;
+ public boolean consistentRadius; + public boolean consistentRadius;
+ public boolean redstoneCache; + public boolean redstoneCache;
+ public int lavaFlowSpeed = -1;
+ +
+ LocalValueConfig(Expiry expiry) { + LocalValueConfig(Expiry expiry) {
+ this.expiry = expiry; + this.expiry = expiry;
@@ -206,6 +207,7 @@ index 0000000000000000000000000000000000000000..b445166f38202ec250bcaf124b88746b
+ this.physicsVersion = storage.getOrDefault(LocalValueKeys.PHYSICS_VERSION, this.physicsVersion); + this.physicsVersion = storage.getOrDefault(LocalValueKeys.PHYSICS_VERSION, this.physicsVersion);
+ this.consistentRadius = storage.getOrDefault(LocalValueKeys.CONSISTENT_EXPLOSION_RADIUS, this.consistentRadius); + this.consistentRadius = storage.getOrDefault(LocalValueKeys.CONSISTENT_EXPLOSION_RADIUS, this.consistentRadius);
+ this.redstoneCache = storage.getOrDefault(LocalValueKeys.REDSTONE_CACHE, this.redstoneCache); + this.redstoneCache = storage.getOrDefault(LocalValueKeys.REDSTONE_CACHE, this.redstoneCache);
+ this.lavaFlowSpeed = storage.getOrDefault(LocalValueKeys.LAVA_FLOW_SPEED, this.lavaFlowSpeed);
+ } + }
+ +
+ Expiry expiry() { + Expiry expiry() {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Option for fast nether dimension lava
diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java 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 e6ed1e46a4880743b7eeb73857b4b501971d6e29..4132e26332e6e8e061f43867426291ec0aefe0a2 100644 index e6ed1e46a4880743b7eeb73857b4b501971d6e29..cc5ed4e2cc0ef8acf3768539103d2cdeab30362f 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -184,7 +184,7 @@ public abstract class LavaFluid extends FlowingFluid { @@ -184,7 +184,7 @@ public abstract class LavaFluid extends FlowingFluid {
@@ -13,7 +13,7 @@ index e6ed1e46a4880743b7eeb73857b4b501971d6e29..4132e26332e6e8e061f43867426291ec
@Override @Override
public int getTickDelay(LevelReader world) { public int getTickDelay(LevelReader world) {
- return world.dimensionType().ultraWarm() ? 10 : 30; - return world.dimensionType().ultraWarm() ? 10 : 30;
+ return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig().environment.disableFastNetherLava) ? 10 : 30; // Sakura + return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig().environment.disableFastNetherLava) ? 10 : 30; // Sakura - add option for fast nether lava
} }
@Override @Override

View File

@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
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 5fb8ad171e132174af12d63e45dd623ecac7480a..e4d5d80a16dbf568ccd932aae0c30ee913873abb 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;