aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0258-Prevent-chunk-loading-from-Fluid-Flowing.patch
blob: 50c82e5d54ce07ce6c92b308e9e23fdeec677fe9 (plain)
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
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 b67bc6d6a02fdac377f32a766fd8cc2c5fc43488..3a2ae2bca410708736da64560e74b8010444f2dc 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -176,7 +176,8 @@ public abstract class FlowingFluid extends Fluid {
                 Direction enumdirection = (Direction) entry.getKey();
                 FluidState fluid1 = (FluidState) entry.getValue();
                 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
 
                 if (this.canSpreadTo(world, pos, blockState, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
                     // CraftBukkit start
@@ -203,7 +204,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 (fluid.getType().isSame(this) && this.canPassThroughWall(enumdirection, world, pos, state, blockposition1, iblockdata1)) {
@@ -320,11 +322,18 @@ public abstract class FlowingFluid extends Fluid {
             if (enumdirection1 != direction) {
                 BlockPos blockposition2 = pos.relative(enumdirection1);
                 short short0 = FlowingFluid.getCacheKey(fromPos, blockposition2);
-                Pair<BlockState, FluidState> pair = (Pair) stateCache.computeIfAbsent(short0, (short1) -> {
-                    BlockState iblockdata1 = world.getBlockState(blockposition2);
+                // Paper start - Prevent chunk loading from fluid flowing
+                Pair<BlockState, FluidState> pair = stateCache.get(short0);
+                if (pair == null) {
+                    BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition2);
+                    if (iblockdatax == null) {
+                        continue;
+                    }
 
-                    return Pair.of(iblockdata1, iblockdata1.getFluidState());
-                });
+                    pair = Pair.of(iblockdatax, iblockdatax.getFluidState());
+                    stateCache.put(short0, pair);
+                }
+                // Paper end - Prevent chunk loading from fluid flowing
                 BlockState iblockdata1 = (BlockState) pair.getFirst();
                 FluidState fluid = (FluidState) pair.getSecond();
 
@@ -396,11 +405,16 @@ public abstract class FlowingFluid extends Fluid {
             Direction enumdirection = (Direction) iterator.next();
             BlockPos blockposition1 = pos.relative(enumdirection);
             short short0 = FlowingFluid.getCacheKey(pos, blockposition1);
-            Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> {
-                BlockState iblockdata1 = world.getBlockState(blockposition1);
-
-                return Pair.of(iblockdata1, iblockdata1.getFluidState());
-            });
+            // Paper start - Prevent chunk loading from fluid flowing
+            Pair pair = (Pair) short2objectmap.get(short0);
+            if (pair == null) {
+                BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition1);
+                if (iblockdatax == null) continue;
+
+                pair = Pair.of(iblockdatax, iblockdatax.getFluidState());
+                short2objectmap.put(short0, pair);
+            }
+            // Paper end - Prevent chunk loading from fluid flowing
             BlockState iblockdata1 = (BlockState) pair.getFirst();
             FluidState fluid = (FluidState) pair.getSecond();
             FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);