1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
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
index 2053d1e0b7577ec99958bae828b4c219b835edfc..83dc8bcd9e2b8ecbd32225e4e10aec392ef28325 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -184,6 +184,8 @@ public abstract class FlowingFluid extends Fluid {
Direction enumdirection = (Direction) entry.getKey();
FluidState fluid1 = (FluidState) entry.getValue();
BlockPos blockposition1 = pos.relative(enumdirection);
+ final BlockState blockStateIfLoaded = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing
+ if (blockStateIfLoaded == null) continue; // Paper - Prevent chunk loading from fluid flowing
// CraftBukkit start
org.bukkit.block.Block source = CraftBlock.at(world, pos);
@@ -194,7 +196,7 @@ public abstract class FlowingFluid extends Fluid {
continue;
}
// CraftBukkit end
- this.spreadTo(world, blockposition1, world.getBlockState(blockposition1), enumdirection, fluid1);
+ this.spreadTo(world, blockposition1, blockStateIfLoaded, enumdirection, fluid1); // Paper - Prevent chunk loading from fluid flowing
}
}
@@ -209,7 +211,8 @@ public abstract class FlowingFluid extends Fluid {
while (iterator.hasNext()) {
Direction enumdirection = (Direction) iterator.next();
BlockPos.MutableBlockPos blockposition_mutableblockposition1 = blockposition_mutableblockposition.setWithOffset(pos, enumdirection);
- BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition1);
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition_mutableblockposition1); // Paper - Prevent chunk loading from fluid flowing
+ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing
FluidState fluid = iblockdata1.getFluidState();
if (fluid.getType().isSame(this) && FlowingFluid.canPassThroughWall(enumdirection, world, pos, state, blockposition_mutableblockposition1, iblockdata1)) {
@@ -332,7 +335,8 @@ public abstract class FlowingFluid extends Fluid {
if (enumdirection1 != direction) {
BlockPos blockposition1 = pos.relative(enumdirection1);
- BlockState iblockdata1 = spreadCache.getBlockState(blockposition1);
+ BlockState iblockdata1 = spreadCache.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing
+ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing
FluidState fluid = iblockdata1.getFluidState();
if (this.canPassThrough(world, this.getFlowing(), pos, state, enumdirection1, blockposition1, iblockdata1, fluid)) {
@@ -398,7 +402,8 @@ public abstract class FlowingFluid extends Fluid {
while (iterator.hasNext()) {
Direction enumdirection = (Direction) iterator.next();
BlockPos blockposition1 = pos.relative(enumdirection);
- BlockState iblockdata1 = world.getBlockState(blockposition1);
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing
+ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing
FluidState fluid = iblockdata1.getFluidState();
if (this.canMaybePassThrough(world, pos, state, enumdirection, blockposition1, iblockdata1, fluid)) {
@@ -564,11 +569,26 @@ public abstract class FlowingFluid extends Fluid {
public BlockState getBlockState(BlockPos pos) {
return this.getBlockState(pos, this.getCacheKey(pos));
}
+ // Paper start - Prevent chunk loading from fluid flowing
+ public @javax.annotation.Nullable BlockState getBlockStateIfLoaded(BlockPos pos) {
+ return this.getBlockState(pos, this.getCacheKey(pos), false);
+ }
+ // Paper end - Prevent chunk loading from fluid flowing
private BlockState getBlockState(BlockPos pos, short packed) {
- return (BlockState) this.stateCache.computeIfAbsent(packed, (short1) -> {
- return this.level.getBlockState(pos);
- });
+ // Paper start - Prevent chunk loading from fluid flowing
+ return getBlockState(pos, packed, true);
+ }
+ private @javax.annotation.Nullable BlockState getBlockState(BlockPos pos, short packed, boolean load) {
+ BlockState blockState = this.stateCache.get(packed);
+ if (blockState == null) {
+ blockState = load ? level.getBlockState(pos) : level.getBlockStateIfLoaded(pos);
+ if (blockState != null) {
+ this.stateCache.put(packed, blockState);
+ }
+ }
+ return blockState;
+ // Paper end - Prevent chunk loading from fluid flowing
}
public boolean isHole(BlockPos pos) {
|