diff --git a/gradle.properties b/gradle.properties index c97c8acb..9a8ada7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,8 +7,8 @@ org.gradle.configuration-cache=false # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=26.1-snapshot-1 - loader_version=0.18.3 + minecraft_version=26.1-snapshot-2 + loader_version=0.18.4 loom_version=1.14-SNAPSHOT # Mod Properties diff --git a/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java b/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java index 4417cfde..19dddc05 100644 --- a/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java +++ b/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java @@ -108,7 +108,7 @@ public abstract class LevelChunk_movableBEMixin extends ChunkAccess implements W if (hadOnlyAir != hasOnlyAir) { this.level.getChunkSource().getLightEngine().updateSectionStatus(blockPos_1, hasOnlyAir); - this.level.getChunkSource().onSectionEmptinessChanged(chunkPos.x, SectionPos.blockToSectionCoord(y), chunkPos.z, hasOnlyAir); + this.level.getChunkSource().onSectionEmptinessChanged(chunkPos.x(), SectionPos.blockToSectionCoord(y), chunkPos.z(), hasOnlyAir); } if (LightEngine.hasDifferentLightProperties(oldBlockState, newBlockState)) { diff --git a/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java b/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java index 51ae9212..b13b77a2 100644 --- a/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java +++ b/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java @@ -21,7 +21,7 @@ public class LevelEntityGetterAdapter_scarpetMixin imple @Override public List getChunkEntities(ChunkPos chpos) { - return this.sectionStorage.getExistingSectionsInChunk(chpos.toLong()).flatMap(EntitySection::getEntities).collect(Collectors.toList()); + return this.sectionStorage.getExistingSectionsInChunk(chpos.pack()).flatMap(EntitySection::getEntities).collect(Collectors.toList()); } } diff --git a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java index ea0eaa22..7b21034a 100644 --- a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java @@ -46,9 +46,9 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends ChunkPos pos = chunk.getPos(); chunk.setLightCorrect(false); - this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + this.addTask(pos.x(), pos.z(), () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { super.setLightEnabled(pos, false); - ((Lighting_scarpetChunkCreationInterface) this).removeLightData(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z))); + ((Lighting_scarpetChunkCreationInterface) this).removeLightData(SectionPos.getZeroNode(SectionPos.asLong(pos.x(), 0, pos.z()))); }, () -> "Remove light data " + pos )); @@ -59,7 +59,7 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends { ChunkPos pos = chunk.getPos(); - this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + this.addTask(pos.x(), pos.z(), () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { super.propagateLightSources(pos); int minY = chunk.getMinY(); int maxY = chunk.getMaxY(); @@ -92,7 +92,7 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends }, () -> "Release relight ticket " + pos ), - runnable -> this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.POST_UPDATE, runnable) + runnable -> this.addTask(pos.x(), pos.z(), () -> 0, ThreadedLevelLightEngine.TaskType.POST_UPDATE, runnable) ); } } diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index c7a8ecc8..0c2005dc 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -509,7 +509,7 @@ public class CarpetEventServer public void onChunkEvent(ServerLevel world, ChunkPos chPos, boolean generated) { handler.call( - () -> Arrays.asList(new NumericValue(chPos.x << 4), new NumericValue(chPos.z << 4)), + () -> Arrays.asList(new NumericValue(chPos.x() << 4), new NumericValue(chPos.z() << 4)), () -> world.getServer().createCommandSourceStack().withLevel(world) ); } @@ -521,7 +521,7 @@ public class CarpetEventServer public void onChunkEvent(ServerLevel world, ChunkPos chPos, boolean generated) { handler.call( - () -> Arrays.asList(new NumericValue(chPos.x << 4), new NumericValue(chPos.z << 4)), + () -> Arrays.asList(new NumericValue(chPos.x() << 4), new NumericValue(chPos.z() << 4)), () -> world.getServer().createCommandSourceStack().withLevel(world) ); } @@ -533,7 +533,7 @@ public class CarpetEventServer public void onChunkEvent(ServerLevel world, ChunkPos chPos, boolean generated) { handler.call( - () -> Arrays.asList(new NumericValue(chPos.x << 4), new NumericValue(chPos.z << 4)), + () -> Arrays.asList(new NumericValue(chPos.x() << 4), new NumericValue(chPos.z() << 4)), () -> world.getServer().createCommandSourceStack().withLevel(world) ); } diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 0b7bd103..a748e752 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -570,9 +570,9 @@ public class WorldAccess expression.addContextFunction("in_slime_chunk", -1, (c, t, lv) -> { BlockPos pos = BlockArgument.findIn((CarpetContext) c, lv, 0).block.getPos(); - ChunkPos chunkPos = new ChunkPos(pos); + ChunkPos chunkPos = ChunkPos.containing(pos); return BooleanValue.of(WorldgenRandom.seedSlimeChunk( - chunkPos.x, chunkPos.z, + chunkPos.x(), chunkPos.z(), ((CarpetContext) c).level().getSeed(), 987234911L ).nextInt(10) == 0); @@ -624,7 +624,7 @@ public class WorldAccess { force = lv.get(locator.offset).getBoolean(); } - return BooleanValue.of(canHasChunk(((CarpetContext) c).level(), new ChunkPos(pos), null, force)); + return BooleanValue.of(canHasChunk(((CarpetContext) c).level(), ChunkPos.containing(pos), null, force)); }); expression.addContextFunction("generation_status", -1, (c, t, lv) -> @@ -651,14 +651,14 @@ public class WorldAccess { for (long key : levelTickets.keySet()) { - ChunkPos chpos = new ChunkPos(key); + ChunkPos chpos = ChunkPos.unpack(key); for (Ticket ticket : levelTickets.get(key)) { res.add(ListValue.of( new StringValue(ticket.getType().toString()), new NumericValue(33 - ticket.getTicketLevel()), - new NumericValue(chpos.x), - new NumericValue(chpos.z) + new NumericValue(chpos.x()), + new NumericValue(chpos.z()) )); } } @@ -667,7 +667,7 @@ public class WorldAccess { BlockArgument blockArgument = BlockArgument.findIn((CarpetContext) c, lv, 0); BlockPos pos = blockArgument.block.getPos(); - List tickets = levelTickets.get(new ChunkPos(pos).toLong()); + List tickets = levelTickets.get(ChunkPos.containing(pos).pack()); if (tickets != null) { for (Ticket ticket : tickets) @@ -1574,7 +1574,7 @@ public class WorldAccess world.getChunk(chpos.getWorldPosition()).getAllReferences(); if (references.containsKey(configuredStructure) && references.get(configuredStructure) != null) { - references.get(configuredStructure).remove(structureChunkPos.toLong()); + references.get(configuredStructure).remove(structureChunkPos.pack()); } } } @@ -1695,7 +1695,7 @@ public class WorldAccess throw new InternalExpressionException("Ticket radius should be between 1 and 32 chunks"); } // due to types we will wing it: - ChunkPos target = new ChunkPos(pos); + ChunkPos target = ChunkPos.containing(pos); if (ticket == TicketType.PORTAL) // portal { cc.level().getChunkSource().addTicketWithRadius(TicketType.PORTAL, target, radius); diff --git a/src/main/java/carpet/script/utils/FeatureGenerator.java b/src/main/java/carpet/script/utils/FeatureGenerator.java index f6186fd3..5955d889 100644 --- a/src/main/java/carpet/script/utils/FeatureGenerator.java +++ b/src/main/java/carpet/script/utils/FeatureGenerator.java @@ -239,8 +239,8 @@ public class FeatureGenerator ChunkGenerator generator = chunkSource.getGenerator(); ChunkGeneratorStructureState structureState = chunkSource.getGeneratorState(); List structureConfig = structureState.getPlacementsForStructure(Holder.direct(structure)); - ChunkPos chunkPos = new ChunkPos(pos); - boolean couldPlace = structureConfig.stream().anyMatch(p -> p.isStructureChunk(structureState, chunkPos.x, chunkPos.z)); + ChunkPos chunkPos = ChunkPos.containing(pos); + boolean couldPlace = structureConfig.stream().anyMatch(p -> p.isStructureChunk(structureState, chunkPos.x(), chunkPos.z())); if (!couldPlace) { return null; @@ -418,7 +418,7 @@ public class FeatureGenerator checks.set(true); try { - StructureStart start = structure.generate(Holder.direct(structure), world.dimension(), world.registryAccess(), generator, generator.getBiomeSource(), world.getChunkSource().randomState(), world.getStructureManager(), world.getSeed(), new ChunkPos(pos), 0, world, b -> true); + StructureStart start = structure.generate(Holder.direct(structure), world.dimension(), world.registryAccess(), generator, generator.getBiomeSource(), world.getChunkSource().randomState(), world.getStructureManager(), world.getSeed(), ChunkPos.containing(pos), 0, world, b -> true); if (start == StructureStart.INVALID_START) { return false; @@ -426,7 +426,7 @@ public class FeatureGenerator RandomSource rand = RandomSource.create(world.getRandom().nextInt()); int j = pos.getX() >> 4; int k = pos.getZ() >> 4; - long chId = ChunkPos.asLong(j, k); + long chId = ChunkPos.pack(j, k); world.getChunk(j, k).setStartForStructure(structure, start); world.getChunk(j, k).addReferenceForStructure(structure, chId); diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index c3c4064f..27dea11b 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -47,7 +47,7 @@ public class WorldTools public static boolean canHasChunk(ServerLevel world, ChunkPos chpos, @Nullable Map regionCache, boolean deepcheck) { - if (world.getChunk(chpos.x, chpos.z, ChunkStatus.STRUCTURE_STARTS, false) != null) + if (world.getChunk(chpos.x(), chpos.z(), ChunkStatus.STRUCTURE_STARTS, false) != null) { return true; } @@ -159,8 +159,8 @@ public class WorldTools public static void forceChunkUpdate(BlockPos pos, ServerLevel world) { - ChunkPos chunkPos = new ChunkPos(pos); - LevelChunk worldChunk = world.getChunkSource().getChunk(chunkPos.x, chunkPos.z, false); + ChunkPos chunkPos = ChunkPos.containing(pos); + LevelChunk worldChunk = world.getChunkSource().getChunk(chunkPos.x(), chunkPos.z(), false); if (worldChunk != null) { List players = world.getChunkSource().chunkMap.getPlayers(chunkPos, false);