mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
77 lines
4.4 KiB
Diff
77 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 89296667d2ad76a706a3f5b817f3ad8c207cac2d..02be7c3d104fe3b3a2772201f5ebdfb6d16e9b49 100644
|
|
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
|
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
|
@@ -174,7 +174,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
|
|
+ if (iblockdata1 == null) continue; // Paper
|
|
|
|
if (this.canSpreadTo(world, pos, blockState, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
|
|
// CraftBukkit start
|
|
@@ -201,7 +202,9 @@ 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
|
|
+ if (iblockdata1 == null) continue; // Paper
|
|
FluidState fluid = iblockdata1.getFluidState();
|
|
|
|
if (fluid.getType().isSame(this) && this.canPassThroughWall(enumdirection, world, pos, state, blockposition1, iblockdata1)) {
|
|
@@ -318,11 +321,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, (short1) -> {
|
|
- 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);
|
|
+ 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();
|
|
|
|
@@ -394,11 +404,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
|
|
+ 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
|
|
BlockState iblockdata1 = (BlockState) pair.getFirst();
|
|
FluidState fluid = (FluidState) pair.getSecond();
|
|
FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);
|