From c1bbde4bc66cae0162b9e58d172bdd21448bb50c Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 7 Jun 2023 20:03:53 +0200 Subject: [PATCH] Let's hope this is fine --- patches/server/0010-Adventure.patch | 41 +- .../0015-Rewrite-dataconverter-system.patch | 859 ++++++++++++++++-- .../server/0016-Starlight.patch | 260 +++--- .../server/0017-Add-TickThread.patch | 0 4 files changed, 944 insertions(+), 216 deletions(-) rename patches/{unapplied => }/server/0015-Rewrite-dataconverter-system.patch (98%) rename patches/{unapplied => }/server/0016-Starlight.patch (96%) rename patches/{unapplied => }/server/0017-Add-TickThread.patch (100%) diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index 7cfc22ae61..6e21af8f59 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -2533,7 +2533,7 @@ index 1cb95db25a20d38faacd99a5805630c1598e9db3..d99b2235038eb1aba8cda474c4aa51e2 @Override diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index c48318d9d5882dd87e423aecf27c31994af42bdb..e65c889dd1a84a1a8959d1cb80a8c233c3600a6f 100644 +index c48318d9d5882dd87e423aecf27c31994af42bdb..77e5b1725a6b8264c098ab91aaf87ae19aedd145 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -8,6 +8,7 @@ import com.mojang.logging.LogUtils; @@ -2578,6 +2578,15 @@ index c48318d9d5882dd87e423aecf27c31994af42bdb..e65c889dd1a84a1a8959d1cb80a8c233 } // CraftBukkit end +@@ -513,7 +513,7 @@ public abstract class PlayerList { + + } + +- public String remove(ServerPlayer entityplayer) { // CraftBukkit - return string ++ public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component + ServerLevel worldserver = entityplayer.serverLevel(); + + entityplayer.awardStat(Stats.LEAVE_GAME); @@ -524,7 +524,7 @@ public abstract class PlayerList { entityplayer.closeContainer(); } @@ -2784,7 +2793,7 @@ index 4c62df5a3781ec9df4a5c5f1b528649e6e8a62d1..affd1b8c7589ba59330dc0b6fc803cce } diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -index 8e35fecb84fb9ed61cb31d218f8a21bb7cabeb48..5ba1c6a8e266883a1342815ec54f13df9054165b 100644 +index 8e35fecb84fb9ed61cb31d218f8a21bb7cabeb48..41c863a104d53b6c6feb4576d5b62cead229efec 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java @@ -185,6 +185,7 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C @@ -2795,6 +2804,34 @@ index 8e35fecb84fb9ed61cb31d218f8a21bb7cabeb48..5ba1c6a8e266883a1342815ec54f13df ((ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit } } +@@ -208,20 +209,22 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C + + // CraftBukkit start + Player player1 = ((ServerPlayer) player).getBukkitEntity(); +- String[] lines = new String[4]; ++ // Paper start ++ List lines = new java.util.ArrayList<>(); + + for (int j = 0; j < messages.size(); ++j) { +- lines[j] = CraftChatMessage.fromComponent(text.getMessage(j, player.isTextFilteringEnabled())); ++ lines.add(io.papermc.paper.adventure.PaperAdventure.asAdventure(text.getMessage(j, player.isTextFilteringEnabled()))); + } + + SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player1, lines); + player.level().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { +- Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); +- for (int j = 0; j < components.length; j++) { +- text = text.setMessage(j, components[j]); ++ // Paper start ++ for (int j = 0; j < 4; j++) { ++ text = text.setMessage(j, io.papermc.paper.adventure.PaperAdventure.asVanilla(lines.get(j))); + } ++ // Paper end + } + // CraftBukkit end + } diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java index 614e567eb1ef10ac7514909a8425e29ac3627d3d..60596c4ac2ebb8caf19d65591624275ba63b0199 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java diff --git a/patches/unapplied/server/0015-Rewrite-dataconverter-system.patch b/patches/server/0015-Rewrite-dataconverter-system.patch similarity index 98% rename from patches/unapplied/server/0015-Rewrite-dataconverter-system.patch rename to patches/server/0015-Rewrite-dataconverter-system.patch index 66028568bf..6109694a0d 100644 --- a/patches/unapplied/server/0015-Rewrite-dataconverter-system.patch +++ b/patches/server/0015-Rewrite-dataconverter-system.patch @@ -196,10 +196,10 @@ index 0000000000000000000000000000000000000000..dde9d36bf6212196caa18f3c9c535aec +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java new file mode 100644 -index 0000000000000000000000000000000000000000..935a6de27ccde911ae95707b5b35d58bba8a3fd0 +index 0000000000000000000000000000000000000000..9ab4cb833c65d086122fc835217ce4708eebe039 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java -@@ -0,0 +1,370 @@ +@@ -0,0 +1,380 @@ +package ca.spottedleaf.dataconverter.minecraft; + +import ca.spottedleaf.dataconverter.converters.DataConverter; @@ -408,8 +408,17 @@ index 0000000000000000000000000000000000000000..935a6de27ccde911ae95707b5b35d58b + 3209, + 3214, + 3319, -+ 3322 -+ // All up to 1.19.4 ++ 3322, ++ 3438, ++ 3439, ++ 3440, ++ 3441, ++ 3447, ++ 3448, ++ 3450, ++ 3451, ++ 3459 ++ // All up to 1.20-rc1 + }; + Arrays.sort(converterVersions); + @@ -440,7 +449,8 @@ index 0000000000000000000000000000000000000000..935a6de27ccde911ae95707b5b35d58b + // final release of major version + registerBreakpoint(MCVersions.V1_18_2, Integer.MAX_VALUE); + -+ ++ // final release of major version ++ registerBreakpoint(MCVersions.V1_19_4, Integer.MAX_VALUE); + } + + static { @@ -572,10 +582,10 @@ index 0000000000000000000000000000000000000000..935a6de27ccde911ae95707b5b35d58b +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java new file mode 100644 -index 0000000000000000000000000000000000000000..e8f11bd4b707f8276ceda29bd16058cb1861e79e +index 0000000000000000000000000000000000000000..dc62351262dc6e53935795ff0c5d03e3020f5ee2 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java -@@ -0,0 +1,457 @@ +@@ -0,0 +1,471 @@ +package ca.spottedleaf.dataconverter.minecraft; + +@SuppressWarnings("unused") @@ -1031,6 +1041,20 @@ index 0000000000000000000000000000000000000000..e8f11bd4b707f8276ceda29bd16058cb + public static final int V1_19_4_RC2 = 3335; + public static final int V1_19_4_RC3 = 3336; + public static final int V1_19_4 = 3337; ++ public static final int V23W12A = 3442; ++ public static final int V23W13A = 3443; ++ public static final int V23W14A = 3445; ++ public static final int V23W16A = 3449; ++ public static final int V23W17A = 3452; ++ public static final int V23W19A = 3453; ++ public static final int V1_20_PRE1 = 3454; ++ public static final int V1_20_PRE2 = 3455; ++ public static final int V1_20_PRE3 = 3456; ++ public static final int V1_20_PRE4 = 3457; ++ public static final int V1_20_PRE5 = 3458; ++ public static final int V1_20_PRE6 = 3460; ++ public static final int V1_20_PRE7 = 3461; ++ public static final int V1_20_RC1 = 3462; + +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/advancements/ConverterAbstractAdvancementsRename.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/advancements/ConverterAbstractAdvancementsRename.java @@ -2218,7 +2242,7 @@ index 0000000000000000000000000000000000000000..300c2d14818b1e0cfe7341aba573ec75 +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/entity/ConverterAbstractEntityRename.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/entity/ConverterAbstractEntityRename.java new file mode 100644 -index 0000000000000000000000000000000000000000..06c075e643415d98b73734b749d9043091ebf9e5 +index 0000000000000000000000000000000000000000..6684915d6c0c44328a9296dc3ceb530e69482083 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/entity/ConverterAbstractEntityRename.java @@ -0,0 +1,38 @@ @@ -2239,7 +2263,7 @@ index 0000000000000000000000000000000000000000..06c075e643415d98b73734b749d90430 + } + + public static void register(final int version, final int subVersion, final Function renamer) { -+ MCTypeRegistry.ENTITY.addStructureConverter(new DataConverter<>(version) { ++ MCTypeRegistry.ENTITY.addStructureConverter(new DataConverter<>(version, subVersion) { + @Override + public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { + final String id = data.getString("id"); @@ -5291,10 +5315,10 @@ index 0000000000000000000000000000000000000000..5008c6d28b7f9b730bfaf257a264edcb +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/helpers/RenameHelper.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/helpers/RenameHelper.java new file mode 100644 -index 0000000000000000000000000000000000000000..d1d99bec73595d49eadf0fdeb8d3999ced38762a +index 0000000000000000000000000000000000000000..051b44ea226db849faf821567f0b5321d360fe45 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/helpers/RenameHelper.java -@@ -0,0 +1,63 @@ +@@ -0,0 +1,89 @@ +package ca.spottedleaf.dataconverter.minecraft.converters.helpers; + +import ca.spottedleaf.dataconverter.types.MapType; @@ -5307,6 +5331,10 @@ index 0000000000000000000000000000000000000000..d1d99bec73595d49eadf0fdeb8d3999c + // assumes no two or more entries are renamed to a single value, otherwise result will be only one of them will win + // and there is no defined winner in such a case + public static void renameKeys(final MapType data, final Function renamer) { ++ if (data == null) { ++ return; ++ } ++ + List newKeys = null; + List newValues = null; + boolean needsRename = false; @@ -5348,6 +5376,10 @@ index 0000000000000000000000000000000000000000..d1d99bec73595d49eadf0fdeb8d3999c + + // Clobbers anything in toKey if fromKey exists + public static void renameSingle(final MapType data, final String fromKey, final String toKey) { ++ if (data == null) { ++ return; ++ } ++ + final Object value = data.getGeneric(fromKey); + if (value != null) { + data.remove(fromKey); @@ -5355,6 +5387,24 @@ index 0000000000000000000000000000000000000000..d1d99bec73595d49eadf0fdeb8d3999c + } + } + ++ public static void renameString(final MapType data, final String key, final Function renamer) { ++ if (data == null) { ++ return; ++ } ++ ++ final String value = data.getString(key); ++ if (value == null) { ++ return; ++ } ++ ++ final String renamed = renamer.apply(value); ++ if (renamed == null) { ++ return; ++ } ++ ++ data.setString(key, renamed); ++ } ++ + private RenameHelper() {} + +} @@ -6598,10 +6648,10 @@ index 0000000000000000000000000000000000000000..76a6e3efa5c69150e8f5e0063cb6357b +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java new file mode 100644 -index 0000000000000000000000000000000000000000..ef056d156e21a403136bae49597fb86a978c29c5 +index 0000000000000000000000000000000000000000..609c9f21fb90aa74ceeefbeaeed4b000ea966a88 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java -@@ -0,0 +1,248 @@ +@@ -0,0 +1,259 @@ +package ca.spottedleaf.dataconverter.minecraft.datatypes; + +import ca.spottedleaf.dataconverter.minecraft.versions.*; @@ -6638,6 +6688,7 @@ index 0000000000000000000000000000000000000000..ef056d156e21a403136bae49597fb86a + public static final MCValueType BIOME = new MCValueType("Biome"); + public static final MCDataType WORLD_GEN_SETTINGS = new MCDataType("WorldGenSettings"); + public static final MCValueType GAME_EVENT_NAME = new MCValueType("GameEventName"); ++ public static final MCValueType MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST = new MCValueType("MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST"); + + static { + try { @@ -6846,6 +6897,16 @@ index 0000000000000000000000000000000000000000..ef056d156e21a403136bae49597fb86a + V3326.register(); + V3327.register(); + V3328.register(); ++ // V1.20 ++ V3438.register(); ++ V3439.register(); ++ V3440.register(); ++ V3441.register(); ++ V3447.register(); ++ V3448.register(); ++ V3450.register(); ++ V3451.register(); ++ V3459.register(); + } + + private MCTypeRegistry() {} @@ -6944,10 +7005,10 @@ index 0000000000000000000000000000000000000000..13c1381261909ef672fbeb665907f01f +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/hooks/DataHookEnforceNamespacedID.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/hooks/DataHookEnforceNamespacedID.java new file mode 100644 -index 0000000000000000000000000000000000000000..26a03007a4386ff037a1ae50045d0c44dd438235 +index 0000000000000000000000000000000000000000..f7dced8a47ebdd262ae815ff9bc453312343ce49 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/hooks/DataHookEnforceNamespacedID.java -@@ -0,0 +1,35 @@ +@@ -0,0 +1,29 @@ +package ca.spottedleaf.dataconverter.minecraft.hooks; + +import ca.spottedleaf.dataconverter.converters.datatypes.DataHook; @@ -6968,13 +7029,7 @@ index 0000000000000000000000000000000000000000..26a03007a4386ff037a1ae50045d0c44 + + @Override + public MapType preHook(final MapType data, final long fromVersion, final long toVersion) { -+ final String id = data.getString(this.path); -+ if (id != null) { -+ final String replace = NamespaceUtil.correctNamespaceOrNull(id); -+ if (replace != null) { -+ data.setString(this.path, replace); -+ } -+ } ++ NamespaceUtil.enforceForPath(data, this.path); + return null; + } + @@ -15428,10 +15483,10 @@ index 0000000000000000000000000000000000000000..d28ade80499dce882a9a84309a2a0da5 +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V2832.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V2832.java new file mode 100644 -index 0000000000000000000000000000000000000000..95a306d6cc5b4ac8161d5bed80b6a7073b3e914e +index 0000000000000000000000000000000000000000..1569cf06aa1dd73961d053a57722aac4c36a4148 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V2832.java -@@ -0,0 +1,920 @@ +@@ -0,0 +1,927 @@ +package ca.spottedleaf.dataconverter.minecraft.versions; + +import ca.spottedleaf.dataconverter.converters.DataConverter; @@ -15963,7 +16018,7 @@ index 0000000000000000000000000000000000000000..95a306d6cc5b4ac8161d5bed80b6a707 + } + + case "minecraft:multi_noise": { -+ // preset is absent, no type for namespaced string ++ WalkerUtils.convert(MCTypeRegistry.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, biomeSource, "preset", fromVersion, toVersion); + + // Vanilla's schema is _still_ wrong. It should be DSL.fields("biomes", DSL.list(DSL.fields("biome"))) + // But it just contains the list part. That obviously can never be the case, because @@ -15975,6 +16030,7 @@ index 0000000000000000000000000000000000000000..95a306d6cc5b4ac8161d5bed80b6a707 + WalkerUtils.convert(MCTypeRegistry.BIOME, biomes.getMap(i), "biome", fromVersion, toVersion); + } + } ++ + break; + } + @@ -16088,6 +16144,12 @@ index 0000000000000000000000000000000000000000..95a306d6cc5b4ac8161d5bed80b6a707 + } + + offsetHeightmaps(level); ++ // Difference from DFU: Still convert the Lights data. Just because it's being removed in a later version doesn't mean ++ // that it should be removed here. ++ // Generally, converters act only on the current version to bring it to the next. This principle allows the converter ++ // for the next version to assume that it acts on its current version, not some in-between of the current version ++ // and some future version that did not exist at the time it was written. This allows converters to be written and tested ++ // only with knowledge of the current version and the next version. + addEmptyListPadding(level, "Lights"); + addEmptyListPadding(level, "LiquidsToBeTicked"); + addEmptyListPadding(level, "PostProcessing"); @@ -17448,75 +17510,31 @@ index 0000000000000000000000000000000000000000..8cc7cadb921d52ebb5b8ed2507814553 +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3088.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3088.java new file mode 100644 -index 0000000000000000000000000000000000000000..d21124f6e70c887b9ca67305c8b0c1f4668af8e2 +index 0000000000000000000000000000000000000000..fb1af7826dd01fd6f5cfe2ad11ba63b934675d31 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3088.java -@@ -0,0 +1,67 @@ +@@ -0,0 +1,23 @@ +package ca.spottedleaf.dataconverter.minecraft.versions; + -+import ca.spottedleaf.dataconverter.converters.DataConverter; +import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.converters.chunk.ConverterAddBlendingData; +import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; -+import ca.spottedleaf.dataconverter.types.MapType; -+import ca.spottedleaf.dataconverter.types.Types; -+import ca.spottedleaf.dataconverter.util.NamespaceUtil; -+import java.util.Arrays; -+import java.util.HashSet; -+import java.util.Set; + +public final class V3088 { + + // this class originally targeted 3079 but was changed to target a later version without changing the converter, zero clue why ++ // this class then targeted 3088 but was changed to target 3441 ++ // to maintain integrity of the data version, I chose to extract the converter to a separate class and use it in both versions ++ // the reason it is important to never change old converters once released is that it creates _two_ versions under the same id. ++ // Consider the case where a user force upgrades their world, but does not load the chunk. Then, consider the case where ++ // the user does not force upgrade their world. Then, Mojang comes along and makes a decision like this and now both ++ // players load the chunk - they went through a different conversion process, which ultimately creates two versions. ++ // Unfortunately this fix doesn't exactly resolve it, as anyone running Mojang's converters will now be different ++ // from DataConverter's. It's broadly a dumb situation all around that could be avoided if Mojang wasn't being careless here. + protected static final int VERSION = MCVersions.V22W14A; + -+ private static final Set STATUSES_TO_SKIP_BLENDING = new HashSet<>( -+ Arrays.asList( -+ "minecraft:empty", -+ "minecraft:structure_starts", -+ "minecraft:structure_references", -+ "minecraft:biomes" -+ ) -+ ); -+ + public static void register() { -+ MCTypeRegistry.CHUNK.addStructureConverter(new DataConverter<>(VERSION) { -+ -+ private static MapType createBlendingData(final int height, final int minY) { -+ final MapType ret = Types.NBT.createEmptyMap(); -+ -+ ret.setInt("min_section", minY >> 4); -+ ret.setInt("max_section", (minY + height) >> 4); -+ -+ return ret; -+ } -+ -+ @Override -+ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { -+ data.remove("blending_data"); -+ final MapType context = data.getMap("__context"); -+ if (!"minecraft:overworld".equals(context == null ? null : context.getString("dimension"))) { -+ return null; -+ } -+ -+ final String status = NamespaceUtil.correctNamespace(data.getString("Status")); -+ if (status == null) { -+ return null; -+ } -+ -+ final MapType belowZeroRetrogen = data.getMap("below_zero_retrogen"); -+ -+ if (!STATUSES_TO_SKIP_BLENDING.contains(status)) { -+ data.setMap("blending_data", createBlendingData(384, -64)); -+ } else if (belowZeroRetrogen != null) { -+ final String realStatus = NamespaceUtil.correctNamespace(belowZeroRetrogen.getString("target_status", "empty")); -+ if (!STATUSES_TO_SKIP_BLENDING.contains(realStatus)) { -+ data.setMap("blending_data", createBlendingData(256, 0)); -+ } -+ } -+ -+ return null; -+ } -+ }); ++ MCTypeRegistry.CHUNK.addStructureConverter(new ConverterAddBlendingData(VERSION)); + } +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3090.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3090.java @@ -18396,10 +18414,10 @@ index 0000000000000000000000000000000000000000..88d9c0fcd88ccfd6d6b46ae050914079 +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V704.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V704.java new file mode 100644 -index 0000000000000000000000000000000000000000..2986cc9ae9d62902a15ce26d89c4b6fd807359eb +index 0000000000000000000000000000000000000000..3beb53d9dc3be46351fec95afa85bfd712bbb00a --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V704.java -@@ -0,0 +1,387 @@ +@@ -0,0 +1,395 @@ +package ca.spottedleaf.dataconverter.minecraft.versions; + +import ca.spottedleaf.dataconverter.converters.DataConverter; @@ -18556,6 +18574,7 @@ index 0000000000000000000000000000000000000000..2986cc9ae9d62902a15ce26d89c4b6fd + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:bee_nest", "minecraft:beehive"); + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:beehive", "minecraft:beehive"); + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:sculk_sensor", "minecraft:sculk_sensor"); ++ ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:decorated_pot", "minecraft:decorated_pot"); + + // These are missing from Vanilla (TODO check on update) + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:enchanting_table", "minecraft:enchanting_table"); @@ -18579,10 +18598,11 @@ index 0000000000000000000000000000000000000000..2986cc9ae9d62902a15ce26d89c4b6fd + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:crimson_hanging_sign", "minecraft:sign"); + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:warped_hanging_sign", "minecraft:sign"); + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:piglin_head", "minecraft:skull"); -+ ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:suspicious_sand", "minecraft:suspicious_sand"); -+ ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:decorated_pot", "minecraft:decorated_pot"); ++ ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:suspicious_sand", "minecraft:brushable_block"); // note: this was renamed in the past, see special case in the itemstack walker + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:cherry_sign", "minecraft:sign"); + ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:cherry_hanging_sign", "minecraft:sign"); ++ ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:suspicious_gravel", "minecraft:brushable_block"); ++ ITEM_ID_TO_TILE_ENTITY_ID.put("minecraft:calibrated_sculk_sensor", "minecraft:calibrated_sculk_sensor"); + } + + // This class is responsible for also integrity checking the item id to tile id map here, we just use the item registry to figure it out @@ -18752,7 +18772,13 @@ index 0000000000000000000000000000000000000000..2986cc9ae9d62902a15ce26d89c4b6fd + MapType blockEntityTag = tag.getMap("BlockEntityTag"); + if (blockEntityTag != null) { + final String itemId = data.getString("id"); -+ final String entityId = ITEM_ID_TO_TILE_ENTITY_ID.get(itemId); ++ final String entityId; ++ if ("minecraft:suspicious_sand".equals(itemId) && fromVersion < V3438.VERSION) { ++ // renamed after this version, and since the id is a mapping to just string we need to special case this ++ entityId = "minecraft:suspicious_sand"; ++ } else { ++ entityId = ITEM_ID_TO_TILE_ENTITY_ID.get(itemId); ++ } + final boolean removeId; + if (entityId == null) { + if (!"minecraft:air".equals(itemId)) { @@ -23071,18 +23097,33 @@ index 0000000000000000000000000000000000000000..6f634c8825589a23f46ad7b54354475c +} diff --git a/src/main/java/ca/spottedleaf/dataconverter/util/NamespaceUtil.java b/src/main/java/ca/spottedleaf/dataconverter/util/NamespaceUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..967ad1186cbc81a76a4958ea99d4eff37c15b48f +index 0000000000000000000000000000000000000000..5a6536377c9c1e1753e930ff2a6bb98ea57055c7 --- /dev/null +++ b/src/main/java/ca/spottedleaf/dataconverter/util/NamespaceUtil.java -@@ -0,0 +1,24 @@ +@@ -0,0 +1,39 @@ +package ca.spottedleaf.dataconverter.util; + ++import ca.spottedleaf.dataconverter.types.MapType; +import net.minecraft.resources.ResourceLocation; + +public final class NamespaceUtil { + + private NamespaceUtil() {} + ++ public static void enforceForPath(final MapType data, final String path) { ++ if (data == null) { ++ return; ++ } ++ ++ final String id = data.getString(path); ++ if (id != null) { ++ final String replace = NamespaceUtil.correctNamespaceOrNull(id); ++ if (replace != null) { ++ data.setString(path, replace); ++ } ++ } ++ } ++ + public static String correctNamespace(final String value) { + if (value == null) { + return null; @@ -23099,12 +23140,648 @@ index 0000000000000000000000000000000000000000..967ad1186cbc81a76a4958ea99d4eff3 + return correct.equals(value) ? null : correct; + } +} +diff --git a/src/main/java/ca/spottedleaf/minecraft/converters/chunk/ConverterAddBlendingData.java b/src/main/java/ca/spottedleaf/minecraft/converters/chunk/ConverterAddBlendingData.java +new file mode 100644 +index 0000000000000000000000000000000000000000..52b1ec0f7027bced865a68c79d547aecb0319e0c +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/converters/chunk/ConverterAddBlendingData.java +@@ -0,0 +1,65 @@ ++package ca.spottedleaf.minecraft.converters.chunk; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.types.MapType; ++import ca.spottedleaf.dataconverter.types.Types; ++import ca.spottedleaf.dataconverter.util.NamespaceUtil; ++import java.util.Arrays; ++import java.util.HashSet; ++import java.util.Set; ++ ++public final class ConverterAddBlendingData extends DataConverter, MapType> { ++ ++ private static final Set STATUSES_TO_SKIP_BLENDING = new HashSet<>( ++ Arrays.asList( ++ "minecraft:empty", ++ "minecraft:structure_starts", ++ "minecraft:structure_references", ++ "minecraft:biomes" ++ ) ++ ); ++ ++ public ConverterAddBlendingData(final int toVersion) { ++ super(toVersion); ++ } ++ ++ public ConverterAddBlendingData(final int toVersion, final int versionStep) { ++ super(toVersion, versionStep); ++ } ++ ++ private static MapType createBlendingData(final int height, final int minY) { ++ final MapType ret = Types.NBT.createEmptyMap(); ++ ++ ret.setInt("min_section", minY >> 4); ++ ret.setInt("max_section", (minY + height) >> 4); ++ ++ return ret; ++ } ++ ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ data.remove("blending_data"); ++ final MapType context = data.getMap("__context"); ++ if (!"minecraft:overworld".equals(context == null ? null : context.getString("dimension"))) { ++ return null; ++ } ++ ++ final String status = NamespaceUtil.correctNamespace(data.getString("Status")); ++ if (status == null) { ++ return null; ++ } ++ ++ final MapType belowZeroRetrogen = data.getMap("below_zero_retrogen"); ++ ++ if (!STATUSES_TO_SKIP_BLENDING.contains(status)) { ++ data.setMap("blending_data", createBlendingData(384, -64)); ++ } else if (belowZeroRetrogen != null) { ++ final String realStatus = NamespaceUtil.correctNamespace(belowZeroRetrogen.getString("target_status", "empty")); ++ if (!STATUSES_TO_SKIP_BLENDING.contains(realStatus)) { ++ data.setMap("blending_data", createBlendingData(256, 0)); ++ } ++ } ++ ++ return null; ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/converters/chunk/ConverterRenameStatus.java b/src/main/java/ca/spottedleaf/minecraft/converters/chunk/ConverterRenameStatus.java +new file mode 100644 +index 0000000000000000000000000000000000000000..797a8641b96a213dc1e8cabb7ca711c0042c09c6 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/converters/chunk/ConverterRenameStatus.java +@@ -0,0 +1,32 @@ ++package ca.spottedleaf.minecraft.converters.chunk; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper; ++import ca.spottedleaf.dataconverter.types.MapType; ++import ca.spottedleaf.dataconverter.util.NamespaceUtil; ++import java.util.function.Function; ++ ++public final class ConverterRenameStatus extends DataConverter, MapType> { ++ ++ private final Function renamer; ++ ++ public ConverterRenameStatus(final int toVersion, final Function renamer) { ++ this(toVersion, 0, renamer); ++ } ++ ++ public ConverterRenameStatus(final int toVersion, final int versionStep, final Function renamer) { ++ super(toVersion, versionStep); ++ this.renamer = renamer; ++ } ++ ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ // Note: DFU technically enforces namespace due to how they wrote their converter, so we will do the same. ++ NamespaceUtil.enforceForPath(data, "Status"); ++ RenameHelper.renameString(data, "Status", this.renamer); ++ ++ NamespaceUtil.enforceForPath(data.getMap("below_zero_retrogen"), "target_status"); ++ RenameHelper.renameString(data.getMap("below_zero_retrogen"), "target_status", this.renamer); ++ return null; ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/converters/leveldat/ConverterRemoveFeatureFlag.java b/src/main/java/ca/spottedleaf/minecraft/converters/leveldat/ConverterRemoveFeatureFlag.java +new file mode 100644 +index 0000000000000000000000000000000000000000..3f23a3e560abc174b570ff4dabf68813d5b73858 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/converters/leveldat/ConverterRemoveFeatureFlag.java +@@ -0,0 +1,46 @@ ++package ca.spottedleaf.minecraft.converters.leveldat; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.types.ListType; ++import ca.spottedleaf.dataconverter.types.MapType; ++import ca.spottedleaf.dataconverter.types.ObjectType; ++import java.util.Set; ++ ++public final class ConverterRemoveFeatureFlag extends DataConverter, MapType> { ++ ++ private final Set flags; ++ ++ public ConverterRemoveFeatureFlag(final int toVersion, final Set flags) { ++ this(toVersion, 0, flags); ++ } ++ ++ public ConverterRemoveFeatureFlag(final int toVersion, final int versionStep, final Set flags) { ++ super(toVersion, versionStep); ++ this.flags = flags; ++ } ++ ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ final ListType enabledFeatures = data.getList("enabled_features", ObjectType.STRING); ++ if (enabledFeatures == null) { ++ return null; ++ } ++ ++ ListType removedFeatures = null; ++ ++ for (int i = 0; i < enabledFeatures.size(); ++i) { ++ final String flag = enabledFeatures.getString(i); ++ if (!this.flags.contains(flag)) { ++ continue; ++ } ++ enabledFeatures.remove(i--); ++ ++ if (removedFeatures == null) { ++ removedFeatures = data.getOrCreateList("removed_features", ObjectType.STRING); ++ } ++ removedFeatures.addString(flag); ++ } ++ ++ return null; ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/converters/tileentity/ConverterAbstractTileEntityRename.java b/src/main/java/ca/spottedleaf/minecraft/converters/tileentity/ConverterAbstractTileEntityRename.java +new file mode 100644 +index 0000000000000000000000000000000000000000..976108d0c3da1994545270507926c7de7612a51f +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/converters/tileentity/ConverterAbstractTileEntityRename.java +@@ -0,0 +1,34 @@ ++package ca.spottedleaf.minecraft.converters.tileentity; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.types.MapType; ++import java.util.function.Function; ++ ++public final class ConverterAbstractTileEntityRename { ++ ++ public static void register(final int version, final Function renamer) { ++ register(version, 0, renamer); ++ } ++ ++ public static void register(final int version, final int subVersion, final Function renamer) { ++ MCTypeRegistry.TILE_ENTITY.addStructureConverter(new DataConverter<>(version, subVersion) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ final String id = data.getString("id"); ++ if (id == null) { ++ return null; ++ } ++ ++ final String converted = renamer.apply(id); ++ ++ if (converted != null) { ++ data.setString("id", converted); ++ } ++ ++ return null; ++ } ++ }); ++ } ++ ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3438.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3438.java +new file mode 100644 +index 0000000000000000000000000000000000000000..d7097e7fc3301b5613580337917c91b6ed4fab42 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3438.java +@@ -0,0 +1,45 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper; ++import ca.spottedleaf.dataconverter.minecraft.converters.itemname.ConverterAbstractItemRename; ++import ca.spottedleaf.minecraft.converters.tileentity.ConverterAbstractTileEntityRename; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.types.MapType; ++ ++import java.util.HashMap; ++import java.util.Map; ++ ++public final class V3438 { ++ ++ public static final int VERSION = MCVersions.V1_19_4 + 101; ++ ++ public static void register() { ++ // brushable block rename ++ MCTypeRegistry.TILE_ENTITY.copyWalkers(VERSION,"minecraft:suspicious_sand", "minecraft:brushable_block"); ++ ++ ConverterAbstractTileEntityRename.register(VERSION, new HashMap<>(Map.of( ++ "minecraft:suspicious_sand", "minecraft:brushable_block" ++ ))::get); ++ ++ ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:brushable_block", new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ RenameHelper.renameSingle(data, "loot_table", "LootTable"); ++ RenameHelper.renameSingle(data, "loot_table_seed", "LootTableSeed"); ++ return null; ++ } ++ }); ++ ++ ConverterAbstractItemRename.register(VERSION, new HashMap<>( ++ Map.of( ++ "minecraft:pottery_shard_archer", "minecraft:archer_pottery_shard", ++ "minecraft:pottery_shard_prize", "minecraft:prize_pottery_shard", ++ "minecraft:pottery_shard_arms_up", "minecraft:arms_up_pottery_shard", ++ "minecraft:pottery_shard_skull", "minecraft:skull_pottery_shard" ++ ) ++ )::get); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3439.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3439.java +new file mode 100644 +index 0000000000000000000000000000000000000000..043c4e402a5ba2182c07df60414aa43da0cd7822 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3439.java +@@ -0,0 +1,65 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.types.ListType; ++import ca.spottedleaf.dataconverter.types.MapType; ++import net.minecraft.network.chat.CommonComponents; ++import net.minecraft.network.chat.Component; ++ ++public final class V3439 { ++ ++ private static final int VERSION = MCVersions.V1_19_4 + 102; ++ ++ public static void register() { ++ final DataConverter, MapType> signTileUpdater = new DataConverter<>(VERSION) { ++ private static final String BLANK_TEXT_LINE = Component.Serializer.toJson(CommonComponents.EMPTY); ++ private static final String DEFAULT_COLOR = "black"; ++ ++ private static ListType migrateToList(final MapType root, final String prefix) { ++ if (root == null) { ++ return null; ++ } ++ ++ final ListType ret = root.getTypeUtil().createEmptyList(); ++ ++ ret.addString(root.getString(prefix.concat("1"), BLANK_TEXT_LINE)); ++ ret.addString(root.getString(prefix.concat("2"), BLANK_TEXT_LINE)); ++ ret.addString(root.getString(prefix.concat("3"), BLANK_TEXT_LINE)); ++ ret.addString(root.getString(prefix.concat("4"), BLANK_TEXT_LINE)); ++ ++ return ret; ++ } ++ ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ final MapType frontText = data.getTypeUtil().createEmptyMap(); ++ data.setMap("front_text", frontText); ++ ++ frontText.setList("messages", migrateToList(data, "Text")); ++ frontText.setList("filtered_messages", migrateToList(data, "FilteredText")); ++ frontText.setString("color", data.getString("Color", DEFAULT_COLOR)); ++ frontText.setBoolean("has_glowing_text", data.getBoolean("GlowingText", false)); ++ ++ final MapType backText = data.getTypeUtil().createEmptyMap(); ++ data.setMap("back_text", backText); ++ ++ final ListType blankMessages = data.getTypeUtil().createEmptyList(); ++ for (int i = 0; i < 4; ++i) { ++ blankMessages.addString(BLANK_TEXT_LINE); ++ } ++ ++ backText.setList("messages", blankMessages); ++ backText.setList("filtered_messages", blankMessages.copy()); // need to copy so that the value isn't mapped to twice, so that updates to one do not reflect in the other ++ backText.setString("color", DEFAULT_COLOR); ++ backText.setBoolean("has_glowing_text", false); ++ ++ return null; ++ } ++ }; ++ ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:sign", signTileUpdater); ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:hanging_sign", signTileUpdater); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3440.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3440.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0f7db5ca038463c239331129ad65ade72d84d00d +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3440.java +@@ -0,0 +1,27 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.converters.helpers.ConverterAbstractStringValueTypeRename; ++import ca.spottedleaf.minecraft.converters.leveldat.ConverterRemoveFeatureFlag; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.util.NamespaceUtil; ++ ++import java.util.Arrays; ++import java.util.HashSet; ++ ++public final class V3440 { ++ ++ private static final int VERSION = MCVersions.V1_19_4 + 103; ++ ++ public static void register() { ++ // Note: MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST is namespaced string ++ ConverterAbstractStringValueTypeRename.register(VERSION, MCTypeRegistry.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, (final String in) -> { ++ return "minecraft:overworld_update_1_20".equals(NamespaceUtil.correctNamespace(in)) ? "minecraft:overworld" : null; ++ }); ++ MCTypeRegistry.LEVEL.addStructureConverter(new ConverterRemoveFeatureFlag(VERSION, new HashSet<>( ++ Arrays.asList( ++ "minecraft:update_1_20" ++ ) ++ ))); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3441.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3441.java +new file mode 100644 +index 0000000000000000000000000000000000000000..76daaf291d7e09967c8f6500022c46d59f95b587 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3441.java +@@ -0,0 +1,15 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.minecraft.converters.chunk.ConverterAddBlendingData; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++ ++public final class V3441 { ++ ++ private static final int VERSION = MCVersions.V1_19_4 + 104; ++ ++ public static void register() { ++ // See V3088 for why this converter is duplicated here and in V3088 ++ MCTypeRegistry.CHUNK.addStructureConverter(new ConverterAddBlendingData(VERSION)); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3447.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3447.java +new file mode 100644 +index 0000000000000000000000000000000000000000..dec73b30d269ce03fb622a64b161377ddaf4b79d +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3447.java +@@ -0,0 +1,47 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.converters.itemname.ConverterAbstractItemRename; ++import java.util.HashMap; ++import java.util.Map; ++ ++public final class V3447 { ++ ++ private static final int VERSION = MCVersions.V23W14A + 2; ++ ++ public static void register() { ++ final String[] targets = new String[] { ++ "minecraft:angler_pottery_shard", ++ "minecraft:archer_pottery_shard", ++ "minecraft:arms_up_pottery_shard", ++ "minecraft:blade_pottery_shard", ++ "minecraft:brewer_pottery_shard", ++ "minecraft:burn_pottery_shard", ++ "minecraft:danger_pottery_shard", ++ "minecraft:explorer_pottery_shard", ++ "minecraft:friend_pottery_shard", ++ "minecraft:heart_pottery_shard", ++ "minecraft:heartbreak_pottery_shard", ++ "minecraft:howl_pottery_shard", ++ "minecraft:miner_pottery_shard", ++ "minecraft:mourner_pottery_shard", ++ "minecraft:plenty_pottery_shard", ++ "minecraft:prize_pottery_shard", ++ "minecraft:sheaf_pottery_shard", ++ "minecraft:shelter_pottery_shard", ++ "minecraft:skull_pottery_shard", ++ "minecraft:snort_pottery_shard" ++ }; ++ // shard->sherd ++ final Map rename = new HashMap<>(targets.length); ++ ++ for (final String target : targets) { ++ final String replace = target.replace("_pottery_shard", "_pottery_sherd"); ++ if (rename.put(target, replace) != null) { ++ throw new IllegalArgumentException("Duplicate target " + target); ++ } ++ } ++ ++ ConverterAbstractItemRename.register(VERSION, rename::get); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3448.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3448.java +new file mode 100644 +index 0000000000000000000000000000000000000000..1d4d7af22e94a347d05ea14c51598f737ffb6b2d +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3448.java +@@ -0,0 +1,24 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.minecraft.walkers.generic.DataWalkerListPaths; ++import ca.spottedleaf.dataconverter.types.MapType; ++ ++public final class V3448 { ++ ++ private static final int VERSION = MCVersions.V23W14A + 3; ++ ++ public static void register() { ++ MCTypeRegistry.TILE_ENTITY.addWalker(VERSION, "minecraft:decorated_pot", new DataWalkerListPaths<>(MCTypeRegistry.ITEM_NAME, "sherds")); ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:decorated_pot", new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ RenameHelper.renameSingle(data, "shards", "sherds"); ++ return null; ++ } ++ }); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3450.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3450.java +new file mode 100644 +index 0000000000000000000000000000000000000000..229c36f1e79d10d80dc2ff03819130d42b841206 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3450.java +@@ -0,0 +1,21 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.minecraft.converters.chunk.ConverterRenameStatus; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import java.util.HashMap; ++import java.util.Map; ++ ++public final class V3450 { ++ ++ private static final int VERSION = MCVersions.V23W16A + 1; ++ ++ public static void register() { ++ MCTypeRegistry.CHUNK.addStructureConverter(new ConverterRenameStatus(VERSION, new HashMap<>( ++ Map.of( ++ "minecraft:liquid_carvers", "minecraft:carvers", ++ "minecraft:heightmaps", "minecraft:spawn" ++ ) ++ )::get)); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3451.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3451.java +new file mode 100644 +index 0000000000000000000000000000000000000000..2c5432e38cdbdffa820fcfb6269d652373fa3f0c +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3451.java +@@ -0,0 +1,36 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.types.ListType; ++import ca.spottedleaf.dataconverter.types.MapType; ++import ca.spottedleaf.dataconverter.types.ObjectType; ++ ++public final class V3451 { ++ ++ private static final int VERSION = MCVersions.V23W16A + 2; ++ ++ public static void register() { ++ MCTypeRegistry.CHUNK.addStructureConverter(new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ data.remove("isLightOn"); ++ ++ final ListType sections = data.getList("sections", ObjectType.MAP); ++ if (sections == null) { ++ return null; ++ } ++ ++ for (int i = 0, len = sections.size(); i < len; ++i) { ++ final MapType section = sections.getMap(i); ++ ++ section.remove("BlockLight"); ++ section.remove("SkyLight"); ++ } ++ ++ return null; ++ } ++ }); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/minecraft/versions/V3459.java b/src/main/java/ca/spottedleaf/minecraft/versions/V3459.java +new file mode 100644 +index 0000000000000000000000000000000000000000..3a01c09e3334e5c73324c3a38996e4721146829a +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/minecraft/versions/V3459.java +@@ -0,0 +1,34 @@ ++package ca.spottedleaf.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.converters.DataConverter; ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import ca.spottedleaf.dataconverter.types.MapType; ++ ++public final class V3459 { ++ ++ private static final int VERSION = MCVersions.V1_20_PRE5 + 1; ++ ++ public static void register() { ++ MCTypeRegistry.LEVEL.addStructureConverter(new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ if (data.hasKey("DragonFight")) { ++ return null; ++ } ++ ++ final MapType dimensionData = data.getMap("DimensionData"); ++ if (dimensionData == null) { ++ return null; ++ } ++ ++ final MapType endData = dimensionData.getMap("1"); ++ if (endData != null) { ++ data.setMap("DragonFight", endData.getMap("DragonFight", endData.getTypeUtil().createEmptyMap())); ++ } ++ ++ return null; ++ } ++ }); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/mixin/PrintTheFuckingErrorJesusChristMixin.java b/src/main/java/ca/spottedleaf/mixin/PrintTheFuckingErrorJesusChristMixin.java +new file mode 100644 +index 0000000000000000000000000000000000000000..3a9a34bd35f8224938c06bbb3e410906b5e7537a +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/mixin/PrintTheFuckingErrorJesusChristMixin.java +@@ -0,0 +1,61 @@ ++package ca.spottedleaf.mixin; ++ ++import com.mojang.datafixers.DataFixer; ++import com.mojang.datafixers.util.Either; ++import net.minecraft.ReportedException; ++import net.minecraft.server.level.ChunkHolder; ++import net.minecraft.server.level.ChunkMap; ++import net.minecraft.world.level.ChunkPos; ++import net.minecraft.world.level.chunk.ChunkAccess; ++import net.minecraft.world.level.chunk.storage.ChunkStorage; ++import org.slf4j.Logger; ++import org.spongepowered.asm.mixin.Final; ++import org.spongepowered.asm.mixin.Mixin; ++import org.spongepowered.asm.mixin.Overwrite; ++import org.spongepowered.asm.mixin.Shadow; ++import java.io.IOException; ++import java.nio.file.Path; ++ ++@Mixin(ChunkMap.class) ++public abstract class PrintTheFuckingErrorJesusChristMixin extends ChunkStorage implements ChunkHolder.PlayerProvider { ++ ++ @Shadow ++ protected abstract void markPositionReplaceable(ChunkPos chunkPos); ++ ++ @Shadow ++ @Final ++ private static Logger LOGGER; ++ ++ @Shadow ++ protected abstract ChunkAccess createEmptyChunk(ChunkPos chunkPos); ++ ++ public PrintTheFuckingErrorJesusChristMixin(Path path, DataFixer dataFixer, boolean bl) { ++ super(path, dataFixer, bl); ++ } ++ ++ /** ++ * @reason Print the fucking exception jesus christ how hard is it: ++ * 1. handle or ++ * 2. print or ++ * 3. rethrow ++ * @author Spottedleaf ++ */ ++ @Overwrite ++ private Either handleChunkLoadFailure(Throwable throwable, ChunkPos chunkPos) { ++ if (throwable instanceof ReportedException reportedException) { ++ Throwable throwable2 = reportedException.getCause(); ++ if (!(throwable2 instanceof IOException)) { ++ this.markPositionReplaceable(chunkPos); ++ throw reportedException; ++ } ++ ++ LOGGER.error("Couldn't load chunk {}", chunkPos, throwable2); ++ } else if (throwable instanceof IOException) { ++ LOGGER.error("Couldn't load chunk {}", chunkPos, throwable); ++ } ++ ++ LOGGER.error("Couldn't load chunk {} (Vanilla swallowed exception)", chunkPos, throwable); ++ ++ return Either.left(this.createEmptyChunk(chunkPos)); ++ } ++} diff --git a/src/main/java/net/minecraft/data/structures/StructureUpdater.java b/src/main/java/net/minecraft/data/structures/StructureUpdater.java -index d7ab56495d6f52e1dc16b1da82bb02c9187b947e..1babe9e3db4c57e8e54607bc962a64f49be2fcf4 100644 +index c1e1f45b00751605625030bd86669627cd5459c7..79f2f9ec71ea12bb520fd1afa47489dd530110be 100644 --- a/src/main/java/net/minecraft/data/structures/StructureUpdater.java +++ b/src/main/java/net/minecraft/data/structures/StructureUpdater.java @@ -25,7 +25,7 @@ public class StructureUpdater implements SnbtToNbt.Filter { - LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", i, 3318, name); + LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", i, 3437, name); } - CompoundTag compoundTag = DataFixTypes.STRUCTURE.updateToCurrentVersion(DataFixers.getDataFixer(), nbt, i); @@ -23113,7 +23790,7 @@ index d7ab56495d6f52e1dc16b1da82bb02c9187b947e..1babe9e3db4c57e8e54607bc962a64f4 return structureTemplate.save(new CompoundTag()); } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index 61b00355b01fb5fb41ff1c02df7724b1af9a5441..ba267f3082607669282a61f013991e1c391a3f09 100644 +index 25623dcd44edc475c5dce2756bf99fc18e142b63..6c0f87535ffa95cf82ab4b03bb7bf8f2132d275f 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java @@ -78,7 +78,7 @@ public class ChunkStorage implements AutoCloseable { diff --git a/patches/unapplied/server/0016-Starlight.patch b/patches/server/0016-Starlight.patch similarity index 96% rename from patches/unapplied/server/0016-Starlight.patch rename to patches/server/0016-Starlight.patch index 6a81c4dc2a..f0c5336546 100644 --- a/patches/unapplied/server/0016-Starlight.patch +++ b/patches/server/0016-Starlight.patch @@ -11,10 +11,10 @@ public net.minecraft.world.level.chunk.LevelChunkSection states 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 -index 0000000000000000000000000000000000000000..4a04eb6449d33d3f15c354b2ac98198f4ac12758 +index 0000000000000000000000000000000000000000..09ddbbfdf656aa347830941abd7c994fac05d1c5 --- /dev/null +++ b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java -@@ -0,0 +1,288 @@ +@@ -0,0 +1,279 @@ +package ca.spottedleaf.starlight.common.light; + +import net.minecraft.core.BlockPos; @@ -218,58 +218,49 @@ index 0000000000000000000000000000000000000000..4a04eb6449d33d3f15c354b2ac98198f + this.performLightDecrease(lightAccess); + } + -+ protected Iterator getSources(final LightChunkGetter lightAccess, final ChunkAccess chunk) { -+ if (chunk instanceof ImposterProtoChunk || chunk instanceof LevelChunk) { -+ // implementation on Chunk is pretty awful, so write our own here. The big optimisation is -+ // skipping empty sections, and the far more optimised reading of types. -+ List sources = new ArrayList<>(); ++ protected List getSources(final LightChunkGetter lightAccess, final ChunkAccess chunk) { ++ final List sources = new ArrayList<>(); + -+ int offX = chunk.getPos().x << 4; -+ int offZ = chunk.getPos().z << 4; ++ final int offX = chunk.getPos().x << 4; ++ final int offZ = chunk.getPos().z << 4; + -+ final LevelChunkSection[] sections = chunk.getSections(); -+ for (int sectionY = this.minSection; sectionY <= this.maxSection; ++sectionY) { -+ final LevelChunkSection section = sections[sectionY - this.minSection]; -+ if (section == null || section.hasOnlyAir()) { -+ // no sources in empty sections -+ continue; -+ } -+ final PalettedContainer states = section.states; -+ final int offY = sectionY << 4; -+ -+ for (int index = 0; index < (16 * 16 * 16); ++index) { -+ final BlockState state = states.get(index); -+ if (state.getLightEmission() <= 0) { -+ continue; -+ } -+ -+ // index = x | (z << 4) | (y << 8) -+ sources.add(new BlockPos(offX | (index & 15), offY | (index >>> 8), offZ | ((index >>> 4) & 15))); -+ } ++ final LevelChunkSection[] sections = chunk.getSections(); ++ for (int sectionY = this.minSection; sectionY <= this.maxSection; ++sectionY) { ++ final LevelChunkSection section = sections[sectionY - this.minSection]; ++ if (section == null || section.hasOnlyAir()) { ++ // no sources in empty sections ++ continue; + } ++ if (!section.maybeHas((final BlockState state) -> { ++ return state.getLightEmission() > 0; ++ })) { ++ // no light sources in palette ++ continue; ++ } ++ final PalettedContainer states = section.states; ++ final int offY = sectionY << 4; + -+ return sources.iterator(); -+ } else { -+ // world gen and lighting run in parallel, and if lighting keeps up it can be lighting chunks that are -+ // being generated. In the nether, lava will add a lot of sources. This resulted in quite a few CME crashes. -+ // So all we do spinloop until we can collect a list of sources, and even if it is out of date we will pick up -+ // the missing sources from checkBlock. -+ for (;;) { -+ try { -+ return chunk.getLights().collect(Collectors.toList()).iterator(); -+ } catch (final Exception cme) { ++ for (int index = 0; index < (16 * 16 * 16); ++index) { ++ final BlockState state = states.get(index); ++ if (state.getLightEmission() <= 0) { + continue; + } ++ ++ // index = x | (z << 4) | (y << 8) ++ sources.add(new BlockPos(offX | (index & 15), offY | (index >>> 8), offZ | ((index >>> 4) & 15))); + } + } ++ ++ return sources; + } + + @Override + public void lightChunk(final LightChunkGetter lightAccess, final ChunkAccess chunk, final boolean needsEdgeChecks) { + // setup sources + final int emittedMask = this.emittedLightMask; -+ for (final Iterator positions = this.getSources(lightAccess, chunk); positions.hasNext();) { -+ final BlockPos pos = positions.next(); ++ final List positions = this.getSources(lightAccess, chunk); ++ for (int i = 0, len = positions.size(); i < len; ++i) { ++ final BlockPos pos = positions.get(i); + final BlockState blockState = this.getBlockState(pos.getX(), pos.getY(), pos.getZ()); + final int emittedLight = blockState.getLightEmission() & emittedMask; + @@ -1466,7 +1457,7 @@ index 0000000000000000000000000000000000000000..5f771962afb44175d446f138c8e74532 +} diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java new file mode 100644 -index 0000000000000000000000000000000000000000..1b0d92c68407cdb09ed8aac271b625d92db87017 +index 0000000000000000000000000000000000000000..ad1eeebe6de219143492b94da309cb54ae9e0a5b --- /dev/null +++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java @@ -0,0 +1,1572 @@ @@ -1537,7 +1528,7 @@ index 0000000000000000000000000000000000000000..1b0d92c68407cdb09ed8aac271b625d9 + this.x = x; + this.y = y; + this.z = z; -+ this.nms = Direction.fromNormal(x, y, z); ++ this.nms = Direction.fromDelta(x, y, z); + this.everythingButThisDirection = (long)(ALL_DIRECTIONS_BITSET ^ (1 << this.ordinal())); + // positive is always even, negative is always odd. Flip the 1 bit to get the negative direction. + this.everythingButTheOppositeDirection = (long)(ALL_DIRECTIONS_BITSET ^ (1 << (this.ordinal() ^ 1))); @@ -3044,10 +3035,10 @@ index 0000000000000000000000000000000000000000..1b0d92c68407cdb09ed8aac271b625d9 +} 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 -index 0000000000000000000000000000000000000000..9a5fa60cb8156fe254a123e237d957ccb82f7195 +index 0000000000000000000000000000000000000000..146c78a333e47cb4d8aa97700e19a12ca176ce76 --- /dev/null +++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java -@@ -0,0 +1,665 @@ +@@ -0,0 +1,673 @@ +package ca.spottedleaf.starlight.common.light; + +import ca.spottedleaf.starlight.common.util.CoordinateUtils; @@ -3134,8 +3125,8 @@ index 0000000000000000000000000000000000000000..9a5fa60cb8156fe254a123e237d957cc + } + + @Override -+ public void onBlockEmissionIncrease(final BlockPos blockPos, final int i) { -+ // skylight doesn't care ++ public void propagateLightSources(final ChunkPos chunkPos) { ++ throw new UnsupportedOperationException(); + } + + @Override @@ -3145,12 +3136,12 @@ index 0000000000000000000000000000000000000000..9a5fa60cb8156fe254a123e237d957cc + } + + @Override -+ public int runUpdates(final int i, final boolean bl, final boolean bl2) { ++ public int runLightUpdates() { + throw new UnsupportedOperationException(); + } + + @Override -+ public void enableLightSources(final ChunkPos chunkPos, final boolean bl) { ++ public void setLightEnabled(final ChunkPos chunkPos, final boolean bl) { + throw new UnsupportedOperationException(); + } + @@ -3191,8 +3182,8 @@ index 0000000000000000000000000000000000000000..9a5fa60cb8156fe254a123e237d957cc + } + + @Override -+ public void onBlockEmissionIncrease(final BlockPos blockPos, final int i) { -+ this.checkBlock(blockPos); ++ public void propagateLightSources(final ChunkPos chunkPos) { ++ throw new UnsupportedOperationException(); + } + + @Override @@ -3202,12 +3193,12 @@ index 0000000000000000000000000000000000000000..9a5fa60cb8156fe254a123e237d957cc + } + + @Override -+ public int runUpdates(final int i, final boolean bl, final boolean bl2) { ++ public int runLightUpdates() { + throw new UnsupportedOperationException(); + } + + @Override -+ public void enableLightSources(final ChunkPos chunkPos, final boolean bl) { ++ public void setLightEnabled(final ChunkPos chunkPos, final boolean bl) { + throw new UnsupportedOperationException(); + } + @@ -3234,6 +3225,14 @@ index 0000000000000000000000000000000000000000..9a5fa60cb8156fe254a123e237d957cc + }; + } + ++ public boolean hasSkyLight() { ++ return this.hasSkyLight; ++ } ++ ++ public boolean hasBlockLight() { ++ return this.hasBlockLight; ++ } ++ + protected int getSkyLightValue(final BlockPos blockPos, final ChunkAccess chunk) { + if (!this.hasSkyLight) { + return 0; @@ -4081,7 +4080,7 @@ index 0000000000000000000000000000000000000000..177d0a969f3d72a34e773e8309c3719a +} 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 -index 0000000000000000000000000000000000000000..6df9e01731d7fcbe279736b8fc18396595b95574 +index 0000000000000000000000000000000000000000..8d1fd22c8b8b0ea3afce6fc3e92057194f82669f --- /dev/null +++ b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java @@ -0,0 +1,192 @@ @@ -4103,7 +4102,7 @@ index 0000000000000000000000000000000000000000..6df9e01731d7fcbe279736b8fc183965 + + private static final Logger LOGGER = LogUtils.getLogger(); + -+ private static final int STARLIGHT_LIGHT_VERSION = 8; ++ private static final int STARLIGHT_LIGHT_VERSION = 9; + + public static int getLightVersion() { + return STARLIGHT_LIGHT_VERSION; @@ -4464,10 +4463,10 @@ index 0000000000000000000000000000000000000000..7784d72ddd6db00c674e22759c00c430 + } +} diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 941ca1b44c7cac656bdd76c7095887b1c3570aec..30e330cc3a2f51e4ec9555671e3eeb7bb14bdfa3 100644 +index 32d186fefa5ff8afedcceacea0c6fa1cefbd5490..4620e64d8eb81520b75fbfbc64603e5887c7b016 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -55,7 +55,7 @@ public class ChunkHolder { +@@ -53,7 +53,7 @@ public class ChunkHolder { private volatile CompletableFuture> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage private volatile CompletableFuture> tickingChunkFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage private volatile CompletableFuture> entityTickingChunkFuture; private volatile boolean isEntityTickingReady; // Paper - cache chunk ticking stage @@ -4477,10 +4476,10 @@ index 941ca1b44c7cac656bdd76c7095887b1c3570aec..30e330cc3a2f51e4ec9555671e3eeb7b private final DebugBuffer chunkToSaveHistory; public int oldTicketLevel; diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 091c9e9bdbe4e956386df011ddf01cba42c30da1..578849f64de38dc75cdefeb243422c4c89a5c69c 100644 +index a645263f148a25e5b4baeed51775eb8e7f596fe8..19bd6f9aee3ccb1af1b010ee51a54aa2d0bf9c84 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -134,7 +134,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -133,7 +133,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private final LongSet entitiesInLevel; public final ServerLevel level; private final ThreadedLevelLightEngine lightEngine; @@ -4490,10 +4489,10 @@ index 091c9e9bdbe4e956386df011ddf01cba42c30da1..578849f64de38dc75cdefeb243422c4c private final RandomState randomState; 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 -index fbe62a31ab199d83a1db0a4e0b1a813824e6f2c2..d38ad1b1eee92a6dbd2b79b4fcdb8959cdb4007d 100644 +index d8b83c8c89143d78620f812c491a1950e3218eb1..f3c9a3dbb6f0e6f825b7477c89ed72ed52845419 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java -@@ -390,7 +390,7 @@ public abstract class DistanceManager { +@@ -386,7 +386,7 @@ public abstract class DistanceManager { } public void removeTicketsOnClosing() { @@ -4503,7 +4502,7 @@ index fbe62a31ab199d83a1db0a4e0b1a813824e6f2c2..d38ad1b1eee92a6dbd2b79b4fcdb8959 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 -index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c832839e5aa9af 100644 +index 65d72701b13c25dd701533833055e77c2aff9db8..10c9512be71f1b7eec7e0c74dc0e118d0b51735b 100644 --- a/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; @@ -4522,10 +4521,10 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 +// Paper end + public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCloseable { + public static final int DEFAULT_BATCH_SIZE = 1000; private static final Logger LOGGER = LogUtils.getLogger(); - private final ProcessorMailbox taskMailbox; -@@ -32,13 +43,154 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl - private volatile int taskPerBatch = 5; +@@ -33,12 +44,153 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + private final int taskPerBatch = 1000; private final AtomicBoolean scheduled = new AtomicBoolean(); + // Paper start - replace light engine impl @@ -4550,8 +4549,8 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 + // Paper start - replace light engine impl + protected final ChunkAccess getChunk(final int chunkX, final int chunkZ) { + return ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().getChunkAtImmediately(chunkX, chunkZ); - } - ++ } ++ + protected long relightCounter; + + public int relight(java.util.Set chunks_param, @@ -4674,18 +4673,17 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 + if (sky == 15) return 15; + final int block = this.theLightEngine.getBlockReader().getLightValue(pos); + return Math.max(sky, block); -+ } + } + // Paper end - replace light engine imp -+ + @Override public void close() { - } -@@ -55,15 +207,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -51,15 +203,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void checkBlock(BlockPos pos) { - BlockPos blockPos = pos.immutable(); -- this.addTask(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ThreadedLevelLightEngine.TaskType.POST_UPDATE, Util.name(() -> { +- this.addTask(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { - super.checkBlock(blockPos); - }, () -> { - return "checkBlock " + blockPos; @@ -4703,7 +4701,7 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 this.addTask(pos.x, pos.z, () -> { return 0; }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -86,17 +239,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -82,17 +235,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void updateSectionStatus(SectionPos pos, boolean notReady) { @@ -4722,20 +4720,28 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 } @Override - public void enableLightSources(ChunkPos pos, boolean retainData) { + public void propagateLightSources(ChunkPos chunkPos) { + if (true) return; // Paper - replace light engine impl - this.addTask(pos.x, pos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { - super.enableLightSources(pos, retainData); + this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + super.propagateLightSources(chunkPos); }, () -> { -@@ -106,6 +258,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -102,6 +254,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override - public void queueSectionData(LightLayer lightType, SectionPos pos, @Nullable DataLayer nibbles, boolean nonEdge) { + public void setLightEnabled(ChunkPos pos, boolean retainData) { ++ if (true) return; // Paper - replace light engine impl + this.addTask(pos.x, pos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + super.setLightEnabled(pos, retainData); + }, () -> { +@@ -111,6 +264,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + + @Override + public void queueSectionData(LightLayer lightType, SectionPos pos, @Nullable DataLayer nibbles) { + if (true) return; // Paper - replace light engine impl this.addTask(pos.x(), pos.z(), () -> { return 0; }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -131,6 +284,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -136,6 +290,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void retainData(ChunkPos pos, boolean retainData) { @@ -4743,7 +4749,15 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 this.addTask(pos.x, pos.z, () -> { return 0; }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -153,6 +307,37 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -146,6 +301,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + } + + public CompletableFuture initializeLight(ChunkAccess chunk, boolean bl) { ++ if (true) return CompletableFuture.completedFuture(chunk); // Paper - replace light engine impl + ChunkPos chunkPos = chunk.getPos(); + this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + LevelChunkSection[] levelChunkSections = chunk.getSections(); +@@ -171,6 +327,37 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } public CompletableFuture lightChunk(ChunkAccess chunk, boolean excludeBlocks) { @@ -4781,7 +4795,7 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 ChunkPos chunkPos = chunk.getPos(); chunk.setLightCorrect(false); this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -187,7 +372,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -191,7 +378,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } public void tryScheduleUpdate() { @@ -4790,11 +4804,11 @@ index 5b238e41ffa3e374b52ee955cb39087571c6ffc2..275b7f7dd36a2073a3eb9f89f4c83283 this.taskMailbox.tell(() -> { this.runUpdate(); this.scheduled.set(false); -@@ -209,7 +394,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -213,7 +400,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } objectListIterator.back(j); -- super.runUpdates(Integer.MAX_VALUE, true, true); +- super.runLightUpdates(); + this.theLightEngine.propagateChanges(); // Paper - rewrite light engine for(int var5 = 0; objectListIterator.hasNext() && var5 < i; ++var5) { @@ -4812,18 +4826,18 @@ index 0d536d72ac918fbd403397ff369d10143ee9c204..6051e5f272838ef23276a90e21c2fc82 public static TicketType create(String name, Comparator argumentComparator) { return new TicketType<>(name, argumentComparator, 0L); 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 2cb3463f3d77a32ada67a6251707d741d18910ca..0eb877c80c6492d03681c70f7866ad705a62454e 100644 +index 88b1aabec2812252c54d0901ccd1eba0216cb7c3..803f3ebaa9fe43c88f461168ee43fc6ba920a764 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -751,6 +751,7 @@ public abstract class BlockBehaviour implements FeatureElement { - this.emissiveRendering = blockbase_info.emissiveRendering; - this.offsetFunction = blockbase_info.offsetFunction; +@@ -807,6 +807,7 @@ public abstract class BlockBehaviour implements FeatureElement { this.spawnParticlesOnBreak = blockbase_info.spawnParticlesOnBreak; + this.instrument = blockbase_info.instrument; + this.replaceable = blockbase_info.replaceable; + this.conditionallyFullOpaque = this.isOpaque() & this.isTransparentOnSomeFaces(); // Paper } - // Paper start -@@ -759,6 +760,18 @@ public abstract class BlockBehaviour implements FeatureElement { + private boolean calculateSolid() { +@@ -835,6 +836,18 @@ public abstract class BlockBehaviour implements FeatureElement { return this.shapeExceedsCube; } // Paper end @@ -4842,19 +4856,19 @@ index 2cb3463f3d77a32ada67a6251707d741d18910ca..0eb877c80c6492d03681c70f7866ad70 public void initCache() { this.fluidState = ((Block) this.owner).getFluidState(this.asState()); -@@ -767,6 +780,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -843,6 +856,7 @@ public abstract class BlockBehaviour implements FeatureElement { this.cache = new BlockBehaviour.BlockStateBase.Cache(this.asState()); } this.shapeExceedsCube = this.cache == null || this.cache.largeCollisionShape; // Paper - moved from actual method to here + this.opacityIfCached = this.cache == null || this.isConditionallyFullOpaque() ? -1 : this.cache.lightBlock; // Paper - starlight - cache opacity for light + 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 -index 3fdbb777d4722596cc4df79b2d4d7b9c553580fd..1b7496cec0ba5a95615a069e3168bd46308d0b40 100644 +index e5e562f75e7d4b6a750f192842940c5e3af81e7d..2caac1a3d80e6c490aa16aa6bc1067065b665c69 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -81,6 +81,47 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom +@@ -86,6 +86,47 @@ 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(); public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY); // CraftBukkit end @@ -4900,13 +4914,13 @@ index 3fdbb777d4722596cc4df79b2d4d7b9c553580fd..1b7496cec0ba5a95615a069e3168bd46 + } + // Paper end - rewrite light engine - public ChunkAccess(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor heightLimitView, Registry biome, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable BlendingData blendingData) { + public ChunkAccess(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor heightLimitView, Registry biomeRegistry, long inhabitedTime, @Nullable LevelChunkSection[] sectionArray, @Nullable BlendingData blendingData) { this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups 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 f4aab0bf544ef5c889c02e41389b1656cf1e4932..e2278ed457a7342d0d1b1a5fc1b5bdef6358816b 100644 +index 70a05fe758565131bbb39c18d6b674a6368ffa45..fb5a06a908d2b42bf0530b62ed648548499d9f87 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java -@@ -293,6 +293,17 @@ public class ChunkStatus { +@@ -258,6 +258,17 @@ public class ChunkStatus { return this.chunkType; } @@ -4925,7 +4939,7 @@ index f4aab0bf544ef5c889c02e41389b1656cf1e4932..e2278ed457a7342d0d1b1a5fc1b5bdef 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 -index 587cc435a58d28e14e88860c8348425101334eda..2eb92dde607d7c8968cb07c6f3c24e1c45e9990f 100644 +index ca0991b07def35b4697ba6d5569bf9a080e48a1c..f49cc61840c6588fca301b4c5c3aaeede03a323e 100644 --- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java @@ -21,6 +21,40 @@ public class EmptyLevelChunk extends LevelChunk { @@ -4970,12 +4984,12 @@ index 587cc435a58d28e14e88860c8348425101334eda..2eb92dde607d7c8968cb07c6f3c24e1c public BlockState getBlockState(BlockPos pos) { 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 -index 80b98e6667f1a0c21d019c58a8a0d4cc5b0f48e1..8033c8741a0f73919a357893652592b317bfb417 100644 +index 6bb508105641b5729572736c5c3f9bd6711e309a..60e760b42dd6471a229dfd45490dcf8c51979d35 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -31,6 +31,48 @@ public class ImposterProtoChunk extends ProtoChunk { - private final LevelChunk wrapped; - private final boolean allowWrites; +@@ -39,6 +39,48 @@ public class ImposterProtoChunk extends ProtoChunk { + this.allowWrites = propagateToWrapped; + } + // Paper start - rewrite light engine + @Override @@ -5019,14 +5033,14 @@ index 80b98e6667f1a0c21d019c58a8a0d4cc5b0f48e1..8033c8741a0f73919a357893652592b3 + } + // Paper end - rewrite light engine + - public ImposterProtoChunk(LevelChunk wrapped, boolean bl) { - super(wrapped.getPos(), UpgradeData.EMPTY, wrapped.levelHeightAccessor, wrapped.getLevel().registryAccess().registryOrThrow(Registries.BIOME), wrapped.getBlendingData()); - this.wrapped = wrapped; + @Nullable + @Override + 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 -index 13202fc9f73f3485328b923de8c1e6080f08e773..975973e858ceb8340d2fdad54f636627d16612fd 100644 +index 6e1ace21431f679d55a2580dc23c32cf5f75b2af..9bd0e817cf717fe6257ceb4ace6bf6f5eed9eb82 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -93,6 +93,10 @@ public class LevelChunk extends ChunkAccess { +@@ -90,6 +90,10 @@ public class LevelChunk extends ChunkAccess { public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks blockTickScheduler, LevelChunkTicks fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) { super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registries.BIOME), inhabitedTime, sectionArrayInitializer, blendingData); @@ -5035,9 +5049,9 @@ index 13202fc9f73f3485328b923de8c1e6080f08e773..975973e858ceb8340d2fdad54f636627 + this.setSkyNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world)); + // Paper end - rewrite light engine this.tickersInLevel = Maps.newHashMap(); - this.clientLightReady = false; this.level = (ServerLevel) world; // CraftBukkit - type -@@ -223,6 +227,12 @@ public class LevelChunk extends ChunkAccess { + this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap(); +@@ -219,6 +223,12 @@ public class LevelChunk extends ChunkAccess { 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()); @@ -5064,10 +5078,10 @@ index afba733824d84d650e669eda028bf4d28cf006b4..cd82985b0aa821dccc0484f328407381 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 -index 92a64c49b1c7227a5b34488ea15d3d8adb0f9c80..0b67858f8d6689b34816f9556f3424af512a7401 100644 +index 38ec21faaa16df5485a81a581506700a5ab0a440..b2c0c7fd06fcd720b4c0875f08a90b6b672c96b2 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -55,6 +55,12 @@ public class ProtoChunk extends ChunkAccess { +@@ -53,6 +53,12 @@ public class ProtoChunk extends ChunkAccess { public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTickScheduler, ProtoChunkTicks fluidTickScheduler, LevelHeightAccessor world, Registry biomeRegistry, @Nullable BlendingData blendingData) { super(pos, upgradeData, world, biomeRegistry, 0L, sections, blendingData); @@ -5081,7 +5095,7 @@ index 92a64c49b1c7227a5b34488ea15d3d8adb0f9c80..0b67858f8d6689b34816f9556f3424af this.fluidTicks = fluidTickScheduler; } 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 aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc1bfdbc7d 100644 +index cc1d7626a82881c4410d65c6a33dadae7ab07172..24892ae367e19038625e243bcdf1bb694632ede5 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -84,6 +84,14 @@ public class ChunkSerializer { @@ -5089,7 +5103,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc public static final String SKY_LIGHT_TAG = "SkyLight"; + // Paper start - replace light engine impl -+ private static final int STARLIGHT_LIGHT_VERSION = 8; ++ private static final int STARLIGHT_LIGHT_VERSION = 9; + + private static final String BLOCKLIGHT_STATE_TAG = "starlight.blocklight_state"; + private static final String SKYLIGHT_STATE_TAG = "starlight.skylight_state"; @@ -5110,7 +5124,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc LevelChunkSection[] achunksection = new LevelChunkSection[i]; boolean flag1 = world.dimensionType().hasSkyLight(); ServerChunkCache chunkproviderserver = world.getChunkSource(); - LevelLightEngine lightengine = chunkproviderserver.getLightEngine(); + LevelLightEngine levellightengine = chunkproviderserver.getLightEngine(); + // Paper start + ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] blockNibbles = ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world); + ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] skyNibbles = ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world); @@ -5130,13 +5144,13 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc byte b0 = nbttagcompound1.getByte("Y"); int k = world.getSectionIndexFromSectionY(b0); -@@ -149,19 +164,39 @@ public class ChunkSerializer { +@@ -151,19 +166,39 @@ public class ChunkSerializer { boolean flag3 = nbttagcompound1.contains("BlockLight", 7); boolean flag4 = flag1 && nbttagcompound1.contains("SkyLight", 7); - if (flag3 || flag4) { - if (!flag2) { -- lightengine.retainData(chunkPos, true); +- levellightengine.retainData(chunkPos, true); - flag2 = true; - } - @@ -5146,7 +5160,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc + int y = sectionData.getByte("Y"); + // Paper end - rewrite the light engine if (flag3) { -- lightengine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, b0), new DataLayer(nbttagcompound1.getByteArray("BlockLight")), true); +- levellightengine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, b0), new DataLayer(nbttagcompound1.getByteArray("BlockLight"))); + // Paper start - rewrite the light engine + // this is where our diff is + blockNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(sectionData.getByteArray("BlockLight").clone(), sectionData.getInt(BLOCKLIGHT_STATE_TAG)); // clone for data safety @@ -5156,7 +5170,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc } if (flag4) { -- lightengine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, b0), new DataLayer(nbttagcompound1.getByteArray("SkyLight")), true); +- levellightengine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, b0), new DataLayer(nbttagcompound1.getByteArray("SkyLight"))); + // Paper start - rewrite the light engine + // we store under the same key so mod programs editing nbt + // can still read the data, hopefully. @@ -5178,7 +5192,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc } } -@@ -190,6 +225,8 @@ public class ChunkSerializer { +@@ -192,6 +227,8 @@ public class ChunkSerializer { }, chunkPos); object1 = new LevelChunk(world.getLevel(), chunkPos, chunkconverter, levelchunkticks, levelchunkticks1, l, achunksection, ChunkSerializer.postLoadChunk(world, nbt), blendingdata); @@ -5187,7 +5201,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc } else { ProtoChunkTicks protochunkticklist = ProtoChunkTicks.load(nbt.getList("block_ticks", 10), (s) -> { return BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(s)); -@@ -198,6 +235,8 @@ public class ChunkSerializer { +@@ -200,6 +237,8 @@ public class ChunkSerializer { return BuiltInRegistries.FLUID.getOptional(ResourceLocation.tryParse(s)); }, chunkPos); ProtoChunk protochunk = new ProtoChunk(chunkPos, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, world, iregistry, blendingdata); @@ -5196,7 +5210,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc object1 = protochunk; protochunk.setInhabitedTime(l); -@@ -342,6 +381,12 @@ public class ChunkSerializer { +@@ -314,6 +353,12 @@ public class ChunkSerializer { // CraftBukkit end public static CompoundTag write(ServerLevel world, ChunkAccess chunk) { @@ -5209,7 +5223,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc ChunkPos chunkcoordintpair = chunk.getPos(); CompoundTag nbttagcompound = NbtUtils.addCurrentDataVersion(new CompoundTag()); -@@ -391,11 +436,14 @@ public class ChunkSerializer { +@@ -363,11 +408,14 @@ public class ChunkSerializer { for (int i = lightenginethreaded.getMinLightSection(); i < lightenginethreaded.getMaxLightSection(); ++i) { int j = chunk.getSectionIndexFromSectionY(i); boolean flag1 = j >= 0 && j < achunksection.length; @@ -5228,7 +5242,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc if (flag1) { LevelChunkSection chunksection = achunksection[j]; -@@ -410,13 +458,27 @@ public class ChunkSerializer { +@@ -382,13 +430,27 @@ public class ChunkSerializer { nbttagcompound1.put("biomes", (Tag) dataresult1.getOrThrow(false, logger1::error)); } @@ -5260,7 +5274,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc if (!nbttagcompound1.isEmpty()) { nbttagcompound1.putByte("Y", (byte) i); -@@ -427,7 +489,8 @@ public class ChunkSerializer { +@@ -399,7 +461,8 @@ public class ChunkSerializer { nbttagcompound.put("sections", nbttaglist); if (flag) { @@ -5270,7 +5284,7 @@ index aa4f2dc63dd79e6c3d7594d2fd63fa0091df5f53..bca8084f7e76d036378705aa802217cc } ListTag nbttaglist1 = new ListTag(); -@@ -502,6 +565,17 @@ public class ChunkSerializer { +@@ -473,6 +536,17 @@ public class ChunkSerializer { })); } diff --git a/patches/unapplied/server/0017-Add-TickThread.patch b/patches/server/0017-Add-TickThread.patch similarity index 100% rename from patches/unapplied/server/0017-Add-TickThread.patch rename to patches/server/0017-Add-TickThread.patch