mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 11:42:55 +01:00
4104545b11
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
75 lines
4.4 KiB
Diff
75 lines
4.4 KiB
Diff
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 21e2ffc105b7b573b19c826a5877ed726156e692..6e3e873efa1f50f53cb6503bde8a981f9cefd006 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.getTypeIfLoaded(blockposition1); // Paper
|
|
+ if (iblockdata1 == null) continue; // Paper
|
|
|
|
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.getTypeIfLoaded(blockposition1); // Paper
|
|
+ if (iblockdata1 == null) continue; // Paper
|
|
FluidState fluid = iblockdata1.getFluidState();
|
|
|
|
if (fluid.getType().isSame((Fluid) this) && this.canPassThroughWall(enumdirection, (BlockGetter) world, pos, state, blockposition1, iblockdata1)) {
|
|
@@ -320,11 +322,18 @@ public abstract class FlowingFluid extends Fluid {
|
|
if (enumdirection1 != enumdirection) {
|
|
BlockPos blockposition2 = blockposition.relative(enumdirection1);
|
|
short short0 = FlowingFluid.getCacheKey(blockposition1, blockposition2);
|
|
- Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (k) -> {
|
|
- BlockState iblockdata1 = world.getBlockState(blockposition2);
|
|
+ // Paper start - avoid loading chunks
|
|
+ Pair<BlockState, FluidState> pair = short2objectmap.get(short0);
|
|
+ if (pair == null) {
|
|
+ BlockState iblockdatax = world.getTypeIfLoaded(blockposition2);
|
|
+ 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();
|
|
|
|
@@ -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, (j) -> {
|
|
- BlockState iblockdata1 = world.getBlockState(blockposition1);
|
|
-
|
|
- return Pair.of(iblockdata1, iblockdata1.getFluidState());
|
|
- });
|
|
+ // Paper start
|
|
+ Pair pair = (Pair) short2objectmap.get(short0);
|
|
+ if (pair == null) {
|
|
+ BlockState iblockdatax = world.getTypeIfLoaded(blockposition1);
|
|
+ if (iblockdatax == null) continue;
|
|
+
|
|
+ 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);
|