9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-22 16:29:16 +00:00
Files
SakuraMC/patches/server/0009-Optimise-New-Liquid-Level.patch
2024-07-20 00:28:08 +01:00

67 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Wed, 6 Oct 2021 17:25:27 +0100
Subject: [PATCH] Optimise New Liquid Level
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 1c0712295695727ee9c4d430d4157b8e17cbd71f..1c82ff348769655f20ba4fde7914a326e072afce 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -137,7 +137,7 @@ public abstract class FlowingFluid extends Fluid {
BlockState iblockdata = world.getBlockState(fluidPos);
BlockPos blockposition1 = fluidPos.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
- FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);
+ FluidState fluid1 = this.getLiquid(world, blockposition1, iblockdata1, fluidPos, iblockdata); // Sakura - optimise new liquid level
if (this.canSpreadTo(world, fluidPos, iblockdata, Direction.DOWN, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
// CraftBukkit start
@@ -197,6 +197,25 @@ public abstract class FlowingFluid extends Fluid {
}
protected FluidState getNewLiquid(Level world, BlockPos pos, BlockState state) {
+ // Sakura start - optimise new liquid level
+ BlockPos blockposition2 = pos.above();
+ BlockState iblockdata3 = world.getBlockState(blockposition2);
+
+ return getLiquid(world, pos, state, blockposition2, iblockdata3);
+ }
+
+ // SANITY: world, pos, state, above pos, above state
+ protected FluidState getLiquid(Level world, BlockPos pos, BlockState state, BlockPos blockposition2, BlockState iblockdata3) {
+ FluidState fluid2 = iblockdata3.getFluidState();
+
+ if (!fluid2.isEmpty() && fluid2.getType().isSame(this) && this.canPassThroughWall(Direction.UP, world, pos, state, blockposition2, iblockdata3)) {
+ return this.getFlowing(8, true);
+ } else {
+ return this.getLiquidFromSurroundings(world, pos, state);
+ }
+ }
+
+ protected FluidState getLiquidFromSurroundings(Level world, BlockPos pos, BlockState state) {
int i = 0;
int j = 0;
Iterator iterator = Direction.Plane.HORIZONTAL.iterator();
@@ -226,17 +245,10 @@ public abstract class FlowingFluid extends Fluid {
}
}
- BlockPos blockposition2 = pos.above();
- BlockState iblockdata3 = world.getBlockState(blockposition2);
- FluidState fluid2 = iblockdata3.getFluidState();
+ int k = i - this.getDropOff(world);
- if (!fluid2.isEmpty() && fluid2.getType().isSame(this) && this.canPassThroughWall(Direction.UP, world, pos, state, blockposition2, iblockdata3)) {
- return this.getFlowing(8, true);
- } else {
- int k = i - this.getDropOff(world);
-
- return k <= 0 ? Fluids.EMPTY.defaultFluidState() : this.getFlowing(k, false);
- }
+ return k <= 0 ? Fluids.EMPTY.defaultFluidState() : this.getFlowing(k, false);
+ // Sakura end - optimise new liquid level
}
private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) {