2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Mon, 10 Sep 2018 23:36:16 -0400
|
|
|
|
Subject: [PATCH] Prevent chunk loading from Fluid Flowing
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
2024-01-21 13:56:22 +01:00
|
|
|
index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..0aeb9faa1ce22359361741a591aa3d465d955970 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
2023-09-22 00:26:51 +02:00
|
|
|
@@ -176,7 +176,8 @@ public abstract class FlowingFluid extends Fluid {
|
2021-06-11 14:02:28 +02:00
|
|
|
Direction enumdirection = (Direction) entry.getKey();
|
|
|
|
FluidState fluid1 = (FluidState) entry.getValue();
|
|
|
|
BlockPos blockposition1 = pos.relative(enumdirection);
|
|
|
|
- BlockState iblockdata1 = world.getBlockState(blockposition1);
|
2024-01-21 13:56:22 +01:00
|
|
|
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing
|
|
|
|
+ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
if (this.canSpreadTo(world, pos, blockState, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
|
|
|
|
// CraftBukkit start
|
2024-01-21 13:56:22 +01:00
|
|
|
@@ -203,7 +204,8 @@ public abstract class FlowingFluid extends Fluid {
|
2021-06-11 14:02:28 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Direction enumdirection = (Direction) iterator.next();
|
|
|
|
BlockPos blockposition1 = pos.relative(enumdirection);
|
|
|
|
- BlockState iblockdata1 = world.getBlockState(blockposition1);
|
2024-01-21 13:56:22 +01:00
|
|
|
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing
|
|
|
|
+ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing
|
2021-06-11 14:02:28 +02:00
|
|
|
FluidState fluid = iblockdata1.getFluidState();
|
|
|
|
|
2021-11-24 00:06:05 +01:00
|
|
|
if (fluid.getType().isSame(this) && this.canPassThroughWall(enumdirection, world, pos, state, blockposition1, iblockdata1)) {
|
2024-01-21 13:56:22 +01:00
|
|
|
@@ -320,11 +322,18 @@ public abstract class FlowingFluid extends Fluid {
|
2023-06-08 11:18:51 +02:00
|
|
|
if (enumdirection1 != direction) {
|
|
|
|
BlockPos blockposition2 = pos.relative(enumdirection1);
|
|
|
|
short short0 = FlowingFluid.getCacheKey(fromPos, blockposition2);
|
|
|
|
- Pair<BlockState, FluidState> pair = (Pair) stateCache.computeIfAbsent(short0, (short1) -> {
|
2021-06-11 14:02:28 +02:00
|
|
|
- BlockState iblockdata1 = world.getBlockState(blockposition2);
|
2024-01-21 13:56:22 +01:00
|
|
|
+ // Paper start - Prevent chunk loading from fluid flowing
|
2023-06-08 11:18:51 +02:00
|
|
|
+ Pair<BlockState, FluidState> pair = stateCache.get(short0);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (pair == null) {
|
2021-12-06 00:32:02 +01:00
|
|
|
+ BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition2);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (iblockdatax == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return Pair.of(iblockdata1, iblockdata1.getFluidState());
|
|
|
|
- });
|
|
|
|
+ pair = Pair.of(iblockdatax, iblockdatax.getFluidState());
|
2023-06-08 11:18:51 +02:00
|
|
|
+ stateCache.put(short0, pair);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2024-01-21 13:56:22 +01:00
|
|
|
+ // Paper end - Prevent chunk loading from fluid flowing
|
2021-06-11 14:02:28 +02:00
|
|
|
BlockState iblockdata1 = (BlockState) pair.getFirst();
|
|
|
|
FluidState fluid = (FluidState) pair.getSecond();
|
|
|
|
|
2024-01-21 13:56:22 +01:00
|
|
|
@@ -396,11 +405,16 @@ public abstract class FlowingFluid extends Fluid {
|
2021-06-11 14:02:28 +02:00
|
|
|
Direction enumdirection = (Direction) iterator.next();
|
|
|
|
BlockPos blockposition1 = pos.relative(enumdirection);
|
2021-06-13 06:03:02 +02:00
|
|
|
short short0 = FlowingFluid.getCacheKey(pos, blockposition1);
|
2021-11-24 00:06:05 +01:00
|
|
|
- Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> {
|
2021-06-11 14:02:28 +02:00
|
|
|
- BlockState iblockdata1 = world.getBlockState(blockposition1);
|
2023-03-23 22:57:03 +01:00
|
|
|
-
|
|
|
|
- return Pair.of(iblockdata1, iblockdata1.getFluidState());
|
|
|
|
- });
|
2024-01-21 13:56:22 +01:00
|
|
|
+ // Paper start - Prevent chunk loading from fluid flowing
|
2021-06-11 14:02:28 +02:00
|
|
|
+ Pair pair = (Pair) short2objectmap.get(short0);
|
|
|
|
+ if (pair == null) {
|
2021-12-06 00:32:02 +01:00
|
|
|
+ BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition1);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (iblockdatax == null) continue;
|
2023-03-23 22:57:03 +01:00
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
+ pair = Pair.of(iblockdatax, iblockdatax.getFluidState());
|
|
|
|
+ short2objectmap.put(short0, pair);
|
|
|
|
+ }
|
2024-01-21 13:56:22 +01:00
|
|
|
+ // Paper end - Prevent chunk loading from fluid flowing
|
2021-06-11 14:02:28 +02:00
|
|
|
BlockState iblockdata1 = (BlockState) pair.getFirst();
|
|
|
|
FluidState fluid = (FluidState) pair.getSecond();
|
|
|
|
FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);
|