starlight

This commit is contained in:
Spottedleaf 2024-04-25 00:14:22 -07:00
parent 6a87d141f3
commit ec9f7e3850

View file

@ -10,29 +10,25 @@ public net.minecraft.server.level.ChunkHolder broadcast(Lnet/minecraft/network/p
diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..09ddbbfdf656aa347830941abd7c994fac05d1c5 index 0000000000000000000000000000000000000000..3732a940d9603cf502983afbc4663113d1400be8
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java
@@ -0,0 +1,279 @@ @@ -0,0 +1,275 @@
+package ca.spottedleaf.starlight.common.light; +package ca.spottedleaf.starlight.common.light;
+ +
+import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos;
+import net.minecraft.world.level.Level; +import net.minecraft.world.level.Level;
+import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus;
+import net.minecraft.world.level.chunk.ImposterProtoChunk;
+import net.minecraft.world.level.chunk.LevelChunk;
+import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.LevelChunkSection;
+import net.minecraft.world.level.chunk.LightChunkGetter; +import net.minecraft.world.level.chunk.LightChunkGetter;
+import net.minecraft.world.level.chunk.PalettedContainer; +import net.minecraft.world.level.chunk.PalettedContainer;
+import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.Shapes;
+import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.VoxelShape;
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List; +import java.util.List;
+import java.util.Set; +import java.util.Set;
+import java.util.stream.Collectors;
+ +
+public final class BlockStarLightEngine extends StarLightEngine { +public final class BlockStarLightEngine extends StarLightEngine {
+ +
@ -741,7 +737,7 @@ index 0000000000000000000000000000000000000000..4ffb4ffe01c4628d52742c5c0bbd3522
+} +}
diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..5f771962afb44175d446f138c8e7453230f48c6c index 0000000000000000000000000000000000000000..43a2cce467d29f81ba57d77c03608e57857dd579
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java
@@ -0,0 +1,709 @@ @@ -0,0 +1,709 @@
@ -756,7 +752,7 @@ index 0000000000000000000000000000000000000000..5f771962afb44175d446f138c8e74532
+import net.minecraft.world.level.Level; +import net.minecraft.world.level.Level;
+import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus;
+import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.LevelChunkSection;
+import net.minecraft.world.level.chunk.LightChunkGetter; +import net.minecraft.world.level.chunk.LightChunkGetter;
+import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.Shapes;
@ -3034,7 +3030,7 @@ index 0000000000000000000000000000000000000000..ad1eeebe6de219143492b94da309cb54
+} +}
diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..499c069d64692872924963d3a7ac39664b20468d index 0000000000000000000000000000000000000000..e0338db4d6fa359029ed5edeacc3646aa98701f5
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java
@@ -0,0 +1,674 @@ @@ -0,0 +1,674 @@
@ -3054,7 +3050,7 @@ index 0000000000000000000000000000000000000000..499c069d64692872924963d3a7ac3966
+import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.Level; +import net.minecraft.world.level.Level;
+import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus;
+import net.minecraft.world.level.chunk.DataLayer; +import net.minecraft.world.level.chunk.DataLayer;
+import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunk;
+import net.minecraft.world.level.chunk.LightChunkGetter; +import net.minecraft.world.level.chunk.LightChunkGetter;
@ -4096,7 +4092,7 @@ index 0000000000000000000000000000000000000000..fabf1e97c019c7365212f40018dcd08d
+} +}
diff --git a/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java diff --git a/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8d1fd22c8b8b0ea3afce6fc3e92057194f82669f index 0000000000000000000000000000000000000000..c2903150c8fc6955f4f4f71acc932b6c2ac83484
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java +++ b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java
@@ -0,0 +1,192 @@ @@ -0,0 +1,192 @@
@ -4111,7 +4107,7 @@ index 0000000000000000000000000000000000000000..8d1fd22c8b8b0ea3afce6fc3e9205719
+import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.Level; +import net.minecraft.world.level.Level;
+import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus;
+import org.slf4j.Logger; +import org.slf4j.Logger;
+ +
+public final class SaveUtil { +public final class SaveUtil {
@ -4359,24 +4355,19 @@ index 534d9c380f26d6cce3c99fa88ad2e15410535094..e47fb2aa5e885162cae5cbfc9f33ff78
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..463c6d8d5b114816ed9065558285945817c30385 index 0000000000000000000000000000000000000000..56524cbe4303901007e1e7fb3703a19efbf79ae7
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java +++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
@@ -0,0 +1,115 @@ @@ -0,0 +1,109 @@
+package io.papermc.paper.command.subcommands; +package io.papermc.paper.command.subcommands;
+ +
+import io.papermc.paper.command.PaperSubcommand; +import io.papermc.paper.command.PaperSubcommand;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import io.papermc.paper.util.MCUtil; +import io.papermc.paper.util.MCUtil;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ChunkHolder;
+import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.server.level.ThreadedLevelLightEngine; +import net.minecraft.server.level.ThreadedLevelLightEngine;
+import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.LevelChunk;
+import org.bukkit.command.CommandSender; +import org.bukkit.command.CommandSender;
+import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
@ -4387,7 +4378,6 @@ index 0000000000000000000000000000000000000000..463c6d8d5b114816ed90655582859458
+import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.Component.text;
+import static net.kyori.adventure.text.format.NamedTextColor.BLUE; +import static net.kyori.adventure.text.format.NamedTextColor.BLUE;
+import static net.kyori.adventure.text.format.NamedTextColor.DARK_AQUA; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_AQUA;
+import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
+import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.kyori.adventure.text.format.NamedTextColor.RED;
+ +
+@DefaultQualifier(NonNull.class) +@DefaultQualifier(NonNull.class)
@ -4445,7 +4435,7 @@ index 0000000000000000000000000000000000000000..463c6d8d5b114816ed90655582859458
+ final ChunkPos chunkPos = iterator.next(); + final ChunkPos chunkPos = iterator.next();
+ +
+ final @Nullable ChunkAccess chunk = (ChunkAccess) world.getChunkSource().getChunkForLighting(chunkPos.x, chunkPos.z); + final @Nullable ChunkAccess chunk = (ChunkAccess) world.getChunkSource().getChunkForLighting(chunkPos.x, chunkPos.z);
+ if (chunk == null || !chunk.isLightCorrect() || !chunk.getStatus().isOrAfter(net.minecraft.world.level.chunk.ChunkStatus.LIGHT)) { + if (chunk == null || !chunk.isLightCorrect() || !chunk.getStatus().isOrAfter(net.minecraft.world.level.chunk.status.ChunkStatus.LIGHT)) {
+ // cannot relight this chunk + // cannot relight this chunk
+ iterator.remove(); + iterator.remove();
+ continue; + continue;
@ -4479,23 +4469,36 @@ index 0000000000000000000000000000000000000000..463c6d8d5b114816ed90655582859458
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index facfdbb87e89f4db33ce13233c2ba4366d35c15b..807a6bb1026dac2c4cd0a50afe06fd62ce23558b 100644 index b12921579cb9ab3cbf5607841cc84f2f843624ea..88729d92878f98729eb5669cce5ae5b1418865a1 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -53,7 +53,7 @@ public class ChunkHolder { @@ -51,7 +51,7 @@ public class ChunkHolder {
private volatile CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage private volatile CompletableFuture<ChunkResult<LevelChunk>> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage
private volatile CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> tickingChunkFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage private volatile CompletableFuture<ChunkResult<LevelChunk>> tickingChunkFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage
private volatile CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> entityTickingChunkFuture; private volatile boolean isEntityTickingReady; // Paper - cache chunk ticking stage private volatile CompletableFuture<ChunkResult<LevelChunk>> entityTickingChunkFuture; private volatile boolean isEntityTickingReady; // Paper - cache chunk ticking stage
- private CompletableFuture<ChunkAccess> chunkToSave; - private CompletableFuture<ChunkAccess> chunkToSave;
+ public CompletableFuture<ChunkAccess> chunkToSave; // Paper - public + public CompletableFuture<ChunkAccess> chunkToSave; // Paper - public
@Nullable @Nullable
private final DebugBuffer<ChunkHolder.ChunkSaveDebug> chunkToSaveHistory; private final DebugBuffer<ChunkHolder.ChunkSaveDebug> chunkToSaveHistory;
public int oldTicketLevel; public int oldTicketLevel;
@@ -261,6 +261,12 @@ public class ChunkHolder {
}
}
+ // Paper start - starlight
+ public void broadcast(Packet<?> packet, boolean onChunkViewEdge) {
+ this.broadcast(this.playerProvider.getPlayers(this.pos, onChunkViewEdge), packet);
+ }
+ // Paper end - starlight
+
public void broadcastChanges(LevelChunk chunk) {
if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) {
Level world = chunk.getLevel();
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d7c58ac9f9f4727cf13c0fd3bc370b10a2aba38f..ee16a8ef86705dc89b1cc300c06cf683431c7ef3 100644 index 35f627c58e93c03ee58b44877398432bba57dc2d..d3f63185edd1db9fab3887ea3f08982435b3a23c 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -125,7 +125,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -128,7 +128,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private final LongSet entitiesInLevel; private final LongSet entitiesInLevel;
public final ServerLevel level; public final ServerLevel level;
private final ThreadedLevelLightEngine lightEngine; private final ThreadedLevelLightEngine lightEngine;
@ -4505,20 +4508,20 @@ index d7c58ac9f9f4727cf13c0fd3bc370b10a2aba38f..ee16a8ef86705dc89b1cc300c06cf683
private final RandomState randomState; private final RandomState randomState;
private final ChunkGeneratorStructureState chunkGeneratorState; private final ChunkGeneratorStructureState chunkGeneratorState;
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
index 4e1618462840a1378dbe6492696c97544815edf2..8e8e3896040241bba8fd15f4d6d046567847f741 100644 index c473cb1888e9ab0e91ba44f1439b81742758304e..7a48ae2ba962ff56d0abff581b51f28b48bd9aae 100644
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java --- a/src/main/java/net/minecraft/server/level/DistanceManager.java
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
@@ -380,7 +380,7 @@ public abstract class DistanceManager { @@ -379,7 +379,7 @@ public abstract class DistanceManager {
} }
public void removeTicketsOnClosing() { public void removeTicketsOnClosing() {
- ImmutableSet<TicketType<?>> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve - ImmutableSet<TicketType<?>> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve
+ ImmutableSet<TicketType<?>> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.CHUNK_RELIGHT, ca.spottedleaf.starlight.common.light.StarLightInterface.CHUNK_WORK_TICKET); // Paper - add additional tickets to preserve + ImmutableSet<TicketType<?>> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.CHUNK_RELIGHT, ca.spottedleaf.starlight.common.light.StarLightInterface.CHUNK_WORK_TICKET); // Paper - add additional tickets to preserve
ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator(); ObjectIterator<Entry<SortedArraySet<Ticket<?>>>> objectiterator = this.tickets.long2ObjectEntrySet().fastIterator();
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java
index 1dfae40ec19c4df0a97359941cf2c948cd1c9cb2..3229bb8dfb9f39e5fa1c8d91cb58057764cd4abb 100644 index 1dfae40ec19c4df0a97359941cf2c948cd1c9cb2..f206df06a7d8895175db31d4a840d7467ffe826f 100644
--- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java
+++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java
@@ -23,6 +23,17 @@ import net.minecraft.world.level.chunk.LightChunkGetter; @@ -23,6 +23,17 @@ import net.minecraft.world.level.chunk.LightChunkGetter;
@ -4533,7 +4536,7 @@ index 1dfae40ec19c4df0a97359941cf2c948cd1c9cb2..3229bb8dfb9f39e5fa1c8d91cb580577
+import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
+import it.unimi.dsi.fastutil.longs.LongArrayList; +import it.unimi.dsi.fastutil.longs.LongArrayList;
+import it.unimi.dsi.fastutil.longs.LongIterator; +import it.unimi.dsi.fastutil.longs.LongIterator;
+import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus;
+// Paper end +// Paper end
+ +
public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCloseable { public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCloseable {
@ -4855,10 +4858,10 @@ index 0d536d72ac918fbd403397ff369d10143ee9c204..6051e5f272838ef23276a90e21c2fc82
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) { public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
return new TicketType<>(name, argumentComparator, 0L); return new TicketType<>(name, argumentComparator, 0L);
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
index 209596e89307b9e1d0ff4c465876d29fef4fc290..c3e7bd8865cc8990fc59f1ff0dfc1697cbb5ca49 100644 index 713509e08c6325816fef7c09477d36aacb0008ef..b17eb5c228264715bdf58895e4e7a3910a13c6e9 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
@@ -107,6 +107,27 @@ public class WorldGenRegion implements WorldGenLevel { @@ -109,6 +109,27 @@ public class WorldGenRegion implements WorldGenLevel {
} }
} }
@ -4887,10 +4890,10 @@ index 209596e89307b9e1d0ff4c465876d29fef4fc290..c3e7bd8865cc8990fc59f1ff0dfc1697
return this.level.getChunkSource().chunkMap.isOldChunkAround(chunkPos, checkRadius); return this.level.getChunkSource().chunkMap.isOldChunkAround(chunkPos, checkRadius);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 64300077fce6eb28b6bddd42b3467eaa4c80c9f5..e28ac8f7960f648099e5f3607530a406c72e5056 100644 index 84033e07fa357bf401190d5b5fadfd783a63ddf9..0cc12c418d18c5c2e927b93907daea3e0f662035 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -881,6 +881,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -812,6 +812,7 @@ public abstract class BlockBehaviour implements FeatureElement {
this.spawnTerrainParticles = blockbase_info.spawnTerrainParticles; this.spawnTerrainParticles = blockbase_info.spawnTerrainParticles;
this.instrument = blockbase_info.instrument; this.instrument = blockbase_info.instrument;
this.replaceable = blockbase_info.replaceable; this.replaceable = blockbase_info.replaceable;
@ -4898,7 +4901,7 @@ index 64300077fce6eb28b6bddd42b3467eaa4c80c9f5..e28ac8f7960f648099e5f3607530a406
} }
// Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time // Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time
private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData; private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData;
@@ -917,6 +918,18 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -848,6 +849,18 @@ public abstract class BlockBehaviour implements FeatureElement {
return this.shapeExceedsCube; return this.shapeExceedsCube;
} }
// Paper end // Paper end
@ -4917,7 +4920,7 @@ index 64300077fce6eb28b6bddd42b3467eaa4c80c9f5..e28ac8f7960f648099e5f3607530a406
public void initCache() { public void initCache() {
this.fluidState = ((Block) this.owner).getFluidState(this.asState()); this.fluidState = ((Block) this.owner).getFluidState(this.asState());
@@ -925,6 +938,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -856,6 +869,7 @@ public abstract class BlockBehaviour implements FeatureElement {
this.cache = new BlockBehaviour.BlockStateBase.Cache(this.asState()); this.cache = new BlockBehaviour.BlockStateBase.Cache(this.asState());
} }
this.shapeExceedsCube = this.cache == null || this.cache.largeCollisionShape; // Paper - moved from actual method to here this.shapeExceedsCube = this.cache == null || this.cache.largeCollisionShape; // Paper - moved from actual method to here
@ -4926,10 +4929,10 @@ index 64300077fce6eb28b6bddd42b3467eaa4c80c9f5..e28ac8f7960f648099e5f3607530a406
this.legacySolid = this.calculateSolid(); this.legacySolid = this.calculateSolid();
} }
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index e5e562f75e7d4b6a750f192842940c5e3af81e7d..3e5addb60ae8f466dad09edb3ae1fc88fe2681e9 100644 index f4e3bd2ae4f63e6d3d25463a3635b8f89fecc068..1f8c72b6c7d8683d67880fa175843c73b3d39b78 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java --- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -74,7 +74,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom @@ -77,7 +77,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
@Nullable @Nullable
protected BlendingData blendingData; protected BlendingData blendingData;
public final Map<Heightmap.Types, Heightmap> heightmaps = Maps.newEnumMap(Heightmap.Types.class); public final Map<Heightmap.Types, Heightmap> heightmaps = Maps.newEnumMap(Heightmap.Types.class);
@ -4938,7 +4941,7 @@ index e5e562f75e7d4b6a750f192842940c5e3af81e7d..3e5addb60ae8f466dad09edb3ae1fc88
private final Map<Structure, StructureStart> structureStarts = Maps.newHashMap(); private final Map<Structure, StructureStart> structureStarts = Maps.newHashMap();
private final Map<Structure, LongSet> structuresRefences = Maps.newHashMap(); private final Map<Structure, LongSet> structuresRefences = Maps.newHashMap();
protected final Map<BlockPos, CompoundTag> pendingBlockEntities = Maps.newHashMap(); protected final Map<BlockPos, CompoundTag> pendingBlockEntities = Maps.newHashMap();
@@ -86,8 +86,55 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom @@ -89,8 +89,55 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY); public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY);
// CraftBukkit end // CraftBukkit end
@ -4994,7 +4997,7 @@ index e5e562f75e7d4b6a750f192842940c5e3af81e7d..3e5addb60ae8f466dad09edb3ae1fc88
this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups
this.chunkPos = pos; this.coordinateKey = ChunkPos.asLong(locX, locZ); // Paper - cache long key this.chunkPos = pos; this.coordinateKey = ChunkPos.asLong(locX, locZ); // Paper - cache long key
this.upgradeData = upgradeData; this.upgradeData = upgradeData;
@@ -96,7 +143,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom @@ -99,7 +146,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
this.inhabitedTime = inhabitedTime; this.inhabitedTime = inhabitedTime;
this.postProcessing = new ShortList[heightLimitView.getSectionsCount()]; this.postProcessing = new ShortList[heightLimitView.getSectionsCount()];
this.blendingData = blendingData; this.blendingData = blendingData;
@ -5003,7 +5006,7 @@ index e5e562f75e7d4b6a750f192842940c5e3af81e7d..3e5addb60ae8f466dad09edb3ae1fc88
if (sectionArray != null) { if (sectionArray != null) {
if (this.sections.length == sectionArray.length) { if (this.sections.length == sectionArray.length) {
System.arraycopy(sectionArray, 0, this.sections, 0, this.sections.length); System.arraycopy(sectionArray, 0, this.sections, 0, this.sections.length);
@@ -507,12 +554,12 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom @@ -510,12 +557,12 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
} }
public void initializeLightSources() { public void initializeLightSources() {
@ -5018,28 +5021,6 @@ index e5e562f75e7d4b6a750f192842940c5e3af81e7d..3e5addb60ae8f466dad09edb3ae1fc88
} }
public static record TicksToSave(SerializableTickContainer<Block> blocks, SerializableTickContainer<Fluid> fluids) { public static record TicksToSave(SerializableTickContainer<Block> blocks, SerializableTickContainer<Fluid> fluids) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
index d5b1fd0ff3f64675f90dd9f7f328a106e0992d51..846ae3fd184a1d63b743aa25e045604576697c96 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
@@ -260,6 +260,17 @@ public class ChunkStatus {
return this.chunkType;
}
+ // Paper start
+ public static ChunkStatus getStatus(String name) {
+ try {
+ // We need this otherwise we return EMPTY for invalid names
+ ResourceLocation key = new ResourceLocation(name);
+ return BuiltInRegistries.CHUNK_STATUS.getOptional(key).orElse(null);
+ } catch (Exception ex) {
+ return null; // invalid name
+ }
+ }
+ // Paper end
public static ChunkStatus byName(String id) {
return (ChunkStatus) BuiltInRegistries.CHUNK_STATUS.get(ResourceLocation.tryParse(id));
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
index 2ee1658532cb00d7bcd1d11e03f19d21ca7f2a9e..ac754827172a4de600d0a57a7d11853481a2dbf2 100644 index 2ee1658532cb00d7bcd1d11e03f19d21ca7f2a9e..ac754827172a4de600d0a57a7d11853481a2dbf2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
@ -5086,10 +5067,10 @@ index 2ee1658532cb00d7bcd1d11e03f19d21ca7f2a9e..ac754827172a4de600d0a57a7d118534
public BlockState getBlockState(BlockPos pos) { public BlockState getBlockState(BlockPos pos) {
return Blocks.VOID_AIR.defaultBlockState(); return Blocks.VOID_AIR.defaultBlockState();
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
index 6d1f924f7a1efe87f1a79f07ac4b4fbaae92f586..030fafe3b0bcad9e95251f5824ac2ef58640c705 100644 index 2953e93965aa688be8fc1620580701ba0c9d907e..aa5dee839d4c0dbc3c2abee9b501ec250c575cb3 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
@@ -45,6 +45,48 @@ public class ImposterProtoChunk extends ProtoChunk { @@ -47,6 +47,48 @@ public class ImposterProtoChunk extends ProtoChunk {
this.allowWrites = propagateToWrapped; this.allowWrites = propagateToWrapped;
} }
@ -5139,10 +5120,10 @@ index 6d1f924f7a1efe87f1a79f07ac4b4fbaae92f586..030fafe3b0bcad9e95251f5824ac2ef5
@Override @Override
public BlockEntity getBlockEntity(BlockPos pos) { public BlockEntity getBlockEntity(BlockPos pos) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index af757309cb46af6df07872f7596b66df6d6f18d7..73e682bb3ef3b2e450ec8c594b5365c7a340615e 100644 index 744db9eec4f7bdeb32f83300960a7fce63b393d8..fca31bc427847141e7317b85a10da9e34e9e2bf6 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -220,6 +220,12 @@ public class LevelChunk extends ChunkAccess { @@ -222,6 +222,12 @@ public class LevelChunk extends ChunkAccess {
public LevelChunk(ServerLevel world, ProtoChunk protoChunk, @Nullable LevelChunk.PostLoadProcessor entityLoader) { public LevelChunk(ServerLevel world, ProtoChunk protoChunk, @Nullable LevelChunk.PostLoadProcessor entityLoader) {
this(world, protoChunk.getPos(), protoChunk.getUpgradeData(), protoChunk.unpackBlockTicks(), protoChunk.unpackFluidTicks(), protoChunk.getInhabitedTime(), protoChunk.getSections(), entityLoader, protoChunk.getBlendingData()); this(world, protoChunk.getPos(), protoChunk.getUpgradeData(), protoChunk.unpackBlockTicks(), protoChunk.unpackFluidTicks(), protoChunk.getInhabitedTime(), protoChunk.getSections(), entityLoader, protoChunk.getBlendingData());
@ -5155,7 +5136,7 @@ index af757309cb46af6df07872f7596b66df6d6f18d7..73e682bb3ef3b2e450ec8c594b5365c7
Iterator iterator = protoChunk.getBlockEntities().values().iterator(); Iterator iterator = protoChunk.getBlockEntities().values().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@@ -246,7 +252,7 @@ public class LevelChunk extends ChunkAccess { @@ -248,7 +254,7 @@ public class LevelChunk extends ChunkAccess {
} }
} }
@ -5174,7 +5155,7 @@ index af757309cb46af6df07872f7596b66df6d6f18d7..73e682bb3ef3b2e450ec8c594b5365c7
this.level.getChunkSource().getLightEngine().checkBlock(blockposition); this.level.getChunkSource().getLightEngine().checkBlock(blockposition);
gameprofilerfiller.pop(); gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index 268752a0b939abcaa9c7a302d2642b0c0fa2d331..2d7c6f00d399c7607e653078d77103a54509d03b 100644 index 2fa0097a9374a89177e4f1068d1bfed30b8ff122..fa9df6ebcd90d4e9e5836a37212b1f60665783b1 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -155,7 +155,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer @@ -155,7 +155,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@ -5187,10 +5168,10 @@ index 268752a0b939abcaa9c7a302d2642b0c0fa2d331..2d7c6f00d399c7607e653078d77103a5
return data.palette.valueFor(data.storage.get(index)); return data.palette.valueFor(data.storage.get(index));
} }
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
index 03e5e5c5ea003ba52b9f3ee405cd77e22ea387c8..1036ff2ac8ba0967a36eb7977ed49500a05a33e6 100644 index bcc70883d23d38c408130ffe778205e371ff4e8a..576ae0cb138b265c8a3995de7b5ebc827d50949d 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
@@ -141,7 +141,7 @@ public class ProtoChunk extends ChunkAccess { @@ -143,7 +143,7 @@ public class ProtoChunk extends ChunkAccess {
} }
if (LightEngine.hasDifferentLightProperties(this, pos, blockState, state)) { if (LightEngine.hasDifferentLightProperties(this, pos, blockState, state)) {
@ -5199,11 +5180,34 @@ index 03e5e5c5ea003ba52b9f3ee405cd77e22ea387c8..1036ff2ac8ba0967a36eb7977ed49500
this.lightEngine.checkBlock(pos); this.lightEngine.checkBlock(pos);
} }
} }
diff --git a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java
index ae992aeb8b836e8c2e5bab338ae46cc31c317245..95318092f8281d98132d1d3ceb4a5c36cf32eb05 100644
--- a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java
+++ b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java
@@ -117,6 +117,18 @@ public class ChunkStatus {
private final ChunkType chunkType;
private final EnumSet<Heightmap.Types> heightmapsAfter;
+ // Paper start - starlight
+ public static ChunkStatus getStatus(String name) {
+ try {
+ // We need this otherwise we return EMPTY for invalid names
+ ResourceLocation key = new ResourceLocation(name);
+ return BuiltInRegistries.CHUNK_STATUS.getOptional(key).orElse(null);
+ } catch (Exception ex) {
+ return null; // invalid name
+ }
+ }
+ // Paper end - starlight
+
private static ChunkStatus register(
String id,
@Nullable ChunkStatus previous,
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412b7c358ba 100644 index 88f0aca2da0e14ed5ec0513944fa0ba28b73b5d1..01d6b8683a9fa30d05b03ebfef8ee2dca4e83a56 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -88,6 +88,14 @@ public class ChunkSerializer { @@ -90,6 +90,14 @@ public class ChunkSerializer {
private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion(); private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion();
private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion");
// Paper end - Do not let the server load chunks from newer versions // Paper end - Do not let the server load chunks from newer versions
@ -5218,7 +5222,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
public ChunkSerializer() {} public ChunkSerializer() {}
// Paper start - guard against serializing mismatching coordinates // Paper start - guard against serializing mismatching coordinates
@@ -119,13 +127,20 @@ public class ChunkSerializer { @@ -121,19 +129,26 @@ public class ChunkSerializer {
} }
UpgradeData chunkconverter = nbt.contains("UpgradeData", 10) ? new UpgradeData(nbt.getCompound("UpgradeData"), world) : UpgradeData.EMPTY; UpgradeData chunkconverter = nbt.contains("UpgradeData", 10) ? new UpgradeData(nbt.getCompound("UpgradeData"), world) : UpgradeData.EMPTY;
@ -5240,8 +5244,6 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
Registry<Biome> iregistry = world.registryAccess().registryOrThrow(Registries.BIOME); Registry<Biome> iregistry = world.registryAccess().registryOrThrow(Registries.BIOME);
Codec<PalettedContainer<Holder<Biome>>> codec = ChunkSerializer.makeBiomeCodecRW(iregistry); // CraftBukkit - read/write Codec<PalettedContainer<Holder<Biome>>> codec = ChunkSerializer.makeBiomeCodecRW(iregistry); // CraftBukkit - read/write
boolean flag2 = false; boolean flag2 = false;
@@ -133,7 +148,7 @@ public class ChunkSerializer {
DataResult dataresult;
for (int j = 0; j < nbttaglist.size(); ++j) { for (int j = 0; j < nbttaglist.size(); ++j) {
- CompoundTag nbttagcompound1 = nbttaglist.getCompound(j); - CompoundTag nbttagcompound1 = nbttaglist.getCompound(j);
@ -5249,7 +5251,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
byte b0 = nbttagcompound1.getByte("Y"); byte b0 = nbttagcompound1.getByte("Y");
int k = world.getSectionIndexFromSectionY(b0); int k = world.getSectionIndexFromSectionY(b0);
@@ -176,19 +191,39 @@ public class ChunkSerializer { @@ -169,19 +184,39 @@ public class ChunkSerializer {
boolean flag3 = nbttagcompound1.contains("BlockLight", 7); boolean flag3 = nbttagcompound1.contains("BlockLight", 7);
boolean flag4 = flag1 && nbttagcompound1.contains("SkyLight", 7); boolean flag4 = flag1 && nbttagcompound1.contains("SkyLight", 7);
@ -5297,7 +5299,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
} }
} }
@@ -217,6 +252,8 @@ public class ChunkSerializer { @@ -211,6 +246,8 @@ public class ChunkSerializer {
}, chunkPos); }, chunkPos);
object1 = new LevelChunk(world.getLevel(), chunkPos, chunkconverter, levelchunkticks, levelchunkticks1, l, achunksection, ChunkSerializer.postLoadChunk(world, nbt), blendingdata); object1 = new LevelChunk(world.getLevel(), chunkPos, chunkconverter, levelchunkticks, levelchunkticks1, l, achunksection, ChunkSerializer.postLoadChunk(world, nbt), blendingdata);
@ -5306,7 +5308,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
} else { } else {
ProtoChunkTicks<Block> protochunkticklist = ProtoChunkTicks.load(nbt.getList("block_ticks", 10), (s) -> { ProtoChunkTicks<Block> protochunkticklist = ProtoChunkTicks.load(nbt.getList("block_ticks", 10), (s) -> {
return BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(s)); return BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(s));
@@ -225,6 +262,8 @@ public class ChunkSerializer { @@ -219,6 +256,8 @@ public class ChunkSerializer {
return BuiltInRegistries.FLUID.getOptional(ResourceLocation.tryParse(s)); return BuiltInRegistries.FLUID.getOptional(ResourceLocation.tryParse(s));
}, chunkPos); }, chunkPos);
ProtoChunk protochunk = new ProtoChunk(chunkPos, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, world, iregistry, blendingdata); ProtoChunk protochunk = new ProtoChunk(chunkPos, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, world, iregistry, blendingdata);
@ -5315,7 +5317,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
object1 = protochunk; object1 = protochunk;
protochunk.setInhabitedTime(l); protochunk.setInhabitedTime(l);
@@ -346,6 +385,12 @@ public class ChunkSerializer { @@ -340,6 +379,12 @@ public class ChunkSerializer {
// CraftBukkit end // CraftBukkit end
public static CompoundTag write(ServerLevel world, ChunkAccess chunk) { public static CompoundTag write(ServerLevel world, ChunkAccess chunk) {
@ -5328,7 +5330,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
ChunkPos chunkcoordintpair = chunk.getPos(); ChunkPos chunkcoordintpair = chunk.getPos();
CompoundTag nbttagcompound = NbtUtils.addCurrentDataVersion(new CompoundTag()); CompoundTag nbttagcompound = NbtUtils.addCurrentDataVersion(new CompoundTag());
@@ -395,11 +440,14 @@ public class ChunkSerializer { @@ -389,11 +434,14 @@ public class ChunkSerializer {
for (int i = lightenginethreaded.getMinLightSection(); i < lightenginethreaded.getMaxLightSection(); ++i) { for (int i = lightenginethreaded.getMinLightSection(); i < lightenginethreaded.getMaxLightSection(); ++i) {
int j = chunk.getSectionIndexFromSectionY(i); int j = chunk.getSectionIndexFromSectionY(i);
boolean flag1 = j >= 0 && j < achunksection.length; boolean flag1 = j >= 0 && j < achunksection.length;
@ -5347,8 +5349,8 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
if (flag1) { if (flag1) {
LevelChunkSection chunksection = achunksection[j]; LevelChunkSection chunksection = achunksection[j];
@@ -414,13 +462,27 @@ public class ChunkSerializer { @@ -402,13 +450,27 @@ public class ChunkSerializer {
nbttagcompound1.put("biomes", (Tag) dataresult1.getOrThrow(false, logger1::error)); nbttagcompound1.put("biomes", (Tag) codec.encodeStart(NbtOps.INSTANCE, chunksection.getBiomes()).getOrThrow());
} }
- if (nibblearray != null && !nibblearray.isEmpty()) { - if (nibblearray != null && !nibblearray.isEmpty()) {
@ -5379,7 +5381,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
if (!nbttagcompound1.isEmpty()) { if (!nbttagcompound1.isEmpty()) {
nbttagcompound1.putByte("Y", (byte) i); nbttagcompound1.putByte("Y", (byte) i);
@@ -431,7 +493,8 @@ public class ChunkSerializer { @@ -419,7 +481,8 @@ public class ChunkSerializer {
nbttagcompound.put("sections", nbttaglist); nbttagcompound.put("sections", nbttaglist);
if (flag) { if (flag) {
@ -5389,7 +5391,7 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
} }
ListTag nbttaglist1 = new ListTag(); ListTag nbttaglist1 = new ListTag();
@@ -505,6 +568,17 @@ public class ChunkSerializer { @@ -493,6 +556,17 @@ public class ChunkSerializer {
})); }));
} }
@ -5404,14 +5406,14 @@ index 85de64c1e75e1323f8425fc53e525c215ff417ce..c6115477cc94bf47a5f459418a232412
+ } + }
+ // Paper end + // Paper end
+ +
public static ChunkStatus.ChunkType getChunkTypeFromTag(@Nullable CompoundTag nbt) { public static ChunkType getChunkTypeFromTag(@Nullable CompoundTag nbt) {
return nbt != null ? ChunkStatus.byName(nbt.getString("Status")).getChunkType() : ChunkStatus.ChunkType.PROTOCHUNK; return nbt != null ? ChunkStatus.byName(nbt.getString("Status")).getChunkType() : ChunkType.PROTOCHUNK;
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 35cc9bc399386344c1acc6446262d278d57febd0..93c10b5a699f4f8a8aa97a0f666999fc4a495a5b 100644 index cb48090de2f9912ed5abd03a543a33452fc83f8e..25ccbeace5bfc10fe3c885ea8dd984b08b4668ae 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -497,12 +497,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -499,12 +499,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
} }
} }