mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
always copy chunk
This commit is contained in:
@@ -158,58 +158,6 @@ index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..bed3a64388bb43e47c2ba4e67f7dde5b
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class SaveState {
|
public static final class SaveState {
|
||||||
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
|
||||||
index df717c545472006b99532280c38c1fbef12bcf82..abb7c8b4ffc73cedd5e03597fe82c71e51161a1b 100644
|
|
||||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
|
||||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
|
||||||
@@ -23,6 +23,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
|
||||||
private short tickingFluidCount;
|
|
||||||
public final PalettedContainer<BlockState> states;
|
|
||||||
private PalettedContainer<Holder<Biome>> biomes; // CraftBukkit - read/write
|
|
||||||
+ private boolean modified = false; // Leaf - Optimize chunkUnload
|
|
||||||
|
|
||||||
// Paper start - block counting
|
|
||||||
private static final it.unimi.dsi.fastutil.shorts.ShortArrayList FULL_LIST = new it.unimi.dsi.fastutil.shorts.ShortArrayList(16*16*16);
|
|
||||||
@@ -133,6 +134,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
|
||||||
// Paper end - block counting
|
|
||||||
|
|
||||||
public BlockState setBlockState(int x, int y, int z, BlockState state, boolean useLocks) {
|
|
||||||
+ this.modified = true; // Leaf - Optimize chunkUnload
|
|
||||||
BlockState blockState;
|
|
||||||
if (useLocks) {
|
|
||||||
blockState = this.states.getAndSet(x, y, z, state);
|
|
||||||
@@ -323,7 +325,31 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
|
||||||
this.biomes = palettedContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Leaf start - Optimize chunkUnload
|
|
||||||
+ private LevelChunkSection(short nonEmptyBlockCount, short tickingBlockCount, short tickingFluidCount,
|
|
||||||
+ PalettedContainer<BlockState> states, PalettedContainer<Holder<Biome>> biomes) {
|
|
||||||
+ this.nonEmptyBlockCount = nonEmptyBlockCount;
|
|
||||||
+ this.tickingBlockCount = tickingBlockCount;
|
|
||||||
+ this.tickingFluidCount = tickingFluidCount;
|
|
||||||
+ this.states = states;
|
|
||||||
+ this.biomes = biomes;
|
|
||||||
+ }
|
|
||||||
+ // Leaf end - Optimize chunkUnload
|
|
||||||
+
|
|
||||||
public LevelChunkSection copy() {
|
|
||||||
+ // Leaf - Optimize chunkUnload
|
|
||||||
+ // If the section hasn't been modified and no random ticking blocks/fluids,
|
|
||||||
+ // return a lightweight copy that shares palette data
|
|
||||||
+ if (!this.modified && this.tickingBlockCount == 0 && this.tickingFluidCount == 0) {
|
|
||||||
+ return new LevelChunkSection(
|
|
||||||
+ this.nonEmptyBlockCount,
|
|
||||||
+ this.tickingBlockCount,
|
|
||||||
+ this.tickingFluidCount,
|
|
||||||
+ this.states, // Share reference instead of copying
|
|
||||||
+ this.biomes // Share reference instead of copying
|
|
||||||
+ );
|
|
||||||
+ }
|
|
||||||
+ // Leaf end - Optimize chunkUnload
|
|
||||||
return new LevelChunkSection(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||||
index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989a2b3627b 100644
|
index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989a2b3627b 100644
|
||||||
--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ index 6a70665e9b8bc767ba316ada542178634e090afa..0ee94459c1995ddd7e8b469088827b87
|
|||||||
public BlockState getBlockState(BlockPos pos) {
|
public BlockState getBlockState(BlockPos pos) {
|
||||||
if (true) {
|
if (true) {
|
||||||
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48ce098027 100644
|
index df717c545472006b99532280c38c1fbef12bcf82..df94db4a21ecb9353b3fbadd19caecd0fb74ae8d 100644
|
||||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
@@ -21,6 +21,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
@@ -21,6 +21,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
@@ -61,8 +61,8 @@ index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48
|
|||||||
+ public short lavaFluidCount; // Leaf
|
+ public short lavaFluidCount; // Leaf
|
||||||
public final PalettedContainer<BlockState> states;
|
public final PalettedContainer<BlockState> states;
|
||||||
private PalettedContainer<Holder<Biome>> biomes; // CraftBukkit - read/write
|
private PalettedContainer<Holder<Biome>> biomes; // CraftBukkit - read/write
|
||||||
private boolean modified = false; // Leaf - Optimize chunkUnload
|
|
||||||
@@ -53,6 +55,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
@@ -52,6 +54,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
this.nonEmptyBlockCount = section.nonEmptyBlockCount;
|
this.nonEmptyBlockCount = section.nonEmptyBlockCount;
|
||||||
this.tickingBlockCount = section.tickingBlockCount;
|
this.tickingBlockCount = section.tickingBlockCount;
|
||||||
this.tickingFluidCount = section.tickingFluidCount;
|
this.tickingFluidCount = section.tickingFluidCount;
|
||||||
@@ -71,7 +71,7 @@ index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48
|
|||||||
this.states = section.states.copy();
|
this.states = section.states.copy();
|
||||||
this.biomes = section.biomes.copy();
|
this.biomes = section.biomes.copy();
|
||||||
}
|
}
|
||||||
@@ -149,6 +153,15 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
@@ -147,6 +151,15 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
if (blockState.isRandomlyTicking()) {
|
if (blockState.isRandomlyTicking()) {
|
||||||
this.tickingBlockCount--;
|
this.tickingBlockCount--;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!!fluidState.isRandomlyTicking()) { // Paper - block counting
|
if (!!fluidState.isRandomlyTicking()) { // Paper - block counting
|
||||||
@@ -160,6 +173,15 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
@@ -158,6 +171,15 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
if (state.isRandomlyTicking()) {
|
if (state.isRandomlyTicking()) {
|
||||||
this.tickingBlockCount++;
|
this.tickingBlockCount++;
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!!fluidState1.isRandomlyTicking()) { // Paper - block counting
|
if (!!fluidState1.isRandomlyTicking()) { // Paper - block counting
|
||||||
@@ -193,6 +215,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
@@ -191,6 +213,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
this.nonEmptyBlockCount = (short)0;
|
this.nonEmptyBlockCount = (short)0;
|
||||||
this.tickingBlockCount = (short)0;
|
this.tickingBlockCount = (short)0;
|
||||||
this.tickingFluidCount = (short)0;
|
this.tickingFluidCount = (short)0;
|
||||||
@@ -112,7 +112,7 @@ index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48
|
|||||||
this.specialCollidingBlocks = (short)0;
|
this.specialCollidingBlocks = (short)0;
|
||||||
this.tickingBlocks.clear();
|
this.tickingBlocks.clear();
|
||||||
|
|
||||||
@@ -240,6 +264,15 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
@@ -238,6 +262,15 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
tickingBlocks.add(raw[i]);
|
tickingBlocks.add(raw[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,27 +128,3 @@ index abb7c8b4ffc73cedd5e03597fe82c71e51161a1b..315cd21ac80b1bbaef96a039b9567c48
|
|||||||
|
|
||||||
final FluidState fluid = state.getFluidState();
|
final FluidState fluid = state.getFluidState();
|
||||||
|
|
||||||
@@ -326,11 +359,13 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leaf start - Optimize chunkUnload
|
|
||||||
- private LevelChunkSection(short nonEmptyBlockCount, short tickingBlockCount, short tickingFluidCount,
|
|
||||||
+ private LevelChunkSection(short nonEmptyBlockCount, short tickingBlockCount, short tickingFluidCount, short waterFluidCount, short lavaFluidCount, // Leaf
|
|
||||||
PalettedContainer<BlockState> states, PalettedContainer<Holder<Biome>> biomes) {
|
|
||||||
this.nonEmptyBlockCount = nonEmptyBlockCount;
|
|
||||||
this.tickingBlockCount = tickingBlockCount;
|
|
||||||
this.tickingFluidCount = tickingFluidCount;
|
|
||||||
+ this.waterFluidCount = waterFluidCount; // Leaf
|
|
||||||
+ this.lavaFluidCount = lavaFluidCount; // Leaf
|
|
||||||
this.states = states;
|
|
||||||
this.biomes = biomes;
|
|
||||||
}
|
|
||||||
@@ -345,6 +380,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
|
||||||
this.nonEmptyBlockCount,
|
|
||||||
this.tickingBlockCount,
|
|
||||||
this.tickingFluidCount,
|
|
||||||
+ this.waterFluidCount, // Leaf
|
|
||||||
+ this.lavaFluidCount, // Leaf
|
|
||||||
this.states, // Share reference instead of copying
|
|
||||||
this.biomes // Share reference instead of copying
|
|
||||||
);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user