From e3db6ac6e4428f6f50c702f3fe39bea6a237ef5e Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 3 Dec 2024 21:11:09 +0100 Subject: [PATCH] moonrise --- .../Moonrise-optimisation-patches.patch | 423 ++++-------------- .../server/Rewrite-dataconverter-system.patch | 216 ++++++++- 2 files changed, 300 insertions(+), 339 deletions(-) rename patches/{unapplied => }/server/Moonrise-optimisation-patches.patch (99%) diff --git a/patches/unapplied/server/Moonrise-optimisation-patches.patch b/patches/server/Moonrise-optimisation-patches.patch similarity index 99% rename from patches/unapplied/server/Moonrise-optimisation-patches.patch rename to patches/server/Moonrise-optimisation-patches.patch index 781778f279..90b9d5abd9 100644 --- a/patches/unapplied/server/Moonrise-optimisation-patches.patch +++ b/patches/server/Moonrise-optimisation-patches.patch @@ -382,6 +382,64 @@ diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java +@@ -0,0 +0,0 @@ import ca.spottedleaf.moonrise.common.PlatformHooks; + import com.mojang.datafixers.DSL; + import com.mojang.datafixers.DataFixer; + import com.mojang.serialization.Dynamic; ++import java.util.Collection; + import net.minecraft.core.BlockPos; + import net.minecraft.nbt.CompoundTag; + import net.minecraft.nbt.NbtOps; +@@ -0,0 +0,0 @@ import net.minecraft.server.level.GenerationChunkHolder; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.boss.EnderDragonPart; + import net.minecraft.world.level.BlockGetter; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.Level; +@@ -0,0 +0,0 @@ public final class PaperHooks implements PlatformHooks { + + @Override + public void addToGetEntities(final Level world, final Entity entity, final AABB boundingBox, final Predicate predicate, final List into) { ++ final Collection parts = world.dragonParts(); ++ if (parts.isEmpty()) { ++ return; ++ } + ++ for (final EnderDragonPart part : parts) { ++ if (part != entity && part.getBoundingBox().intersects(boundingBox) && (predicate == null || predicate.test(part))) { ++ into.add(part); ++ } ++ } + } + + @Override + public void addToGetEntities(final Level world, final EntityTypeTest entityTypeTest, final AABB boundingBox, final Predicate predicate, final List into, final int maxCount) { ++ if (into.size() >= maxCount) { ++ // fix neoforge issue: do not add if list is already full ++ return; ++ } + ++ final Collection parts = world.dragonParts(); ++ if (parts.isEmpty()) { ++ return; ++ } ++ for (final EnderDragonPart part : parts) { ++ if (!part.getBoundingBox().intersects(boundingBox)) { ++ continue; ++ } ++ final T casted = (T)entityTypeTest.tryCast(part); ++ if (casted != null && (predicate == null || predicate.test(casted))) { ++ into.add(casted); ++ if (into.size() >= maxCount) { ++ break; ++ } ++ } ++ } + } + + @Override @@ -0,0 +0,0 @@ public final class PaperHooks implements PlatformHooks { @Override @@ -3281,21 +3339,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { -+ this.allEntities.getEntitiesWithEnderDragonParts(except, box, into, predicate); -+ } -+ -+ public void getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List into, final Predicate predicate) { + this.allEntities.getEntities(except, box, into, predicate); + } + + + public boolean getEntities(final Entity except, final AABB box, final List into, final Predicate predicate, -+ final int maxCount) { -+ return this.allEntities.getEntitiesWithEnderDragonPartsLimited(except, box, into, predicate, maxCount); -+ } -+ -+ public boolean getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List into, final Predicate predicate, -+ final int maxCount) { ++ final int maxCount) { + return this.allEntities.getEntitiesLimited(except, box, into, predicate, maxCount); + } + @@ -3309,7 +3358,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public boolean getEntities(final EntityType type, final AABB box, final List into, -+ final Predicate predicate, final int maxCount) { ++ final Predicate predicate, final int maxCount) { + final EntityCollectionBySection byType = this.entitiesByType.get(type); + + if (byType != null) { @@ -3346,21 +3395,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final Predicate predicate) { + EntityCollectionBySection collection = this.entitiesByClass.get(clazz); + if (collection != null) { -+ collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List)into, (Predicate)predicate); ++ collection.getEntities(except, box, (List)into, (Predicate)predicate); + } else { + this.entitiesByClass.put(clazz, collection = this.initClass(clazz)); -+ collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List)into, (Predicate)predicate); ++ collection.getEntities(except, box, (List)into, (Predicate)predicate); + } + } + + public boolean getEntities(final Class clazz, final Entity except, final AABB box, final List into, -+ final Predicate predicate, final int maxCount) { ++ final Predicate predicate, final int maxCount) { + EntityCollectionBySection collection = this.entitiesByClass.get(clazz); + if (collection != null) { -+ return collection.getEntitiesWithEnderDragonPartsLimited(except, clazz, box, (List)into, (Predicate)predicate, maxCount); ++ return collection.getEntitiesLimited(except, box, (List)into, (Predicate)predicate, maxCount); + } else { + this.entitiesByClass.put(clazz, collection = this.initClass(clazz)); -+ return collection.getEntitiesWithEnderDragonPartsLimited(except, clazz, box, (List)into, (Predicate)predicate, maxCount); ++ return collection.getEntitiesLimited(except, box, (List)into, (Predicate)predicate, maxCount); + } + } + @@ -3564,226 +3613,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + return false; + } -+ -+ public void getEntitiesWithEnderDragonParts(final Entity except, final AABB box, final List into, -+ final Predicate predicate) { -+ if (this.count == 0) { -+ return; -+ } -+ -+ final int minSection = this.slices.minSection; -+ final int maxSection = this.slices.maxSection; -+ -+ final int min = Mth.clamp(Mth.floor(box.minY - 2.0) >> 4, minSection, maxSection); -+ final int max = Mth.clamp(Mth.floor(box.maxY + 2.0) >> 4, minSection, maxSection); -+ -+ final BasicEntityList[] entitiesBySection = this.entitiesBySection; -+ -+ for (int section = min; section <= max; ++section) { -+ final BasicEntityList list = entitiesBySection[section - minSection]; -+ -+ if (list == null) { -+ continue; -+ } -+ -+ final Entity[] storage = list.storage; -+ -+ for (int i = 0, len = Math.min(storage.length, list.size()); i < len; ++i) { -+ final Entity entity = storage[i]; -+ -+ if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) { -+ continue; -+ } -+ -+ if (predicate == null || predicate.test(entity)) { -+ into.add(entity); -+ } // else: continue to test the ender dragon parts -+ -+ if (entity instanceof EnderDragon) { -+ for (final EnderDragonPart part : ((EnderDragon)entity).getSubEntities()) { -+ if (part == except || !part.getBoundingBox().intersects(box)) { -+ continue; -+ } -+ -+ if (predicate != null && !predicate.test(part)) { -+ continue; -+ } -+ -+ into.add(part); -+ } -+ } -+ } -+ } -+ } -+ -+ public boolean getEntitiesWithEnderDragonPartsLimited(final Entity except, final AABB box, final List into, -+ final Predicate predicate, final int maxCount) { -+ if (this.count == 0) { -+ return false; -+ } -+ -+ final int minSection = this.slices.minSection; -+ final int maxSection = this.slices.maxSection; -+ -+ final int min = Mth.clamp(Mth.floor(box.minY - 2.0) >> 4, minSection, maxSection); -+ final int max = Mth.clamp(Mth.floor(box.maxY + 2.0) >> 4, minSection, maxSection); -+ -+ final BasicEntityList[] entitiesBySection = this.entitiesBySection; -+ -+ for (int section = min; section <= max; ++section) { -+ final BasicEntityList list = entitiesBySection[section - minSection]; -+ -+ if (list == null) { -+ continue; -+ } -+ -+ final Entity[] storage = list.storage; -+ -+ for (int i = 0, len = Math.min(storage.length, list.size()); i < len; ++i) { -+ final Entity entity = storage[i]; -+ -+ if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) { -+ continue; -+ } -+ -+ if (predicate == null || predicate.test(entity)) { -+ into.add(entity); -+ if (into.size() >= maxCount) { -+ return true; -+ } -+ } // else: continue to test the ender dragon parts -+ -+ if (entity instanceof EnderDragon) { -+ for (final EnderDragonPart part : ((EnderDragon)entity).getSubEntities()) { -+ if (part == except || !part.getBoundingBox().intersects(box)) { -+ continue; -+ } -+ -+ if (predicate != null && !predicate.test(part)) { -+ continue; -+ } -+ -+ into.add(part); -+ if (into.size() >= maxCount) { -+ return true; -+ } -+ } -+ } -+ } -+ } -+ -+ return false; -+ } -+ -+ public void getEntitiesWithEnderDragonParts(final Entity except, final Class clazz, final AABB box, final List into, -+ final Predicate predicate) { -+ if (this.count == 0) { -+ return; -+ } -+ -+ final int minSection = this.slices.minSection; -+ final int maxSection = this.slices.maxSection; -+ -+ final int min = Mth.clamp(Mth.floor(box.minY - 2.0) >> 4, minSection, maxSection); -+ final int max = Mth.clamp(Mth.floor(box.maxY + 2.0) >> 4, minSection, maxSection); -+ -+ final BasicEntityList[] entitiesBySection = this.entitiesBySection; -+ -+ for (int section = min; section <= max; ++section) { -+ final BasicEntityList list = entitiesBySection[section - minSection]; -+ -+ if (list == null) { -+ continue; -+ } -+ -+ final Entity[] storage = list.storage; -+ -+ for (int i = 0, len = Math.min(storage.length, list.size()); i < len; ++i) { -+ final Entity entity = storage[i]; -+ -+ if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) { -+ continue; -+ } -+ -+ if (predicate == null || predicate.test(entity)) { -+ into.add(entity); -+ } // else: continue to test the ender dragon parts -+ -+ if (entity instanceof EnderDragon) { -+ for (final EnderDragonPart part : ((EnderDragon)entity).getSubEntities()) { -+ if (part == except || !part.getBoundingBox().intersects(box) || !clazz.isInstance(part)) { -+ continue; -+ } -+ -+ if (predicate != null && !predicate.test(part)) { -+ continue; -+ } -+ -+ into.add(part); -+ } -+ } -+ } -+ } -+ } -+ -+ public boolean getEntitiesWithEnderDragonPartsLimited(final Entity except, final Class clazz, final AABB box, final List into, -+ final Predicate predicate, final int maxCount) { -+ if (this.count == 0) { -+ return false; -+ } -+ -+ final int minSection = this.slices.minSection; -+ final int maxSection = this.slices.maxSection; -+ -+ final int min = Mth.clamp(Mth.floor(box.minY - 2.0) >> 4, minSection, maxSection); -+ final int max = Mth.clamp(Mth.floor(box.maxY + 2.0) >> 4, minSection, maxSection); -+ -+ final BasicEntityList[] entitiesBySection = this.entitiesBySection; -+ -+ for (int section = min; section <= max; ++section) { -+ final BasicEntityList list = entitiesBySection[section - minSection]; -+ -+ if (list == null) { -+ continue; -+ } -+ -+ final Entity[] storage = list.storage; -+ -+ for (int i = 0, len = Math.min(storage.length, list.size()); i < len; ++i) { -+ final Entity entity = storage[i]; -+ -+ if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) { -+ continue; -+ } -+ -+ if (predicate == null || predicate.test(entity)) { -+ into.add(entity); -+ if (into.size() >= maxCount) { -+ return true; -+ } -+ } // else: continue to test the ender dragon parts -+ -+ if (entity instanceof EnderDragon) { -+ for (final EnderDragonPart part : ((EnderDragon)entity).getSubEntities()) { -+ if (part == except || !part.getBoundingBox().intersects(box) || !clazz.isInstance(part)) { -+ continue; -+ } -+ -+ if (predicate != null && !predicate.test(part)) { -+ continue; -+ } -+ -+ into.add(part); -+ if (into.size() >= maxCount) { -+ return true; -+ } -+ } -+ } -+ } -+ } -+ -+ return false; -+ } + } +} diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java @@ -3864,9 +3693,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + protected abstract void onEmptySlices(final int chunkX, final int chunkZ); + + protected abstract void entitySectionChangeCallback( -+ final Entity entity, -+ final int oldSectionX, final int oldSectionY, final int oldSectionZ, -+ final int newSectionX, final int newSectionY, final int newSectionZ ++ final Entity entity, ++ final int oldSectionX, final int oldSectionY, final int oldSectionZ, ++ final int newSectionX, final int newSectionY, final int newSectionZ + ); + + protected abstract void addEntityCallback(final Entity entity); @@ -4003,7 +3832,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void get(final AABB box, final Consumer action) { + List entities = new ArrayList<>(); -+ this.getEntitiesWithoutDragonParts(null, box, entities, null); ++ this.getEntities((Entity)null, box, entities, null); + for (int i = 0, len = entities.size(); i < len; ++i) { + action.accept(entities.get(i)); + } @@ -4012,7 +3841,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void get(final EntityTypeTest filter, final AABB box, final AbortableIterationConsumer action) { + List entities = new ArrayList<>(); -+ this.getEntitiesWithoutDragonParts(null, box, entities, null); ++ this.getEntities((Entity)null, box, entities, null); + for (int i = 0, len = entities.size(); i < len; ++i) { + final U casted = filter.tryCast(entities.get(i)); + if (casted != null && action.accept(casted).shouldAbort()) { @@ -4172,7 +4001,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + this.addRecursivelySafe(entity, fromDisk); -+ } ++ } + } + + public boolean addNewEntity(final Entity entity) { @@ -4346,53 +4175,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + this.entitySectionChangeCallback( -+ entity, -+ sectionX, sectionY, sectionZ, -+ newSectionX, newSectionY, newSectionZ ++ entity, ++ sectionX, sectionY, sectionZ, ++ newSectionX, newSectionY, newSectionZ + ); + + return slices; + } + -+ public void getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List into, final Predicate predicate) { -+ final int minChunkX = (Mth.floor(box.minX) - 2) >> 4; -+ final int minChunkZ = (Mth.floor(box.minZ) - 2) >> 4; -+ final int maxChunkX = (Mth.floor(box.maxX) + 2) >> 4; -+ final int maxChunkZ = (Mth.floor(box.maxZ) + 2) >> 4; -+ -+ final int minRegionX = minChunkX >> REGION_SHIFT; -+ final int minRegionZ = minChunkZ >> REGION_SHIFT; -+ final int maxRegionX = maxChunkX >> REGION_SHIFT; -+ final int maxRegionZ = maxChunkZ >> REGION_SHIFT; -+ -+ for (int currRegionZ = minRegionZ; currRegionZ <= maxRegionZ; ++currRegionZ) { -+ final int minZ = currRegionZ == minRegionZ ? minChunkZ & REGION_MASK : 0; -+ final int maxZ = currRegionZ == maxRegionZ ? maxChunkZ & REGION_MASK : REGION_MASK; -+ -+ for (int currRegionX = minRegionX; currRegionX <= maxRegionX; ++currRegionX) { -+ final ChunkSlicesRegion region = this.getRegion(currRegionX, currRegionZ); -+ -+ if (region == null) { -+ continue; -+ } -+ -+ final int minX = currRegionX == minRegionX ? minChunkX & REGION_MASK : 0; -+ final int maxX = currRegionX == maxRegionX ? maxChunkX & REGION_MASK : REGION_MASK; -+ -+ for (int currZ = minZ; currZ <= maxZ; ++currZ) { -+ for (int currX = minX; currX <= maxX; ++currX) { -+ final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT)); -+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) { -+ continue; -+ } -+ -+ chunk.getEntitiesWithoutDragonParts(except, box, into, predicate); -+ } -+ } -+ } -+ } -+ } -+ + public void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { + final int minChunkX = (Mth.floor(box.minX) - 2) >> 4; + final int minChunkZ = (Mth.floor(box.minZ) - 2) >> 4; @@ -4553,48 +4343,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + //////// Limited //////// + -+ public void getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List into, final Predicate predicate, -+ final int maxCount) { -+ final int minChunkX = (Mth.floor(box.minX) - 2) >> 4; -+ final int minChunkZ = (Mth.floor(box.minZ) - 2) >> 4; -+ final int maxChunkX = (Mth.floor(box.maxX) + 2) >> 4; -+ final int maxChunkZ = (Mth.floor(box.maxZ) + 2) >> 4; -+ -+ final int minRegionX = minChunkX >> REGION_SHIFT; -+ final int minRegionZ = minChunkZ >> REGION_SHIFT; -+ final int maxRegionX = maxChunkX >> REGION_SHIFT; -+ final int maxRegionZ = maxChunkZ >> REGION_SHIFT; -+ -+ for (int currRegionZ = minRegionZ; currRegionZ <= maxRegionZ; ++currRegionZ) { -+ final int minZ = currRegionZ == minRegionZ ? minChunkZ & REGION_MASK : 0; -+ final int maxZ = currRegionZ == maxRegionZ ? maxChunkZ & REGION_MASK : REGION_MASK; -+ -+ for (int currRegionX = minRegionX; currRegionX <= maxRegionX; ++currRegionX) { -+ final ChunkSlicesRegion region = this.getRegion(currRegionX, currRegionZ); -+ -+ if (region == null) { -+ continue; -+ } -+ -+ final int minX = currRegionX == minRegionX ? minChunkX & REGION_MASK : 0; -+ final int maxX = currRegionX == maxRegionX ? maxChunkX & REGION_MASK : REGION_MASK; -+ -+ for (int currZ = minZ; currZ <= maxZ; ++currZ) { -+ for (int currX = minX; currX <= maxX; ++currX) { -+ final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT)); -+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) { -+ continue; -+ } -+ -+ if (chunk.getEntitiesWithoutDragonParts(except, box, into, predicate, maxCount)) { -+ return; -+ } -+ } -+ } -+ } -+ } -+ } -+ + public void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate, + final int maxCount) { + final int minChunkX = (Mth.floor(box.minX) - 2) >> 4; @@ -25886,7 +25634,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public void removeTicketsOnClosing() { -- ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve +- ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve - ObjectIterator>>> objectiterator = this.tickets.long2ObjectEntrySet().fastIterator(); - - while (objectiterator.hasNext()) { @@ -30343,24 +30091,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - list.add(entity1); - } - -- if (entity1 instanceof EnderDragon) { -- EnderDragonPart[] aentitycomplexpart = ((EnderDragon) entity1).getSubEntities(); -- int i = aentitycomplexpart.length; +- }); +- Iterator iterator = this.dragonParts().iterator(); + // Paper start - rewrite chunk system + final List ret = new java.util.ArrayList<>(); -- for (int j = 0; j < i; ++j) { -- EnderDragonPart entitycomplexpart = aentitycomplexpart[j]; +- while (iterator.hasNext()) { +- EnderDragonPart entitycomplexpart = (EnderDragonPart) iterator.next(); + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(except, box, ret, predicate); -- if (entity1 != except && predicate.test(entitycomplexpart)) { -- list.add(entitycomplexpart); -- } -- } +- if (entitycomplexpart != except && entitycomplexpart.parentMob != except && predicate.test(entitycomplexpart) && box.intersects(entitycomplexpart.getBoundingBox())) { +- list.add(entitycomplexpart); - } +- } + ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, except, box, predicate, ret); -- }); - return list; + return ret; + // Paper end - rewrite chunk system @@ -33351,6 +33096,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - Util.backgroundExecutor().forName("parseSection") - ) - .exceptionally(throwable -> { +- if (throwable instanceof CompletionException) { +- throwable = throwable.getCause(); +- } +- - if (throwable instanceof IOException iOException) { - LOGGER.error("Error reading chunk {} data from disk", chunkPos, iOException); - this.errorReporter.reportChunkLoadFailure(iOException, this.simpleRegionStorage.storageInfo(), chunkPos); diff --git a/patches/server/Rewrite-dataconverter-system.patch b/patches/server/Rewrite-dataconverter-system.patch index 7611f1bcfc..e290520f52 100644 --- a/patches/server/Rewrite-dataconverter-system.patch +++ b/patches/server/Rewrite-dataconverter-system.patch @@ -451,7 +451,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 4067, + 4068, + 4081, -+ // All up to 1.21.3 ++ 4173, ++ 4175, ++ 4176, ++ 4180, ++ 4181 ++ // All up to 1.21.4-pre2 + }; + Arrays.sort(converterVersions); + @@ -1201,6 +1206,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static final int V1_21_2_RC2 = 4079; + public static final int V1_21_2 = 4080; + public static final int V1_21_3 = 4082; ++ public static final int V24W44A = 4174; ++ public static final int V24W45A = 4177; ++ public static final int V24W46A = 4178; ++ public static final int V1_21_4_PRE1 = 4179; ++ public static final int V1_21_4_PRE2 = 4182; + + private MCVersions() {} +} @@ -9664,6 +9674,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + V4071.register(); + // V1.21.3 + V4081.register(); ++ // V1.21.4 ++ V4173.register(); ++ V4175.register(); ++ V4176.register(); ++ V4180.register(); ++ V4181.register(); + } + + private MCTypeRegistry() {} @@ -24374,6 +24390,202 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private V4081() {} +} +diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4173.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4173.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4173.java +@@ -0,0 +0,0 @@ ++package ca.spottedleaf.dataconverter.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.types.MapType; ++ ++public final class V4173 { ++ ++ private static final int VERSION = MCVersions.V1_21_3 + 91; ++ ++ public static void register() { ++ MCTypeRegistry.ENTITY.addStructureConverter(new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ RenameHelper.renameSingle(data, "TNTFuse", "fuse"); ++ return null; ++ } ++ }); ++ } ++ ++ private V4173() {} ++} +diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4175.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4175.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4175.java +@@ -0,0 +0,0 @@ ++package ca.spottedleaf.dataconverter.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.types.ListType; ++import ca.spottedleaf.dataconverter.types.MapType; ++import ca.spottedleaf.dataconverter.types.TypeUtil; ++ ++public final class V4175 { ++ ++ private static final int VERSION = MCVersions.V24W44A + 1; ++ ++ public static void register() { ++ MCTypeRegistry.DATA_COMPONENTS.addStructureConverter(new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ RenameHelper.renameSingle(data.getMap("minecraft:equippable"), "model", "asset_id"); ++ ++ final Number modelData = data.getNumber("minecraft:custom_model_data"); ++ if (modelData != null) { ++ final TypeUtil typeUtil = data.getTypeUtil(); ++ ++ final MapType newModelData = typeUtil.createEmptyMap(); ++ data.setMap("minecraft:custom_model_data", newModelData); ++ ++ final ListType floats = typeUtil.createEmptyList(); ++ newModelData.setList("floats", floats); ++ ++ floats.addFloat(modelData.floatValue()); ++ } ++ ++ return null; ++ } ++ }); ++ } ++ ++ private V4175() {} ++} +diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4176.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4176.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4176.java +@@ -0,0 +0,0 @@ ++package ca.spottedleaf.dataconverter.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 V4176 { ++ ++ private static final int VERSION = MCVersions.V24W44A + 2; ++ ++ private static void fixInvalidLock(final MapType root, final String path) { ++ final MapType lock = root.getMap(path); ++ if (lock == null || lock.size() != 1) { ++ return; ++ } ++ ++ final MapType components = lock.getMap("components"); ++ if (components == null || components.size() != 1 || !"\"\"".equals(components.getString("minecraft:custom_name"))) { ++ return; ++ } ++ ++ root.remove(path); ++ } ++ ++ public static void register() { ++ MCTypeRegistry.TILE_ENTITY.addStructureConverter(new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ fixInvalidLock(data, "lock"); ++ return null; ++ } ++ }); ++ MCTypeRegistry.DATA_COMPONENTS.addStructureConverter(new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ fixInvalidLock(data, "minecraft:lock"); ++ return null; ++ } ++ }); ++ } ++ ++ private V4176() {} ++} +diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4180.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4180.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4180.java +@@ -0,0 +0,0 @@ ++package ca.spottedleaf.dataconverter.minecraft.versions; ++ ++import ca.spottedleaf.dataconverter.minecraft.MCVersions; ++import ca.spottedleaf.dataconverter.minecraft.converters.leveldat.ConverterRemoveFeatureFlag; ++import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry; ++import java.util.Arrays; ++import java.util.HashSet; ++ ++public final class V4180 { ++ ++ private static final int VERSION = MCVersions.V1_21_4_PRE1 + 1; ++ ++ public static void register() { ++ MCTypeRegistry.LEVEL.addStructureConverter(new ConverterRemoveFeatureFlag(VERSION, new HashSet<>( ++ Arrays.asList( ++ "minecraft:winter_drop" ++ ) ++ ))); ++ } ++ ++ private V4180() {} ++} +diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4181.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4181.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4181.java +@@ -0,0 +0,0 @@ ++package ca.spottedleaf.dataconverter.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.types.MapType; ++ ++public final class V4181 { ++ ++ private static final int VERSION = MCVersions.V1_21_4_PRE1 + 2; ++ ++ public static void register() { ++ final DataConverter, MapType> furnaceConverter = new DataConverter<>(VERSION) { ++ @Override ++ public MapType convert(final MapType data, final long sourceVersion, final long toVersion) { ++ RenameHelper.renameSingle(data, "CookTime", "cooking_time_spent"); ++ RenameHelper.renameSingle(data, "CookTimeTotal", "cooking_total_time"); ++ RenameHelper.renameSingle(data, "BurnTime", "lit_time_remaining"); ++ ++ final Object litTotalTime = data.getGeneric("lit_total_time"); ++ if (litTotalTime != null) { ++ data.setGeneric("lit_time_remaining", litTotalTime); ++ } ++ ++ return null; ++ } ++ }; ++ ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:furnace", furnaceConverter); ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:smoker", furnaceConverter); ++ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:blast_furnace", furnaceConverter); ++ } ++ ++ private V4181() {} ++} diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V501.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V501.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -30239,7 +30451,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/data/structures/StructureUpdater.java +++ b/src/main/java/net/minecraft/data/structures/StructureUpdater.java @@ -0,0 +0,0 @@ public class StructureUpdater implements SnbtToNbt.Filter { - LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", i, 4053, name); + LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", i, 4173, name); } - CompoundTag compoundTag = DataFixTypes.STRUCTURE.updateToCurrentVersion(DataFixers.getDataFixer(), nbt, i);