9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-19 23:09:32 +00:00
Files
SakuraMC/patches/server/0081-Add-lava-flow-speed-api.patch
2024-12-06 13:21:22 +00:00

65 lines
3.5 KiB
Diff

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/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
index 6cc129afdb19e121e1abe8dc07f5cc2216c7b084..b4a775c486d6de994591dd6b34055e3a80d9a4d3 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -158,7 +158,7 @@ public class LiquidBlock extends Block implements BucketPickup {
return world.paperConfig().environment.waterOverLavaFlowSpeed;
}
}
- return this.fluid.getTickDelay(world);
+ return this.fluid.getTickDelay(world, blockposition); // Sakura - lava flow speed api
}
private static boolean isLava(Level world, BlockPos blockPos) {
final FluidState fluidState = world.getFluidIfLoaded(blockPos);
diff --git a/src/main/java/net/minecraft/world/level/material/Fluid.java b/src/main/java/net/minecraft/world/level/material/Fluid.java
index 69586077f0d9b0eed1a7de7ef1d743048de0c9d5..86afcda1f14aec7ee9c459e935782037cb0c6634 100644
--- a/src/main/java/net/minecraft/world/level/material/Fluid.java
+++ b/src/main/java/net/minecraft/world/level/material/Fluid.java
@@ -69,6 +69,12 @@ public abstract class Fluid {
protected abstract Vec3 getFlow(BlockGetter world, BlockPos pos, FluidState state);
+ // Sakura start - lava flow speed api
+ public int getTickDelay(final Level world, final BlockPos pos) {
+ return this.getTickDelay(world);
+ }
+ // Sakura end - lava flow speed api
+
public abstract int getTickDelay(LevelReader world);
protected boolean isRandomlyTicking() {
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..62d1487ee5820a38f033d60f197b476079ea3e51 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -182,6 +182,14 @@ public abstract class LavaFluid extends FlowingFluid {
// Sakura end - physics version api
}
+ // Sakura start - lava flow speed api
+ @Override
+ public final int getTickDelay(Level world, BlockPos pos) {
+ final int flowSpeed = world.localConfig().config(pos).lavaFlowSpeed;
+ return flowSpeed >= 0 ? flowSpeed : this.getTickDelay(world);
+ }
+ // Sakura end - lava flow speed api
+
@Override
public int getTickDelay(LevelReader world) {
return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig().environment.disableFastNetherLava) ? 10 : 30; // Sakura - add option for fast nether lava
@@ -189,7 +197,7 @@ public abstract class LavaFluid extends FlowingFluid {
@Override
public int getSpreadDelay(Level world, BlockPos pos, FluidState oldState, FluidState newState) {
- int i = this.getTickDelay(world);
+ int i = this.getTickDelay(world, pos); // Sakura - 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;