9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-20 15:29:33 +00:00

Add lava flow speed api

This commit is contained in:
Samsuik
2024-12-05 22:23:07 +00:00
parent 49e3c7c746
commit bf77968d55
3 changed files with 49 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
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 780a02fb451d5b4b98f6895b488b90c75a6507a8..ed5ff8c6262e2c9ab01417859061cba2897b2422 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<T>(NamespacedKey key, Supplier<T> defaultSupplier) {
new NamespacedKey("sakura", "redstone-cache"), () -> false
);
+ public static final LocalValueKey<Integer> LAVA_FLOW_SPEED = new LocalValueKey<>(
+ new NamespacedKey("sakura", "lava-flow-speed"), () -> -1
+ );
+
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@@ -155,10 +155,10 @@ index 0000000000000000000000000000000000000000..a3a09b8d58589883c7c465597bc64502
+}
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..3f518f3f1241d3dc1f76fab42e9fd789fab4d53e
index 0000000000000000000000000000000000000000..529087b8b5158e96a66e1cafc19979cd4afc8cf3
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java
@@ -0,0 +1,71 @@
@@ -0,0 +1,75 @@
+package me.samsuik.sakura.local.config;
+
+import io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation;
@@ -182,6 +182,7 @@ index 0000000000000000000000000000000000000000..3f518f3f1241d3dc1f76fab42e9fd789
+ public RedstoneImplementation redstoneImplementation;
+ public boolean consistentRadius;
+ public boolean redstoneCache;
+ public int lavaFlowSpeed = -1;
+
+ LocalValueConfig(Expiry expiry) {
+ this.expiry = expiry;
@@ -223,6 +224,9 @@ index 0000000000000000000000000000000000000000..3f518f3f1241d3dc1f76fab42e9fd789
+
+ // 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() {

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 c3c24f616345e41772062032406c308ca130147d..d89b21b4b732f372fcd602329a84148958fdbb1a 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -188,7 +188,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;