Paper/patches/server/0259-Prevent-chunk-loading-from-Fluid-Flowing.patch

77 Zeilen
4.4 KiB
Diff

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
2023-03-14 20:24:52 +01:00
index f809a19afdfdb7df439e907531f54b2df1baf08c..00516a230073391b31795ec5af2aa7aa48db639a 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
2022-03-01 06:43:03 +01:00
@@ -174,7 +174,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);
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper
2021-06-11 14:02:28 +02:00
+ if (iblockdata1 == null) continue; // Paper
if (this.canSpreadTo(world, pos, blockState, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
// CraftBukkit start
2022-03-01 06:43:03 +01:00
@@ -201,7 +202,9 @@ 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);
+
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper
2021-06-11 14:02:28 +02:00
+ if (iblockdata1 == null) continue; // Paper
FluidState fluid = iblockdata1.getFluidState();
if (fluid.getType().isSame(this) && this.canPassThroughWall(enumdirection, world, pos, state, blockposition1, iblockdata1)) {
2022-03-01 06:43:03 +01:00
@@ -318,11 +321,18 @@ public abstract class FlowingFluid extends Fluid {
2021-06-11 14:02:28 +02:00
if (enumdirection1 != enumdirection) {
BlockPos blockposition2 = blockposition.relative(enumdirection1);
2021-06-13 06:03:02 +02:00
short short0 = FlowingFluid.getCacheKey(blockposition1, blockposition2);
- Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> {
2021-06-11 14:02:28 +02:00
- BlockState iblockdata1 = world.getBlockState(blockposition2);
+ // Paper start - avoid loading chunks
+ Pair<BlockState, FluidState> pair = short2objectmap.get(short0);
+ if (pair == null) {
+ 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());
+ short2objectmap.put(short0, pair);
+ }
+ // Paper end
BlockState iblockdata1 = (BlockState) pair.getFirst();
FluidState fluid = (FluidState) pair.getSecond();
2022-03-01 06:43:03 +01:00
@@ -394,11 +404,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);
- 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());
- });
2021-06-11 14:02:28 +02:00
+ // Paper start
+ Pair pair = (Pair) short2objectmap.get(short0);
+ if (pair == null) {
+ 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);
+ }
+ // Paper end
BlockState iblockdata1 = (BlockState) pair.getFirst();
FluidState fluid = (FluidState) pair.getSecond();
FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);