From c23c63ba2fd3a333fa4c9701766744e5dedee438 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Wed, 10 Dec 2025 03:52:39 +0000 Subject: [PATCH 1/4] Update to dasm 3.1.0 --- build.gradle | 11 +- .../client/multiplayer/ClientCubeCache.java | 18 +- .../multiplayer/MixinClientChunkCache.java | 14 +- .../client/renderer/MixinLevelRenderer.java | 3 +- .../renderer/MixinSectionOcclusionGraph.java | 18 +- .../renderer/chunk/MixinSectionCopy.java | 13 +- .../MixinGenerationChunkHolder_Forge.java | 4 +- .../level/MixinChunkGenerationTask.java | 40 ++-- .../common/server/level/MixinChunkHolder.java | 56 +++--- .../level/MixinChunkMap$TrackedEntity.java | 6 +- .../common/server/level/MixinChunkMap.java | 182 ++++++++++-------- .../level/MixinChunkTaskDispatcher.java | 4 +- .../level/MixinChunkTaskPriorityQueue.java | 3 +- .../level/MixinGenerationChunkHolder.java | 51 ++--- .../server/level/MixinServerChunkCache.java | 115 ++++++----- .../common/server/level/MixinServerLevel.java | 25 +-- .../server/level/MixinServerPlayer.java | 10 +- .../level/MixinSimulationChunkTracker.java | 3 +- .../MixinLoggerChunkProgressListener.java | 5 +- .../MixinProcessorChunkProgressListener.java | 9 +- .../MixinStoringChunkProgressListener.java | 11 +- .../network/MixinPlayerChunkSender.java | 14 +- .../core/common/world/entity/MixinEntity.java | 15 +- .../core/common/world/level/MixinLevel.java | 72 ++++--- .../world/level/MixinTicketStorage.java | 17 +- .../chunk/storage/MixinChunkStorage.java | 9 +- .../mixin/dasmsets/ChunkToCloSet.java | 162 +++++++++------- .../mixin/dasmsets/ChunkToCubeSet.java | 160 +++++++++------ .../cubicchunks/mixin/dasmsets/GlobalSet.java | 39 ++-- .../mixin/dasmsets/SectionPosToChunkSet.java | 3 +- .../mixin/dasmsets/SectionPosToCubeSet.java | 3 +- .../CCCommonHooks.java | 10 +- .../CCEventHooks.java | 21 +- .../server/level/CloTrackingView.java | 44 +++-- .../cubicchunks/server/level/CubeLevel.java | 23 ++- .../chunk/status/CCChunkStatusTasks.java | 92 ++++++--- .../world/level/cube/CubeAccess.java | 99 +++++----- .../world/level/cube/ImposterProtoCube.java | 4 +- .../world/level/cube/LevelCube.java | 130 +++++++------ .../world/level/cube/ProtoCube.java | 75 ++++---- .../world/level/cube/status/CubePyramid.java | 13 +- .../level/cube/status/CubeStatusTasks.java | 94 +++++---- .../world/level/cube/status/CubeStep.java | 52 ++--- 43 files changed, 1005 insertions(+), 747 deletions(-) diff --git a/build.gradle b/build.gradle index 7fb172af..1b534158 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ import io.github.opencubicchunks.gradle.FixAnnotationsFormatterStep import io.github.opencubicchunks.gradle.GeneratePackageInfo -import org.gradle.api.tasks.testing.logging.TestExceptionFormat buildscript { dependencies { @@ -229,10 +228,10 @@ neoForge { enable() // Configure which mod is being tested. // This allows NeoForge to load the test/ classes and resources as belonging to the mod. - testedMod = mods.cubicchunks // must match the name in the mods { } block. - // Configure which mods are loaded in the test environment, if the default (all declared mods) is not appropriate. - // This must contain testedMod, and can include other mods as well. - // loadedMods = [mods., mods.] + testedMod = mods.cubicchunks // must match the name in the mods { } block. + // Configure which mods are loaded in the test environment, if the default (all declared mods) is not appropriate. + // This must contain testedMod, and can include other mods as well. + // loadedMods = [mods., mods.] } } @@ -269,7 +268,7 @@ dependencies { targetConfiguration = "testArchivesOutput" } - libraries("io.github.notstirred:dasm:2.5.4") { + libraries("io.github.notstirred:dasm:3.1.0") { transitive = false } libraries("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT") diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java index 2a6e4479..95451f31 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java @@ -9,7 +9,6 @@ import javax.annotation.Nullable; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -36,8 +35,8 @@ public interface ClientCubeCache extends CubeSource { void cc_replaceBiomes(int x, int y, int z, FriendlyByteBuf buffer); @Nullable LevelCube cc_replaceWithPacketData( - int x, int y, int z, FriendlyByteBuf buffer, Map map, - Consumer consumer + int x, int y, int z, FriendlyByteBuf buffer, Map map, + Consumer consumer ); void cc_updateViewCenter(int x, int y, int z); @@ -68,7 +67,7 @@ public Storage(int chunkRadius, ClientLevel clientLevel) { public int getIndex(int x, int y, int z) { return Math.floorMod(z, this.viewRange) * this.viewRange * this.viewRange + Math.floorMod(y, this.viewRange) * this.viewRange - + Math.floorMod(x, this.viewRange); + + Math.floorMod(x, this.viewRange); } public void replace(int chunkIndex, @Nullable LevelCube chunk) { @@ -111,7 +110,7 @@ public void dropEmptySections(LevelCube chunk) { for (int dy = 0; dy < CubicConstants.DIAMETER_IN_SECTIONS; dy++) { for (int dz = 0; dz < CubicConstants.DIAMETER_IN_SECTIONS; dz++) { long sectionPosLong = SectionPos.asLong(Coords.cubeToSection(cubePos.getX(), dx), Coords.cubeToSection(cubePos.getY(), dy), - Coords.cubeToSection(cubePos.getZ(), dz)); + Coords.cubeToSection(cubePos.getZ(), dz)); this.loadedEmptySections.remove(sectionPosLong); } } @@ -127,7 +126,7 @@ public void addEmptySections(LevelCube chunk) { for (int dz = 0; dz < CubicConstants.DIAMETER_IN_SECTIONS; dz++) { var chunkSection = chunkSections[Coords.sectionToIndex(dx, dy, dz)]; long sectionPosLong = SectionPos.asLong(Coords.cubeToSection(cubePos.getX(), dx), Coords.cubeToSection(cubePos.getY(), dy), - Coords.cubeToSection(cubePos.getZ(), dz)); + Coords.cubeToSection(cubePos.getZ(), dz)); if (chunkSection.hasOnlyAir()) { this.loadedEmptySections.add(sectionPosLong); } @@ -145,7 +144,7 @@ public void refreshEmptySections(LevelCube chunk) { for (int dz = 0; dz < CubicConstants.DIAMETER_IN_SECTIONS; dz++) { var chunkSection = chunkSections[Coords.sectionToIndex(dx, dy, dz)]; long sectionPosLong = SectionPos.asLong(Coords.cubeToSection(cubePos.getX(), dx), Coords.cubeToSection(cubePos.getY(), dy), - Coords.cubeToSection(cubePos.getZ(), dz)); + Coords.cubeToSection(cubePos.getZ(), dz)); if (chunkSection.hasOnlyAir()) { this.loadedEmptySections.add(sectionPosLong); } else if (this.loadedEmptySections.remove(sectionPosLong)) { @@ -158,10 +157,11 @@ public void refreshEmptySections(LevelCube chunk) { public boolean inRange(int x, int y, int z) { return Math.abs(x - this.viewCenterX) <= this.cubeRadius && Math.abs(y - this.viewCenterY) <= this.cubeRadius - && Math.abs(z - this.viewCenterZ) <= this.cubeRadius; + && Math.abs(z - this.viewCenterZ) <= this.cubeRadius; } - @TransformFromMethod(owner = @Ref(ClientChunkCache.Storage.class), value = @MethodSig("getChunk(I)Lnet/minecraft/world/level/chunk/LevelChunk;"), visibility = PUBLIC) + @TransformFromMethod(owner = @Ref(ClientChunkCache.Storage.class), value = "getChunk(I)Lnet/minecraft/world/level/chunk/LevelChunk;", + visibility = PUBLIC) public native @Nullable LevelCube getChunk(int chunkIndex); public void dumpChunks(String filePath) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java index efcbb29f..4cc4ae2b 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java @@ -10,7 +10,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; @@ -38,13 +37,14 @@ /** * The vanilla {@link ClientChunkCache} class stores all loaded chunks on the client and has methods to update and unload them, as well as change the - * center and range of the chunk storage. - * This mixin adds versions of these methods for cubes, meaning that this class now stores both cubes and chunks. + * center and range of the chunk storage. This mixin adds versions of these methods for cubes, meaning that this class now stores both cubes and + * chunks. */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ClientChunkCache.class)) @Mixin(ClientChunkCache.class) public abstract class MixinClientChunkCache extends MixinChunkSource implements ClientCubeCache { - @AddFieldToSets(containers = ChunkToCubeSet.ClientChunkCache_redirects.class, field = @FieldSig(type = @Ref(ClientChunkCache.Storage.class), name = "storage")) + @AddFieldToSets(containers = ChunkToCubeSet.ClientChunkCache_redirects.class, + field = "storage:Lnet/minecraft/client/multiplayer/ClientChunkCache$Storage;") volatile ClientCubeCache.Storage cc_cubeStorage; private LevelCube cc_emptyCube; @@ -58,7 +58,7 @@ public abstract class MixinClientChunkCache extends MixinChunkSource implements private void cc_onConstruct(ClientLevel level, int viewDistance, CallbackInfo ci) { if (((CanBeCubic) level).cc_isCubic()) { cc_emptyCube = new EmptyLevelCube(level, CubePos.of(0, 0, 0), - level.registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS)); + level.registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS)); cc_cubeStorage = new ClientCubeCache.Storage(calculateStorageRange(viewDistance), level); // TODO we could redirect the initial construction instead of immediately resizing. doesn't really matter updateViewRadius(cc_calculateChunkViewDistance(viewDistance)); @@ -116,8 +116,8 @@ private static boolean cc_isValidCube(@Nullable LevelCube chunk, int x, int y, i } @Override public @Nullable LevelCube cc_replaceWithPacketData( - int x, int y, int z, FriendlyByteBuf buffer, Map map, - Consumer consumer + int x, int y, int z, FriendlyByteBuf buffer, Map map, + Consumer consumer ) { if (!this.cc_cubeStorage.inRange(x, y, z)) { LOGGER.warn("Ignoring cube since it's not in the view range: {}, {}, {}", x, y, z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java index 846af3d3..d7a7946c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -15,6 +14,6 @@ @Mixin(LevelRenderer.class) public abstract class MixinLevelRenderer implements CubicLevelRenderer { @AddTransformToSets(ChunkToCubeSet.LevelRenderer_redirects.class) - @TransformFromMethod(@MethodSig("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_onCubeReadyToRender(CubePos cubePos); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java index 5026cf5c..829b55d9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java @@ -7,7 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -43,10 +42,11 @@ private void cc_onWaitAndReset(@Nullable ViewArea viewArea, CallbackInfo ci) { } @AddTransformToSets(ChunkToCubeSet.SectionOcclusionGraph_redirects.class) - @TransformFromMethod(@MethodSig("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_onCubeReadyToRender(CubePos cubePos); - @AddMethodToSets(containers = ChunkToCubeSet.SectionOcclusionGraph_redirects.class, method = @MethodSig("addNeighbors(Lnet/minecraft/client/renderer/SectionOcclusionGraph$GraphEvents;Lnet/minecraft/world/level/ChunkPos;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.SectionOcclusionGraph_redirects.class, + method = "addNeighbors(Lnet/minecraft/client/renderer/SectionOcclusionGraph$GraphEvents;Lnet/minecraft/world/level/ChunkPos;)V") private void cc_addNeighbors(SectionOcclusionGraph.GraphEvents graphEvents, CubePos cubePos) { var access = ((SectionOcclusionGraph$GraphEventsAccess) (Object) graphEvents); int cubeX = cubePos.getX(); @@ -64,9 +64,11 @@ private void cc_addNeighbors(SectionOcclusionGraph.GraphEvents graphEvents, Cube } } - @WrapOperation(method = "initializeQueueForFullUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ViewArea;getRenderSection(J)Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection;")) + @WrapOperation(method = "initializeQueueForFullUpdate", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ViewArea;getRenderSection(J)" + + "Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection;")) private @Nullable SectionRenderDispatcher.RenderSection cc_onInitializeQueueForFullUpdate_getRenderSectionAt( - ViewArea instance, long sectionPos, Operation original + ViewArea instance, long sectionPos, Operation original ) { var result = original.call(instance, sectionPos); if (result == null && cc_isCubic) { @@ -95,13 +97,13 @@ private void cc_onIsInViewDistance(long originSectionPosLong, long sectionPosLon int posCubeY = Coords.blockToCube(SectionPos.y(sectionPosLong)); int posCubeZ = Coords.blockToCube(SectionPos.z(sectionPosLong)); cir.setReturnValue(CloTrackingView.cc_isInViewDistance(originCubeX, originCubeY, originCubeZ, - Coords.sectionToCubeRenderDistance(this.viewArea.getViewDistance()), posCubeX, posCubeY, posCubeZ)); + Coords.sectionToCubeRenderDistance(this.viewArea.getViewDistance()), posCubeX, posCubeY, posCubeZ)); } @Inject(method = "getRelativeFrom", at = @At("HEAD"), cancellable = true) private void cc_onGetRelativeFrom( - long sectionPosLong, SectionRenderDispatcher.RenderSection section, Direction direction, - CallbackInfoReturnable cir + long sectionPosLong, SectionRenderDispatcher.RenderSection section, Direction direction, + CallbackInfoReturnable cir ) { if (!cc_isCubic) { return; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java index 5d5ae755..372fef90 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java @@ -3,31 +3,28 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.exception.DasmFailedToApply; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; import net.minecraft.client.renderer.chunk.SectionCopy; -import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; import org.spongepowered.asm.mixin.Mixin; /** - * The vanilla {@link SectionCopy} stores block data of a {@link LevelChunkSection} and is used for rendering that section. - * We simply add a constructor that creates the {@code SectionCopy} from a cube instead of a chunk. + * The vanilla {@link SectionCopy} stores block data of a {@link LevelChunkSection} and is used for rendering that section. We simply add a + * constructor that creates the {@code SectionCopy} from a cube instead of a chunk. */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(SectionCopy.class)) @Mixin(SectionCopy.class) public class MixinSectionCopy { // TODO is this field on the vanilla class actually used anywhere? based on snowblower output not having it, it seems like neoforge is adding it? - @AddFieldToSets(containers = ChunkToCubeSet.SectionCopy_redirects.class, field = @FieldSig(type = @Ref(LevelChunk.class), name = "wrapped")) - final LevelCube cc_wrapped; + @AddFieldToSets(containers = ChunkToCubeSet.SectionCopy_redirects.class, + field = "wrapped:Lnet/minecraft/world/level/chunk/LevelChunk;") final LevelCube cc_wrapped; @AddTransformToSets(ChunkToCubeSet.SectionCopy_redirects.class) - @TransformFromMethod(@MethodSig("(Lnet/minecraft/world/level/chunk/LevelChunk;I)V")) + @TransformFromMethod("(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") public MixinSectionCopy(LevelCube wrapped, int sectionIndex) { throw new DasmFailedToApply(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java index 05b3eb1a..aa53abf2 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; @@ -21,7 +20,8 @@ public class MixinGenerationChunkHolder_Forge { @Shadow public LevelChunk currentlyLoading; // Corresponds to field added by Forge - @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_Forge_Jank_redirects.class, field = @FieldSig(name = "currentlyLoading", type = @Ref(LevelChunk.class))) + @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_Forge_Jank_redirects.class, + field = "currentlyLoading:Lnet/minecraft/world/level/chunk/LevelChunk;") public LevelCube cc_currentlyLoadingCube; public LevelClo cc_getCurrentlyLoading() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java index 23a98d7c..8ea52bce 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java @@ -5,8 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.annotation.Public; @@ -45,8 +43,7 @@ * chunks as required. *

* We modify it to support cube loading as well, loading both neighboring cubes and chunks as required, and preserving chunk-cube load order - * invariants - * (cube status never exceeds the status of any chunks intersecting it) + * invariants (cube status never exceeds the status of any chunks intersecting it) */ @Dasm(value = GlobalSet.class, target = @Ref(ChunkGenerationTask.class)) @Mixin(ChunkGenerationTask.class) @@ -57,13 +54,13 @@ public abstract class MixinChunkGenerationTask implements CloGenerationTask { @Shadow @Final public ChunkStatus targetStatus; @Shadow private volatile boolean markedForCancellation; @Shadow @Final private StaticCache2D cache; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = @FieldSig(type = @Ref(ChunkPos.class), name = "pos")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = "pos:Lnet/minecraft/world/level/ChunkPos;") private CubePos cc_cubePos; // scheduledChunkStatus must be one status higher than the scheduled status for cubes until the target status is reached, to ensure load order // invariants are preserved // we use the vanilla field for cube status, since that is the status of the actual cube that is being generated public @Nullable ChunkStatus cc_scheduledChunkStatus; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = @FieldSig(type = @Ref(StaticCache2D.class), name = "cache")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = "cache:Lnet/minecraft/util/StaticCache2D;") private StaticCache3D cc_cubeCache; private GeneratingCubeMap cc_getGeneratingCubeMap() { @@ -80,7 +77,9 @@ private GeneratingCubeMap cc_getGeneratingCubeMap() { /** * Factory method to create a {@code ChunkGenerationTask} for a cube. */ - @AddMethodToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, method = @MethodSig("create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, + method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;") @Public private static ChunkGenerationTask cc_createCubeGenerationTask(GeneratingChunkMap chunkMap, ChunkStatus targetStatus, CubePos pos) { int cubeRadius = CubePyramid.CC_GENERATION_PYRAMID_CUBES.getStepTo(targetStatus).getAccumulatedRadiusOf(ChunkStatus.EMPTY); int cubeDiameter = cubeRadius * 2 + 1; @@ -88,16 +87,18 @@ private GeneratingCubeMap cc_getGeneratingCubeMap() { // We directly use the StaticCache2D constructor, as the `create` factory method only allows for odd dimensions, and `chunkDiameter` is even // (for cube sizes greater than 16) StaticCache2D staticcache2d = new StaticCache2D<>(Coords.cubeToSection(pos.getX() - cubeRadius, 0), - Coords.cubeToSection(pos.getZ() - cubeRadius, 0), chunkDiameter, chunkDiameter, - (x, z) -> chunkMap.acquireGeneration(ChunkPos.asLong(x, z))); + Coords.cubeToSection(pos.getZ() - cubeRadius, 0), chunkDiameter, chunkDiameter, + (x, z) -> chunkMap.acquireGeneration(ChunkPos.asLong(x, z))); var chunkGenerationTask = new ChunkGenerationTask(chunkMap, targetStatus, null, staticcache2d); ((MixinChunkGenerationTask) (Object) chunkGenerationTask).cc_cubePos = pos; ((MixinChunkGenerationTask) (Object) chunkGenerationTask).cc_cubeCache = StaticCache3D.create(pos.getX(), pos.getY(), pos.getZ(), cubeRadius, - (x, y, z) -> chunkMap.acquireGeneration(CubePos.asLong(x, y, z))); + (x, y, z) -> chunkMap.acquireGeneration(CubePos.asLong(x, y, z))); return chunkGenerationTask; } - @AddMethodToSets(containers = ChunkToCloSet.ChunkGenerationTask_redirects.class, method = @MethodSig("create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkGenerationTask_redirects.class, + method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;") @Public private static ChunkGenerationTask cc_createCubeGenerationTask(GeneratingChunkMap chunkMap, ChunkStatus targetStatus, CloPos pos) { if (pos.isCube()) { return cc_createCubeGenerationTask(chunkMap, targetStatus, pos.cubePos()); @@ -115,9 +116,8 @@ private void cc_onScheduleNextLayer(CallbackInfo ci) { } /** - * Cube equivalent to {@code scheduleNextLayer}. - * Loads chunks one status higher than cubes until chunks have reached the target status, as otherwise cubes could reach a status before their - * intersecting chunks do. + * Cube equivalent to {@code scheduleNextLayer}. Loads chunks one status higher than cubes until chunks have reached the target status, as + * otherwise cubes could reach a status before their intersecting chunks do. */ private void cc_scheduleNextLayer() { ChunkStatus nextChunkStatus; @@ -175,7 +175,7 @@ private void cc_onCanLoadWithoutGeneration(CallbackInfoReturnable cir) cir.setReturnValue(true); } else { ChunkStatus currentCubeStatus = this.cc_cubeCache.get(this.cc_cubePos.getX(), this.cc_cubePos.getY(), this.cc_cubePos.getZ()) - .getPersistedStatus(); + .getPersistedStatus(); if (currentCubeStatus != null && !currentCubeStatus.isBefore(this.targetStatus)) { ChunkDependencies cubeDependencies = CubePyramid.CC_LOADING_PYRAMID_CUBES.getStepTo(this.targetStatus).accumulatedDependencies(); int cubeRadius = cubeDependencies.getRadius(); @@ -230,7 +230,7 @@ private void cc_onGetCenter(CallbackInfoReturnable cir) { private void cc_scheduleLayer(@Nullable ChunkStatus chunkStatus, @Nullable ChunkStatus cubeStatus, boolean needsGeneration) { try (Zone zone = Profiler.get().zone("scheduleLayer")) { zone.addText(() -> String.format("Chunk: %s, Cube: %s", chunkStatus == null ? "null" : chunkStatus.getName(), - cubeStatus == null ? "null" : cubeStatus.getName())); + cubeStatus == null ? "null" : cubeStatus.getName())); if (cubeStatus != null) { int cubeRadius = this.cc_getCubeRadiusForLayer(cubeStatus, needsGeneration); for (int cubeX = this.cc_cubePos.getX() - cubeRadius; cubeX <= this.cc_cubePos.getX() + cubeRadius; cubeX++) { @@ -272,7 +272,8 @@ private void cc_onScheduleLayer(ChunkStatus status, boolean needsGeneration, Cal throw new IllegalStateException("shouldn't call vanilla scheduleLayer for cube generation task"); } - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = @MethodSig("getRadiusForLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Z)I")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), + value = "getRadiusForLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Z)I") private native int cc_getCubeRadiusForLayer(ChunkStatus status, boolean needsGeneration); @Shadow protected abstract boolean scheduleChunkInLayer(ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk); @@ -287,13 +288,14 @@ private void cc_onScheduleLayer(ChunkStatus status, boolean needsGeneration, Cal @Inject(method = "scheduleChunkInLayer", at = @At("HEAD"), cancellable = true) private void cc_onScheduleChunkInLayer( - ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk, CallbackInfoReturnable cir + ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk, CallbackInfoReturnable cir ) { if (((GenerationCloHolder) chunk).cc_getCubePos() != null) { cir.setReturnValue(cc_scheduleCubeInLayer(status, needsGeneration, chunk)); } } - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = @MethodSig("scheduleChunkInLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;ZLnet/minecraft/server/level/GenerationChunkHolder;)Z")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), + value = "scheduleChunkInLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;ZLnet/minecraft/server/level/GenerationChunkHolder;)Z") private native boolean cc_scheduleCubeInLayer(ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java index c15d7c4f..594cb975 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java @@ -11,8 +11,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -47,9 +45,8 @@ /** * The vanilla {@link ChunkHolder} class extends {@link GenerationChunkHolder} to have methods for getting a fully loaded chunk, and handle saving - * dependencies and broadcasting updates to clients. - * This mixin adds cubic chunks equivalents for methods where necessary, to allow GenerationChunkHolder to dynamically wrap either a chunk or a cube - * (i.e. a CLO). + * dependencies and broadcasting updates to clients. This mixin adds cubic chunks equivalents for methods where necessary, to allow + * GenerationChunkHolder to dynamically wrap either a chunk or a cube (i.e. a CLO). */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ChunkHolder.class)) @Mixin(ChunkHolder.class) @@ -57,14 +54,19 @@ public abstract class MixinChunkHolder extends MixinGenerationChunkHolder implem @Shadow private boolean hasChangedSections; @Shadow @Final private ShortSet[] changedBlocksPerSection; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = @FieldSig(type = @Ref(ChunkHolder.LevelChangeListener.class), name = "onLevelChange")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, + field = "onLevelChange:Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;") private final LevelChangeListener cc_onLevelChange; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = @FieldSig(type = @Ref(ChunkHolder.PlayerProvider.class), name = "playerProvider")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, + field = "playerProvider:Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;") private final PlayerProvider cc_playerProvider; @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("(Lnet/minecraft/world/level/ChunkPos;ILnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/world/level/lighting/LevelLightEngine;Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), + value = "(Lnet/minecraft/world/level/ChunkPos;ILnet/minecraft/world/level/LevelHeightAccessor;" + + "Lnet/minecraft/world/level/lighting/LevelLightEngine;Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;" + + "Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V") public MixinChunkHolder() { throw new DasmFailedToApply(); } @@ -72,10 +74,10 @@ public MixinChunkHolder() { @Shadow public abstract @Nullable LevelChunk getTickingChunk(); @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;") public native @Nullable LevelCube cc_getTickingCube(); - @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = @MethodSig("getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = "getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;") public @Nullable LevelClo cc_getTickingClo() { if (cc_cubePos != null) { return cc_getTickingCube(); @@ -86,11 +88,11 @@ public MixinChunkHolder() { @Shadow public abstract @Nullable LevelChunk getChunkToSend(); @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;") public native @Nullable LevelCube cc_getCubeToSend(); @AddTransformToSets(ChunkToCloSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;") public @Nullable LevelClo cc_getCloToSend() { if (cc_cubePos != null) { return cc_getCubeToSend(); @@ -106,10 +108,11 @@ public void cc_onBlockChanged(BlockPos pos, CallbackInfoReturnable cir) } // region [cc_blockChanged dasm + mixin] - @TransformFromMethod(@MethodSig("blockChanged(Lnet/minecraft/core/BlockPos;)Z")) + @TransformFromMethod("blockChanged(Lnet/minecraft/core/BlockPos;)Z") private native boolean cc_blockChanged(BlockPos pos); - @Dynamic @Redirect(method = "cc_dasm$cc_blockChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_dasm$cc_blockChanged", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) private int cc_onBlockChanged_sectionIndex(LevelHeightAccessor instance, int y, BlockPos pos) { return Coords.sectionToIndex(Coords.blockToSection(pos.getX()), Coords.blockToSection(pos.getY()), Coords.blockToSection(pos.getZ())); } @@ -126,12 +129,13 @@ public void cc_onSectionLightChanged(LightLayer lightLayer, int sectionY, Callba // region [cc_broadcastCubeChanges dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_broadcastCubeChanges(LevelCube cube); // TODO (P2) lighting - ClientboundLightUpdatePacket branch is currently never reached; once we have lighting it will have to be a CC packet, and // this.broadcast will need to redirect to a CC method - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instance, int sectionIndex) { // The vanilla method uses SectionPos.of(ChunkPos, sectionY), but we want SectionPos.of(CubePos, sectionIndex). // The easiest way to accomplish this is to turn `getSectionYFromSectionIndex` into a no-op so that we get sectionIndex instead of sectionY. @@ -139,13 +143,15 @@ private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instan return sectionIndex; } - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) + @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", + target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) private SectionPos cc_onBroadcastCubeChanges_sectionPos(CubePos cubePos, int sectionIndex) { return Coords.sectionPosByIndex(cubePos, sectionIndex); } // endregion - @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = @MethodSig("broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, + method = "broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public void cc_broadcastCloChanges(LevelClo clo) { if (cc_cubePos != null) { cc_broadcastCubeChanges((LevelCube) clo); @@ -155,9 +161,11 @@ public void cc_broadcastCloChanges(LevelClo clo) { } @WrapOperation(method = { "lambda$scheduleFullChunkPromotion$4", - "demoteFullChunk" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V")) + "demoteFullChunk" }, at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;" + + "Lnet/minecraft/server/level/FullChunkStatus;)V")) private void cc_onCallChunkMapOnFullChunkStatusChange( - ChunkMap instance, ChunkPos chunkPos, FullChunkStatus fullChunkStatus, Operation original + ChunkMap instance, ChunkPos chunkPos, FullChunkStatus fullChunkStatus, Operation original ) { if (cc_cubePos != null) { ((CubicChunkMap) instance).cc_onFullChunkStatusChange(cc_cubePos, fullChunkStatus); @@ -166,10 +174,12 @@ private void cc_onCallChunkMapOnFullChunkStatusChange( } } - @WrapOperation(method = "updateFutures", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @WrapOperation(method = "updateFutures", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;onLevelChange(Lnet/minecraft/world/level/ChunkPos;" + + "Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) protected void cc_onUpdateFutures_onCallOnLevelChange( - ChunkHolder.LevelChangeListener instance, ChunkPos chunkPos, IntSupplier intSupplier, int i, IntConsumer intConsumer, - Operation original + ChunkHolder.LevelChangeListener instance, ChunkPos chunkPos, IntSupplier intSupplier, int i, IntConsumer intConsumer, + Operation original ) { if (cc_cubePos != null) { cc_onLevelChange.cc_onLevelChange(cc_cubePos, intSupplier, i, intConsumer); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java index d5e81778..9bd096bb 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; @@ -23,10 +22,11 @@ public abstract class MixinChunkMap$TrackedEntity { // region [cc_updatePlayer dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap$TrackedEntity_redirects.class) - @TransformFromMethod(@MethodSig("updatePlayer(Lnet/minecraft/server/level/ServerPlayer;)V")) + @TransformFromMethod("updatePlayer(Lnet/minecraft/server/level/ServerPlayer;)V") public native void cc_updatePlayer(ServerPlayer player); - @Dynamic @Redirect(method = "cc_dasm$cc_updatePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_dasm$cc_updatePlayer", + at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_updatePlayer_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z) { // FIXME entity clo position once implemented return false; // ((CubicChunkMap) instance).cc_isChunkTracked(player, this.entity.chunkPosition().x, 0, this.entity.chunkPosition().z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java index fcd300fd..43de1168 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java @@ -23,8 +23,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -92,8 +90,8 @@ /** * The vanilla {@link ChunkMap} class stores all loaded chunks for a world and handles loading and unloading them, including dependencies on - * neighboring chunks. - * This mixin adds cubic chunks equivalents for methods where necessary, to allow ChunkMap to work with CLOs (i.e. both chunks and cubes). + * neighboring chunks. This mixin adds cubic chunks equivalents for methods where necessary, to allow ChunkMap to work with CLOs (i.e. both chunks and + * cubes). */ @Dasm(value = ChunkToCloSet.class, target = @Ref(ChunkMap.class)) @Mixin(ChunkMap.class) @@ -113,18 +111,20 @@ public abstract class MixinChunkMap extends MixinChunkStorage implements Generat } // TODO this one being on GlobalSet is a bit jank - @AddFieldToSets(containers = GlobalSet.ChunkMap_redirects.class, field = @FieldSig(type = @Ref(ChunkProgressListener.class), name = "progressListener")) + @AddFieldToSets(containers = GlobalSet.ChunkMap_redirects.class, + field = "progressListener:Lnet/minecraft/server/level/progress/ChunkProgressListener;") private CloProgressListener cc_progressListener; - @AddFieldToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, field = @FieldSig(type = @Ref(ChunkStatusUpdateListener.class), name = "chunkStatusListener")) + @AddFieldToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, + field = "chunkStatusListener:Lnet/minecraft/world/level/entity/ChunkStatusUpdateListener;") private CloStatusUpdateListener cc_cloStatusListener; // TODO once we can target non-return locations in constructors, do this when the vanilla field is set @Inject(method = "", at = @At("RETURN")) private void cc_onInit( - ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, - StructureTemplateManager structureManager, Executor dispatcher, BlockableEventLoop mainThreadExecutor, LightChunkGetter lightChunk, - ChunkGenerator generator, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, - Supplier overworldDataStorage, TicketStorage ticketStorage, int serverViewDistance, boolean sync, CallbackInfo ci + ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, + StructureTemplateManager structureManager, Executor dispatcher, BlockableEventLoop mainThreadExecutor, LightChunkGetter lightChunk, + ChunkGenerator generator, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, + Supplier overworldDataStorage, TicketStorage ticketStorage, int serverViewDistance, boolean sync, CallbackInfo ci ) { if (((CanBeCubic) level).cc_isCubic()) { cc_progressListener = ((CloProgressListener) progressListener); @@ -136,13 +136,14 @@ private void cc_onInit( } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("setChunkUnsaved(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("setChunkUnsaved(Lnet/minecraft/world/level/ChunkPos;)V") private native void cc_setCloUnsaved(CloPos cloPos); /** * Returns the squared distance to the center of the cube. */ - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = @MethodSig("euclideanDistanceSquared(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/phys/Vec3;)D")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, + method = "euclideanDistanceSquared(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/phys/Vec3;)D") private static double cc_euclideanDistanceSquared(CloPos cloPos, Vec3 vec3) { if (cloPos.isChunk()) { // FIXME we shouldn't be getting euclidean distance for chunks, as this doesn't make sense in context @@ -163,8 +164,8 @@ private static double cc_euclideanDistanceSquared(CloPos cloPos, Vec3 vec3) { // These methods are not copied due to taking 3 ints instead of 2 @Override public boolean cc_isChunkTracked(ServerPlayer player, int x, int y, int z) { return ((CCServerPlayer) player).cc_getCloTrackingView().cc_contains(x, y, z) - // TODO this requires PlayerChunkSender to accept Clo longs - && !player.connection.chunkSender.isPending(CloPos.cubeAsLong(x, y, z)); + // TODO this requires PlayerChunkSender to accept Clo longs + && !player.connection.chunkSender.isPending(CloPos.cubeAsLong(x, y, z)); } private boolean cc_isChunkOnTrackedBorder(ServerPlayer player, int x, int y, int z) { @@ -186,20 +187,22 @@ private boolean cc_isChunkOnTrackedBorder(ServerPlayer player, int x, int y, int // region [cc_getChunkRangeFuture dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getChunkRangeFuture(Lnet/minecraft/server/level/ChunkHolder;ILjava/util/function/IntFunction;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod( + "getChunkRangeFuture(Lnet/minecraft/server/level/ChunkHolder;ILjava/util/function/IntFunction;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture>> cc_getChunkRangeFuture( - ChunkHolder cloHolder, int radius, IntFunction statusByRadius + ChunkHolder cloHolder, int radius, IntFunction statusByRadius ); // TODO this could be substantially improved probably hopefully + /** * Cubes require different adjacency logic compared to Chunks */ @SuppressWarnings("checkstyle:CyclomaticComplexity") // <-- TODO this method is just a bit of a disaster @Dynamic @Inject(method = "cc_dasm$cc_getChunkRangeFuture", at = @At("HEAD"), cancellable = true) private void cc_onGetChunkRangeFuture( - ChunkHolder cloHolder, int radius, IntFunction statusByRadius, - CallbackInfoReturnable>>> cir + ChunkHolder cloHolder, int radius, IntFunction statusByRadius, + CallbackInfoReturnable>>> cir ) { // Note that statusByRadius sometimes isn't actually correct for cubes beyond the first few steps, but getChunkRangeFuture is only called with // parameters for which it's correct within the radius @@ -222,14 +225,14 @@ private void cc_onGetChunkRangeFuture( for (int sectionZ = 0; sectionZ < CubicConstants.DIAMETER_IN_SECTIONS; sectionZ++) { for (int sectionX = 0; sectionX < CubicConstants.DIAMETER_IN_SECTIONS; sectionX++) { ChunkHolder holder = this.getUpdatingChunkIfPresent( - CloPos.chunkAsLong(Coords.cubeToSection(pos.getX() + dx, sectionX), Coords.cubeToSection(pos.getZ() + dz, sectionZ))); + CloPos.chunkAsLong(Coords.cubeToSection(pos.getX() + dx, sectionX), Coords.cubeToSection(pos.getZ() + dz, sectionZ))); if (holder == null) { cir.setReturnValue(UNLOADED_CHUNK_LIST_FUTURE); return; } ChunkStatus expectedStatus = statusByRadius.apply(chunkDistance); futures.add((CompletableFuture>) (Object) holder.scheduleChunkGenerationTask(expectedStatus, - (ChunkMap) (Object) this)); + (ChunkMap) (Object) this)); } } for (int dy = -radius; dy <= radius; dy++) { @@ -243,7 +246,7 @@ private void cc_onGetChunkRangeFuture( } ChunkStatus expectedStatus = statusByRadius.apply(Math.max(chunkDistance, Math.abs(dy))); futures.add((CompletableFuture>) (Object) holder.scheduleChunkGenerationTask(expectedStatus, - (ChunkMap) (Object) this)); + (ChunkMap) (Object) this)); } } } @@ -259,7 +262,7 @@ private void cc_onGetChunkRangeFuture( for (final ChunkResult chunkResult : resultList) { if (chunkResult == null) { throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), - "n/a"); + "n/a"); } CloAccess cloAccess = chunkResult.orElse(null); @@ -277,7 +280,8 @@ private void cc_onGetChunkRangeFuture( // region [cc_updateCubeScheduling dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkMap_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = @MethodSig("updateChunkScheduling(JILnet/minecraft/server/level/ChunkHolder;I)Lnet/minecraft/server/level/ChunkHolder;")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, + value = "updateChunkScheduling(JILnet/minecraft/server/level/ChunkHolder;I)Lnet/minecraft/server/level/ChunkHolder;") public native @Nullable ChunkHolder cc_updateCubeScheduling(long cubePos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); @Inject(method = "updateChunkScheduling", at = @At("HEAD"), cancellable = true) @@ -289,16 +293,17 @@ private void cc_onUpdateChunkScheduling(long cloPos, int newLevel, ChunkHolder h // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @TransformFromMethod("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") private native void cc_onLevelChange(CloPos cloPos, IntSupplier intsupplier, int i, IntConsumer intconsumer); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, + method = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") public void cc_onCubeLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter) { cc_onLevelChange(CloPos.cube(cubePos), queueLevelGetter, ticketLevel, queueLevelSetter); } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("saveAllChunks(Z)V")) + @TransformFromMethod("saveAllChunks(Z)V") public native void cc_saveAllChunks(boolean flush); @Inject(method = "saveAllChunks", at = @At("HEAD"), cancellable = true) @@ -310,25 +315,28 @@ private void cc_onSaveAllChunks(boolean flush, CallbackInfo ci) { } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("saveChunksEagerly(Ljava/util/function/BooleanSupplier;)V")) + @TransformFromMethod("saveChunksEagerly(Ljava/util/function/BooleanSupplier;)V") private native void cc_saveClosEagerly(BooleanSupplier hasMoreTime); - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = @MethodSig("scheduleUnload(JLnet/minecraft/server/level/ChunkHolder;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = "scheduleUnload(JLnet/minecraft/server/level/ChunkHolder;)V") private void cc_scheduleUnload(long chunkPos, ChunkHolder chunkHolder) { // TODO (P2) save/load } // region [cc_scheduleChunkLoad dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture cc_scheduleChunkLoad(CloPos cloPos); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, + method = "scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private CompletableFuture cc_scheduleChunkLoad(CubePos cubePos) { return cc_scheduleChunkLoad(CloPos.cube(cubePos)); } - @Dynamic @Redirect(method = "cc_dasm$cc_scheduleChunkLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)Ljava/util/concurrent/CompletableFuture;")) + @Dynamic @Redirect(method = "cc_dasm$cc_scheduleChunkLoad", at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)" + + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManager instance, CloPos cloPos) { // TODO (P2) save/load - PoiManager return CompletableFuture.completedFuture(null); @@ -336,46 +344,54 @@ private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManage // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("handleChunkLoadFailure(Ljava/lang/Throwable;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod( + "handleChunkLoadFailure(Ljava/lang/Throwable;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;") private native ChunkResult cc_handleChunkLoadFailure(Throwable exception, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("createEmptyChunk(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(value = "createEmptyChunk(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;") private native CloAccess cc_createEmptyChunk(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markPositionReplaceable(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("markPositionReplaceable(Lnet/minecraft/world/level/ChunkPos;)V") private native void cc_markPositionReplaceable(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markPosition(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkType;)B")) + @TransformFromMethod("markPosition(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkType;)B") private native byte cc_markPosition(CloPos cloPos, ChunkType chunkType); // region [cc_applyCubeStep dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkMap_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = @MethodSig("applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, + value = "applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture cc_applyCubeStep( - GenerationChunkHolder generationchunkholder, CubeStep chunkstep, StaticCache3D cache + GenerationChunkHolder generationchunkholder, CubeStep chunkstep, StaticCache3D cache ); - @Dynamic @Redirect(method = "cc_dasm$cc_applyCubeStep", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) + @Dynamic @Redirect(method = "cc_dasm$cc_applyCubeStep", + at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) private Object cc_onApplyCubeStep_staticCacheGet(StaticCache3D instance, int x, int z, @Local(ordinal = 0) CubePos cubePos) { return instance.get(cubePos.getX(), cubePos.getY(), cubePos.getZ()); } // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @TransformFromMethod( + "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + + "Lnet/minecraft/server/level/ChunkGenerationTask;") public native ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus chunkstatus, CloPos cloPos); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, + method = "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + + "Lnet/minecraft/server/level/ChunkGenerationTask;") public ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus chunkstatus, CubePos cubePos) { return cc_scheduleGenerationTask(chunkstatus, CloPos.cube(cubePos)); } // region [cc_runGenerationTask dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("runGenerationTask(Lnet/minecraft/server/level/ChunkGenerationTask;)V")) + @TransformFromMethod("runGenerationTask(Lnet/minecraft/server/level/ChunkGenerationTask;)V") private native void cc_runGenerationTask(ChunkGenerationTask chunkgenerationtask); // Delegate to the cube method for cubes @@ -389,7 +405,7 @@ private void cc_onVanillaRunGenerationTask(ChunkGenerationTask task, CallbackInf // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("prepareEntityTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("prepareEntityTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture> cc_prepareEntityTickingChunk(ChunkHolder holder); @Inject(method = "prepareEntityTickingChunk", at = @At("HEAD"), cancellable = true) @@ -400,7 +416,7 @@ private void cc_onVanillaPrepareEntityTickingChunk(ChunkHolder chunk, CallbackIn } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("prepareTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("prepareTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture> cc_prepareTickingChunk(ChunkHolder holder); @Inject(method = "prepareTickingChunk", at = @At("HEAD"), cancellable = true) @@ -411,11 +427,11 @@ private void cc_onVanillaPrepareTickingChunk(ChunkHolder chunk, CallbackInfoRetu } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("onChunkReadyToSend(Lnet/minecraft/server/level/ChunkHolder;Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod("onChunkReadyToSend(Lnet/minecraft/server/level/ChunkHolder;Lnet/minecraft/world/level/chunk/LevelChunk;)V") private native void cc_onChunkReadyToSend(ChunkHolder chunkholder, LevelClo cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("prepareAccessibleChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("prepareAccessibleChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture> cc_prepareAccessibleChunk(ChunkHolder holder); @Inject(method = "prepareAccessibleChunk", at = @At("HEAD"), cancellable = true) @@ -426,23 +442,25 @@ private void cc_onVanillaPrepareAccessibleChunk(ChunkHolder chunk, CallbackInfoR } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("saveChunkIfNeeded(Lnet/minecraft/server/level/ChunkHolder;J)Z")) + @TransformFromMethod("saveChunkIfNeeded(Lnet/minecraft/server/level/ChunkHolder;J)Z") private native boolean cc_saveChunkIfNeeded(ChunkHolder holder, long gameTime); // TODO (P2): for now we just don't save (requires more things to be CC-ified to not crash) - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = @MethodSig("save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = "save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private boolean cc_save(CloAccess cloAccess) { return false; } // //region [cc_save dasm + mixin] -// @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) @TransformFromMethod(@MethodSig("save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) +// @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) @TransformFromMethod(@MethodSig("save +// (Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) // private native boolean cc_save(CloAccess cloAccess); // // /** // * Redirect error logging to log with CloPos // */ -// @Dynamic @Inject(method = "cc_dasm$cc_save", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;getX()I"), cancellable = true) +// @Dynamic @Inject(method = "cc_dasm$cc_save", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;getX +// ()I"), cancellable = true) // private void cc_onSave_errorLog(CloAccess cloAccess, CallbackInfoReturnable cir, @Local Exception exception) { // LOGGER.error("Failed to save chunk or cube {}", cloAccess.cc_getCloPos().toString(), exception); // cir.setReturnValue(false); @@ -451,23 +469,23 @@ private boolean cc_save(CloAccess cloAccess) { // This calls ChunkSerializer.getChunkTypeFromTag, which could be an issue? @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("isExistingChunkFull(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("isExistingChunkFull(Lnet/minecraft/world/level/ChunkPos;)Z") private native boolean cc_isExistingChunkFull(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") private native void cc_markChunkPendingToSend(ServerPlayer player, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;)V") private static native void cc_markChunkPendingToSend(ServerPlayer player, LevelClo clo); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") private static native void cc_dropChunk(ServerPlayer player, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getChunkToSend(J)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod("getChunkToSend(J)Lnet/minecraft/world/level/chunk/LevelChunk;") public native LevelClo cc_getChunkToSend(long cloPos); // dumpChunks (low prio) @@ -477,47 +495,48 @@ private boolean cc_save(CloAccess cloAccess) { // TODO (P2) readChunk: this.upgradeChunkTag might need a dasm redirect? @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("readChunk(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("readChunk(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture> cc_readChunk(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("collectSpawningChunks(Ljava/util/List;)V")) + @TransformFromMethod("collectSpawningChunks(Ljava/util/List;)V") native void cc_collectSpawningClos(List list); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("forEachBlockTickingChunk(Ljava/util/function/Consumer;)V")) + @TransformFromMethod("forEachBlockTickingChunk(Ljava/util/function/Consumer;)V") native void cc_forEachBlockTickingClo(Consumer consumer); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z") public native boolean cc_anyPlayerCloseEnoughForSpawning(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("anyPlayerCloseEnoughForSpawningInternal(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("anyPlayerCloseEnoughForSpawningInternal(Lnet/minecraft/world/level/ChunkPos;)Z") private native boolean cc_anyPlayerCloseEnoughForSpawningInternal(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getPlayersCloseForSpawning(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;")) + @TransformFromMethod("getPlayersCloseForSpawning(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;") public native List cc_getPlayersCloseForSpawning(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("playerIsCloseEnoughForSpawning(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("playerIsCloseEnoughForSpawning(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)Z") private native boolean cc_playerIsCloseEnoughForSpawning(ServerPlayer player, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("updatePlayerStatus(Lnet/minecraft/server/level/ServerPlayer;Z)V")) + @TransformFromMethod("updatePlayerStatus(Lnet/minecraft/server/level/ServerPlayer;Z)V") public native void cc_updatePlayerStatus(ServerPlayer player, boolean track); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("move(Lnet/minecraft/server/level/ServerPlayer;)V")) + @TransformFromMethod("move(Lnet/minecraft/server/level/ServerPlayer;)V") public native void cc_move(ServerPlayer player); // region [cc_updateChunkTracking dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("updateChunkTracking(Lnet/minecraft/server/level/ServerPlayer;)V")) + @TransformFromMethod("updateChunkTracking(Lnet/minecraft/server/level/ServerPlayer;)V") private native void cc_updateChunkTracking(ServerPlayer player); - @Dynamic @WrapOperation(method = "cc_dasm$cc_updateChunkTracking", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) + @Dynamic @WrapOperation(method = "cc_dasm$cc_updateChunkTracking", + at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPlayer player, Operation original) { return Coords.sectionToCubeRenderDistance(original.call(instance, player)); } @@ -525,65 +544,70 @@ private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPl // region [cc_applyChunkTrackingView dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("applyChunkTrackingView(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/server/level/ChunkTrackingView;)V")) + @TransformFromMethod("applyChunkTrackingView(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/server/level/ChunkTrackingView;)V") private native void cc_applyChunkTrackingView(ServerPlayer player, CloTrackingView chunkTrackingView); - @Dynamic @Redirect(method = "cc_dasm$cc_applyChunkTrackingView", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) + @Dynamic @Redirect(method = "cc_dasm$cc_applyChunkTrackingView", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( - ServerGamePacketListenerImpl instance, Packet packet, ServerPlayer player, CloTrackingView cloTrackingView + ServerGamePacketListenerImpl instance, Packet packet, ServerPlayer player, CloTrackingView cloTrackingView ) { PacketDistributor.sendToPlayer(player, - new CCClientboundSetCubeCacheCenterPacket(((CloTrackingView.Positioned) cloTrackingView).center().cubePos())); + new CCClientboundSetCubeCacheCenterPacket(((CloTrackingView.Positioned) cloTrackingView).center().cubePos())); } // endregion // region [cc_getPlayers dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;")) + @TransformFromMethod("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") public native List cc_getPlayers(CloPos pos, boolean boundaryOnly); - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkOnTrackedBorder(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkOnTrackedBorder(player, pos.getX(), pos.getY(), pos.getZ()); } - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", + at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkTracked(player, pos.getX(), pos.getY(), pos.getZ()); } // endregion - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, + method = "getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") @Override public List cc_getPlayers(CubePos pos, boolean boundaryOnly) { return cc_getPlayers(CloPos.cube(pos), boundaryOnly); } // Replace `SectionPos.chunk()` with `SectionPos.cc_cube()` unconditionally here @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("tick(Ljava/util/function/BooleanSupplier;)V"), useRedirectSets = { ChunkToCloSet.class, + @TransformFromMethod(value = "tick(Ljava/util/function/BooleanSupplier;)V", useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) protected native void cc_tick(BooleanSupplier hasMoreTime); @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("tick()V"), useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) + @TransformFromMethod(value = "tick()V", useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) public native void cc_tick(); @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("processUnloads(Ljava/util/function/BooleanSupplier;)V")) + @TransformFromMethod(value = "processUnloads(Ljava/util/function/BooleanSupplier;)V") private native void cc_processUnloads(BooleanSupplier hasMoreTime); // TODO resendBiomesForChunks - only used for FillBiomeCommand @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V")) + @TransformFromMethod("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") public native void cc_onFullChunkStatusChange(CloPos cloPos, FullChunkStatus fullChunkStatus); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, + method = "onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") public void cc_onFullChunkStatusChange(CubePos cubePos, FullChunkStatus fullChunkStatus) { cc_onFullChunkStatusChange(CloPos.cube(cubePos), fullChunkStatus); } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("waitForLightBeforeSending(Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod("waitForLightBeforeSending(Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_waitForLightBeforeSending(CloPos cloPos, int radius); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java index e0f5f15a..6aabd1d7 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java @@ -5,7 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -20,7 +19,8 @@ @Mixin(ChunkTaskDispatcher.class) public class MixinChunkTaskDispatcher implements CubeHolder.LevelChangeListener, CloTaskDispatcher { @AddTransformToSets(ChunkToCloSet.ChunkTaskDispatcher_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkTaskDispatcher.class), value = @MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @TransformFromMethod(owner = @Ref(ChunkTaskDispatcher.class), + value = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") @Override public native void cc_onLevelChange(CloPos cloPos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter); public void cc_onLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java index 69a6dee2..ab4f5c80 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; @@ -36,6 +35,6 @@ private void cc_onResortChunkTasks(int queueLevel, ChunkPos chunkPos, int ticket @UsedFromASM @AddTransformToSets(ChunkToCloSet.ChunkTaskPriorityQueue_redirects.class) - @TransformFromMethod(@MethodSig("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V") public native void cc_resortCubicTasks(int queueLevel, CloPos cloPos, int ticketLevel); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java index c9f487a8..8b8aa63a 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java @@ -11,8 +11,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -45,9 +43,8 @@ /** * The vanilla {@link GenerationChunkHolder} class wraps completable futures for different statuses (load levels) of a single chunk and handles logic - * for scheduling generation of that chunk. - * This mixin adds cubic chunks equivalents for methods where necessary, to allow GenerationChunkHolder to dynamically wrap either a chunk or a cube - * (i.e. a CLO). + * for scheduling generation of that chunk. This mixin adds cubic chunks equivalents for methods where necessary, to allow GenerationChunkHolder to + * dynamically wrap either a chunk or a cube (i.e. a CLO). */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(GenerationChunkHolder.class)) @Mixin(GenerationChunkHolder.class) @@ -56,10 +53,10 @@ public abstract class MixinGenerationChunkHolder implements GenerationCloHolder @Shadow @Final private AtomicReferenceArray>> futures; @Shadow @Final private static ChunkResult NOT_DONE_YET; - @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_redirects.class, field = @FieldSig(name = "pos", type = @Ref(ChunkPos.class))) + @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_redirects.class, field = "pos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cc_cubePos; - @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = @MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = "getPos()Lnet/minecraft/world/level/ChunkPos;") @Override public CloPos cc_getCloPos() { if (cc_cubePos != null) { return CloPos.cube(cc_cubePos); @@ -68,18 +65,21 @@ public abstract class MixinGenerationChunkHolder implements GenerationCloHolder } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "(Lnet/minecraft/world/level/ChunkPos;)V") public MixinGenerationChunkHolder() { throw new DasmFailedToApply(); } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("applyStep(Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), + value = "applyStep(Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/server/level/GeneratingChunkMap;" + + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") native CompletableFuture> cc_applyCubeStep( - CubeStep step, GeneratingChunkMap chunkMap, StaticCache3D cache + CubeStep step, GeneratingChunkMap chunkMap, StaticCache3D cache ); - @WrapOperation(method = "updateHighestAllowedStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkLevel;generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @WrapOperation(method = "updateHighestAllowedStatus", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ChunkLevel;generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) protected @Nullable ChunkStatus cc_onUpdateHighestAllowedStatus_generationStatus(int level, Operation original) { if (cc_cubePos != null) { return CubeLevel.cubeGenerationStatus(level); @@ -88,12 +88,15 @@ native CompletableFuture> cc_applyCubeStep( } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), + value = "replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V") public native void cc_replaceProtoCube(ImposterProtoCube cube); - @WrapOperation(method = "rescheduleChunkTask", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @WrapOperation(method = "rescheduleChunkTask", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ChunkMap;scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( - ChunkMap instance, ChunkStatus status, ChunkPos chunkPos, Operation original + ChunkMap instance, ChunkStatus status, ChunkPos chunkPos, Operation original ) { if (cc_cubePos != null) { return ((CubicChunkMap) instance).cc_scheduleGenerationTask(status, cc_cubePos); @@ -102,24 +105,28 @@ private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("completeFuture(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/ChunkAccess;)V")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), + value = "completeFuture(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") private native void cc_completeFuture(ChunkStatus targetStatus, CubeAccess cubeAccess); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getChunkIfPresentUnchecked(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), + value = "getChunkIfPresentUnchecked(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getCubeIfPresentUnchecked(ChunkStatus status); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getChunkIfPresent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), + value = "getChunkIfPresent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getCubeIfPresent(ChunkStatus status); @Shadow public abstract @Nullable ChunkAccess getLatestChunk(); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getLatestCube(); - @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = @MethodSig("getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, + method = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") public @Nullable CloAccess cc_getLatestClo() { if (cc_cubePos != null) { return cc_getLatestCube(); @@ -132,15 +139,15 @@ private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( public void cc_onGetPersistedStatus(CallbackInfoReturnable cir) { if (cc_cubePos != null) { CompletableFuture> completablefuture = (CompletableFuture>) (Object) this.futures - .get(ChunkStatus.EMPTY.getIndex()); + .get(ChunkStatus.EMPTY.getIndex()); CubeAccess cubeAccess = completablefuture == null ? null - : completablefuture.getNow((ChunkResult) (Object) NOT_DONE_YET).orElse(null); + : completablefuture.getNow((ChunkResult) (Object) NOT_DONE_YET).orElse(null); cir.setReturnValue(cubeAccess == null ? null : cubeAccess.getPersistedStatus()); } } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getPos()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_getCubePos(); // TODO getLatestStatus - only used for vanilla debug code diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java index a18d33c9..f6789116 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java @@ -15,8 +15,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.AddUnusedParam; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -29,7 +27,6 @@ import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet; import io.github.opencubicchunks.cubicchunks.server.level.ServerCubeCache; -import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo; import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess; import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; @@ -68,8 +65,8 @@ /** * The vanilla {@link ServerChunkCache} class stores all loaded chunks on the server and has methods for getting chunks, ticking all chunks, handling - * block+light updates, managing chunkloading tickets, etc. - * This mixin adds versions of these methods for cubes, meaning that this class now stores and manages both cubes and chunks. + * block+light updates, managing chunkloading tickets, etc. This mixin adds versions of these methods for cubes, meaning that this class now stores + * and manages both cubes and chunks. */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ServerChunkCache.class)) @Mixin(ServerChunkCache.class) @@ -77,16 +74,18 @@ public abstract class MixinServerChunkCache extends MixinChunkSource implements // Cube equivalents for cached chunks @Shadow @Final private static int CACHE_SIZE; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(long[].class), name = "lastChunkPos")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunkPos:[J") private final long[] cc_lastCubePos = new long[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(ChunkStatus[].class), name = "lastChunkStatus")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, + field = "lastChunkStatus:[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") private final ChunkStatus[] cc_lastCubeStatus = new ChunkStatus[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(CloAccess[].class), name = "lastChunk")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, + field = "lastChunk:[Lio/github/opencubicchunks/cubicchunks/world/level/chunklike/CloAccess;") private final CubeAccess[] cc_lastCube = new CubeAccess[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(List.class), name = "spawningChunks")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "spawningChunks:Ljava/util/List;") private final List cc_spawningCubes = new ObjectArrayList<>(); @Shadow @Final public ServerLevel level; @@ -111,10 +110,10 @@ public abstract class MixinServerChunkCache extends MixinChunkSource implements @Inject(method = "", at = @At("CTOR_HEAD")) private void cc_onInit( - ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, - StructureTemplateManager structureManager, Executor dispatcher, ChunkGenerator generator, int viewDistance, int simulationDistance, - boolean sync, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, Supplier overworldDataStorage, - CallbackInfo ci + ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, + StructureTemplateManager structureManager, Executor dispatcher, ChunkGenerator generator, int viewDistance, int simulationDistance, + boolean sync, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, Supplier overworldDataStorage, + CallbackInfo ci ) { if (((CanBeCubic) level).cc_isCubic()) { this.cc_setCubic(); @@ -122,51 +121,58 @@ private void cc_onInit( } @AddTransformToSets(ChunkToCubeSet.ServerChunkCache_redirects.class) - @TransformFromMethod(@MethodSig("storeInCache(JLnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("storeInCache(JLnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") private native void cc_storeInCache(long pChunkPos, CubeAccess pChunk, ChunkStatus pChunkStatus); - @TransformFromMethod(@MethodSig("getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;")) - @Override public native @Nullable CubeAccess cc_getCube(int chunkX, @AddUnusedParam int chunkY, int chunkZ, ChunkStatus requiredStatus, boolean load); + @TransformFromMethod("getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;") + @Override + public native @Nullable CubeAccess cc_getCube(int chunkX, @AddUnusedParam int chunkY, int chunkZ, ChunkStatus requiredStatus, boolean load); // mixin-into-dasm to replace call to getChunk with getCube - @Dynamic @Inject(method = "cc_dasm$cc_getCube", cancellable = true, at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) + @Dynamic @Inject(method = "cc_dasm$cc_getCube", cancellable = true, at = @At(value = "INVOKE", + target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)" + + "Ljava/util/concurrent/CompletableFuture;")) private void cc_getCube_supplyAsync( - int pChunkX, int pChunkY, int pChunkZ, ChunkStatus pRequiredStatus, boolean pLoad, CallbackInfoReturnable cir + int pChunkX, int pChunkY, int pChunkZ, ChunkStatus pRequiredStatus, boolean pLoad, CallbackInfoReturnable cir ) { cir.setReturnValue(CompletableFuture - .supplyAsync(() -> this.cc_getCube(pChunkX, pChunkY, pChunkZ, pRequiredStatus, pLoad), this.mainThreadProcessor).join()); + .supplyAsync(() -> this.cc_getCube(pChunkX, pChunkY, pChunkZ, pRequiredStatus, pLoad), this.mainThreadProcessor).join()); } // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCube", + at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } // The second through fifth params are the params to the call being redirected; the next three params are the x/y/z coordinates in the params of // getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_getCube_getChunkFutureMainThread( - ServerChunkCache instance, int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load, int chunkXRepeated, int chunkY, - int chunkZRepeated + ServerChunkCache instance, int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load, int chunkXRepeated, int chunkY, + int chunkZRepeated ) { return this.cc_getCubeFutureMainThread(chunkX, chunkY, chunkZ, requiredStatus, load); } - @TransformFromMethod(@MethodSig("getChunkNow(II)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod("getChunkNow(II)Lnet/minecraft/world/level/chunk/LevelChunk;") @Override public native @Nullable LevelCube cc_getCubeNow(int pChunkX, @AddUnusedParam int chunkY, int pChunkZ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCubeNow - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", + at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCubeNow_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } // Note that we don't add this to any redirect sets; we just need it for the below mixin // (Whenever clearing caches, we want to clear all caches, not just cubes or chunks specifically) - @TransformFromMethod(@MethodSig("clearCache()V")) + @TransformFromMethod("clearCache()V") private native void cc_clearCache(); /** @@ -178,7 +184,8 @@ private void cc_onClearCache(CallbackInfo ci) { } // This method requires enough manual redirects that we just replace it entirely - @Override public CompletableFuture> cc_getCubeFuture(int pX, int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad) { + @Override public CompletableFuture> cc_getCubeFuture(int pX, int chunkY, int pZ, ChunkStatus pChunkStatus, + boolean pLoad) { boolean flag = Thread.currentThread() == this.mainThread; CompletableFuture> completablefuture; if (flag) { @@ -186,31 +193,33 @@ private void cc_onClearCache(CallbackInfo ci) { this.mainThreadProcessor.managedBlock(completablefuture::isDone); } else { completablefuture = CompletableFuture - .supplyAsync(() -> this.cc_getCubeFutureMainThread(pX, chunkY, pZ, pChunkStatus, pLoad), this.mainThreadProcessor) - .thenCompose(future -> future); + .supplyAsync(() -> this.cc_getCubeFutureMainThread(pX, chunkY, pZ, pChunkStatus, pLoad), this.mainThreadProcessor) + .thenCompose(future -> future); } return completablefuture; } - @TransformFromMethod(@MethodSig("getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture> cc_getCubeFutureMainThread( - int pX, @AddUnusedParam int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad + int pX, @AddUnusedParam int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_getCubeFutureMainThread - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", + target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } - @TransformFromMethod(@MethodSig("hasChunk(II)Z")) + @TransformFromMethod("hasChunk(II)Z") public native boolean cc_hasCube(int pX, @AddUnusedParam int y, int pZ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_hasCube - @Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", + target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_hasCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } @@ -229,11 +238,11 @@ private void cc_onTick(BooleanSupplier hasTimeLeft, boolean tickChunks, Callback } @AddTransformToSets(GlobalSet.ServerChunkCache_redirects.class) - @TransformFromMethod(@MethodSig("tick(Ljava/util/function/BooleanSupplier;Z)V")) + @TransformFromMethod("tick(Ljava/util/function/BooleanSupplier;Z)V") public native void cc_tick(BooleanSupplier hasTimeLeft, boolean tickChunks); @AddTransformToSets(GlobalSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("broadcastChangedChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "broadcastChangedChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V") private native void cc_broadcastChangedClos(ProfilerFiller profiler); @Inject(method = "broadcastChangedChunks", at = @At("HEAD"), cancellable = true) @@ -245,7 +254,7 @@ private void cc_onVanillaBroadcastChangedChunks(ProfilerFiller profiler, Callbac } @AddTransformToSets(GlobalSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V") private native void cc_tickClos(ProfilerFiller profiler, long timeInhabited); @Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V", at = @At("HEAD"), cancellable = true) @@ -256,7 +265,9 @@ private void cc_onVanillaTickChunks(ProfilerFiller profiler, long timeInhabited, } } - @AddMethodToSets(containers = ChunkToCloSet.ServerChunkCache_redirects.class, method = @MethodSig("tickSpawningChunk(Lnet/minecraft/world/level/chunk/LevelChunk;JLjava/util/List;Lnet/minecraft/world/level/NaturalSpawner$SpawnState;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ServerChunkCache_redirects.class, + method = "tickSpawningChunk(Lnet/minecraft/world/level/chunk/LevelChunk;JLjava/util/List;" + + "Lnet/minecraft/world/level/NaturalSpawner$SpawnState;)V") private void cc_tickSpawningClo(LevelClo levelClo, long timeInhabited, List spawnCategories, NaturalSpawner.SpawnState spawnState) { // TODO (P2) } @@ -284,50 +295,58 @@ private void cc_onVanillaOnLightUpdate(LightLayer type, SectionPos pos, Callback } } - @Override @AddMethodToSets(containers = GlobalSet.ServerChunkCache_redirects.class, method = @MethodSig("onLightUpdate(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/SectionPos;)V")) + @Override @AddMethodToSets(containers = GlobalSet.ServerChunkCache_redirects.class, + method = "onLightUpdate(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/SectionPos;)V") public void cc_onLightUpdate(LightLayer pType, SectionPos pPos) { // TODO (P2) lighting } @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, + value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_addTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, + value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_addTicketWithRadius(TicketType ticket, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, + value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_removeTicketWithRadius(TicketType ticket, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z") public native boolean cc_updateCloForced(CloPos pPos, boolean pAdd); // Cube-specific methods that delegate to the corresponding Clo methods - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, + method = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public void cc_addTicket(Ticket ticket, CubePos cubePos) { cc_addTicket(ticket, CloPos.cube(cubePos)); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, + method = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public void cc_addTicketWithRadius(TicketType ticket, CubePos cubePos, int radius) { cc_addTicketWithRadius(ticket, CloPos.cube(cubePos), radius); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, + method = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public void cc_removeTicketWithRadius(TicketType ticket, CubePos cubePos, int radius) { cc_removeTicketWithRadius(ticket, CloPos.cube(cubePos), radius); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z\"")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, + method = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z\"") @Override public boolean cc_updateCubeForced(CubePos cubePos, boolean forced) { return cc_updateCloForced(CloPos.cube(cubePos), forced); } // TODO should probably be implemented properly, but is low priority (debug) @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(@MethodSig("getChunkDebugData(Lnet/minecraft/world/level/ChunkPos;)Ljava/lang/String;")) + @TransformFromMethod("getChunkDebugData(Lnet/minecraft/world/level/ChunkPos;)Ljava/lang/String;") public native String cc_getChunkDebugData(CloPos pChunkPos); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java index cc5c834f..a4832fd0 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java @@ -8,7 +8,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -45,9 +44,9 @@ public abstract class MixinServerLevel extends MixinLevel implements CubicServer @Inject(method = "", at = @At("CTOR_HEAD")) private void cc_onInit( - MinecraftServer server, Executor dispatcher, LevelStorageSource.LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, - ResourceKey dimension, LevelStem levelStem, ChunkProgressListener progressListener, boolean isDebug, long biomeZoomSeed, - List customSpawners, boolean tickTime, RandomSequences randomSequences, CallbackInfo ci + MinecraftServer server, Executor dispatcher, LevelStorageSource.LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, + ResourceKey dimension, LevelStem levelStem, ChunkProgressListener progressListener, boolean isDebug, long biomeZoomSeed, + List customSpawners, boolean tickTime, RandomSequences randomSequences, CallbackInfo ci ) { // TODO conditionally mark as cubic based on dimension, config, level data, etc } @@ -57,12 +56,14 @@ private void cc_onInit( } @AddTransformToSets(ChunkToCloSet.ServerLevel_redirects.class) - @TransformFromMethod(@MethodSig("startTickingChunk(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod("startTickingChunk(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_startTickingClo(LevelClo chunk); - @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ServerChunkCache;removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + + "Lnet/minecraft/world/level/ChunkPos;I)V")) private void cc_onSetDefaultSpawnPos_removeTicketWithRadius( - ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos + ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos ) { if (cc_isCubic) { ((ServerCubeCache) instance).cc_removeTicketWithRadius(ticket, CloPos.cube(pos), radius); @@ -71,9 +72,11 @@ private void cc_onSetDefaultSpawnPos_removeTicketWithRadius( } } - @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/level/ServerChunkCache;addTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + + "Lnet/minecraft/world/level/ChunkPos;I)V")) private void cc_onSetDefaultSpawnPos_addicketWithRadius( - ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos + ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos ) { if (cc_isCubic) { ((ServerCubeCache) instance).cc_addTicketWithRadius(ticket, CloPos.cube(pos), radius); @@ -82,7 +85,7 @@ private void cc_onSetDefaultSpawnPos_addicketWithRadius( } } - @AddMethodToSets(containers = ChunkToCloSet.ServerLevel_redirects.class, method = @MethodSig("tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V")) + @AddMethodToSets(containers = ChunkToCloSet.ServerLevel_redirects.class, method = "tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") public void cc_tickClo(LevelClo levelClo, int randomTickSpeed) { if (levelClo instanceof LevelCube levelCube) { cc_tickCube(levelCube, randomTickSpeed); @@ -91,7 +94,7 @@ public void cc_tickClo(LevelClo levelClo, int randomTickSpeed) { } } - @AddMethodToSets(containers = ChunkToCubeSet.ServerLevel_redirects.class, method = @MethodSig("tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerLevel_redirects.class, method = "tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") public void cc_tickCube(LevelCube levelCube, int randomTickSpeed) { // TODO (P2) cube ticking } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java index 1cf243ba..bec811c3 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java @@ -3,30 +3,28 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.mixin.core.common.world.entity.MixinEntity; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; import io.github.opencubicchunks.cubicchunks.server.level.CCServerPlayer; import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; -import net.minecraft.server.level.ChunkTrackingView; import net.minecraft.server.level.ServerPlayer; import org.spongepowered.asm.mixin.Mixin; @Dasm(value = ChunkToCloSet.class, target = @Ref(ServerPlayer.class)) @Mixin(ServerPlayer.class) public abstract class MixinServerPlayer extends MixinEntity implements CCServerPlayer { - @AddFieldToSets(containers = ChunkToCloSet.ServerPlayer_redirects.class, field = @FieldSig(type = @Ref(ChunkTrackingView.class), name = "chunkTrackingView")) + @AddFieldToSets(containers = ChunkToCloSet.ServerPlayer_redirects.class, + field = "chunkTrackingView:Lnet/minecraft/server/level/ChunkTrackingView;") private CloTrackingView cc_cloTrackingView = CloTrackingView.EMPTY; @AddTransformToSets(ChunkToCloSet.ServerPlayer_redirects.class) - @TransformFromMethod(@MethodSig("getChunkTrackingView()Lnet/minecraft/server/level/ChunkTrackingView;")) + @TransformFromMethod("getChunkTrackingView()Lnet/minecraft/server/level/ChunkTrackingView;") public native CloTrackingView cc_getCloTrackingView(); @AddTransformToSets(ChunkToCloSet.ServerPlayer_redirects.class) - @TransformFromMethod(@MethodSig("setChunkTrackingView(Lnet/minecraft/server/level/ChunkTrackingView;)V")) + @TransformFromMethod("setChunkTrackingView(Lnet/minecraft/server/level/ChunkTrackingView;)V") public native void cc_setCloTrackingView(CloTrackingView chunkTrackingView); // TODO P3 :: findDimensionEntryPoint diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java index 6924d56e..677df330 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -18,7 +17,7 @@ @Mixin(SimulationChunkTracker.class) public abstract class MixinSimulationChunkTracker extends MixinChunkTracker implements SimulationCloTracker { @AddTransformToSets(ChunkToCloSet.SimulationChunkTracker_redirects.class) - @TransformFromMethod(owner = @Ref(SimulationChunkTracker.class), value = @MethodSig("getLevel(Lnet/minecraft/world/level/ChunkPos;)I")) + @TransformFromMethod(owner = @Ref(SimulationChunkTracker.class), value = "getLevel(Lnet/minecraft/world/level/ChunkPos;)I") public native int cc_getLevel(CloPos cloPos); @Inject(method = "setLevel", at = @At("HEAD")) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java index c7e37e51..9c4449de 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -17,10 +16,10 @@ @Mixin(LoggerChunkProgressListener.class) public abstract class MixinLoggerChunkProgressListener implements CloProgressListener { @AddTransformToSets(ChunkToCloSet.LoggerChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") @Override public native void cc_updateSpawnPos(CloPos center); @AddTransformToSets(ChunkToCloSet.LoggerChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @Override public native void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java index 57e7dfa2..44e62e12 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -26,7 +24,8 @@ @Mixin(ProcessorChunkProgressListener.class) public abstract class MixinProcessorChunkProgressListener implements CloProgressListener { // We need a field referencing the delegate as a CloProgressListener, otherwise we end up trying to access a field of the wrong type - @AddFieldToSets(containers = ChunkToCloSet.ProcessorChunkProgressListener_redirects.class, field = @FieldSig(type = @Ref(ChunkProgressListener.class), name = "delegate")) + @AddFieldToSets(containers = ChunkToCloSet.ProcessorChunkProgressListener_redirects.class, + field = "delegate:Lnet/minecraft/server/level/progress/ChunkProgressListener;") private CloProgressListener cc_delegate; @Inject(method = "", at = @At("RETURN")) @@ -35,10 +34,10 @@ private void cc_onInit(ChunkProgressListener delegate, Executor dispatcher, Call } @AddTransformToSets(ChunkToCloSet.ProcessorChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") @Override public native void cc_updateSpawnPos(CloPos center); @AddTransformToSets(ChunkToCloSet.ProcessorChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @Override public native void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java index 6c4de990..578689a0 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java @@ -5,8 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -18,7 +16,6 @@ import io.github.opencubicchunks.cubicchunks.server.level.progress.StoringCloProgressListener; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.server.level.progress.StoringChunkProgressListener; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.status.ChunkStatus; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -29,21 +26,21 @@ public abstract class MixinStoringChunkProgressListener implements CloProgressListener, StoringCloProgressListener { @Shadow @Final private Long2ObjectOpenHashMap statuses; @Shadow @Final private int radius; - @AddFieldToSets(containers = GlobalSet.StoringChunkProgressListener_redirects.class, field = @FieldSig(type = @Ref(ChunkPos.class), name = "spawnPos")) + @AddFieldToSets(containers = GlobalSet.StoringChunkProgressListener_redirects.class, field = "spawnPos:Lnet/minecraft/world/level/ChunkPos;") private CloPos cc_spawnPos; @AddTransformToSets(ChunkToCloSet.StoringChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") @Override public native void cc_updateSpawnPos(CloPos center); @AddTransformToSets(ChunkToCloSet.StoringChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @Override public native void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); @Override @Nullable public ChunkStatus cc_getStatus(int cubeX, int cubeY, int cubeZ) { int cubeRadius = Coords.sectionToCubeCeil(radius); var spawnPos = cc_spawnPos != null && cc_spawnPos.isCube() ? cc_spawnPos.cubePos() : CubePos.ZERO; return this.statuses.get( - CubePos.asLong(cubeX + spawnPos.getX() - cubeRadius, cubeY + spawnPos.getY() - cubeRadius, cubeZ + spawnPos.getZ() - cubeRadius)); + CubePos.asLong(cubeX + spawnPos.getX() - cubeRadius, cubeY + spawnPos.getY() - cubeRadius, cubeZ + spawnPos.getZ() - cubeRadius)); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java index 2d0f6a7b..7bbf6b2c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java @@ -7,7 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -53,10 +52,11 @@ public class MixinPlayerChunkSender { @Shadow @Final private LongSet pendingChunks; @AddTransformToSets(ChunkToCloSet.PlayerChunkSender_redirects.class) - @TransformFromMethod(value = @MethodSig("markChunkPendingToSend(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod(value = "markChunkPendingToSend(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_markCloPendingToSend(LevelClo clo); - @AddMethodToSets(containers = ChunkToCloSet.PlayerChunkSender_redirects.class, method = @MethodSig("dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V")) + @AddMethodToSets(containers = ChunkToCloSet.PlayerChunkSender_redirects.class, + method = "dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") public void cc_dropClo(ServerPlayer player, CloPos cloPos) { if (!this.pendingChunks.remove(cloPos.toLong()) && player.isAlive()) { PacketDistributor.sendToPlayer(player, new CCClientboundForgetLevelCloPacket(cloPos)); @@ -138,16 +138,18 @@ private static void cc_sendChunk(ServerGamePacketListenerImpl packetListener, Se // net.neoforged.neoforge.event.EventHooks.fireChunkSent(packetListener.player, chunk, level); } - @TransformFromMethod(value = @MethodSig("collectChunksToSend(Lnet/minecraft/server/level/ChunkMap;Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;")) + @TransformFromMethod(value = "collectChunksToSend(Lnet/minecraft/server/level/ChunkMap;Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;") private native List cc_collectChunksToSend(ChunkMap chunkMap, CloPos cloPos); // FIXME these should probably have some kind of reasonable sort order - at the very least, chunks before cubes - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", + target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator1(ToIntFunction keyExtractor) { return (a, b) -> 0; } - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", + target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator2(ToIntFunction keyExtractor) { return (a, b) -> 0; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java index 5ce4ac76..38171857 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java @@ -4,8 +4,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -19,7 +17,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import org.objectweb.asm.Opcodes; @@ -48,23 +45,25 @@ public abstract class MixinEntity implements EntityCubePosGetter { @Shadow public abstract int getId(); - @AddFieldToSets(containers = ChunkToCubeSet.Entity_redirects.class, field = @FieldSig(type = @Ref(ChunkPos.class), name = "chunkPosition")) + @AddFieldToSets(containers = ChunkToCubeSet.Entity_redirects.class, field = "chunkPosition:Lnet/minecraft/world/level/ChunkPos;") private CubePos cc_cubePosition = CubePos.of(0, 0, 0); @AddTransformToSets(ChunkToCubeSet.Entity_redirects.class) - @TransformFromMethod(@MethodSig("chunkPosition()Lnet/minecraft/world/level/ChunkPos;")) + @TransformFromMethod("chunkPosition()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_cubePosition(); - @AddMethodToSets(containers = ChunkToCloSet.Entity_redirects.class, method = @MethodSig("chunkPosition()Lnet/minecraft/world/level/ChunkPos;")) + @AddMethodToSets(containers = ChunkToCloSet.Entity_redirects.class, method = "chunkPosition()Lnet/minecraft/world/level/ChunkPos;") public CloPos cc_cubePositionAsClo() { return CloPos.cube(cc_cubePosition()); } // Update cube position when blockpos changes - this is the same location as where vanilla updates the chunk position - @Inject(method = "setPosRaw", at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Entity;blockPosition:Lnet/minecraft/core/BlockPos;", opcode = Opcodes.PUTFIELD)) + @Inject(method = "setPosRaw", + at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Entity;blockPosition:Lnet/minecraft/core/BlockPos;", + opcode = Opcodes.PUTFIELD)) private void cc_onSetPosRaw(double x, double y, double z, CallbackInfo ci) { if (Coords.blockToCube(x) != cc_cubePosition.getX() || Coords.blockToCube(y) != cc_cubePosition.getY() - || Coords.blockToCube(z) != cc_cubePosition.getZ()) { + || Coords.blockToCube(z) != cc_cubePosition.getZ()) { this.cc_cubePosition = CubePos.from(this.blockPosition); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java index 694f7add..a12995ac 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java @@ -10,7 +10,6 @@ import com.llamalad7.mixinextras.sugar.ref.LocalRef; import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.utils.Coords; @@ -90,10 +89,11 @@ private void cc_init(CallbackInfo ci) { // setBlock // Uses LevelChunk to call setBlockState and markAndNotifyBlock, so we replace it with a LevelCube and call the Cubic variants of those functions. - @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level" + @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level" + "/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/LevelChunk;")) private LevelChunk cc_replaceLevelChunkInGetChunkAt( - Level level, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + Level level, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.set(this.cc_getCubeAt(blockPos)); @@ -102,10 +102,12 @@ private LevelChunk cc_replaceLevelChunkInGetChunkAt( return original.call(level, blockPos); } - @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Lnet/minecraft/world/level/block/state/BlockState;")) + @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/chunk/LevelChunk;setBlockState(Lnet/minecraft/core/BlockPos;" + + "Lnet/minecraft/world/level/block/state/BlockState;I)Lnet/minecraft/world/level/block/state/BlockState;")) private BlockState cc_replaceLevelChunkInSetBlockState( - LevelChunk levelChunk, BlockPos blockPos, BlockState blockState, int flags, Operation original, - @Share("levelCube") LocalRef levelCubeLocalRef + LevelChunk levelChunk, BlockPos blockPos, BlockState blockState, int flags, Operation original, + @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { return levelCubeLocalRef.get().setBlockState(blockPos, blockState, flags); @@ -113,10 +115,13 @@ private BlockState cc_replaceLevelChunkInSetBlockState( return original.call(levelChunk, blockPos, blockState, flags); } - @WrapWithCondition(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) + @WrapWithCondition(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) private boolean cc_replaceLevelChunkInMarkAndNotifyBlock( - Level level, BlockPos blockPos, LevelChunk levelChunk, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft, - @Share("levelCube") LocalRef levelCubeLocalRef + Level level, BlockPos blockPos, LevelChunk levelChunk, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft, + @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { this.cc_markAndNotifyBlock(blockPos, levelCubeLocalRef.get(), blockStatePrev, blockStateNew, flags, recursionLeft); @@ -127,26 +132,30 @@ private boolean cc_replaceLevelChunkInMarkAndNotifyBlock( @AddTransformToSets(ChunkToCubeSet.Level_redirects.class) @TransformFromMethod(useRedirectSets = { - ChunkToCubeSet.class }, value = @MethodSig("markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) + ChunkToCubeSet.class }, + value = "markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V") public native void cc_markAndNotifyBlock( - BlockPos blockPos, @Nullable LevelCube levelCube, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft + BlockPos blockPos, @Nullable LevelCube levelCube, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft ); // getBlockState // Replaces LevelChunk with a LevelCube to call getBlockState - @Inject(method = "getBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(II)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @Inject(method = "getBlockState", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(II)Lnet/minecraft/world/level/chunk/LevelChunk;")) private void cc_replaceLevelChunkInGetBlockState( - BlockPos blockPos, CallbackInfoReturnable cir, @Share("levelCube") LocalRef levelCubeLocalRef + BlockPos blockPos, CallbackInfoReturnable cir, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.set(this.cc_getCubeAt(blockPos)); } } - @WrapOperation(method = "getBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getBlockState(Lnet/minecraft/core/BlockPos;)" + @WrapOperation(method = "getBlockState", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getBlockState(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/block/state/BlockState;")) private BlockState cc_replaceLevelChunkInGetBlockState( - LevelChunk levelChunk, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + LevelChunk levelChunk, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { return levelCubeLocalRef.get().getBlockState(blockPos); @@ -156,7 +165,8 @@ private BlockState cc_replaceLevelChunkInGetBlockState( // getBlockEntity // Replaces LevelChunk with a LevelCube to call getBlockEntity - @Inject(method = "getBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + @Inject(method = "getBlockEntity", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/chunk/LevelChunk;"), cancellable = true) private void cc_replaceGetChunkAtInSetBlockEntity(BlockPos blockPos, CallbackInfoReturnable cir) { if (cc_isCubic) { @@ -166,7 +176,9 @@ private void cc_replaceGetChunkAtInSetBlockEntity(BlockPos blockPos, CallbackInf // getFluidState // Replaces LevelChunk with a LevelCube to call getFluidState - @WrapOperation(method = "getFluidState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;")) + @WrapOperation(method = "getFluidState", at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/chunk/LevelChunk;getFluidState(Lnet/minecraft/core/BlockPos;)" + + "Lnet/minecraft/world/level/material/FluidState;")) private FluidState cc_replaceGetChunkAtInGetFluidState(LevelChunk levelChunk, BlockPos blockPos, Operation original) { if (cc_isCubic) { return this.cc_getCubeAt(blockPos).getFluidState(blockPos); @@ -176,7 +188,8 @@ private FluidState cc_replaceGetChunkAtInGetFluidState(LevelChunk levelChunk, Bl // setBlockEntity // Replaces LevelChunk with a LevelCube to call addAndRegisterBlockEntity - @Inject(method = "setBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + @Inject(method = "setBlockEntity", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/chunk/LevelChunk;"), cancellable = true) private void cc_replaceLevelChunkInSetBlockEntity(BlockEntity blockEntity, CallbackInfo ci, @Local(ordinal = 0) BlockPos blockPos) { if (cc_isCubic) { @@ -187,9 +200,10 @@ private void cc_replaceLevelChunkInSetBlockEntity(BlockEntity blockEntity, Callb // removeBlockEntity // Replaces LevelChunk with a LevelCube to call removeBlockEntity, needs a local ref to do so - @WrapOperation(method = "removeBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @WrapOperation(method = "removeBlockEntity", at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/LevelChunk;")) private LevelChunk cc_replaceGetChunkAtInRemoveBlockEntity( - Level level, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + Level level, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.set(cc_getCubeAt(pos)); @@ -198,9 +212,10 @@ private LevelChunk cc_replaceGetChunkAtInRemoveBlockEntity( return original.call(level, pos); } - @WrapOperation(method = "removeBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;removeBlockEntity(Lnet/minecraft/core/BlockPos;)V")) + @WrapOperation(method = "removeBlockEntity", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;removeBlockEntity(Lnet/minecraft/core/BlockPos;)V")) private void cc_replaceLevelChunkInRemoveBlockEntity( - LevelChunk levelChunk, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + LevelChunk levelChunk, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.get().removeBlockEntity(pos); @@ -215,22 +230,25 @@ private void cc_replaceLevelChunkInRemoveBlockEntity( private boolean cc_replaceHasChunkInIsLoaded(ChunkSource chunkSource, int x, int z, Operation original, BlockPos blockPos) { if (cc_isCubic) { return ((CubeSource) chunkSource).cc_hasCube(Coords.blockToCube(blockPos.getX()), Coords.blockToCube(blockPos.getY()), - Coords.blockToCube(blockPos.getZ())); + Coords.blockToCube(blockPos.getZ())); } return false; } // loadedAndEntityCanStandOnFace // Uses an inject here since the entire second half of the method needs to be replaced anyways - @Inject(method = "loadedAndEntityCanStandOnFace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;"), cancellable = true) + @Inject(method = "loadedAndEntityCanStandOnFace", at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + + "Lnet/minecraft/world/level/chunk/ChunkAccess;"), + cancellable = true) private void cc_replaceGetChunkAtInLoadedAndEntityCanStandOnFace( - BlockPos blockPos, Entity entity, Direction direction, CallbackInfoReturnable cir + BlockPos blockPos, Entity entity, Direction direction, CallbackInfoReturnable cir ) { if (cc_isCubic) { CubeAccess cubeAccess = this.cc_getCube(Coords.blockToCube(blockPos.getX()), Coords.blockToCube(blockPos.getY()), - Coords.blockToCube(blockPos.getZ()), ChunkStatus.FULL, false); + Coords.blockToCube(blockPos.getZ()), ChunkStatus.FULL, false); cir.setReturnValue( - cubeAccess == null ? false : cubeAccess.getBlockState(blockPos).entityCanStandOnFace(this, blockPos, entity, direction)); + cubeAccess == null ? false : cubeAccess.getBlockState(blockPos).entityCanStandOnFace(this, blockPos, entity, direction)); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java index 4a813fc4..d1ec12a0 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -19,27 +18,31 @@ public class MixinTicketStorage implements CubicTicketStorage { // TODO (P2) codec nonsense for save/load @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), + value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_addTicketWithRadius(TicketType ticketType, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), + value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_addTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), + value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_removeTicketWithRadius(TicketType ticketType, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("removeTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), + value = "removeTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_removeTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z") public native boolean cc_updateChunkForced(CloPos cloPos, boolean add); // TODO move to neoforge-specific mixin @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("shouldForceNaturalSpawning(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "shouldForceNaturalSpawning(Lnet/minecraft/world/level/ChunkPos;)Z") public native boolean cc_shouldForceNaturalSpawning(CloPos cloPos); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java index 286f40de..fc57e848 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java @@ -5,7 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; @@ -16,18 +15,20 @@ @Dasm(value = ChunkToCloSet.class, target = @Ref(ChunkStorage.class)) @Mixin(ChunkStorage.class) public abstract class MixinChunkStorage { - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = @MethodSig("isOldChunkAround(Lnet/minecraft/world/level/ChunkPos;I)Z")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = "isOldChunkAround(Lnet/minecraft/world/level/ChunkPos;I)Z") public boolean cc_isOldChunkAround(CloPos pos, int radius) { return false; // TODO (P2) should be dasm'd once IOWorker is done } - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = @MethodSig("read(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, + method = "read(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") public CompletableFuture> cc_read(CloPos cloPos) { // TODO (P2) loading - this method should be dasm'd return CompletableFuture.completedFuture(Optional.empty()); } - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = @MethodSig("write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, + method = "write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)V") public void cc_write(CloPos cloPos, CompoundTag chunkData) { // TODO (P2) loading/unloading } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java index c2bcdb65..42709c74 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java @@ -10,9 +10,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.sets.InterOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.ConstructorMethodSig; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.exception.DasmFailedToApply; @@ -66,93 +63,97 @@ import net.neoforged.neoforge.event.level.ChunkEvent; /** - * Should be used for DASM transforms that work with Clos (i.e. work with both Chunks and Cubes) - *
- *
- * Clo-related field and type redirects, and method redirects containing Clo-related types in the signature or return type should be added to this - * set. - *
- * Other redirects may also be added to this set if they should only be applied in contexts working with both Chunks and Cubes. - * Redirects applicable in all contexts should be added to {@link GlobalSet}. + * Should be used for DASM transforms that work with Clos (i.e. work with both Chunks and Cubes)

Clo-related field and type redirects, and + * method redirects containing Clo-related types in the signature or return type should be added to this set.
Other redirects may also be added + * to this set if they should only be applied in contexts working with both Chunks and Cubes. Redirects applicable in all contexts should be added to + * {@link GlobalSet}. */ @RedirectSet public interface ChunkToCloSet extends GlobalSet { @TypeRedirect(from = @Ref(ChunkPos.class), to = @Ref(CloPos.class)) abstract class ChunkPos_to_CloPos_redirects { - @FieldRedirect(@FieldSig(type = @Ref(long.class), name = "INVALID_CHUNK_POS")) + @FieldRedirect("INVALID_CHUNK_POS:J") static final long INVALID_CLO_POS = Long.MAX_VALUE; - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "x")) + @FieldToMethodRedirect("x:I") native int getX(); - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "z")) + @FieldToMethodRedirect("z:I") native int getZ(); // Note that this relies on ChunkPos and CloPos encoding to longs in the same way - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(long.class) })) + @ConstructorToFactoryRedirect("(J)V") static native CloPos fromLong(long cloPos); - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(int.class), @Ref(int.class) })) + @ConstructorToFactoryRedirect("(II)V") static native CloPos chunk(int x, int z); - @MethodRedirect(@MethodSig("asLong(II)J")) + @MethodRedirect("asLong(II)J") static native long chunkAsLong(int x, int z); } @TypeRedirect(from = @Ref(ChunkAccess.class), to = @Ref(CloAccess.class)) interface ChunkAccess_to_CloAccess_redirects { - @MethodRedirect(@MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("getPos()Lnet/minecraft/world/level/ChunkPos;") CloPos cc_getCloPos(); - @MethodRedirect(@MethodSig("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @MethodRedirect("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;") ChunkStatus getPersistedStatus(); } @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelClo.class)) interface LevelChunk_to_LevelClo_redirects extends ChunkAccess_to_CloAccess_redirects { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(Level.class), @Ref(CloPos.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/Level;Lio/github/opencubicchunks/cc_core/world/level/CloPos;)V") static LevelClo create(Level level, ChunkPos pos) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(Level.class), @Ref(ChunkPos.class), @Ref(UpgradeData.class), - @Ref(LevelChunkTicks.class), @Ref(LevelChunkTicks.class), @Ref(long.class), @Ref(LevelChunkSection[].class), - @Ref(LevelChunk.PostLoadProcessor.class), @Ref(BlendingData.class) })) + @ConstructorToFactoryRedirect( + "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + + "Lnet/minecraft/world/ticks/LevelChunkTicks;Lnet/minecraft/world/ticks/LevelChunkTicks;" + + "J[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;" + + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static LevelClo create( - Level level, CloPos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, - @Nullable LevelChunkSection[] sections, @Nullable LevelClo.PostLoadProcessor postLoad, @Nullable BlendingData blendingData + Level level, CloPos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, + @Nullable LevelChunkSection[] sections, @Nullable LevelClo.PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(ServerLevel.class), @Ref(ProtoChunk.class), - @Ref(LevelChunk.PostLoadProcessor.class) })) + @ConstructorToFactoryRedirect( + "(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;" + + "Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;)V") static LevelClo create(ServerLevel level, ProtoClo clo, @Nullable LevelClo.PostLoadProcessor postLoad) { throw new DasmFailedToApply(); } } @TypeRedirect(from = @Ref(LevelChunk.PostLoadProcessor.class), to = @Ref(LevelClo.PostLoadProcessor.class)) - interface LevelChunk$PostLoadProcessor_to_LevelClo$PostLoadProcessor_redirects {} + interface LevelChunk$PostLoadProcessor_to_LevelClo$PostLoadProcessor_redirects { + } @TypeRedirect(from = @Ref(ProtoChunk.class), to = @Ref(ProtoClo.class)) interface ProtoChunk_to_ProtoClo_redirects extends ChunkAccess_to_CloAccess_redirects { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(ChunkPos.class), @Ref(UpgradeData.class), @Ref(LevelHeightAccessor.class), - @Ref(Registry.class), @Ref(BlendingData.class) })) + @ConstructorToFactoryRedirect( + "(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + + "Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/core/Registry;" + + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static ProtoClo create( - CloPos cloPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CloPos cloPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(ChunkPos.class), @Ref(UpgradeData.class), @Ref(LevelChunkSection[].class), - @Ref(ProtoChunkTicks.class), @Ref(ProtoChunkTicks.class), @Ref(LevelHeightAccessor.class), @Ref(Registry.class), - @Ref(BlendingData.class) })) + @ConstructorToFactoryRedirect( + "(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + + "[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/ticks/ProtoChunkTicks;" + + "Lnet/minecraft/world/ticks/ProtoChunkTicks;Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/core/Registry;" + + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static ProtoClo create( - CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, - ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, + ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { throw new DasmFailedToApply(); } @@ -160,108 +161,133 @@ static ProtoClo create( @TypeRedirect(from = @Ref(ImposterProtoChunk.class), to = @Ref(ImposterProtoClo.class)) interface ImposterProtoChunk_to_ImposterProtoClo_redirects { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class), @Ref(boolean.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;Z)V") static ImposterProtoClo create(LevelClo wrapped, boolean allowWrites) { throw new DasmFailedToApply(); } - @MethodRedirect(@MethodSig("getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @MethodRedirect("getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;") LevelClo cc_getWrappedClo(); } @TypeRedirect(from = @Ref(ChunkTrackingView.class), to = @Ref(CloTrackingView.class)) - interface ChunkTrackingView_to_CloTrackingView_redirects {} + interface ChunkTrackingView_to_CloTrackingView_redirects { + } @TypeRedirect(from = @Ref(ChunkTrackingView.Positioned.class), to = @Ref(CloTrackingView.Positioned.class)) - abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects implements ChunkTrackingView_to_CloTrackingView_redirects {} + abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects implements ChunkTrackingView_to_CloTrackingView_redirects { + } // region [Forge stuff] // TODO move to a forge-specific sourceset @TypeRedirect(from = @Ref(ChunkEvent.Load.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Load_to_Event_redirects {} + abstract class ChunkEvent$Load_to_Event_redirects { + } @InterOwnerContainer(from = @Ref(ChunkEvent.Load.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Load_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class), @Ref(boolean.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;Z)V") static native Event create_ChunkEvent$Load(LevelCube levelCube, boolean newChunk); } @TypeRedirect(from = @Ref(ChunkEvent.Unload.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Unload_to_Event_redirects {} + abstract class ChunkEvent$Unload_to_Event_redirects { + } @InterOwnerContainer(from = @Ref(ChunkEvent.Unload.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Unload_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;)V") static native Event create_ChunkEvent$Unload(LevelCube levelCube); } @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) abstract class GenerationChunkHolder_Forge_Jank_redirects { - @FieldToMethodRedirect(value = @FieldSig(name = "currentlyLoading", type = @Ref(LevelChunk.class)), setter = "cc_setCurrentlyLoading") + @FieldToMethodRedirect(value = "currentlyLoading:Lnet/minecraft/world/level/chunk/LevelChunk;", setter = "cc_setCurrentlyLoading") public native LevelClo cc_getCurrentlyLoading(); } @IntraOwnerContainer(@Ref(ChunkHolder.class)) - abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects {} + abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects { + } // endregion @IntraOwnerContainer(@Ref(ChunkHolder.class)) - class ChunkHolder_redirects extends GenerationChunkHolder_redirects {} + class ChunkHolder_redirects extends GenerationChunkHolder_redirects { + } @IntraOwnerContainer(@Ref(ProcessorChunkProgressListener.class)) - class ProcessorChunkProgressListener_redirects {} + class ProcessorChunkProgressListener_redirects { + } @IntraOwnerContainer(@Ref(ChunkGenerationTask.class)) - class ChunkGenerationTask_redirects {} + class ChunkGenerationTask_redirects { + } @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) - class GenerationChunkHolder_redirects {} + class GenerationChunkHolder_redirects { + } @IntraOwnerContainer(@Ref(ChunkStorage.class)) - class ChunkStorage_redirects {} + class ChunkStorage_redirects { + } @IntraOwnerContainer(@Ref(ChunkMap.class)) - class ChunkMap_redirects extends ChunkStorage_redirects {} + class ChunkMap_redirects extends ChunkStorage_redirects { + } @IntraOwnerContainer(@Ref(ChunkMap.TrackedEntity.class)) - class ChunkMap$TrackedEntity_redirects {} + class ChunkMap$TrackedEntity_redirects { + } @IntraOwnerContainer(@Ref(ServerChunkCache.class)) - class ServerChunkCache_redirects {} + class ServerChunkCache_redirects { + } @IntraOwnerContainer(@Ref(ServerLevel.class)) - class ServerLevel_redirects {} + class ServerLevel_redirects { + } @IntraOwnerContainer(@Ref(Entity.class)) - class Entity_redirects {} + class Entity_redirects { + } @IntraOwnerContainer(@Ref(ServerPlayer.class)) - class ServerPlayer_redirects extends Entity_redirects {} + class ServerPlayer_redirects extends Entity_redirects { + } @IntraOwnerContainer(@Ref(PlayerChunkSender.class)) - class PlayerChunkSender_redirects {} + class PlayerChunkSender_redirects { + } @InterOwnerContainer(from = @Ref(EventHooks.class), to = @Ref(CCEventHooks.class)) - class EventHooks_to_CCEventHooks_redirects {} + class EventHooks_to_CCEventHooks_redirects { + } @InterOwnerContainer(from = @Ref(CommonHooks.class), to = @Ref(CCCommonHooks.class)) - class CommonHooks_to_CCCommonHooks_redirects {} + class CommonHooks_to_CCCommonHooks_redirects { + } @IntraOwnerContainer(@Ref(ChunkTaskDispatcher.class)) - class ChunkTaskDispatcher_redirects {} + class ChunkTaskDispatcher_redirects { + } @IntraOwnerContainer(@Ref(ChunkTaskPriorityQueue.class)) - class ChunkTaskPriorityQueue_redirects {} + class ChunkTaskPriorityQueue_redirects { + } @IntraOwnerContainer(@Ref(SimulationChunkTracker.class)) - class SimulationChunkTracker_redirects {} + class SimulationChunkTracker_redirects { + } @IntraOwnerContainer(@Ref(LoggerChunkProgressListener.class)) - class LoggerChunkProgressListener_redirects {} + class LoggerChunkProgressListener_redirects { + } @IntraOwnerContainer(@Ref(StoringChunkProgressListener.class)) - class StoringChunkProgressListener_redirects {} + class StoringChunkProgressListener_redirects { + } @IntraOwnerContainer(@Ref(TicketStorage.class)) - class TicketStorage_redirects {} + class TicketStorage_redirects { + } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java index 3180ed31..8465ee15 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java @@ -13,9 +13,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.sets.InterOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.ConstructorMethodSig; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.client.multiplayer.ClientCubeCache; @@ -66,205 +63,240 @@ import net.neoforged.neoforge.event.level.ChunkEvent; /** - * Should be used for DASM transforms that work with only Cubes (as opposed to working with both Chunks and Cubes) - *
- *
- * Cube-related field and type redirects, and method redirects containing Cube-related types in the signature or return type should be added to this - * set. - *
- * Other redirects may also be added to this set if they should only be applied in contexts working with only Cubes. - * Redirects applicable in all contexts should be added to {@link GlobalSet}. + * Should be used for DASM transforms that work with only Cubes (as opposed to working with both Chunks and Cubes)

Cube-related field and + * type redirects, and method redirects containing Cube-related types in the signature or return type should be added to this set.
Other + * redirects may also be added to this set if they should only be applied in contexts working with only Cubes. Redirects applicable in all contexts + * should be added to {@link GlobalSet}. */ @RedirectSet public interface ChunkToCubeSet extends GlobalSet { @TypeRedirect(from = @Ref(ChunkPos.class), to = @Ref(CubePos.class)) abstract class ChunkPos_to_CubePos_redirects { - @FieldRedirect(@FieldSig(type = @Ref(long.class), name = "INVALID_CHUNK_POS")) + @FieldRedirect("INVALID_CHUNK_POS:J") static final long INVALID_CUBE_POS = Long.MAX_VALUE; - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "x")) + @FieldToMethodRedirect("x:I") native int getX(); - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "z")) + @FieldToMethodRedirect("z:I") native int getZ(); - @MethodRedirect(@MethodSig("toLong()J")) + @MethodRedirect("toLong()J") native long asLong(); // Dummy methods that throw errors; these should be manually redirected to the correct x,y,z methods using mixin. // (See: MixinCubePos) - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(int.class), @Ref(int.class) })) + @ConstructorToFactoryRedirect("(II)V") static native CubePos dummy_fromChunkCoords(int x, int z); - @MethodRedirect(@MethodSig("asLong(II)J")) + @MethodRedirect("asLong(II)J") static native long dummy_chunkAsLong(int x, int z); } @TypeRedirect(from = @Ref(ChunkAccess.class), to = @Ref(CubeAccess.class)) abstract class ChunkAccess_to_CubeAccess_redirects { - @FieldRedirect(@FieldSig(type = @Ref(ChunkPos.class), name = "chunkPos")) + @FieldRedirect("chunkPos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cubePos; - @MethodRedirect(@MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("getPos()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_getCubePos(); } - @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.ChunkAccess$ChunkPathElement"), to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess$CubePathElement")) + @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.ChunkAccess$ChunkPathElement"), + to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess$CubePathElement")) abstract class ChunkAccess$ChunkPathElement_to_CubeAccess$CubePathElement_redirects { } @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelCube.class)) abstract class LevelChunk_to_LevelCube_redirects { - @FieldRedirect(@FieldSig(type = @Ref(ChunkPos.class), name = "chunkPos")) + @FieldRedirect("chunkPos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cubePos; - @MethodRedirect(@MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("getPos()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_getCubePos(); } @TypeRedirect(from = @Ref(LevelChunk.PostLoadProcessor.class), to = @Ref(LevelCube.PostLoadProcessor.class)) - interface LevelChunk$PostLoadProcessor_to_LevelCube$PostLoadProcessor_redirects {} + interface LevelChunk$PostLoadProcessor_to_LevelCube$PostLoadProcessor_redirects { + } - @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity"), to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity")) - abstract class LevelChunk$BoundTickingBlockEntity_to_LevelCube$BoundTickingBlockEntity_redirects {} + @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity"), + to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity")) + abstract class LevelChunk$BoundTickingBlockEntity_to_LevelCube$BoundTickingBlockEntity_redirects { + } - @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper")) - abstract class LevelChunk$RebindableTickingBlockEntityWrapper_to_LevelCube$RebindableTickingBlockEntityWrapper_redirects {} + @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), + to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper")) + abstract class LevelChunk$RebindableTickingBlockEntityWrapper_to_LevelCube$RebindableTickingBlockEntityWrapper_redirects { + } @TypeRedirect(from = @Ref(ProtoChunk.class), to = @Ref(ProtoCube.class)) - abstract class ProtoChunk_to_ProtoCube_redirects {} + abstract class ProtoChunk_to_ProtoCube_redirects { + } @TypeRedirect(from = @Ref(ImposterProtoChunk.class), to = @Ref(ImposterProtoCube.class)) - abstract class ImposterProtoChunk_to_ImposterProtoCube_redirects {} + abstract class ImposterProtoChunk_to_ImposterProtoCube_redirects { + } @TypeRedirect(from = @Ref(EmptyLevelChunk.class), to = @Ref(EmptyLevelCube.class)) - abstract class EmptyLevelChunk_to_EmptyLevelCube_redirects {} + abstract class EmptyLevelChunk_to_EmptyLevelCube_redirects { + } // FIXME probably need to move to a client-only set @TypeRedirect(from = @Ref(ClientChunkCache.Storage.class), to = @Ref(ClientCubeCache.Storage.class)) - abstract class ClientChunkCache$Storage_to_ClientCubeCache$Storage_redirects {} + abstract class ClientChunkCache$Storage_to_ClientCubeCache$Storage_redirects { + } @TypeRedirect(from = @Ref(ChunkStatusTask.class), to = @Ref(CubeStatusTask.class)) - interface ChunkStatusTask_to_CubeStatusTask_redirects {} + interface ChunkStatusTask_to_CubeStatusTask_redirects { + } @TypeRedirect(from = @Ref(StaticCache2D.class), to = @Ref(StaticCache3D.class)) - abstract class StaticCache2D_to_StaticCache3D_redirects {} + abstract class StaticCache2D_to_StaticCache3D_redirects { + } @TypeRedirect(from = @Ref(ChunkStep.class), to = @Ref(CubeStep.class)) - abstract class ChunkStep_to_CubeStep_redirects {} + abstract class ChunkStep_to_CubeStep_redirects { + } @TypeRedirect(from = @Ref(ChunkStep.Builder.class), to = @Ref(CubeStep.Builder.class)) - abstract class ChunkStep$Builder_to_CubeStep$Builder_redirects {} + abstract class ChunkStep$Builder_to_CubeStep$Builder_redirects { + } @TypeRedirect(from = @Ref(ChunkPyramid.class), to = @Ref(CubePyramid.class)) - abstract class ChunkPyramid_to_CubePyramid_redirects {} + abstract class ChunkPyramid_to_CubePyramid_redirects { + } @TypeRedirect(from = @Ref(ChunkPyramid.Builder.class), to = @Ref(CubePyramid.Builder.class)) - abstract class ChunkPyramid$Builder_to_CubePyramid$Builder_redirects {} + abstract class ChunkPyramid$Builder_to_CubePyramid$Builder_redirects { + } @TypeRedirect(from = @Ref(ChunkHolder.LevelChangeListener.class), to = @Ref(CubeHolder.LevelChangeListener.class)) interface ChunkHolder$LevelChangeListener_to_CubeHolder$LevelChangeListener_redirects { - @MethodRedirect(@MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @MethodRedirect("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") void cc_onLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter); } @TypeRedirect(from = @Ref(ChunkHolder.PlayerProvider.class), to = @Ref(CubeHolder.PlayerProvider.class)) interface ChunkHolder$PlayerProvider_to_CubeHolder$PlayerProvider_redirects { - @MethodRedirect(@MethodSig("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;")) + @MethodRedirect("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") List cc_getPlayers(CubePos pos, boolean boundaryOnly); } @TypeRedirect(from = @Ref(GeneratingChunkMap.class), to = @Ref(GeneratingCubeMap.class)) interface GeneratingChunkMap_to_GeneratingCubeMap_redirects { - @MethodRedirect(@MethodSig("applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;")) + @MethodRedirect( + "applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") CompletableFuture cc_applyCubeStep(GenerationChunkHolder chunk, CubeStep step, StaticCache3D cache); - @MethodRedirect(@MethodSig("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @MethodRedirect( + "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + + "Lnet/minecraft/server/level/ChunkGenerationTask;") ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus targetStatus, CubePos pos); } @IntraOwnerContainer(@Ref(ChunkGenerationTask.class)) abstract class ChunkGenerationTask_redirects { - @FieldToMethodRedirect(@FieldSig(type = @Ref(GeneratingChunkMap.class), name = "chunkMap")) + @FieldToMethodRedirect("chunkMap:Lnet/minecraft/server/level/GeneratingChunkMap;") private native GeneratingCubeMap cc_getGeneratingCubeMap(); } @TypeRedirect(from = @Ref(LevelChunk.UnsavedListener.class), to = @Ref(LevelCube.UnsavedListener.class)) - interface LevelChunk$UnsavedListener_to_LevelCube$UnsavedListener_redirects {} + interface LevelChunk$UnsavedListener_to_LevelCube$UnsavedListener_redirects { + } @IntraOwnerContainer(@Ref(ChunkHolder.class)) - abstract class ChunkHolder_redirects extends GenerationChunkHolder_redirects {} + abstract class ChunkHolder_redirects extends GenerationChunkHolder_redirects { + } // region [Forge stuff] // TODO move to a forge-specific sourceset @TypeRedirect(from = @Ref(ChunkEvent.Load.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Load_to_Event_redirects {} + abstract class ChunkEvent$Load_to_Event_redirects { + } @InterOwnerContainer(from = @Ref(ChunkEvent.Load.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Load_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class), @Ref(boolean.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;Z)V") static native Event create_ChunkEvent$Load(LevelCube levelCube, boolean newChunk); } @TypeRedirect(from = @Ref(ChunkEvent.Unload.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Unload_to_Event_redirects {} + abstract class ChunkEvent$Unload_to_Event_redirects { + } @InterOwnerContainer(from = @Ref(ChunkEvent.Unload.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Unload_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;)V") static native Event create_ChunkEvent$Unload(LevelCube levelCube); } @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) - abstract class GenerationChunkHolder_Forge_Jank_redirects {} + abstract class GenerationChunkHolder_Forge_Jank_redirects { + } @IntraOwnerContainer(@Ref(ChunkHolder.class)) - abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects {} + abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects { + } // endregion @InterOwnerContainer(from = @Ref(ChunkLevel.class), to = @Ref(CubeLevel.class)) - class ChunkLevel_to_CubeLevel_redirects {} + class ChunkLevel_to_CubeLevel_redirects { + } @InterOwnerContainer(from = @Ref(ChunkStatusTasks.class), to = @Ref(CubeStatusTasks.class)) - class ChunkStatusTasks_to_CubeStatusTasks_redirects {} + class ChunkStatusTasks_to_CubeStatusTasks_redirects { + } @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) class GenerationChunkHolder_redirects { - @FieldRedirect(@FieldSig(name = "pos", type = @Ref(ChunkPos.class))) + @FieldRedirect("pos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cc_cubePos; } @IntraOwnerContainer(@Ref(ChunkMap.class)) - class ChunkMap_redirects {} + class ChunkMap_redirects { + } @IntraOwnerContainer(@Ref(ServerChunkCache.class)) - class ServerChunkCache_redirects {} + class ServerChunkCache_redirects { + } @IntraOwnerContainer(@Ref(Entity.class)) - class Entity_redirects {} + class Entity_redirects { + } @IntraOwnerContainer(@Ref(ServerPlayer.class)) - class ServerPlayer_redirects extends Entity_redirects {} + class ServerPlayer_redirects extends Entity_redirects { + } @IntraOwnerContainer(@Ref(ClientChunkCache.class)) - class ClientChunkCache_redirects {} + class ClientChunkCache_redirects { + } @IntraOwnerContainer(@Ref(SectionOcclusionGraph.class)) - class SectionOcclusionGraph_redirects {} + class SectionOcclusionGraph_redirects { + } @InterOwnerContainer(from = @Ref(CommonHooks.class), to = @Ref(CCCommonHooks.class)) - class CommonHooks_to_CCCommonHooks_redirects {} + class CommonHooks_to_CCCommonHooks_redirects { + } @IntraOwnerContainer(@Ref(Level.class)) - class Level_redirects {} + class Level_redirects { + } @IntraOwnerContainer(@Ref(ServerLevel.class)) - class ServerLevel_redirects extends Level_redirects {} + class ServerLevel_redirects extends Level_redirects { + } @IntraOwnerContainer(@Ref(LevelRenderer.class)) - class LevelRenderer_redirects {} + class LevelRenderer_redirects { + } @IntraOwnerContainer(@Ref(SectionCopy.class)) - class SectionCopy_redirects {} + class SectionCopy_redirects { + } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java index b6ec1b21..1933f162 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java @@ -11,7 +11,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.TypeRedirect; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; @@ -32,46 +31,54 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; /** - * Contains redirects that are applied to all DASM transforms. - *
- *
- * Redirects should only be added to this set if they are applicable in all contexts. + * Contains redirects that are applied to all DASM transforms.

Redirects should only be added to this set if they are applicable in all + * contexts. */ @RedirectSet public interface GlobalSet extends ForgeSet { @IntraOwnerContainer(@Ref(ChunkStatus.class)) abstract class ChunkStatus_redirects { - @MethodRedirect(@MethodSig("generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager;Lnet/minecraft/server/level/ThreadedLevelLightEngine;Ljava/util/function/Function;Ljava/util/List;)Ljava/util/concurrent/CompletableFuture;")) + @MethodRedirect( + "generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;" + + "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager;" + + "Lnet/minecraft/server/level/ThreadedLevelLightEngine;Ljava/util/function/Function;Ljava/util/List;)" + + "Ljava/util/concurrent/CompletableFuture;") public abstract CompletableFuture> cc_generate( - Executor exectutor, ServerLevel level, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, - ThreadedLevelLightEngine lightEngine, Function>> task, List cache + Executor exectutor, ServerLevel level, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, + ThreadedLevelLightEngine lightEngine, Function>> task, List cache ); } @TypeRedirect(from = @Ref(ChunkProgressListener.class), to = @Ref(CloProgressListener.class)) interface ChunkProgressListener_to_CloProgressListener_redirects { - @MethodRedirect(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @MethodRedirect("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") void cc_updateSpawnPos(CloPos center); - @MethodRedirect(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @MethodRedirect("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); } @TypeRedirect(from = @Ref(ChunkStatusUpdateListener.class), to = @Ref(CloStatusUpdateListener.class)) - interface ChunkStatusUpdateListener_to_CloStatusUpdateListener_redirects {} + interface ChunkStatusUpdateListener_to_CloStatusUpdateListener_redirects { + } @TypeRedirect(from = @Ref(ChunkTrackingView.class), to = @Ref(CloTrackingView.class)) - interface ChunkTrackingView_to_CloTrackingView_redirects {} + interface ChunkTrackingView_to_CloTrackingView_redirects { + } @TypeRedirect(from = @Ref(ChunkTrackingView.Positioned.class), to = @Ref(CloTrackingView.Positioned.class)) - abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects {} + abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects { + } @IntraOwnerContainer(@Ref(StoringChunkProgressListener.class)) - class StoringChunkProgressListener_redirects {} + class StoringChunkProgressListener_redirects { + } @IntraOwnerContainer(@Ref(ChunkMap.class)) - class ChunkMap_redirects {} + class ChunkMap_redirects { + } @IntraOwnerContainer(@Ref(ServerChunkCache.class)) - class ServerChunkCache_redirects {} + class ServerChunkCache_redirects { + } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java index 817b079d..ff9d9030 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java @@ -3,7 +3,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.MethodRedirect; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import net.minecraft.core.SectionPos; @@ -15,7 +14,7 @@ public interface SectionPosToChunkSet { @IntraOwnerContainer(@Ref(SectionPos.class)) abstract class SectionPos_redirects { - @MethodRedirect(@MethodSig("chunk()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("chunk()Lnet/minecraft/world/level/ChunkPos;") public native CloPos cc_chunk(); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java index 5de45fdd..c57e4394 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java @@ -3,7 +3,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.MethodRedirect; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import net.minecraft.core.SectionPos; @@ -15,7 +14,7 @@ public interface SectionPosToCubeSet { @IntraOwnerContainer(@Ref(SectionPos.class)) abstract class SectionPos_redirects { - @MethodRedirect(@MethodSig("chunk()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("chunk()Lnet/minecraft/world/level/ChunkPos;") public native CloPos cc_cube(); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java index 7c386621..1bbf6385 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet; @@ -14,14 +13,17 @@ @Dasm(GlobalSet.class) public class CCCommonHooks { - private CCCommonHooks() {} + private CCCommonHooks() { + } - @AddMethodToSets(containers = ChunkToCubeSet.CommonHooks_to_CCCommonHooks_redirects.class, method = @MethodSig("onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.CommonHooks_to_CCCommonHooks_redirects.class, + method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") public static void onCubeUnload(PoiManager poiManager, CubeAccess cubeAccess) { // TODO (P2) save/load: once PoiManager cubic methods are implemented, this method can be a dasm copy } - @AddMethodToSets(containers = ChunkToCloSet.CommonHooks_to_CCCommonHooks_redirects.class, method = @MethodSig("onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V")) + @AddMethodToSets(containers = ChunkToCloSet.CommonHooks_to_CCCommonHooks_redirects.class, + method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") public static void onCloUnload(PoiManager poiManager, CloAccess cloAccess) { if (cloAccess instanceof CubeAccess cubeAccess) { onCubeUnload(poiManager, cubeAccess); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java index eff053c3..d2b2a03a 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ForgeSet; @@ -16,14 +15,16 @@ @Dasm(ForgeSet.class) public class CCEventHooks { - private CCEventHooks() {} + private CCEventHooks() { + } // TODO onCreateWorldSpawn? // TODO onTrySpawnPortal? - @AddMethodToSets(containers = ForgeSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkTicketLevelUpdated(Lnet/minecraft/server/level/ServerLevel;JIILnet/minecraft/server/level/ChunkHolder;)V")) + @AddMethodToSets(containers = ForgeSet.EventHooks_to_CCEventHooks_redirects.class, + method = "fireChunkTicketLevelUpdated(Lnet/minecraft/server/level/ServerLevel;JIILnet/minecraft/server/level/ChunkHolder;)V") public static void fireChunkTicketLevelUpdated( - ServerLevel level, long cloPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder + ServerLevel level, long cloPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder ) { if (CloPos.isChunk(cloPos)) { EventHooks.fireChunkTicketLevelUpdated(level, cloPos, oldTicketLevel, newTicketLevel, chunkHolder); @@ -33,7 +34,9 @@ public static void fireChunkTicketLevelUpdated( } // TODO do we need a ChunkToCloForgeSet, etc? actually I guess if we only tell dasm about this class on forge then it's fine - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/server/level/ServerLevel;)V")) + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, + method = "fireChunkWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkWatch(ServerPlayer entity, LevelClo clo, ServerLevel level) { if (clo instanceof LevelChunk chunk) { EventHooks.fireChunkWatch(entity, chunk, level); @@ -42,7 +45,9 @@ public static void fireChunkWatch(ServerPlayer entity, LevelClo clo, ServerLevel } } - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkSent(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/server/level/ServerLevel;)V")) + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, + method = "fireChunkSent(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkSent(ServerPlayer entity, LevelClo clo, ServerLevel level) { if (clo instanceof LevelChunk chunk) { EventHooks.fireChunkSent(entity, chunk, level); @@ -51,7 +56,9 @@ public static void fireChunkSent(ServerPlayer entity, LevelClo clo, ServerLevel } } - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkUnWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/ServerLevel;)V")) + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, + method = "fireChunkUnWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;" + + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkUnWatch(ServerPlayer entity, CloPos cloPos, ServerLevel level) { if (cloPos.isChunk()) { EventHooks.fireChunkUnWatch(entity, cloPos.chunkPos(), level); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java index 9faa865f..13dcaddd 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java @@ -5,9 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; -import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -17,30 +14,36 @@ @Dasm(ChunkToCloSet.class) public interface CloTrackingView extends ChunkTrackingView { - @AddFieldToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, field = @FieldSig(type = @Ref(ChunkTrackingView.class), name = "EMPTY")) + @AddFieldToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, + field = "EMPTY:Lnet/minecraft/server/level/ChunkTrackingView;") CloTrackingView EMPTY = new CloTrackingView() { @Override public boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks) { return false; } - @Override public void cc_forEach(Consumer action) {} + @Override public void cc_forEach(Consumer action) { + } @Override public boolean contains(int x, int z, boolean searchAllChunks) { return false; } - @Override public void forEach(Consumer action) {} + @Override public void forEach(Consumer action) { + } }; - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("of(Lnet/minecraft/world/level/ChunkPos;I)Lnet/minecraft/server/level/ChunkTrackingView;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, + method = "of(Lnet/minecraft/world/level/ChunkPos;I)Lnet/minecraft/server/level/ChunkTrackingView;") static CloTrackingView cc_of(CloPos center, int viewDistanceCubes) { return new CloTrackingView.Positioned(center, viewDistanceCubes); } @SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:JavaNCSS" }) // <-- copies structure of vanilla method - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("difference(Lnet/minecraft/server/level/ChunkTrackingView;Lnet/minecraft/server/level/ChunkTrackingView;Ljava/util/function/Consumer;Ljava/util/function/Consumer;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, + method = "difference(Lnet/minecraft/server/level/ChunkTrackingView;Lnet/minecraft/server/level/ChunkTrackingView;" + + "Ljava/util/function/Consumer;Ljava/util/function/Consumer;)V") static void cc_difference( - CloTrackingView oldCloTrackingView, CloTrackingView newCloTrackingView, Consumer chunkDropper, Consumer chunkMarker + CloTrackingView oldCloTrackingView, CloTrackingView newCloTrackingView, Consumer chunkDropper, Consumer chunkMarker ) { if (!oldCloTrackingView.equals(newCloTrackingView)) { if (oldCloTrackingView instanceof Positioned oldPositioned && newCloTrackingView instanceof Positioned newPositioned) { @@ -120,7 +123,8 @@ static void cc_difference( } } - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("contains(Lnet/minecraft/world/level/ChunkPos;)Z")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, + method = "contains(Lnet/minecraft/world/level/ChunkPos;)Z") default boolean cc_contains(CloPos cloPos) { if (cloPos.isCube()) { return this.cc_contains(cloPos.getX(), cloPos.getY(), cloPos.getZ()); @@ -135,7 +139,8 @@ default boolean cc_contains(int cubeX, int cubeY, int cubeZ) { boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks); - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("forEach(Ljava/util/function/Consumer;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, + method = "forEach(Ljava/util/function/Consumer;)V") void cc_forEach(Consumer action); default boolean cc_isInViewDistance(int cubeX, int cubeY, int cubeZ) { @@ -147,8 +152,8 @@ static boolean cc_isInViewDistance(int centerCubeX, int centerCubeY, int centerC } static boolean cc_isWithinDistance( - int centerCubeX, int centerCubeY, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeY, int cubeZ, - boolean includeOuterChunksAdjacentToViewBorder + int centerCubeX, int centerCubeY, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeY, int cubeZ, + boolean includeOuterChunksAdjacentToViewBorder ) { int i = includeOuterChunksAdjacentToViewBorder ? 2 : 1; int dx = Math.max(0, Math.abs(cubeX - centerCubeX) - i); @@ -158,15 +163,16 @@ static boolean cc_isWithinDistance( } static boolean cc_isWithinDistanceCubeColumn( - int centerCubeX, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeZ, boolean includeOuterChunksAdjacentToViewBorder + int centerCubeX, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeZ, boolean includeOuterChunksAdjacentToViewBorder ) { return cc_isWithinDistance(centerCubeX, 0, centerCubeZ, viewDistanceCubes, cubeX, 0, cubeZ, includeOuterChunksAdjacentToViewBorder); } @Dasm(ChunkToCloSet.class) record Positioned( - CloPos center, - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects.class, method = @MethodSig("viewDistance()I")) int viewDistanceCubes + CloPos center, + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects.class, + method = "viewDistance()I") int viewDistanceCubes ) implements CloTrackingView { int minX() { return this.center.getX() - this.viewDistanceCubes - 1; @@ -194,7 +200,7 @@ int maxZ() { @Override public boolean contains(int chunkX, int chunkZ, boolean searchAllChunks) { return cc_isWithinDistanceCubeColumn(this.center.getX(), this.center.getZ(), this.viewDistanceCubes, Coords.sectionToCube(chunkX), - Coords.sectionToCube(chunkZ), searchAllChunks); + Coords.sectionToCube(chunkZ), searchAllChunks); } @Override public void forEach(Consumer action) { @@ -213,7 +219,7 @@ int maxZ() { private boolean cc_cubeIntersects(CloTrackingView.Positioned other) { return this.minX() <= other.maxX() && this.maxX() >= other.minX() && this.minY() <= other.maxY() && this.maxY() >= other.minY() - && this.minZ() <= other.maxZ() && this.maxZ() >= other.minZ(); + && this.minZ() <= other.maxZ() && this.maxZ() >= other.minZ(); } private boolean cc_chunkIntersects(CloTrackingView.Positioned other) { @@ -222,7 +228,7 @@ private boolean cc_chunkIntersects(CloTrackingView.Positioned other) { @Override public boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks) { return cc_isWithinDistance(this.center.getX(), this.center.getY(), this.center.getZ(), this.viewDistanceCubes, cubeX, cubeY, cubeZ, - searchAllChunks); + searchAllChunks); } @Override public void cc_forEach(Consumer action) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java index 2d199f5c..0910ab15 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java @@ -5,9 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; -import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet; import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubePyramid; @@ -21,22 +18,26 @@ */ @Dasm(GlobalSet.class) public class CubeLevel { - private CubeLevel() {} + private CubeLevel() { + } private static final int FULL_CHUNK_LEVEL = 33; private static final CubeStep FULL_CUBE_STEP = CubePyramid.CC_GENERATION_PYRAMID_CUBES.getStepTo(ChunkStatus.FULL); - @AddFieldToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, field = @FieldSig(type = @Ref(int.class), name = "RADIUS_AROUND_FULL_CHUNK")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, field = "RADIUS_AROUND_FULL_CHUNK:I") public static final int RADIUS_AROUND_FULL_CUBE = FULL_CUBE_STEP.accumulatedDependencies().getRadius(); // TODO not sure if this one should actually be redirected? in some cases we want this MAX_LEVEL, in some cases we want the true MAX_LEVEL, which // is greater. public static final int MAX_LEVEL = FULL_CHUNK_LEVEL + RADIUS_AROUND_FULL_CUBE; - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, + method = "generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") public static @Nullable ChunkStatus cubeGenerationStatus(int level) { return getStatusAroundFullCube(level - FULL_CHUNK_LEVEL, null); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("getStatusAroundFullChunk(ILnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, + method = "getStatusAroundFullChunk(ILnet/minecraft/world/level/chunk/status/ChunkStatus;)" + + "Lnet/minecraft/world/level/chunk/status/ChunkStatus;") @Nullable @Contract("_,!null->!null;_,_->_") public static ChunkStatus getStatusAroundFullCube(int distance, @Nullable ChunkStatus chunkStatus) { if (distance > RADIUS_AROUND_FULL_CUBE) { @@ -46,17 +47,19 @@ public static ChunkStatus getStatusAroundFullCube(int distance, @Nullable ChunkS } } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("getStatusAroundFullChunk(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, + method = "getStatusAroundFullChunk(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") public static ChunkStatus getStatusAroundFullCube(int distance) { return getStatusAroundFullCube(distance, ChunkStatus.EMPTY); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("byStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, + method = "byStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") public static int byCubeStatus(ChunkStatus status) { return FULL_CHUNK_LEVEL + FULL_CUBE_STEP.getAccumulatedRadiusOf(status); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("isLoaded(I)Z")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "isLoaded(I)Z") public static boolean isLoadedCube(int level) { return level <= MAX_LEVEL; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java index 54a36ee7..c90d145d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkInCubicContextSet; @@ -30,108 +28,138 @@ */ @Dasm(ChunkInCubicContextSet.class) public class CCChunkStatusTasks { - private CCChunkStatusTasks() {} + private CCChunkStatusTasks() { + } - @AddFieldToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, field = @FieldSig(type = @Ref(Logger.class), name = "LOGGER")) + @AddFieldToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, field = "LOGGER:Lorg/slf4j/Logger;") private static final Logger LOGGER = LogUtils.getLogger(); @AddTransformToSets(ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private static native boolean isLighted(ChunkAccess chunk); - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture passThrough( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return CompletableFuture.completedFuture(chunk); } // We skip chunk generation steps in cubic contexts by delegating to passThrough - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureStarts( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture loadStructureStarts( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureReferences( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateBiomes( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateNoise( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSurface( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateCarvers( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateFeatures( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture initializeLight( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture light( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSpawn( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } // We still want to upgrade ProtoChunks to LevelChunks normally @AddTransformToSets(ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), + value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static native CompletableFuture full( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ); - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, + method = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") private static void postLoadProtoChunk(ServerLevel level, ValueInput.ValueInputList entityTags) { // Entities should be handled on the cube, not the chunk } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java index 91b3ea52..0e131fe6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java @@ -10,7 +10,6 @@ import com.google.common.collect.Maps; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -81,8 +80,8 @@ public abstract class CubeAccess implements CloAccess { // Constructor signature matches ChunkAccess for DASM redirect purposes public CubeAccess( - CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, long inhabitedTime, - @Nullable LevelChunkSection[] chunkSections, @Nullable BlendingData blendingData + CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, long inhabitedTime, + @Nullable LevelChunkSection[] chunkSections, @Nullable BlendingData blendingData ) { this.cubePos = cubePos; this.upgradeData = upgradeData; @@ -97,7 +96,7 @@ public CubeAccess( System.arraycopy(chunkSections, 0, this.sections, 0, this.sections.length); } else { CubicChunks.LOGGER.warn("Could not set level cube sections, array length is {} instead of {}", chunkSections.length, - this.sections.length); + this.sections.length); } } @@ -112,10 +111,13 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC } } - @TransformFromMethod(value = @MethodSig("getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", + owner = @Ref(ChunkAccess.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); - @TransformFromMethod(owner = @Ref(ChunkAccess.class), value = @MethodSig("setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/state/BlockState;")) + @TransformFromMethod(owner = @Ref(ChunkAccess.class), + value = "setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)" + + "Lnet/minecraft/world/level/block/state/BlockState;") @Override public native @Nullable BlockState setBlockState(BlockPos pos, BlockState state); @Override public abstract @Nullable BlockState setBlockState(BlockPos pos, BlockState state, int flags); @@ -134,13 +136,13 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return this.getMinY(); } - @TransformFromMethod(value = @MethodSig("getBlockEntitiesPos()Ljava/util/Set;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getBlockEntitiesPos()Ljava/util/Set;", owner = @Ref(ChunkAccess.class)) @Override public native Set getBlockEntitiesPos(); - @TransformFromMethod(value = @MethodSig("getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;", owner = @Ref(ChunkAccess.class)) @Override public native LevelChunkSection[] getSections(); - @TransformFromMethod(value = @MethodSig("getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;", owner = @Ref(ChunkAccess.class)) @Override public native LevelChunkSection getSection(int index); // TODO (P2) heightmap methods on cubes @@ -148,7 +150,8 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC throw new UnsupportedOperationException(); } - @Override public void setHeightmap(Heightmap.Types type, long[] data) {} + @Override public void setHeightmap(Heightmap.Types type, long[] data) { + } @Override public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Types type) { throw new UnsupportedOperationException(); @@ -171,28 +174,37 @@ public CubePos cc_getCubePos() { return CloPos.cube(cubePos); } - @TransformFromMethod(value = @MethodSig("getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lnet/minecraft/world/level/levelgen/structure/StructureStart;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod( + value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;", + owner = @Ref(ChunkAccess.class)) @Override public native @Nullable StructureStart getStartForStructure(Structure structure); - @TransformFromMethod(value = @MethodSig("setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod( + value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" + + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V", + owner = @Ref(ChunkAccess.class)) @Override public native void setStartForStructure(Structure structure, StructureStart structureStart); - @TransformFromMethod(value = @MethodSig("getAllStarts()Ljava/util/Map;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getAllStarts()Ljava/util/Map;", owner = @Ref(ChunkAccess.class)) @Override public native Map getAllStarts(); - @TransformFromMethod(value = @MethodSig("setAllStarts(Ljava/util/Map;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setAllStarts(Ljava/util/Map;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setAllStarts(Map structureStarts); - @TransformFromMethod(value = @MethodSig("getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod( + value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;", + owner = @Ref(ChunkAccess.class)) @Override public native LongSet getReferencesForStructure(Structure structure); - @TransformFromMethod(value = @MethodSig("addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V", + owner = @Ref(ChunkAccess.class)) @Override public native void addReferenceForStructure(Structure structure, long reference); - @TransformFromMethod(value = @MethodSig("getAllReferences()Ljava/util/Map;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getAllReferences()Ljava/util/Map;", owner = @Ref(ChunkAccess.class)) @Override public native Map getAllReferences(); - @TransformFromMethod(value = @MethodSig("setAllReferences(Ljava/util/Map;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setAllReferences(Ljava/util/Map;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setAllReferences(Map structureReferencesMap); @Override public boolean isYSpaceEmpty(int startY, int endY) { @@ -205,13 +217,13 @@ public CubePos cc_getCubePos() { return false; } - @TransformFromMethod(value = @MethodSig("markUnsaved()V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "markUnsaved()V", owner = @Ref(ChunkAccess.class)) @Override public native void markUnsaved(); - @TransformFromMethod(value = @MethodSig("tryMarkSaved()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "tryMarkSaved()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean tryMarkSaved(); - @TransformFromMethod(value = @MethodSig("isUnsaved()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "isUnsaved()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean isUnsaved(); @Override public abstract ChunkStatus getPersistedStatus(); @@ -223,31 +235,31 @@ public CubePos cc_getCubePos() { @Override public abstract void removeBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ChunkAccess.class)) @Override public native void markPosForPostprocessing(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;", owner = @Ref(ChunkAccess.class)) @Override public native ShortList[] getPostProcessing(); - @TransformFromMethod(value = @MethodSig("addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V", owner = @Ref(ChunkAccess.class)) @Override public native void addPackedPostProcess(ShortList offsets, int index); - @TransformFromMethod(value = @MethodSig("setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setBlockEntityNbt(CompoundTag tag); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;", owner = @Ref(ChunkAccess.class)) @Override public native @Nullable CompoundTag getBlockEntityNbt(BlockPos pos); @Override public abstract @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); - @TransformFromMethod(value = @MethodSig("findBlockLightSources(Ljava/util/function/BiConsumer;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "findBlockLightSources(Ljava/util/function/BiConsumer;)V", owner = @Ref(ChunkAccess.class)) @Override public native void findBlockLightSources(BiConsumer output); - @TransformFromMethod(value = @MethodSig("findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V", owner = @Ref(ChunkAccess.class)) @Override public native void findBlocks(Predicate predicate, BiConsumer output); @Override public void findBlocks( - Predicate predicate, java.util.function.BiPredicate fineFilter, BiConsumer output + Predicate predicate, java.util.function.BiPredicate fineFilter, BiConsumer output ) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); @@ -279,46 +291,47 @@ public CubePos cc_getCubePos() { @Override public abstract TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = @MethodSig("canBeSerialized()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "canBeSerialized()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean canBeSerialized(); @Override public abstract ChunkAccess.PackedTicks getTicksForSerialization(long todoNameThis); - @TransformFromMethod(value = @MethodSig("getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;", owner = @Ref(ChunkAccess.class)) @Override public native UpgradeData getUpgradeData(); - @TransformFromMethod(value = @MethodSig("isOldNoiseGeneration()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "isOldNoiseGeneration()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean isOldNoiseGeneration(); - @TransformFromMethod(value = @MethodSig("getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;", owner = @Ref(ChunkAccess.class)) @Override public native @Nullable BlendingData getBlendingData(); - @TransformFromMethod(value = @MethodSig("getInhabitedTime()J"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getInhabitedTime()J", owner = @Ref(ChunkAccess.class)) @Override public native long getInhabitedTime(); - @TransformFromMethod(value = @MethodSig("incrementInhabitedTime(J)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "incrementInhabitedTime(J)V", owner = @Ref(ChunkAccess.class)) @Override public native void incrementInhabitedTime(long amount); - @TransformFromMethod(value = @MethodSig("setInhabitedTime(J)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setInhabitedTime(J)V", owner = @Ref(ChunkAccess.class)) @Override public native void setInhabitedTime(long inhabitedTime); - @TransformFromMethod(value = @MethodSig("getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;", + owner = @Ref(ChunkAccess.class)) public static native ShortList getOrCreateOffsetList(ShortList[] packedPositions, int index); - @TransformFromMethod(value = @MethodSig("isLightCorrect()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "isLightCorrect()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean isLightCorrect(); - @TransformFromMethod(value = @MethodSig("setLightCorrect(Z)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setLightCorrect(Z)V", owner = @Ref(ChunkAccess.class)) @Override public native void setLightCorrect(boolean lightCorrect); - @TransformFromMethod(value = @MethodSig("getMinY()I"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getMinY()I", owner = @Ref(ChunkAccess.class)) @Override public native int getMinY(); // these are two semantically different methods that happen to share a name; // one is for accessing heightmaps, and the other for getting height of the world. // we match the method ordering of the vanilla ChunkAccess class, which doesn't group them. @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder") - @TransformFromMethod(value = @MethodSig("getHeight()I"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getHeight()I", owner = @Ref(ChunkAccess.class)) @Override public native int getHeight(); @Override public NoiseChunk getOrCreateNoiseChunk(Function noiseChunkCreator) { @@ -337,7 +350,7 @@ public CubePos cc_getCubePos() { throw new UnsupportedOperationException(); // TODO P3 } - @TransformFromMethod(value = @MethodSig("hasAnyStructureReferences()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "hasAnyStructureReferences()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean hasAnyStructureReferences(); @Override public @Nullable BelowZeroRetrogen getBelowZeroRetrogen() { @@ -348,7 +361,7 @@ public CubePos cc_getCubePos() { return false; // Used for below-zero retrogen; not applicable to cubes } - @TransformFromMethod(value = @MethodSig("getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;", owner = @Ref(ChunkAccess.class)) @Override public native LevelHeightAccessor getHeightAccessorForGeneration(); @Override public void initializeLightSources() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java index 2227f0bf..432e9991 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.world.level.cube; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.opencubicchunks.cubicchunks.exception.DasmFailedToApply; @@ -22,7 +21,8 @@ public ImposterProtoCube(LevelCube wrapped, boolean allowWrites) { } // Method is implemented in MixinImposterProtoCube instead, since DASM clears everything in this class. - @AddMethodToSets(containers = ChunkToCubeSet.ImposterProtoChunk_to_ImposterProtoCube_redirects.class, method = @MethodSig("Lnet/minecraft/world/level/chunk/ImposterProtoChunk;getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @AddMethodToSets(containers = ChunkToCubeSet.ImposterProtoChunk_to_ImposterProtoCube_redirects.class, + method = "Lnet/minecraft/world/level/chunk/ImposterProtoChunk;getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;") @Override public LevelClo cc_getWrappedClo() { throw new DasmFailedToApply(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java index 989e82f8..9468329d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java @@ -13,7 +13,6 @@ import com.google.common.collect.Maps; import com.mojang.logging.LogUtils; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -66,7 +65,8 @@ public class LevelCube extends CubeAccess implements LevelClo { // Fields matching LevelChunk static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { - @Override public void tick() {} + @Override public void tick() { + } @Override public boolean isRemoved() { return true; @@ -96,8 +96,8 @@ public LevelCube(Level level, CubePos pos) { } public LevelCube( - Level level, CubePos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, - @Nullable LevelChunkSection[] sections, @Nullable LevelCube.PostLoadProcessor postLoad, @Nullable BlendingData blendingData + Level level, CubePos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, + @Nullable LevelChunkSection[] sections, @Nullable LevelCube.PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { super(pos, data, level, level.registryAccess().lookupOrThrow(Registries.BIOME), inhabitedTime, sections, blendingData); this.level = level; @@ -117,7 +117,7 @@ public LevelCube( public LevelCube(ServerLevel level, ProtoCube cube, @Nullable LevelCube.PostLoadProcessor postLoad) { this(level, cube.cc_getCubePos(), cube.getUpgradeData(), cube.unpackBlockTicks(), cube.unpackFluidTicks(), cube.getInhabitedTime(), - cube.getSections(), postLoad, cube.getBlendingData()); + cube.getSections(), postLoad, cube.getBlendingData()); if (!Collections.disjoint(cube.pendingBlockEntities.keySet(), cube.blockEntities.keySet())) { LOGGER.error("Cube at {} contains duplicated block entities", cube.cc_getCubePos()); @@ -159,31 +159,35 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { this.setUnsavedListener(cubePos -> unsavedListener.setUnsaved(CloPos.cube(cubePos))); } - @TransformFromMethod(value = @MethodSig("markUnsaved()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "markUnsaved()V", owner = @Ref(LevelChunk.class)) @Override public native void markUnsaved(); - @TransformFromMethod(value = @MethodSig("getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getBlockTicks(); - @TransformFromMethod(value = @MethodSig("getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = @MethodSig("getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", + owner = @Ref(LevelChunk.class)) @Override public native ChunkAccess.PackedTicks getTicksForSerialization(long gameTime); // TODO should this actually be dasm'd? - @TransformFromMethod(value = @MethodSig("getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", + owner = @Ref(LevelChunk.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", + owner = @Ref(LevelChunk.class)) @Override public native @NotNull BlockState getBlockState(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", + owner = @Ref(LevelChunk.class)) @Override public native @NotNull FluidState getFluidState(BlockPos pos); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getFluidState(III)Lnet/minecraft/world/level/material/FluidState;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", owner = @Ref(LevelChunk.class)) @Override public native FluidState getFluidState(int x, int y, int z); // TODO might be dasm-able eventually, if we get more powerful mixin tools @@ -207,7 +211,7 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { if (wasOnlyAir != isOnlyAir) { this.level.getChunkSource().getLightEngine().updateSectionStatus(pos, isOnlyAir); this.level.getChunkSource().onSectionEmptinessChanged(SectionPos.blockToSectionCoord(pos.getX()), - SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ()), isOnlyAir); + SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ()), isOnlyAir); } if (LightEngine.hasDifferentLightProperties(this, pos, previousState, state)) { @@ -243,7 +247,7 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { BlockEntity blockentity1 = this.getBlockEntity(pos, LevelChunk.EntityCreationType.CHECK); if (blockentity1 != null && !blockentity1.isValidBlockState(state)) { LOGGER.warn("Found mismatched block entity @ {}: type = {}, state = {}", pos, - blockentity1.getType().builtInRegistryHolder().key().location(), state); + blockentity1.getType().builtInRegistryHolder().key().location(), state); this.removeBlockEntity(pos); blockentity1 = null; } @@ -266,58 +270,64 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { } } - @TransformFromMethod(value = @MethodSig("addEntity(Lnet/minecraft/world/entity/Entity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "addEntity(Lnet/minecraft/world/entity/Entity;)V", owner = @Ref(LevelChunk.class)) @Deprecated @Override public native void addEntity(Entity entity); - @TransformFromMethod(value = @MethodSig("createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", + owner = @Ref(LevelChunk.class)) private native @Nullable BlockEntity createBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", + owner = @Ref(LevelChunk.class)) @Override public native @Nullable BlockEntity getBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" - + "Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) public native @Nullable BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType); - @TransformFromMethod(value = @MethodSig("addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) public native void addAndRegisterBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = @MethodSig("isInLevel()Z"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "isInLevel()Z", owner = @Ref(LevelChunk.class)) private native boolean isInLevel(); - @TransformFromMethod(value = @MethodSig("isTicking(Lnet/minecraft/core/BlockPos;)Z"), owner = @Ref(LevelChunk.class), visibility = PUBLIC) + @TransformFromMethod(value = "isTicking(Lnet/minecraft/core/BlockPos;)Z", owner = @Ref(LevelChunk.class), visibility = PUBLIC) public native boolean isTicking(BlockPos pos); - @TransformFromMethod(value = @MethodSig("setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod( + value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", + owner = @Ref(LevelChunk.class)) @Override public native @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); - @TransformFromMethod(value = @MethodSig("removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(LevelChunk.class)) @Override public native void removeBlockEntity(BlockPos pos); // TODO maybe shouldn't be dasm - @TransformFromMethod(value = @MethodSig("removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod( + value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", + owner = @Ref(LevelChunk.class)) private native void removeGameEventListener(T blockEntity, ServerLevel level); // TODO sectionY is definitely wrong here - @TransformFromMethod(value = @MethodSig("removeGameEventListenerRegistry(I)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeGameEventListenerRegistry(I)V", owner = @Ref(LevelChunk.class)) private native void removeGameEventListenerRegistry(int sectionY); - @TransformFromMethod(value = @MethodSig("removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(LevelChunk.class)) private native void removeBlockEntityTicker(BlockPos pos); - @TransformFromMethod(value = @MethodSig("runPostLoad()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "runPostLoad()V", owner = @Ref(LevelChunk.class)) public native void runPostLoad(); - @TransformFromMethod(value = @MethodSig("isEmpty()Z"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "isEmpty()Z", owner = @Ref(LevelChunk.class)) public native boolean isEmpty(); // TODO this should maybe be dasm + mixin, there's a lot of vanilla code duplication here public void replaceWithPacketData( - FriendlyByteBuf buffer, Map map, Consumer outputTagConsumer + FriendlyByteBuf buffer, Map map, Consumer outputTagConsumer ) { this.clearAllBlockEntities(); @@ -334,22 +344,22 @@ public void replaceWithPacketData( BlockEntity blockentity = this.getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && tag != null && blockentity.getType() == blockEntityType) { blockentity.handleUpdateTag(TagValueInput.create(problemreporter$scopedcollector.forChild(blockentity.problemPath()), - this.level.registryAccess(), tag)); + this.level.registryAccess(), tag)); } }); } } - @TransformFromMethod(value = @MethodSig("replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V", owner = @Ref(LevelChunk.class)) public native void replaceBiomes(FriendlyByteBuf buffer); - @TransformFromMethod(value = @MethodSig("setLoaded(Z)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "setLoaded(Z)V", owner = @Ref(LevelChunk.class)) public native void setLoaded(boolean loaded); - @TransformFromMethod(value = @MethodSig("getLevel()Lnet/minecraft/world/level/Level;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getLevel()Lnet/minecraft/world/level/Level;", owner = @Ref(LevelChunk.class)) public native Level getLevel(); - @TransformFromMethod(value = @MethodSig("getBlockEntities()Ljava/util/Map;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntities()Ljava/util/Map;", owner = @Ref(LevelChunk.class)) public native Map getBlockEntities(); // TODO P2 or P3 figure this out later - stub method for now @@ -367,51 +377,62 @@ public void postProcessGeneration(ServerLevel serverLevel) { this.pendingBlockEntities.clear(); } - @TransformFromMethod(value = @MethodSig("promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod( + value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", + owner = @Ref(LevelChunk.class)) private native @Nullable BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag); - @TransformFromMethod(value = @MethodSig("unpackTicks(J)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "unpackTicks(J)V", owner = @Ref(LevelChunk.class)) public native void unpackTicks(long pos); // TODO (P2 or P3) ticks are disabled for now; stub methods as placeholders -// @TransformFromMethod(value = @MethodSig("registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) +// @TransformFromMethod(value = @MethodSig("registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk +// .class)) // public native void registerTickContainerInLevel(ServerLevel level); - public void registerTickContainerInLevel(ServerLevel level) {} + public void registerTickContainerInLevel(ServerLevel level) { + } -// @TransformFromMethod(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) + // @TransformFromMethod(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref + // (LevelChunk.class)) // public native void unregisterTickContainerFromLevel(ServerLevel level); - public void unregisterTickContainerFromLevel(ServerLevel level) {} + public void unregisterTickContainerFromLevel(ServerLevel level) { + } - @TransformFromMethod(value = @MethodSig("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;", owner = @Ref(LevelChunk.class)) @Override public native ChunkStatus getPersistedStatus(); - @TransformFromMethod(value = @MethodSig("getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;", owner = @Ref(LevelChunk.class)) public native FullChunkStatus getFullStatus(); - @TransformFromMethod(value = @MethodSig("setFullStatus(Ljava/util/function/Supplier;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "setFullStatus(Ljava/util/function/Supplier;)V", owner = @Ref(LevelChunk.class)) public native void setFullStatus(Supplier fullStatus); // TODO a bit concerning - @TransformFromMethod(value = @MethodSig("clearAllBlockEntities()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "clearAllBlockEntities()V", owner = @Ref(LevelChunk.class)) public native void clearAllBlockEntities(); - @TransformFromMethod(value = @MethodSig("registerAllBlockEntitiesAfterLevelLoad()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "registerAllBlockEntitiesAfterLevelLoad()V", owner = @Ref(LevelChunk.class)) public native void registerAllBlockEntitiesAfterLevelLoad(); // TODO (P3): GameEvent stuff is a bit concerning - @TransformFromMethod(value = @MethodSig("addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod( + value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", + owner = @Ref(LevelChunk.class)) private native void addGameEventListener(T blockEntity, ServerLevel level); - @TransformFromMethod(value = @MethodSig("updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) private native void updateBlockEntityTicker(T blockEntity); - @TransformFromMethod(value = @MethodSig("createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" - + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = + "createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" + + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;", owner = @Ref(LevelChunk.class)) private native TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker ticker); // TODO forge stuff // FORGE START -// private final net.neoforged.neoforge.attachment.AttachmentHolder.AsField attachmentHolder = new net.neoforged.neoforge.attachment.AttachmentHolder.AsField(); +// private final net.neoforged.neoforge.attachment.AttachmentHolder.AsField attachmentHolder = new net.neoforged.neoforge.attachment +// .AttachmentHolder.AsField(); // // @Override public boolean hasData(net.neoforged.neoforge.attachment.AttachmentType type) { // return attachmentHolder.hasData(type); @@ -453,7 +474,8 @@ public interface PostLoadProcessor { void run(LevelCube cube); } - @TransformFromClass(value = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), sets = ChunkToCubeSet.class) + @TransformFromClass(value = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), + sets = ChunkToCubeSet.class) public class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { private TickingBlockEntity ticker; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java index 18504004..199e4bc2 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java @@ -7,7 +7,6 @@ import com.google.common.collect.Lists; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -57,16 +56,16 @@ public class ProtoCube extends CubeAccess implements ProtoClo { // Constructors mirroring vanilla signatures public ProtoCube( - CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { this(cubePos, upgradeData, null, new ProtoChunkTicks(), new ProtoChunkTicks(), levelHeightAccessor, biomeRegistry, blendingData); } public ProtoCube( - CubePos cubePos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, - ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CubePos cubePos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, + ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { super(cubePos, upgradeData, levelHeightAccessor, biomeRegistry, 0L, sections, blendingData); this.status = ChunkStatus.EMPTY; @@ -75,21 +74,24 @@ public ProtoCube( this.fluidTicks = liquidTicks; } - @TransformFromMethod(value = @MethodSig("getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(ProtoChunk.class)) @Override public native TickContainerAccess getBlockTicks(); - @TransformFromMethod(value = @MethodSig("getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(ProtoChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = @MethodSig("getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", + owner = @Ref(ProtoChunk.class)) @Override public native ChunkAccess.PackedTicks getTicksForSerialization(long todoNameThis); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", + owner = @Ref(ProtoChunk.class)) @Override public native BlockState getBlockState(BlockPos pos); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", + owner = @Ref(ProtoChunk.class)) @Override public native FluidState getFluidState(BlockPos pos); @Override public @Nullable BlockState setBlockState(BlockPos pos, BlockState state, int flags) { @@ -111,80 +113,85 @@ public ProtoCube( } } - @TransformFromMethod(value = @MethodSig("setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", + owner = @Ref(ProtoChunk.class)) @Override public native @Nullable BlockEntity getBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getBlockEntities()Ljava/util/Map;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntities()Ljava/util/Map;", owner = @Ref(ProtoChunk.class)) @Override public native Map getBlockEntities(); - @TransformFromMethod(value = @MethodSig("addEntity(Lnet/minecraft/nbt/CompoundTag;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "addEntity(Lnet/minecraft/nbt/CompoundTag;)V", owner = @Ref(ProtoChunk.class)) @Override public native void addEntity(CompoundTag tag); - @TransformFromMethod(value = @MethodSig("addEntity(Lnet/minecraft/world/entity/Entity;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "addEntity(Lnet/minecraft/world/entity/Entity;)V", owner = @Ref(ProtoChunk.class)) @Override public native void addEntity(Entity entity); // setStartForStructure: ProtoChunk logic handles below-zero retrogen then calls super, so we don't need to override - @TransformFromMethod(value = @MethodSig("getEntities()Ljava/util/List;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getEntities()Ljava/util/List;", owner = @Ref(ProtoChunk.class)) @Override public native List getEntities(); - @TransformFromMethod(value = @MethodSig("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;", owner = @Ref(ProtoChunk.class)) @Override public native ChunkStatus getPersistedStatus(); - @TransformFromMethod(value = @MethodSig("setPersistedStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setPersistedStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setPersistedStatus(ChunkStatus status); - @TransformFromMethod(value = @MethodSig("getNoiseBiome(III)Lnet/minecraft/core/Holder;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getNoiseBiome(III)Lnet/minecraft/core/Holder;", owner = @Ref(ProtoChunk.class)) @Override public native Holder getNoiseBiome(int x, int y, int z); - @TransformFromMethod(value = @MethodSig("packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S", owner = @Ref(ProtoChunk.class)) public static native short packOffsetCoordinates(BlockPos pos); - @TransformFromMethod(value = @MethodSig("unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;", + owner = @Ref(ProtoChunk.class)) public static native BlockPos unpackOffsetCoordinates(short packedPos, int yOffset, ChunkPos chunkPos); // dasm + mixin - @TransformFromMethod(value = @MethodSig("markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ProtoChunk.class)) @Override public native void markPosForPostprocessing(BlockPos pos); - @TransformFromMethod(value = @MethodSig("addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V", owner = @Ref(ProtoChunk.class)) @Override public native void addPackedPostProcess(ShortList offsets, int index); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbts()Ljava/util/Map;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntityNbts()Ljava/util/Map;", owner = @Ref(ProtoChunk.class)) @Override public native Map getBlockEntityNbts(); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod( + value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", + owner = @Ref(ProtoChunk.class)) @Override public native @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); - @TransformFromMethod(value = @MethodSig("removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ProtoChunk.class)) @Override public native void removeBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;", owner = @Ref(ProtoChunk.class)) @Override public native @Nullable CarvingMask getCarvingMask(); - @TransformFromMethod(value = @MethodSig("getOrCreateCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getOrCreateCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;", owner = @Ref(ProtoChunk.class)) @Override public native CarvingMask getOrCreateCarvingMask(); - @TransformFromMethod(value = @MethodSig("setCarvingMask(Lnet/minecraft/world/level/chunk/CarvingMask;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setCarvingMask(Lnet/minecraft/world/level/chunk/CarvingMask;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setCarvingMask(CarvingMask carvingMask); - @TransformFromMethod(value = @MethodSig("setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setLightEngine(LevelLightEngine lightEngine); @Override public void setBelowZeroRetrogen(@Nullable BelowZeroRetrogen belowZeroRetrogen) { // Below-zero retrogen is unused in CC, hence empty method body } - @TransformFromMethod(value = @MethodSig("unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;", + owner = @Ref(ProtoChunk.class)) private static native LevelChunkTicks unpackTicks(ProtoChunkTicks ticks); - @TransformFromMethod(value = @MethodSig("unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) @Override public native LevelChunkTicks unpackBlockTicks(); - @TransformFromMethod(value = @MethodSig("unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) @Override public native LevelChunkTicks unpackFluidTicks(); @Override public LevelHeightAccessor getHeightAccessorForGeneration() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java index 7d446101..1172b75d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java @@ -3,8 +3,6 @@ import com.google.common.collect.ImmutableList; import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -24,12 +22,14 @@ public CubeStep getStepTo(ChunkStatus status) { return this.steps.get(status.getIndex()); } - @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = @FieldSig(type = @Ref(ChunkPyramid.class), name = "GENERATION_PYRAMID")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, + field = "GENERATION_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") public static CubePyramid CC_GENERATION_PYRAMID_CUBES; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = @FieldSig(type = @Ref(ChunkPyramid.class), name = "LOADING_PYRAMID")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, + field = "LOADING_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") public static CubePyramid CC_LOADING_PYRAMID_CUBES; - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkPyramid.class), value = @MethodSig("()V")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkPyramid.class), value = "()V") static void initCubePyramids() { throw new DasmFailedToApply(); } @@ -40,5 +40,6 @@ static void initCubePyramids() { @Dasm(ChunkToCubeSet.class) @TransformFromClass(sets = ChunkToCubeSet.class, value = @Ref(ChunkPyramid.Builder.class)) - public static class Builder {} + public static class Builder { + } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java index f811067e..4fbe57e1 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubicConstants; @@ -33,55 +31,70 @@ */ @Dasm(ChunkToCubeSet.class) public class CubeStatusTasks { - private CubeStatusTasks() {} + private CubeStatusTasks() { + } - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, field = @FieldSig(type = @Ref(Logger.class), name = "LOGGER")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, field = "LOGGER:Lorg/slf4j/Logger;") private static final Logger LOGGER = LogUtils.getLogger(); @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private static native boolean isLighted(CubeAccess cube); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture passThrough( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return CompletableFuture.completedFuture(cube); } // TODO (P3) we skip cube generation steps for now by delegating to passThrough - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureStarts( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture loadStructureStarts( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureReferences( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateBiomes( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } @SuppressWarnings("checkstyle:MagicNumber") // hardcoded terrain generation; the constants are arbitrary - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateNoise( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { // Temporary basic sinusoidal terrain, so we can generate a simple test world int amplitude = 20; @@ -95,7 +108,7 @@ public static CompletableFuture generateNoise( for (int x = 0; x < CubicConstants.DIAMETER_IN_BLOCKS; x++) { for (int z = 0; z < CubicConstants.DIAMETER_IN_BLOCKS; z++) { if (y + Math.round((amplitude * (Math.sin((x + cubeX) / 8.0 + (z + cubeZ) / 21.0) + Math.cos((z + cubeZ) / 13.0))) - / 2.0) <= CubicChunks.SUPERFLAT_HEIGHT) { + / 2.0) <= CubicChunks.SUPERFLAT_HEIGHT) { cube.setBlockState(blockPos.set(x, y, z), blockState); } } @@ -104,44 +117,56 @@ public static CompletableFuture generateNoise( return CompletableFuture.completedFuture(cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSurface( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateCarvers( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateFeatures( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture initializeLight( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture light( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, + method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSpawn( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } @@ -149,12 +174,15 @@ public static CompletableFuture generateSpawn( // Upgrade ProtoCube to LevelCube // dasm + mixin @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), + value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static native CompletableFuture full( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ); @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), + value = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") private static native void postLoadProtoCube(ServerLevel level, ValueInput.ValueInputList entityTags); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java index c695e368..62801cfc 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -25,25 +23,23 @@ import net.minecraft.world.level.chunk.status.WorldGenContext; /** - * {@link ChunkStep} represents a single step in either chunk loading or chunk generation. - * This class represents a single step in cube loading or generation. It is identical to {@code ChunkStep}, but stores a {@link CubeStatusTask} - * instead of a {@link ChunkStatusTask}. - * - * @param targetStatus The status that this step corresponds to. - * @param directDependencies The dependencies of this individual step, by radius. - * Always includes the parent status at radius zero (except for EMPTY, which has no parent), and may have additional - * dependencies. - * @param accumulatedDependencies All dependencies needed to reach this step from unloaded, by radius. - * Effectively a combination of the directDependencies of this step and all previous steps. - * @param blockStateWriteRadius The radius of chunks that can receive blockstate writes. 0 if only the center chunk can; -1 if there are no - * blockstate writes. Always -1 for chunk loading. - * @param task The chunk loading or generation task for this step. + * {@link ChunkStep} represents a single step in either chunk loading or chunk generation. This class represents a single step in cube loading or + * generation. It is identical to {@code ChunkStep}, but stores a {@link CubeStatusTask} instead of a {@link ChunkStatusTask}. + * + * @param targetStatus The status that this step corresponds to. + * @param directDependencies The dependencies of this individual step, by radius. Always includes the parent status at radius zero (except for + * EMPTY, which has no parent), and may have additional dependencies. + * @param accumulatedDependencies All dependencies needed to reach this step from unloaded, by radius. Effectively a combination of the + * directDependencies of this step and all previous steps. + * @param blockStateWriteRadius The radius of chunks that can receive blockstate writes. 0 if only the center chunk can; -1 if there are no + * blockstate writes. Always -1 for chunk loading. + * @param task The chunk loading or generation task for this step. */ @Dasm(ChunkToCubeSet.class) @TransformFromClass(sets = ChunkToCubeSet.class, value = @Ref(ChunkStep.class)) public record CubeStep( - ChunkStatus targetStatus, ChunkDependencies directDependencies, ChunkDependencies accumulatedDependencies, int blockStateWriteRadius, - CubeStatusTask task + ChunkStatus targetStatus, ChunkDependencies directDependencies, ChunkDependencies accumulatedDependencies, int blockStateWriteRadius, + CubeStatusTask task ) { public int getAccumulatedRadiusOf(ChunkStatus status) { throw new DasmFailedToApply(); @@ -56,19 +52,22 @@ public CompletableFuture apply(WorldGenContext worldGenContext, Stat @Dasm(ChunkToCubeSet.class) public static class Builder { private final ChunkStatus status; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = @FieldSig(type = @Ref(CubeStep.class), name = "parent")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, + field = "parent:Lio/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep;") private final @Nullable CubeStep parent; private ChunkStatus[] directDependenciesByRadius; private int blockStateWriteRadius = -1; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = @FieldSig(type = @Ref(ChunkStatusTask.class), name = "task")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, + field = "task:Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;") private CubeStatusTask task = (worldGenContext, step, cache, cube) -> CompletableFuture.completedFuture(cube); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") protected Builder(ChunkStatus status) { throw new DasmFailedToApply(); } - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/status/ChunkStep;)V")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), + value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/status/ChunkStep;)V") protected Builder(ChunkStatus status, CubeStep parent) { throw new DasmFailedToApply(); } @@ -99,16 +98,19 @@ public CubeStep.Builder blockStateWriteRadius(int blockStateWriteRadiusInSection return this; } - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("setTask(Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;)Lnet/minecraft/world/level/chunk/status/ChunkStep$Builder;")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), + value = "setTask(Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;)Lnet/minecraft/world/level/chunk/status/ChunkStep$Builder;") public native CubeStep.Builder setTask(CubeStatusTask task); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("build()Lnet/minecraft/world/level/chunk/status/ChunkStep;")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "build()Lnet/minecraft/world/level/chunk/status/ChunkStep;") public native CubeStep build(); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("buildAccumulatedDependencies()[Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), + value = "buildAccumulatedDependencies()[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") private native ChunkStatus[] buildAccumulatedDependencies(); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("getRadiusOfParent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), + value = "getRadiusOfParent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") private native int getRadiusOfParent(ChunkStatus parentStatus); } } From d6ae81b83e77b9f0f1e586610fe7747693b5c245 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Wed, 10 Dec 2025 03:54:56 +0000 Subject: [PATCH 2/4] Fix dasm issues after upgrading to 3.1.0 --- .../client/multiplayer/ClientCubeCache.java | 17 ++- .../multiplayer/MixinClientChunkCache.java | 9 +- .../renderer/MixinSectionOcclusionGraph.java | 14 +- .../renderer/chunk/MixinSectionCopy.java | 4 +- .../MixinGenerationChunkHolder_Forge.java | 3 +- .../level/MixinChunkGenerationTask.java | 24 ++-- .../common/server/level/MixinChunkHolder.java | 35 ++--- .../level/MixinChunkMap$TrackedEntity.java | 3 +- .../common/server/level/MixinChunkMap.java | 92 +++++-------- .../level/MixinChunkTaskDispatcher.java | 3 +- .../level/MixinGenerationChunkHolder.java | 32 ++--- .../server/level/MixinServerChunkCache.java | 79 +++++------ .../common/server/level/MixinServerLevel.java | 16 +-- .../server/level/MixinServerPlayer.java | 3 +- .../MixinProcessorChunkProgressListener.java | 3 +- .../MixinStoringChunkProgressListener.java | 2 +- .../network/MixinPlayerChunkSender.java | 9 +- .../core/common/world/entity/MixinEntity.java | 6 +- .../core/common/world/level/MixinLevel.java | 72 ++++------ .../world/level/MixinTicketStorage.java | 12 +- .../chunk/storage/MixinChunkStorage.java | 6 +- .../mixin/dasmsets/ChunkToCloSet.java | 113 ++++++---------- .../mixin/dasmsets/ChunkToCubeSet.java | 126 ++++++------------ .../cubicchunks/mixin/dasmsets/GlobalSet.java | 29 ++-- .../CCCommonHooks.java | 9 +- .../CCEventHooks.java | 17 +-- .../server/level/CloTrackingView.java | 40 +++--- .../cubicchunks/server/level/CubeLevel.java | 15 +-- .../chunk/status/CCChunkStatusTasks.java | 71 ++++------ .../world/level/cube/CubeAccess.java | 39 ++---- .../world/level/cube/ImposterProtoCube.java | 3 +- .../world/level/cube/LevelCube.java | 71 ++++------ .../world/level/cube/ProtoCube.java | 32 ++--- .../world/level/cube/status/CubePyramid.java | 11 +- .../level/cube/status/CubeStatusTasks.java | 73 ++++------ .../world/level/cube/status/CubeStep.java | 36 +++-- 36 files changed, 431 insertions(+), 698 deletions(-) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java index 95451f31..37c7588e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java @@ -35,8 +35,8 @@ public interface ClientCubeCache extends CubeSource { void cc_replaceBiomes(int x, int y, int z, FriendlyByteBuf buffer); @Nullable LevelCube cc_replaceWithPacketData( - int x, int y, int z, FriendlyByteBuf buffer, Map map, - Consumer consumer + int x, int y, int z, FriendlyByteBuf buffer, Map map, + Consumer consumer ); void cc_updateViewCenter(int x, int y, int z); @@ -67,7 +67,7 @@ public Storage(int chunkRadius, ClientLevel clientLevel) { public int getIndex(int x, int y, int z) { return Math.floorMod(z, this.viewRange) * this.viewRange * this.viewRange + Math.floorMod(y, this.viewRange) * this.viewRange - + Math.floorMod(x, this.viewRange); + + Math.floorMod(x, this.viewRange); } public void replace(int chunkIndex, @Nullable LevelCube chunk) { @@ -110,7 +110,7 @@ public void dropEmptySections(LevelCube chunk) { for (int dy = 0; dy < CubicConstants.DIAMETER_IN_SECTIONS; dy++) { for (int dz = 0; dz < CubicConstants.DIAMETER_IN_SECTIONS; dz++) { long sectionPosLong = SectionPos.asLong(Coords.cubeToSection(cubePos.getX(), dx), Coords.cubeToSection(cubePos.getY(), dy), - Coords.cubeToSection(cubePos.getZ(), dz)); + Coords.cubeToSection(cubePos.getZ(), dz)); this.loadedEmptySections.remove(sectionPosLong); } } @@ -126,7 +126,7 @@ public void addEmptySections(LevelCube chunk) { for (int dz = 0; dz < CubicConstants.DIAMETER_IN_SECTIONS; dz++) { var chunkSection = chunkSections[Coords.sectionToIndex(dx, dy, dz)]; long sectionPosLong = SectionPos.asLong(Coords.cubeToSection(cubePos.getX(), dx), Coords.cubeToSection(cubePos.getY(), dy), - Coords.cubeToSection(cubePos.getZ(), dz)); + Coords.cubeToSection(cubePos.getZ(), dz)); if (chunkSection.hasOnlyAir()) { this.loadedEmptySections.add(sectionPosLong); } @@ -144,7 +144,7 @@ public void refreshEmptySections(LevelCube chunk) { for (int dz = 0; dz < CubicConstants.DIAMETER_IN_SECTIONS; dz++) { var chunkSection = chunkSections[Coords.sectionToIndex(dx, dy, dz)]; long sectionPosLong = SectionPos.asLong(Coords.cubeToSection(cubePos.getX(), dx), Coords.cubeToSection(cubePos.getY(), dy), - Coords.cubeToSection(cubePos.getZ(), dz)); + Coords.cubeToSection(cubePos.getZ(), dz)); if (chunkSection.hasOnlyAir()) { this.loadedEmptySections.add(sectionPosLong); } else if (this.loadedEmptySections.remove(sectionPosLong)) { @@ -157,11 +157,10 @@ public void refreshEmptySections(LevelCube chunk) { public boolean inRange(int x, int y, int z) { return Math.abs(x - this.viewCenterX) <= this.cubeRadius && Math.abs(y - this.viewCenterY) <= this.cubeRadius - && Math.abs(z - this.viewCenterZ) <= this.cubeRadius; + && Math.abs(z - this.viewCenterZ) <= this.cubeRadius; } - @TransformFromMethod(owner = @Ref(ClientChunkCache.Storage.class), value = "getChunk(I)Lnet/minecraft/world/level/chunk/LevelChunk;", - visibility = PUBLIC) + @TransformFromMethod(owner = @Ref(ClientChunkCache.Storage.class), value = "getChunk(I)Lnet/minecraft/world/level/chunk/LevelChunk;", visibility = PUBLIC) public native @Nullable LevelCube getChunk(int chunkIndex); public void dumpChunks(String filePath) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java index 4cc4ae2b..8877dfc4 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java @@ -43,8 +43,7 @@ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ClientChunkCache.class)) @Mixin(ClientChunkCache.class) public abstract class MixinClientChunkCache extends MixinChunkSource implements ClientCubeCache { - @AddFieldToSets(containers = ChunkToCubeSet.ClientChunkCache_redirects.class, - field = "storage:Lnet/minecraft/client/multiplayer/ClientChunkCache$Storage;") + @AddFieldToSets(containers = ChunkToCubeSet.ClientChunkCache_redirects.class, field = "storage:Lnet/minecraft/client/multiplayer/ClientChunkCache$Storage;") volatile ClientCubeCache.Storage cc_cubeStorage; private LevelCube cc_emptyCube; @@ -58,7 +57,7 @@ public abstract class MixinClientChunkCache extends MixinChunkSource implements private void cc_onConstruct(ClientLevel level, int viewDistance, CallbackInfo ci) { if (((CanBeCubic) level).cc_isCubic()) { cc_emptyCube = new EmptyLevelCube(level, CubePos.of(0, 0, 0), - level.registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS)); + level.registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS)); cc_cubeStorage = new ClientCubeCache.Storage(calculateStorageRange(viewDistance), level); // TODO we could redirect the initial construction instead of immediately resizing. doesn't really matter updateViewRadius(cc_calculateChunkViewDistance(viewDistance)); @@ -116,8 +115,8 @@ private static boolean cc_isValidCube(@Nullable LevelCube chunk, int x, int y, i } @Override public @Nullable LevelCube cc_replaceWithPacketData( - int x, int y, int z, FriendlyByteBuf buffer, Map map, - Consumer consumer + int x, int y, int z, FriendlyByteBuf buffer, Map map, + Consumer consumer ) { if (!this.cc_cubeStorage.inRange(x, y, z)) { LOGGER.warn("Ignoring cube since it's not in the view range: {}, {}, {}", x, y, z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java index 829b55d9..e4506ab8 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java @@ -45,8 +45,7 @@ private void cc_onWaitAndReset(@Nullable ViewArea viewArea, CallbackInfo ci) { @TransformFromMethod("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_onCubeReadyToRender(CubePos cubePos); - @AddMethodToSets(containers = ChunkToCubeSet.SectionOcclusionGraph_redirects.class, - method = "addNeighbors(Lnet/minecraft/client/renderer/SectionOcclusionGraph$GraphEvents;Lnet/minecraft/world/level/ChunkPos;)V") + @AddMethodToSets(containers = ChunkToCubeSet.SectionOcclusionGraph_redirects.class, method = "addNeighbors(Lnet/minecraft/client/renderer/SectionOcclusionGraph$GraphEvents;Lnet/minecraft/world/level/ChunkPos;)V") private void cc_addNeighbors(SectionOcclusionGraph.GraphEvents graphEvents, CubePos cubePos) { var access = ((SectionOcclusionGraph$GraphEventsAccess) (Object) graphEvents); int cubeX = cubePos.getX(); @@ -64,11 +63,10 @@ private void cc_addNeighbors(SectionOcclusionGraph.GraphEvents graphEvents, Cube } } - @WrapOperation(method = "initializeQueueForFullUpdate", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/renderer/ViewArea;getRenderSection(J)" + @WrapOperation(method = "initializeQueueForFullUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ViewArea;getRenderSection(J)" + "Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection;")) private @Nullable SectionRenderDispatcher.RenderSection cc_onInitializeQueueForFullUpdate_getRenderSectionAt( - ViewArea instance, long sectionPos, Operation original + ViewArea instance, long sectionPos, Operation original ) { var result = original.call(instance, sectionPos); if (result == null && cc_isCubic) { @@ -97,13 +95,13 @@ private void cc_onIsInViewDistance(long originSectionPosLong, long sectionPosLon int posCubeY = Coords.blockToCube(SectionPos.y(sectionPosLong)); int posCubeZ = Coords.blockToCube(SectionPos.z(sectionPosLong)); cir.setReturnValue(CloTrackingView.cc_isInViewDistance(originCubeX, originCubeY, originCubeZ, - Coords.sectionToCubeRenderDistance(this.viewArea.getViewDistance()), posCubeX, posCubeY, posCubeZ)); + Coords.sectionToCubeRenderDistance(this.viewArea.getViewDistance()), posCubeX, posCubeY, posCubeZ)); } @Inject(method = "getRelativeFrom", at = @At("HEAD"), cancellable = true) private void cc_onGetRelativeFrom( - long sectionPosLong, SectionRenderDispatcher.RenderSection section, Direction direction, - CallbackInfoReturnable cir + long sectionPosLong, SectionRenderDispatcher.RenderSection section, Direction direction, + CallbackInfoReturnable cir ) { if (!cc_isCubic) { return; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java index 372fef90..71a3cf5e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java @@ -20,8 +20,8 @@ @Mixin(SectionCopy.class) public class MixinSectionCopy { // TODO is this field on the vanilla class actually used anywhere? based on snowblower output not having it, it seems like neoforge is adding it? - @AddFieldToSets(containers = ChunkToCubeSet.SectionCopy_redirects.class, - field = "wrapped:Lnet/minecraft/world/level/chunk/LevelChunk;") final LevelCube cc_wrapped; + @AddFieldToSets(containers = ChunkToCubeSet.SectionCopy_redirects.class, field = "wrapped:Lnet/minecraft/world/level/chunk/LevelChunk;") + final LevelCube cc_wrapped; @AddTransformToSets(ChunkToCubeSet.SectionCopy_redirects.class) @TransformFromMethod("(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java index aa53abf2..db420547 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java @@ -20,8 +20,7 @@ public class MixinGenerationChunkHolder_Forge { @Shadow public LevelChunk currentlyLoading; // Corresponds to field added by Forge - @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_Forge_Jank_redirects.class, - field = "currentlyLoading:Lnet/minecraft/world/level/chunk/LevelChunk;") + @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_Forge_Jank_redirects.class, field = "currentlyLoading:Lnet/minecraft/world/level/chunk/LevelChunk;") public LevelCube cc_currentlyLoadingCube; public LevelClo cc_getCurrentlyLoading() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java index 8ea52bce..213138db 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java @@ -77,8 +77,7 @@ private GeneratingCubeMap cc_getGeneratingCubeMap() { /** * Factory method to create a {@code ChunkGenerationTask} for a cube. */ - @AddMethodToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, - method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;") @Public private static ChunkGenerationTask cc_createCubeGenerationTask(GeneratingChunkMap chunkMap, ChunkStatus targetStatus, CubePos pos) { int cubeRadius = CubePyramid.CC_GENERATION_PYRAMID_CUBES.getStepTo(targetStatus).getAccumulatedRadiusOf(ChunkStatus.EMPTY); @@ -87,17 +86,16 @@ private GeneratingCubeMap cc_getGeneratingCubeMap() { // We directly use the StaticCache2D constructor, as the `create` factory method only allows for odd dimensions, and `chunkDiameter` is even // (for cube sizes greater than 16) StaticCache2D staticcache2d = new StaticCache2D<>(Coords.cubeToSection(pos.getX() - cubeRadius, 0), - Coords.cubeToSection(pos.getZ() - cubeRadius, 0), chunkDiameter, chunkDiameter, - (x, z) -> chunkMap.acquireGeneration(ChunkPos.asLong(x, z))); + Coords.cubeToSection(pos.getZ() - cubeRadius, 0), chunkDiameter, chunkDiameter, + (x, z) -> chunkMap.acquireGeneration(ChunkPos.asLong(x, z))); var chunkGenerationTask = new ChunkGenerationTask(chunkMap, targetStatus, null, staticcache2d); ((MixinChunkGenerationTask) (Object) chunkGenerationTask).cc_cubePos = pos; ((MixinChunkGenerationTask) (Object) chunkGenerationTask).cc_cubeCache = StaticCache3D.create(pos.getX(), pos.getY(), pos.getZ(), cubeRadius, - (x, y, z) -> chunkMap.acquireGeneration(CubePos.asLong(x, y, z))); + (x, y, z) -> chunkMap.acquireGeneration(CubePos.asLong(x, y, z))); return chunkGenerationTask; } - @AddMethodToSets(containers = ChunkToCloSet.ChunkGenerationTask_redirects.class, - method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + @AddMethodToSets(containers = ChunkToCloSet.ChunkGenerationTask_redirects.class, method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;") @Public private static ChunkGenerationTask cc_createCubeGenerationTask(GeneratingChunkMap chunkMap, ChunkStatus targetStatus, CloPos pos) { if (pos.isCube()) { @@ -175,7 +173,7 @@ private void cc_onCanLoadWithoutGeneration(CallbackInfoReturnable cir) cir.setReturnValue(true); } else { ChunkStatus currentCubeStatus = this.cc_cubeCache.get(this.cc_cubePos.getX(), this.cc_cubePos.getY(), this.cc_cubePos.getZ()) - .getPersistedStatus(); + .getPersistedStatus(); if (currentCubeStatus != null && !currentCubeStatus.isBefore(this.targetStatus)) { ChunkDependencies cubeDependencies = CubePyramid.CC_LOADING_PYRAMID_CUBES.getStepTo(this.targetStatus).accumulatedDependencies(); int cubeRadius = cubeDependencies.getRadius(); @@ -230,7 +228,7 @@ private void cc_onGetCenter(CallbackInfoReturnable cir) { private void cc_scheduleLayer(@Nullable ChunkStatus chunkStatus, @Nullable ChunkStatus cubeStatus, boolean needsGeneration) { try (Zone zone = Profiler.get().zone("scheduleLayer")) { zone.addText(() -> String.format("Chunk: %s, Cube: %s", chunkStatus == null ? "null" : chunkStatus.getName(), - cubeStatus == null ? "null" : cubeStatus.getName())); + cubeStatus == null ? "null" : cubeStatus.getName())); if (cubeStatus != null) { int cubeRadius = this.cc_getCubeRadiusForLayer(cubeStatus, needsGeneration); for (int cubeX = this.cc_cubePos.getX() - cubeRadius; cubeX <= this.cc_cubePos.getX() + cubeRadius; cubeX++) { @@ -272,8 +270,7 @@ private void cc_onScheduleLayer(ChunkStatus status, boolean needsGeneration, Cal throw new IllegalStateException("shouldn't call vanilla scheduleLayer for cube generation task"); } - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), - value = "getRadiusForLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Z)I") + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = "getRadiusForLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Z)I") private native int cc_getCubeRadiusForLayer(ChunkStatus status, boolean needsGeneration); @Shadow protected abstract boolean scheduleChunkInLayer(ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk); @@ -288,14 +285,13 @@ private void cc_onScheduleLayer(ChunkStatus status, boolean needsGeneration, Cal @Inject(method = "scheduleChunkInLayer", at = @At("HEAD"), cancellable = true) private void cc_onScheduleChunkInLayer( - ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk, CallbackInfoReturnable cir + ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk, CallbackInfoReturnable cir ) { if (((GenerationCloHolder) chunk).cc_getCubePos() != null) { cir.setReturnValue(cc_scheduleCubeInLayer(status, needsGeneration, chunk)); } } - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), - value = "scheduleChunkInLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;ZLnet/minecraft/server/level/GenerationChunkHolder;)Z") + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = "scheduleChunkInLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;ZLnet/minecraft/server/level/GenerationChunkHolder;)Z") private native boolean cc_scheduleCubeInLayer(ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java index 594cb975..4a8fb6ef 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java @@ -54,17 +54,14 @@ public abstract class MixinChunkHolder extends MixinGenerationChunkHolder implem @Shadow private boolean hasChangedSections; @Shadow @Final private ShortSet[] changedBlocksPerSection; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, - field = "onLevelChange:Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;") + @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = "onLevelChange:Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;") private final LevelChangeListener cc_onLevelChange; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, - field = "playerProvider:Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;") + @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = "playerProvider:Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;") private final PlayerProvider cc_playerProvider; @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), - value = "(Lnet/minecraft/world/level/ChunkPos;ILnet/minecraft/world/level/LevelHeightAccessor;" + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "(Lnet/minecraft/world/level/ChunkPos;ILnet/minecraft/world/level/LevelHeightAccessor;" + "Lnet/minecraft/world/level/lighting/LevelLightEngine;Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;" + "Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V") public MixinChunkHolder() { @@ -111,8 +108,7 @@ public void cc_onBlockChanged(BlockPos pos, CallbackInfoReturnable cir) @TransformFromMethod("blockChanged(Lnet/minecraft/core/BlockPos;)Z") private native boolean cc_blockChanged(BlockPos pos); - @Dynamic @Redirect(method = "cc_dasm$cc_blockChanged", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_dasm$cc_blockChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) private int cc_onBlockChanged_sectionIndex(LevelHeightAccessor instance, int y, BlockPos pos) { return Coords.sectionToIndex(Coords.blockToSection(pos.getX()), Coords.blockToSection(pos.getY()), Coords.blockToSection(pos.getZ())); } @@ -134,8 +130,7 @@ public void cc_onSectionLightChanged(LightLayer lightLayer, int sectionY, Callba // TODO (P2) lighting - ClientboundLightUpdatePacket branch is currently never reached; once we have lighting it will have to be a CC packet, and // this.broadcast will need to redirect to a CC method - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instance, int sectionIndex) { // The vanilla method uses SectionPos.of(ChunkPos, sectionY), but we want SectionPos.of(CubePos, sectionIndex). // The easiest way to accomplish this is to turn `getSectionYFromSectionIndex` into a no-op so that we get sectionIndex instead of sectionY. @@ -143,15 +138,13 @@ private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instan return sectionIndex; } - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", - target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) + @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) private SectionPos cc_onBroadcastCubeChanges_sectionPos(CubePos cubePos, int sectionIndex) { return Coords.sectionPosByIndex(cubePos, sectionIndex); } // endregion - @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, - method = "broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V") + @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = "broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public void cc_broadcastCloChanges(LevelClo clo) { if (cc_cubePos != null) { cc_broadcastCubeChanges((LevelCube) clo); @@ -161,11 +154,10 @@ public void cc_broadcastCloChanges(LevelClo clo) { } @WrapOperation(method = { "lambda$scheduleFullChunkPromotion$4", - "demoteFullChunk" }, at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;" - + "Lnet/minecraft/server/level/FullChunkStatus;)V")) + "demoteFullChunk" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;" + + "Lnet/minecraft/server/level/FullChunkStatus;)V")) private void cc_onCallChunkMapOnFullChunkStatusChange( - ChunkMap instance, ChunkPos chunkPos, FullChunkStatus fullChunkStatus, Operation original + ChunkMap instance, ChunkPos chunkPos, FullChunkStatus fullChunkStatus, Operation original ) { if (cc_cubePos != null) { ((CubicChunkMap) instance).cc_onFullChunkStatusChange(cc_cubePos, fullChunkStatus); @@ -174,12 +166,11 @@ private void cc_onCallChunkMapOnFullChunkStatusChange( } } - @WrapOperation(method = "updateFutures", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;onLevelChange(Lnet/minecraft/world/level/ChunkPos;" + @WrapOperation(method = "updateFutures", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;onLevelChange(Lnet/minecraft/world/level/ChunkPos;" + "Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) protected void cc_onUpdateFutures_onCallOnLevelChange( - ChunkHolder.LevelChangeListener instance, ChunkPos chunkPos, IntSupplier intSupplier, int i, IntConsumer intConsumer, - Operation original + ChunkHolder.LevelChangeListener instance, ChunkPos chunkPos, IntSupplier intSupplier, int i, IntConsumer intConsumer, + Operation original ) { if (cc_cubePos != null) { cc_onLevelChange.cc_onLevelChange(cc_cubePos, intSupplier, i, intConsumer); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java index 9bd096bb..6b18d840 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java @@ -25,8 +25,7 @@ public abstract class MixinChunkMap$TrackedEntity { @TransformFromMethod("updatePlayer(Lnet/minecraft/server/level/ServerPlayer;)V") public native void cc_updatePlayer(ServerPlayer player); - @Dynamic @Redirect(method = "cc_dasm$cc_updatePlayer", - at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_dasm$cc_updatePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_updatePlayer_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z) { // FIXME entity clo position once implemented return false; // ((CubicChunkMap) instance).cc_isChunkTracked(player, this.entity.chunkPosition().x, 0, this.entity.chunkPosition().z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java index 43de1168..20bb039e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java @@ -111,20 +111,18 @@ public abstract class MixinChunkMap extends MixinChunkStorage implements Generat } // TODO this one being on GlobalSet is a bit jank - @AddFieldToSets(containers = GlobalSet.ChunkMap_redirects.class, - field = "progressListener:Lnet/minecraft/server/level/progress/ChunkProgressListener;") + @AddFieldToSets(containers = GlobalSet.ChunkMap_redirects.class, field = "progressListener:Lnet/minecraft/server/level/progress/ChunkProgressListener;") private CloProgressListener cc_progressListener; - @AddFieldToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, - field = "chunkStatusListener:Lnet/minecraft/world/level/entity/ChunkStatusUpdateListener;") + @AddFieldToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, field = "chunkStatusListener:Lnet/minecraft/world/level/entity/ChunkStatusUpdateListener;") private CloStatusUpdateListener cc_cloStatusListener; // TODO once we can target non-return locations in constructors, do this when the vanilla field is set @Inject(method = "", at = @At("RETURN")) private void cc_onInit( - ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, - StructureTemplateManager structureManager, Executor dispatcher, BlockableEventLoop mainThreadExecutor, LightChunkGetter lightChunk, - ChunkGenerator generator, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, - Supplier overworldDataStorage, TicketStorage ticketStorage, int serverViewDistance, boolean sync, CallbackInfo ci + ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, + StructureTemplateManager structureManager, Executor dispatcher, BlockableEventLoop mainThreadExecutor, LightChunkGetter lightChunk, + ChunkGenerator generator, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, + Supplier overworldDataStorage, TicketStorage ticketStorage, int serverViewDistance, boolean sync, CallbackInfo ci ) { if (((CanBeCubic) level).cc_isCubic()) { cc_progressListener = ((CloProgressListener) progressListener); @@ -142,8 +140,7 @@ private void cc_onInit( /** * Returns the squared distance to the center of the cube. */ - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, - method = "euclideanDistanceSquared(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/phys/Vec3;)D") + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = "euclideanDistanceSquared(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/phys/Vec3;)D") private static double cc_euclideanDistanceSquared(CloPos cloPos, Vec3 vec3) { if (cloPos.isChunk()) { // FIXME we shouldn't be getting euclidean distance for chunks, as this doesn't make sense in context @@ -164,8 +161,8 @@ private static double cc_euclideanDistanceSquared(CloPos cloPos, Vec3 vec3) { // These methods are not copied due to taking 3 ints instead of 2 @Override public boolean cc_isChunkTracked(ServerPlayer player, int x, int y, int z) { return ((CCServerPlayer) player).cc_getCloTrackingView().cc_contains(x, y, z) - // TODO this requires PlayerChunkSender to accept Clo longs - && !player.connection.chunkSender.isPending(CloPos.cubeAsLong(x, y, z)); + // TODO this requires PlayerChunkSender to accept Clo longs + && !player.connection.chunkSender.isPending(CloPos.cubeAsLong(x, y, z)); } private boolean cc_isChunkOnTrackedBorder(ServerPlayer player, int x, int y, int z) { @@ -187,10 +184,9 @@ private boolean cc_isChunkOnTrackedBorder(ServerPlayer player, int x, int y, int // region [cc_getChunkRangeFuture dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod( - "getChunkRangeFuture(Lnet/minecraft/server/level/ChunkHolder;ILjava/util/function/IntFunction;)Ljava/util/concurrent/CompletableFuture;") + @TransformFromMethod("getChunkRangeFuture(Lnet/minecraft/server/level/ChunkHolder;ILjava/util/function/IntFunction;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture>> cc_getChunkRangeFuture( - ChunkHolder cloHolder, int radius, IntFunction statusByRadius + ChunkHolder cloHolder, int radius, IntFunction statusByRadius ); // TODO this could be substantially improved probably hopefully @@ -201,8 +197,8 @@ private native CompletableFuture>> cc_getChunkRangeF @SuppressWarnings("checkstyle:CyclomaticComplexity") // <-- TODO this method is just a bit of a disaster @Dynamic @Inject(method = "cc_dasm$cc_getChunkRangeFuture", at = @At("HEAD"), cancellable = true) private void cc_onGetChunkRangeFuture( - ChunkHolder cloHolder, int radius, IntFunction statusByRadius, - CallbackInfoReturnable>>> cir + ChunkHolder cloHolder, int radius, IntFunction statusByRadius, + CallbackInfoReturnable>>> cir ) { // Note that statusByRadius sometimes isn't actually correct for cubes beyond the first few steps, but getChunkRangeFuture is only called with // parameters for which it's correct within the radius @@ -225,14 +221,14 @@ private void cc_onGetChunkRangeFuture( for (int sectionZ = 0; sectionZ < CubicConstants.DIAMETER_IN_SECTIONS; sectionZ++) { for (int sectionX = 0; sectionX < CubicConstants.DIAMETER_IN_SECTIONS; sectionX++) { ChunkHolder holder = this.getUpdatingChunkIfPresent( - CloPos.chunkAsLong(Coords.cubeToSection(pos.getX() + dx, sectionX), Coords.cubeToSection(pos.getZ() + dz, sectionZ))); + CloPos.chunkAsLong(Coords.cubeToSection(pos.getX() + dx, sectionX), Coords.cubeToSection(pos.getZ() + dz, sectionZ))); if (holder == null) { cir.setReturnValue(UNLOADED_CHUNK_LIST_FUTURE); return; } ChunkStatus expectedStatus = statusByRadius.apply(chunkDistance); futures.add((CompletableFuture>) (Object) holder.scheduleChunkGenerationTask(expectedStatus, - (ChunkMap) (Object) this)); + (ChunkMap) (Object) this)); } } for (int dy = -radius; dy <= radius; dy++) { @@ -246,7 +242,7 @@ private void cc_onGetChunkRangeFuture( } ChunkStatus expectedStatus = statusByRadius.apply(Math.max(chunkDistance, Math.abs(dy))); futures.add((CompletableFuture>) (Object) holder.scheduleChunkGenerationTask(expectedStatus, - (ChunkMap) (Object) this)); + (ChunkMap) (Object) this)); } } } @@ -262,7 +258,7 @@ private void cc_onGetChunkRangeFuture( for (final ChunkResult chunkResult : resultList) { if (chunkResult == null) { throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), - "n/a"); + "n/a"); } CloAccess cloAccess = chunkResult.orElse(null); @@ -280,8 +276,7 @@ private void cc_onGetChunkRangeFuture( // region [cc_updateCubeScheduling dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkMap_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, - value = "updateChunkScheduling(JILnet/minecraft/server/level/ChunkHolder;I)Lnet/minecraft/server/level/ChunkHolder;") + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = "updateChunkScheduling(JILnet/minecraft/server/level/ChunkHolder;I)Lnet/minecraft/server/level/ChunkHolder;") public native @Nullable ChunkHolder cc_updateCubeScheduling(long cubePos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); @Inject(method = "updateChunkScheduling", at = @At("HEAD"), cancellable = true) @@ -296,8 +291,7 @@ private void cc_onUpdateChunkScheduling(long cloPos, int newLevel, ChunkHolder h @TransformFromMethod("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") private native void cc_onLevelChange(CloPos cloPos, IntSupplier intsupplier, int i, IntConsumer intconsumer); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, - method = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") public void cc_onCubeLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter) { cc_onLevelChange(CloPos.cube(cubePos), queueLevelGetter, ticketLevel, queueLevelSetter); } @@ -328,14 +322,12 @@ private void cc_scheduleUnload(long chunkPos, ChunkHolder chunkHolder) { @TransformFromMethod("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture cc_scheduleChunkLoad(CloPos cloPos); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, - method = "scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private CompletableFuture cc_scheduleChunkLoad(CubePos cubePos) { return cc_scheduleChunkLoad(CloPos.cube(cubePos)); } - @Dynamic @Redirect(method = "cc_dasm$cc_scheduleChunkLoad", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)" + @Dynamic @Redirect(method = "cc_dasm$cc_scheduleChunkLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)" + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManager instance, CloPos cloPos) { // TODO (P2) save/load - PoiManager @@ -344,8 +336,7 @@ private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManage // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod( - "handleChunkLoadFailure(Ljava/lang/Throwable;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;") + @TransformFromMethod("handleChunkLoadFailure(Ljava/lang/Throwable;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;") private native ChunkResult cc_handleChunkLoadFailure(Throwable exception, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) @@ -362,28 +353,24 @@ private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManage // region [cc_applyCubeStep dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkMap_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, - value = "applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = "applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture cc_applyCubeStep( - GenerationChunkHolder generationchunkholder, CubeStep chunkstep, StaticCache3D cache + GenerationChunkHolder generationchunkholder, CubeStep chunkstep, StaticCache3D cache ); - @Dynamic @Redirect(method = "cc_dasm$cc_applyCubeStep", - at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) + @Dynamic @Redirect(method = "cc_dasm$cc_applyCubeStep", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) private Object cc_onApplyCubeStep_staticCacheGet(StaticCache3D instance, int x, int z, @Local(ordinal = 0) CubePos cubePos) { return instance.get(cubePos.getX(), cubePos.getY(), cubePos.getZ()); } // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod( - "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + @TransformFromMethod("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + "Lnet/minecraft/server/level/ChunkGenerationTask;") public native ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus chunkstatus, CloPos cloPos); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, - method = "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + "Lnet/minecraft/server/level/ChunkGenerationTask;") public ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus chunkstatus, CubePos cubePos) { return cc_scheduleGenerationTask(chunkstatus, CloPos.cube(cubePos)); @@ -535,8 +522,7 @@ private boolean cc_save(CloAccess cloAccess) { @TransformFromMethod("updateChunkTracking(Lnet/minecraft/server/level/ServerPlayer;)V") private native void cc_updateChunkTracking(ServerPlayer player); - @Dynamic @WrapOperation(method = "cc_dasm$cc_updateChunkTracking", - at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) + @Dynamic @WrapOperation(method = "cc_dasm$cc_updateChunkTracking", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPlayer player, Operation original) { return Coords.sectionToCubeRenderDistance(original.call(instance, player)); } @@ -547,13 +533,12 @@ private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPl @TransformFromMethod("applyChunkTrackingView(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/server/level/ChunkTrackingView;)V") private native void cc_applyChunkTrackingView(ServerPlayer player, CloTrackingView chunkTrackingView); - @Dynamic @Redirect(method = "cc_dasm$cc_applyChunkTrackingView", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) + @Dynamic @Redirect(method = "cc_dasm$cc_applyChunkTrackingView", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( - ServerGamePacketListenerImpl instance, Packet packet, ServerPlayer player, CloTrackingView cloTrackingView + ServerGamePacketListenerImpl instance, Packet packet, ServerPlayer player, CloTrackingView cloTrackingView ) { PacketDistributor.sendToPlayer(player, - new CCClientboundSetCubeCacheCenterPacket(((CloTrackingView.Positioned) cloTrackingView).center().cubePos())); + new CCClientboundSetCubeCacheCenterPacket(((CloTrackingView.Positioned) cloTrackingView).center().cubePos())); } // endregion @@ -562,29 +547,25 @@ private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( @TransformFromMethod("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") public native List cc_getPlayers(CloPos pos, boolean boundaryOnly); - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkOnTrackedBorder(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkOnTrackedBorder(player, pos.getX(), pos.getY(), pos.getZ()); } - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", - at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkTracked(player, pos.getX(), pos.getY(), pos.getZ()); } // endregion - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, - method = "getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") @Override public List cc_getPlayers(CubePos pos, boolean boundaryOnly) { return cc_getPlayers(CloPos.cube(pos), boundaryOnly); } // Replace `SectionPos.chunk()` with `SectionPos.cc_cube()` unconditionally here @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = "tick(Ljava/util/function/BooleanSupplier;)V", useRedirectSets = { ChunkToCloSet.class, - SectionPosToCubeSet.class }) + @TransformFromMethod(value = "tick(Ljava/util/function/BooleanSupplier;)V", useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) protected native void cc_tick(BooleanSupplier hasMoreTime); @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) @@ -601,8 +582,7 @@ private boolean cc_getPlayers_isChunkTracked(ChunkMap instance, ServerPlayer pla @TransformFromMethod("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") public native void cc_onFullChunkStatusChange(CloPos cloPos, FullChunkStatus fullChunkStatus); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, - method = "onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") public void cc_onFullChunkStatusChange(CubePos cubePos, FullChunkStatus fullChunkStatus) { cc_onFullChunkStatusChange(CloPos.cube(cubePos), fullChunkStatus); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java index 6aabd1d7..300a2c08 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java @@ -19,8 +19,7 @@ @Mixin(ChunkTaskDispatcher.class) public class MixinChunkTaskDispatcher implements CubeHolder.LevelChangeListener, CloTaskDispatcher { @AddTransformToSets(ChunkToCloSet.ChunkTaskDispatcher_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkTaskDispatcher.class), - value = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") + @TransformFromMethod(owner = @Ref(ChunkTaskDispatcher.class), value = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") @Override public native void cc_onLevelChange(CloPos cloPos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter); public void cc_onLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java index 8b8aa63a..7d8d6ed6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java @@ -71,15 +71,13 @@ public MixinGenerationChunkHolder() { } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), - value = "applyStep(Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/server/level/GeneratingChunkMap;" + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "applyStep(Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/server/level/GeneratingChunkMap;" + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") native CompletableFuture> cc_applyCubeStep( - CubeStep step, GeneratingChunkMap chunkMap, StaticCache3D cache + CubeStep step, GeneratingChunkMap chunkMap, StaticCache3D cache ); - @WrapOperation(method = "updateHighestAllowedStatus", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ChunkLevel;generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @WrapOperation(method = "updateHighestAllowedStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkLevel;generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) protected @Nullable ChunkStatus cc_onUpdateHighestAllowedStatus_generationStatus(int level, Operation original) { if (cc_cubePos != null) { return CubeLevel.cubeGenerationStatus(level); @@ -88,15 +86,13 @@ native CompletableFuture> cc_applyCubeStep( } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), - value = "replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V") + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V") public native void cc_replaceProtoCube(ImposterProtoCube cube); - @WrapOperation(method = "rescheduleChunkTask", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ChunkMap;scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + @WrapOperation(method = "rescheduleChunkTask", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( - ChunkMap instance, ChunkStatus status, ChunkPos chunkPos, Operation original + ChunkMap instance, ChunkStatus status, ChunkPos chunkPos, Operation original ) { if (cc_cubePos != null) { return ((CubicChunkMap) instance).cc_scheduleGenerationTask(status, cc_cubePos); @@ -105,18 +101,15 @@ private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), - value = "completeFuture(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "completeFuture(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") private native void cc_completeFuture(ChunkStatus targetStatus, CubeAccess cubeAccess); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), - value = "getChunkIfPresentUnchecked(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getChunkIfPresentUnchecked(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getCubeIfPresentUnchecked(ChunkStatus status); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), - value = "getChunkIfPresent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getChunkIfPresent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getCubeIfPresent(ChunkStatus status); @Shadow public abstract @Nullable ChunkAccess getLatestChunk(); @@ -125,8 +118,7 @@ private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getLatestCube(); - @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, - method = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") + @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") public @Nullable CloAccess cc_getLatestClo() { if (cc_cubePos != null) { return cc_getLatestCube(); @@ -139,9 +131,9 @@ private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( public void cc_onGetPersistedStatus(CallbackInfoReturnable cir) { if (cc_cubePos != null) { CompletableFuture> completablefuture = (CompletableFuture>) (Object) this.futures - .get(ChunkStatus.EMPTY.getIndex()); + .get(ChunkStatus.EMPTY.getIndex()); CubeAccess cubeAccess = completablefuture == null ? null - : completablefuture.getNow((ChunkResult) (Object) NOT_DONE_YET).orElse(null); + : completablefuture.getNow((ChunkResult) (Object) NOT_DONE_YET).orElse(null); cir.setReturnValue(cubeAccess == null ? null : cubeAccess.getPersistedStatus()); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java index f6789116..e8a76dbd 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java @@ -77,12 +77,10 @@ public abstract class MixinServerChunkCache extends MixinChunkSource implements @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunkPos:[J") private final long[] cc_lastCubePos = new long[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, - field = "lastChunkStatus:[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunkStatus:[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") private final ChunkStatus[] cc_lastCubeStatus = new ChunkStatus[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, - field = "lastChunk:[Lio/github/opencubicchunks/cubicchunks/world/level/chunklike/CloAccess;") + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunk:[Lnet/minecraft/world/level/chunk/ChunkAccess;") private final CubeAccess[] cc_lastCube = new CubeAccess[CACHE_SIZE]; @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "spawningChunks:Ljava/util/List;") @@ -110,10 +108,10 @@ public abstract class MixinServerChunkCache extends MixinChunkSource implements @Inject(method = "", at = @At("CTOR_HEAD")) private void cc_onInit( - ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, - StructureTemplateManager structureManager, Executor dispatcher, ChunkGenerator generator, int viewDistance, int simulationDistance, - boolean sync, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, Supplier overworldDataStorage, - CallbackInfo ci + ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer fixerUpper, + StructureTemplateManager structureManager, Executor dispatcher, ChunkGenerator generator, int viewDistance, int simulationDistance, + boolean sync, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, Supplier overworldDataStorage, + CallbackInfo ci ) { if (((CanBeCubic) level).cc_isCubic()) { this.cc_setCubic(); @@ -125,36 +123,32 @@ private void cc_onInit( private native void cc_storeInCache(long pChunkPos, CubeAccess pChunk, ChunkStatus pChunkStatus); @TransformFromMethod("getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;") - @Override - public native @Nullable CubeAccess cc_getCube(int chunkX, @AddUnusedParam int chunkY, int chunkZ, ChunkStatus requiredStatus, boolean load); + @Override public native @Nullable CubeAccess cc_getCube(int chunkX, @AddUnusedParam int chunkY, int chunkZ, ChunkStatus requiredStatus, boolean load); // mixin-into-dasm to replace call to getChunk with getCube - @Dynamic @Inject(method = "cc_dasm$cc_getCube", cancellable = true, at = @At(value = "INVOKE", - target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)" + @Dynamic @Inject(method = "cc_dasm$cc_getCube", cancellable = true, at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)" + "Ljava/util/concurrent/CompletableFuture;")) private void cc_getCube_supplyAsync( - int pChunkX, int pChunkY, int pChunkZ, ChunkStatus pRequiredStatus, boolean pLoad, CallbackInfoReturnable cir + int pChunkX, int pChunkY, int pChunkZ, ChunkStatus pRequiredStatus, boolean pLoad, CallbackInfoReturnable cir ) { cir.setReturnValue(CompletableFuture - .supplyAsync(() -> this.cc_getCube(pChunkX, pChunkY, pChunkZ, pRequiredStatus, pLoad), this.mainThreadProcessor).join()); + .supplyAsync(() -> this.cc_getCube(pChunkX, pChunkY, pChunkZ, pRequiredStatus, pLoad), this.mainThreadProcessor).join()); } // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", - at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } // The second through fifth params are the params to the call being redirected; the next three params are the x/y/z coordinates in the params of // getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_getCube_getChunkFutureMainThread( - ServerChunkCache instance, int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load, int chunkXRepeated, int chunkY, - int chunkZRepeated + ServerChunkCache instance, int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load, int chunkXRepeated, int chunkY, + int chunkZRepeated ) { return this.cc_getCubeFutureMainThread(chunkX, chunkY, chunkZ, requiredStatus, load); } @@ -164,8 +158,7 @@ private CompletableFuture cc_getCube_getChunkFutureMainThread( // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCubeNow - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", - at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCubeNow_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } @@ -184,8 +177,7 @@ private void cc_onClearCache(CallbackInfo ci) { } // This method requires enough manual redirects that we just replace it entirely - @Override public CompletableFuture> cc_getCubeFuture(int pX, int chunkY, int pZ, ChunkStatus pChunkStatus, - boolean pLoad) { + @Override public CompletableFuture> cc_getCubeFuture(int pX, int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad) { boolean flag = Thread.currentThread() == this.mainThread; CompletableFuture> completablefuture; if (flag) { @@ -193,8 +185,8 @@ private void cc_onClearCache(CallbackInfo ci) { this.mainThreadProcessor.managedBlock(completablefuture::isDone); } else { completablefuture = CompletableFuture - .supplyAsync(() -> this.cc_getCubeFutureMainThread(pX, chunkY, pZ, pChunkStatus, pLoad), this.mainThreadProcessor) - .thenCompose(future -> future); + .supplyAsync(() -> this.cc_getCubeFutureMainThread(pX, chunkY, pZ, pChunkStatus, pLoad), this.mainThreadProcessor) + .thenCompose(future -> future); } return completablefuture; @@ -202,13 +194,12 @@ private void cc_onClearCache(CallbackInfo ci) { @TransformFromMethod("getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture> cc_getCubeFutureMainThread( - int pX, @AddUnusedParam int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad + int pX, @AddUnusedParam int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_getCubeFutureMainThread - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", - target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } @@ -218,8 +209,7 @@ private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_hasCube - @Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", - target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_hasCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } @@ -265,8 +255,7 @@ private void cc_onVanillaTickChunks(ProfilerFiller profiler, long timeInhabited, } } - @AddMethodToSets(containers = ChunkToCloSet.ServerChunkCache_redirects.class, - method = "tickSpawningChunk(Lnet/minecraft/world/level/chunk/LevelChunk;JLjava/util/List;" + @AddMethodToSets(containers = ChunkToCloSet.ServerChunkCache_redirects.class, method = "tickSpawningChunk(Lnet/minecraft/world/level/chunk/LevelChunk;JLjava/util/List;" + "Lnet/minecraft/world/level/NaturalSpawner$SpawnState;)V") private void cc_tickSpawningClo(LevelClo levelClo, long timeInhabited, List spawnCategories, NaturalSpawner.SpawnState spawnState) { // TODO (P2) @@ -295,25 +284,21 @@ private void cc_onVanillaOnLightUpdate(LightLayer type, SectionPos pos, Callback } } - @Override @AddMethodToSets(containers = GlobalSet.ServerChunkCache_redirects.class, - method = "onLightUpdate(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/SectionPos;)V") + @Override @AddMethodToSets(containers = GlobalSet.ServerChunkCache_redirects.class, method = "onLightUpdate(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/SectionPos;)V") public void cc_onLightUpdate(LightLayer pType, SectionPos pPos) { // TODO (P2) lighting } @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, - value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_addTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, - value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_addTicketWithRadius(TicketType ticket, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, - value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_removeTicketWithRadius(TicketType ticket, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) @@ -321,26 +306,22 @@ public void cc_onLightUpdate(LightLayer pType, SectionPos pPos) { public native boolean cc_updateCloForced(CloPos pPos, boolean pAdd); // Cube-specific methods that delegate to the corresponding Clo methods - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, - method = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public void cc_addTicket(Ticket ticket, CubePos cubePos) { cc_addTicket(ticket, CloPos.cube(cubePos)); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, - method = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public void cc_addTicketWithRadius(TicketType ticket, CubePos cubePos, int radius) { cc_addTicketWithRadius(ticket, CloPos.cube(cubePos), radius); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, - method = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public void cc_removeTicketWithRadius(TicketType ticket, CubePos cubePos, int radius) { cc_removeTicketWithRadius(ticket, CloPos.cube(cubePos), radius); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, - method = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z\"") + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z\"") @Override public boolean cc_updateCubeForced(CubePos cubePos, boolean forced) { return cc_updateCloForced(CloPos.cube(cubePos), forced); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java index a4832fd0..6230b0a3 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java @@ -44,9 +44,9 @@ public abstract class MixinServerLevel extends MixinLevel implements CubicServer @Inject(method = "", at = @At("CTOR_HEAD")) private void cc_onInit( - MinecraftServer server, Executor dispatcher, LevelStorageSource.LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, - ResourceKey dimension, LevelStem levelStem, ChunkProgressListener progressListener, boolean isDebug, long biomeZoomSeed, - List customSpawners, boolean tickTime, RandomSequences randomSequences, CallbackInfo ci + MinecraftServer server, Executor dispatcher, LevelStorageSource.LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, + ResourceKey dimension, LevelStem levelStem, ChunkProgressListener progressListener, boolean isDebug, long biomeZoomSeed, + List customSpawners, boolean tickTime, RandomSequences randomSequences, CallbackInfo ci ) { // TODO conditionally mark as cubic based on dimension, config, level data, etc } @@ -59,11 +59,10 @@ private void cc_onInit( @TransformFromMethod("startTickingChunk(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_startTickingClo(LevelClo chunk); - @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerChunkCache;removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + "Lnet/minecraft/world/level/ChunkPos;I)V")) private void cc_onSetDefaultSpawnPos_removeTicketWithRadius( - ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos + ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos ) { if (cc_isCubic) { ((ServerCubeCache) instance).cc_removeTicketWithRadius(ticket, CloPos.cube(pos), radius); @@ -72,11 +71,10 @@ private void cc_onSetDefaultSpawnPos_removeTicketWithRadius( } } - @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerChunkCache;addTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;addTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + "Lnet/minecraft/world/level/ChunkPos;I)V")) private void cc_onSetDefaultSpawnPos_addicketWithRadius( - ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos + ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos ) { if (cc_isCubic) { ((ServerCubeCache) instance).cc_addTicketWithRadius(ticket, CloPos.cube(pos), radius); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java index bec811c3..8dc6dab6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java @@ -15,8 +15,7 @@ @Dasm(value = ChunkToCloSet.class, target = @Ref(ServerPlayer.class)) @Mixin(ServerPlayer.class) public abstract class MixinServerPlayer extends MixinEntity implements CCServerPlayer { - @AddFieldToSets(containers = ChunkToCloSet.ServerPlayer_redirects.class, - field = "chunkTrackingView:Lnet/minecraft/server/level/ChunkTrackingView;") + @AddFieldToSets(containers = ChunkToCloSet.ServerPlayer_redirects.class, field = "chunkTrackingView:Lnet/minecraft/server/level/ChunkTrackingView;") private CloTrackingView cc_cloTrackingView = CloTrackingView.EMPTY; @AddTransformToSets(ChunkToCloSet.ServerPlayer_redirects.class) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java index 44e62e12..2835613d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java @@ -24,8 +24,7 @@ @Mixin(ProcessorChunkProgressListener.class) public abstract class MixinProcessorChunkProgressListener implements CloProgressListener { // We need a field referencing the delegate as a CloProgressListener, otherwise we end up trying to access a field of the wrong type - @AddFieldToSets(containers = ChunkToCloSet.ProcessorChunkProgressListener_redirects.class, - field = "delegate:Lnet/minecraft/server/level/progress/ChunkProgressListener;") + @AddFieldToSets(containers = ChunkToCloSet.ProcessorChunkProgressListener_redirects.class, field = "delegate:Lnet/minecraft/server/level/progress/ChunkProgressListener;") private CloProgressListener cc_delegate; @Inject(method = "", at = @At("RETURN")) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java index 578689a0..4697a488 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java @@ -41,6 +41,6 @@ public abstract class MixinStoringChunkProgressListener implements CloProgressLi int cubeRadius = Coords.sectionToCubeCeil(radius); var spawnPos = cc_spawnPos != null && cc_spawnPos.isCube() ? cc_spawnPos.cubePos() : CubePos.ZERO; return this.statuses.get( - CubePos.asLong(cubeX + spawnPos.getX() - cubeRadius, cubeY + spawnPos.getY() - cubeRadius, cubeZ + spawnPos.getZ() - cubeRadius)); + CubePos.asLong(cubeX + spawnPos.getX() - cubeRadius, cubeY + spawnPos.getY() - cubeRadius, cubeZ + spawnPos.getZ() - cubeRadius)); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java index 7bbf6b2c..51610ed7 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java @@ -55,8 +55,7 @@ public class MixinPlayerChunkSender { @TransformFromMethod(value = "markChunkPendingToSend(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_markCloPendingToSend(LevelClo clo); - @AddMethodToSets(containers = ChunkToCloSet.PlayerChunkSender_redirects.class, - method = "dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") + @AddMethodToSets(containers = ChunkToCloSet.PlayerChunkSender_redirects.class, method = "dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") public void cc_dropClo(ServerPlayer player, CloPos cloPos) { if (!this.pendingChunks.remove(cloPos.toLong()) && player.isAlive()) { PacketDistributor.sendToPlayer(player, new CCClientboundForgetLevelCloPacket(cloPos)); @@ -142,14 +141,12 @@ private static void cc_sendChunk(ServerGamePacketListenerImpl packetListener, Se private native List cc_collectChunksToSend(ChunkMap chunkMap, CloPos cloPos); // FIXME these should probably have some kind of reasonable sort order - at the very least, chunks before cubes - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", - target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator1(ToIntFunction keyExtractor) { return (a, b) -> 0; } - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", - target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator2(ToIntFunction keyExtractor) { return (a, b) -> 0; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java index 38171857..4ebfe854 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java @@ -58,12 +58,10 @@ public CloPos cc_cubePositionAsClo() { } // Update cube position when blockpos changes - this is the same location as where vanilla updates the chunk position - @Inject(method = "setPosRaw", - at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Entity;blockPosition:Lnet/minecraft/core/BlockPos;", - opcode = Opcodes.PUTFIELD)) + @Inject(method = "setPosRaw", at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Entity;blockPosition:Lnet/minecraft/core/BlockPos;", opcode = Opcodes.PUTFIELD)) private void cc_onSetPosRaw(double x, double y, double z, CallbackInfo ci) { if (Coords.blockToCube(x) != cc_cubePosition.getX() || Coords.blockToCube(y) != cc_cubePosition.getY() - || Coords.blockToCube(z) != cc_cubePosition.getZ()) { + || Coords.blockToCube(z) != cc_cubePosition.getZ()) { this.cc_cubePosition = CubePos.from(this.blockPosition); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java index a12995ac..663d2e33 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java @@ -89,11 +89,10 @@ private void cc_init(CallbackInfo ci) { // setBlock // Uses LevelChunk to call setBlockState and markAndNotifyBlock, so we replace it with a LevelCube and call the Cubic variants of those functions. - @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level" + @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level" + "/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/LevelChunk;")) private LevelChunk cc_replaceLevelChunkInGetChunkAt( - Level level, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + Level level, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.set(this.cc_getCubeAt(blockPos)); @@ -102,12 +101,11 @@ private LevelChunk cc_replaceLevelChunkInGetChunkAt( return original.call(level, blockPos); } - @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/chunk/LevelChunk;setBlockState(Lnet/minecraft/core/BlockPos;" + @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;setBlockState(Lnet/minecraft/core/BlockPos;" + "Lnet/minecraft/world/level/block/state/BlockState;I)Lnet/minecraft/world/level/block/state/BlockState;")) private BlockState cc_replaceLevelChunkInSetBlockState( - LevelChunk levelChunk, BlockPos blockPos, BlockState blockState, int flags, Operation original, - @Share("levelCube") LocalRef levelCubeLocalRef + LevelChunk levelChunk, BlockPos blockPos, BlockState blockState, int flags, Operation original, + @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { return levelCubeLocalRef.get().setBlockState(blockPos, blockState, flags); @@ -115,13 +113,11 @@ private BlockState cc_replaceLevelChunkInSetBlockState( return original.call(levelChunk, blockPos, blockState, flags); } - @WrapWithCondition(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", - at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/Level;markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" - + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) + @WrapWithCondition(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) private boolean cc_replaceLevelChunkInMarkAndNotifyBlock( - Level level, BlockPos blockPos, LevelChunk levelChunk, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft, - @Share("levelCube") LocalRef levelCubeLocalRef + Level level, BlockPos blockPos, LevelChunk levelChunk, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft, + @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { this.cc_markAndNotifyBlock(blockPos, levelCubeLocalRef.get(), blockStatePrev, blockStateNew, flags, recursionLeft); @@ -132,30 +128,27 @@ private boolean cc_replaceLevelChunkInMarkAndNotifyBlock( @AddTransformToSets(ChunkToCubeSet.Level_redirects.class) @TransformFromMethod(useRedirectSets = { - ChunkToCubeSet.class }, - value = "markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" - + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V") + ChunkToCubeSet.class }, value = "markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V") public native void cc_markAndNotifyBlock( - BlockPos blockPos, @Nullable LevelCube levelCube, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft + BlockPos blockPos, @Nullable LevelCube levelCube, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft ); // getBlockState // Replaces LevelChunk with a LevelCube to call getBlockState - @Inject(method = "getBlockState", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(II)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @Inject(method = "getBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(II)Lnet/minecraft/world/level/chunk/LevelChunk;")) private void cc_replaceLevelChunkInGetBlockState( - BlockPos blockPos, CallbackInfoReturnable cir, @Share("levelCube") LocalRef levelCubeLocalRef + BlockPos blockPos, CallbackInfoReturnable cir, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.set(this.cc_getCubeAt(blockPos)); } } - @WrapOperation(method = "getBlockState", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getBlockState(Lnet/minecraft/core/BlockPos;)" + @WrapOperation(method = "getBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getBlockState(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/block/state/BlockState;")) private BlockState cc_replaceLevelChunkInGetBlockState( - LevelChunk levelChunk, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + LevelChunk levelChunk, BlockPos blockPos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { return levelCubeLocalRef.get().getBlockState(blockPos); @@ -165,8 +158,7 @@ private BlockState cc_replaceLevelChunkInGetBlockState( // getBlockEntity // Replaces LevelChunk with a LevelCube to call getBlockEntity - @Inject(method = "getBlockEntity", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + @Inject(method = "getBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/chunk/LevelChunk;"), cancellable = true) private void cc_replaceGetChunkAtInSetBlockEntity(BlockPos blockPos, CallbackInfoReturnable cir) { if (cc_isCubic) { @@ -176,8 +168,7 @@ private void cc_replaceGetChunkAtInSetBlockEntity(BlockPos blockPos, CallbackInf // getFluidState // Replaces LevelChunk with a LevelCube to call getFluidState - @WrapOperation(method = "getFluidState", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/chunk/LevelChunk;getFluidState(Lnet/minecraft/core/BlockPos;)" + @WrapOperation(method = "getFluidState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getFluidState(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/material/FluidState;")) private FluidState cc_replaceGetChunkAtInGetFluidState(LevelChunk levelChunk, BlockPos blockPos, Operation original) { if (cc_isCubic) { @@ -188,8 +179,7 @@ private FluidState cc_replaceGetChunkAtInGetFluidState(LevelChunk levelChunk, Bl // setBlockEntity // Replaces LevelChunk with a LevelCube to call addAndRegisterBlockEntity - @Inject(method = "setBlockEntity", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + @Inject(method = "setBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/chunk/LevelChunk;"), cancellable = true) private void cc_replaceLevelChunkInSetBlockEntity(BlockEntity blockEntity, CallbackInfo ci, @Local(ordinal = 0) BlockPos blockPos) { if (cc_isCubic) { @@ -200,10 +190,9 @@ private void cc_replaceLevelChunkInSetBlockEntity(BlockEntity blockEntity, Callb // removeBlockEntity // Replaces LevelChunk with a LevelCube to call removeBlockEntity, needs a local ref to do so - @WrapOperation(method = "removeBlockEntity", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @WrapOperation(method = "removeBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunkAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/LevelChunk;")) private LevelChunk cc_replaceGetChunkAtInRemoveBlockEntity( - Level level, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + Level level, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.set(cc_getCubeAt(pos)); @@ -212,10 +201,9 @@ private LevelChunk cc_replaceGetChunkAtInRemoveBlockEntity( return original.call(level, pos); } - @WrapOperation(method = "removeBlockEntity", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;removeBlockEntity(Lnet/minecraft/core/BlockPos;)V")) + @WrapOperation(method = "removeBlockEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;removeBlockEntity(Lnet/minecraft/core/BlockPos;)V")) private void cc_replaceLevelChunkInRemoveBlockEntity( - LevelChunk levelChunk, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef + LevelChunk levelChunk, BlockPos pos, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef ) { if (cc_isCubic) { levelCubeLocalRef.get().removeBlockEntity(pos); @@ -230,25 +218,23 @@ private void cc_replaceLevelChunkInRemoveBlockEntity( private boolean cc_replaceHasChunkInIsLoaded(ChunkSource chunkSource, int x, int z, Operation original, BlockPos blockPos) { if (cc_isCubic) { return ((CubeSource) chunkSource).cc_hasCube(Coords.blockToCube(blockPos.getX()), Coords.blockToCube(blockPos.getY()), - Coords.blockToCube(blockPos.getZ())); + Coords.blockToCube(blockPos.getZ())); } return false; } // loadedAndEntityCanStandOnFace // Uses an inject here since the entire second half of the method needs to be replaced anyways - @Inject(method = "loadedAndEntityCanStandOnFace", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/Level;getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" - + "Lnet/minecraft/world/level/chunk/ChunkAccess;"), - cancellable = true) + @Inject(method = "loadedAndEntityCanStandOnFace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + + "Lnet/minecraft/world/level/chunk/ChunkAccess;"), cancellable = true) private void cc_replaceGetChunkAtInLoadedAndEntityCanStandOnFace( - BlockPos blockPos, Entity entity, Direction direction, CallbackInfoReturnable cir + BlockPos blockPos, Entity entity, Direction direction, CallbackInfoReturnable cir ) { if (cc_isCubic) { CubeAccess cubeAccess = this.cc_getCube(Coords.blockToCube(blockPos.getX()), Coords.blockToCube(blockPos.getY()), - Coords.blockToCube(blockPos.getZ()), ChunkStatus.FULL, false); + Coords.blockToCube(blockPos.getZ()), ChunkStatus.FULL, false); cir.setReturnValue( - cubeAccess == null ? false : cubeAccess.getBlockState(blockPos).entityCanStandOnFace(this, blockPos, entity, direction)); + cubeAccess == null ? false : cubeAccess.getBlockState(blockPos).entityCanStandOnFace(this, blockPos, entity, direction)); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java index d1ec12a0..721bd6de 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java @@ -18,23 +18,19 @@ public class MixinTicketStorage implements CubicTicketStorage { // TODO (P2) codec nonsense for save/load @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), - value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_addTicketWithRadius(TicketType ticketType, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), - value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_addTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), - value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_removeTicketWithRadius(TicketType ticketType, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), - value = "removeTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "removeTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_removeTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java index fc57e848..cbf81678 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java @@ -20,15 +20,13 @@ public boolean cc_isOldChunkAround(CloPos pos, int radius) { return false; // TODO (P2) should be dasm'd once IOWorker is done } - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, - method = "read(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = "read(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") public CompletableFuture> cc_read(CloPos cloPos) { // TODO (P2) loading - this method should be dasm'd return CompletableFuture.completedFuture(Optional.empty()); } - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, - method = "write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)V") + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = "write(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/Supplier;)Ljava/util/concurrent/CompletableFuture;") public void cc_write(CloPos cloPos, CompoundTag chunkData) { // TODO (P2) loading/unloading } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java index 42709c74..f4749eaa 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java @@ -63,8 +63,11 @@ import net.neoforged.neoforge.event.level.ChunkEvent; /** - * Should be used for DASM transforms that work with Clos (i.e. work with both Chunks and Cubes)

Clo-related field and type redirects, and - * method redirects containing Clo-related types in the signature or return type should be added to this set.
Other redirects may also be added + * Should be used for DASM transforms that work with Clos (i.e. work with both Chunks and Cubes)
+ *
+ * Clo-related field and type redirects, and + * method redirects containing Clo-related types in the signature or return type should be added to this set.
+ * Other redirects may also be added * to this set if they should only be applied in contexts working with both Chunks and Cubes. Redirects applicable in all contexts should be added to * {@link GlobalSet}. */ @@ -103,25 +106,23 @@ interface ChunkAccess_to_CloAccess_redirects { @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelClo.class)) interface LevelChunk_to_LevelClo_redirects extends ChunkAccess_to_CloAccess_redirects { - @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/Level;Lio/github/opencubicchunks/cc_core/world/level/CloPos;)V") + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;)V") static LevelClo create(Level level, ChunkPos pos) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect( - "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + "Lnet/minecraft/world/ticks/LevelChunkTicks;Lnet/minecraft/world/ticks/LevelChunkTicks;" + "J[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;" + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static LevelClo create( - Level level, CloPos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, - @Nullable LevelChunkSection[] sections, @Nullable LevelClo.PostLoadProcessor postLoad, @Nullable BlendingData blendingData + Level level, CloPos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, + @Nullable LevelChunkSection[] sections, @Nullable LevelClo.PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect( - "(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;" + @ConstructorToFactoryRedirect("(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;" + "Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;)V") static LevelClo create(ServerLevel level, ProtoClo clo, @Nullable LevelClo.PostLoadProcessor postLoad) { throw new DasmFailedToApply(); @@ -129,31 +130,28 @@ static LevelClo create(ServerLevel level, ProtoClo clo, @Nullable LevelClo.PostL } @TypeRedirect(from = @Ref(LevelChunk.PostLoadProcessor.class), to = @Ref(LevelClo.PostLoadProcessor.class)) - interface LevelChunk$PostLoadProcessor_to_LevelClo$PostLoadProcessor_redirects { - } + interface LevelChunk$PostLoadProcessor_to_LevelClo$PostLoadProcessor_redirects {} @TypeRedirect(from = @Ref(ProtoChunk.class), to = @Ref(ProtoClo.class)) interface ProtoChunk_to_ProtoClo_redirects extends ChunkAccess_to_CloAccess_redirects { - @ConstructorToFactoryRedirect( - "(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + "Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/core/Registry;" + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static ProtoClo create( - CloPos cloPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CloPos cloPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect( - "(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + "[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/ticks/ProtoChunkTicks;" + "Lnet/minecraft/world/ticks/ProtoChunkTicks;Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/core/Registry;" + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static ProtoClo create( - CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, - ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, + ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { throw new DasmFailedToApply(); } @@ -171,18 +169,15 @@ static ImposterProtoClo create(LevelClo wrapped, boolean allowWrites) { } @TypeRedirect(from = @Ref(ChunkTrackingView.class), to = @Ref(CloTrackingView.class)) - interface ChunkTrackingView_to_CloTrackingView_redirects { - } + interface ChunkTrackingView_to_CloTrackingView_redirects {} @TypeRedirect(from = @Ref(ChunkTrackingView.Positioned.class), to = @Ref(CloTrackingView.Positioned.class)) - abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects implements ChunkTrackingView_to_CloTrackingView_redirects { - } + abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects implements ChunkTrackingView_to_CloTrackingView_redirects {} // region [Forge stuff] // TODO move to a forge-specific sourceset @TypeRedirect(from = @Ref(ChunkEvent.Load.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Load_to_Event_redirects { - } + abstract class ChunkEvent$Load_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Load.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Load_delegateConstruction { @@ -191,8 +186,7 @@ abstract class ChunkEvent$Load_delegateConstruction { } @TypeRedirect(from = @Ref(ChunkEvent.Unload.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Unload_to_Event_redirects { - } + abstract class ChunkEvent$Unload_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Unload.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Unload_delegateConstruction { @@ -207,87 +201,66 @@ abstract class GenerationChunkHolder_Forge_Jank_redirects { } @IntraOwnerContainer(@Ref(ChunkHolder.class)) - abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects { - } + abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects {} // endregion @IntraOwnerContainer(@Ref(ChunkHolder.class)) - class ChunkHolder_redirects extends GenerationChunkHolder_redirects { - } + class ChunkHolder_redirects extends GenerationChunkHolder_redirects {} @IntraOwnerContainer(@Ref(ProcessorChunkProgressListener.class)) - class ProcessorChunkProgressListener_redirects { - } + class ProcessorChunkProgressListener_redirects {} @IntraOwnerContainer(@Ref(ChunkGenerationTask.class)) - class ChunkGenerationTask_redirects { - } + class ChunkGenerationTask_redirects {} @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) - class GenerationChunkHolder_redirects { - } + class GenerationChunkHolder_redirects {} @IntraOwnerContainer(@Ref(ChunkStorage.class)) - class ChunkStorage_redirects { - } + class ChunkStorage_redirects {} @IntraOwnerContainer(@Ref(ChunkMap.class)) - class ChunkMap_redirects extends ChunkStorage_redirects { - } + class ChunkMap_redirects extends ChunkStorage_redirects {} @IntraOwnerContainer(@Ref(ChunkMap.TrackedEntity.class)) - class ChunkMap$TrackedEntity_redirects { - } + class ChunkMap$TrackedEntity_redirects {} @IntraOwnerContainer(@Ref(ServerChunkCache.class)) - class ServerChunkCache_redirects { - } + class ServerChunkCache_redirects {} @IntraOwnerContainer(@Ref(ServerLevel.class)) - class ServerLevel_redirects { - } + class ServerLevel_redirects {} @IntraOwnerContainer(@Ref(Entity.class)) - class Entity_redirects { - } + class Entity_redirects {} @IntraOwnerContainer(@Ref(ServerPlayer.class)) - class ServerPlayer_redirects extends Entity_redirects { - } + class ServerPlayer_redirects extends Entity_redirects {} @IntraOwnerContainer(@Ref(PlayerChunkSender.class)) - class PlayerChunkSender_redirects { - } + class PlayerChunkSender_redirects {} @InterOwnerContainer(from = @Ref(EventHooks.class), to = @Ref(CCEventHooks.class)) - class EventHooks_to_CCEventHooks_redirects { - } + class EventHooks_to_CCEventHooks_redirects {} @InterOwnerContainer(from = @Ref(CommonHooks.class), to = @Ref(CCCommonHooks.class)) - class CommonHooks_to_CCCommonHooks_redirects { - } + class CommonHooks_to_CCCommonHooks_redirects {} @IntraOwnerContainer(@Ref(ChunkTaskDispatcher.class)) - class ChunkTaskDispatcher_redirects { - } + class ChunkTaskDispatcher_redirects {} @IntraOwnerContainer(@Ref(ChunkTaskPriorityQueue.class)) - class ChunkTaskPriorityQueue_redirects { - } + class ChunkTaskPriorityQueue_redirects {} @IntraOwnerContainer(@Ref(SimulationChunkTracker.class)) - class SimulationChunkTracker_redirects { - } + class SimulationChunkTracker_redirects {} @IntraOwnerContainer(@Ref(LoggerChunkProgressListener.class)) - class LoggerChunkProgressListener_redirects { - } + class LoggerChunkProgressListener_redirects {} @IntraOwnerContainer(@Ref(StoringChunkProgressListener.class)) - class StoringChunkProgressListener_redirects { - } + class StoringChunkProgressListener_redirects {} @IntraOwnerContainer(@Ref(TicketStorage.class)) - class TicketStorage_redirects { - } + class TicketStorage_redirects {} } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java index 8465ee15..60ac0f05 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java @@ -63,8 +63,11 @@ import net.neoforged.neoforge.event.level.ChunkEvent; /** - * Should be used for DASM transforms that work with only Cubes (as opposed to working with both Chunks and Cubes)

Cube-related field and - * type redirects, and method redirects containing Cube-related types in the signature or return type should be added to this set.
Other + * Should be used for DASM transforms that work with only Cubes (as opposed to working with both Chunks and Cubes)
+ *
+ * Cube-related field and + * type redirects, and method redirects containing Cube-related types in the signature or return type should be added to this set.
+ * Other * redirects may also be added to this set if they should only be applied in contexts working with only Cubes. Redirects applicable in all contexts * should be added to {@link GlobalSet}. */ @@ -102,75 +105,53 @@ abstract class ChunkAccess_to_CubeAccess_redirects { public native CubePos cc_getCubePos(); } - @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.ChunkAccess$ChunkPathElement"), - to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess$CubePathElement")) + @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.ChunkAccess$ChunkPathElement"), to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess$CubePathElement")) abstract class ChunkAccess$ChunkPathElement_to_CubeAccess$CubePathElement_redirects { } @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelCube.class)) - abstract class LevelChunk_to_LevelCube_redirects { - @FieldRedirect("chunkPos:Lnet/minecraft/world/level/ChunkPos;") - protected CubePos cubePos; - - @MethodRedirect("getPos()Lnet/minecraft/world/level/ChunkPos;") - public native CubePos cc_getCubePos(); - } + abstract class LevelChunk_to_LevelCube_redirects extends ChunkAccess_to_CubeAccess_redirects {} @TypeRedirect(from = @Ref(LevelChunk.PostLoadProcessor.class), to = @Ref(LevelCube.PostLoadProcessor.class)) - interface LevelChunk$PostLoadProcessor_to_LevelCube$PostLoadProcessor_redirects { - } + interface LevelChunk$PostLoadProcessor_to_LevelCube$PostLoadProcessor_redirects {} - @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity"), - to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity")) - abstract class LevelChunk$BoundTickingBlockEntity_to_LevelCube$BoundTickingBlockEntity_redirects { - } + @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity"), to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity")) + abstract class LevelChunk$BoundTickingBlockEntity_to_LevelCube$BoundTickingBlockEntity_redirects {} - @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), - to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper")) - abstract class LevelChunk$RebindableTickingBlockEntityWrapper_to_LevelCube$RebindableTickingBlockEntityWrapper_redirects { - } + @TypeRedirect(from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper")) + abstract class LevelChunk$RebindableTickingBlockEntityWrapper_to_LevelCube$RebindableTickingBlockEntityWrapper_redirects {} @TypeRedirect(from = @Ref(ProtoChunk.class), to = @Ref(ProtoCube.class)) - abstract class ProtoChunk_to_ProtoCube_redirects { - } + abstract class ProtoChunk_to_ProtoCube_redirects {} @TypeRedirect(from = @Ref(ImposterProtoChunk.class), to = @Ref(ImposterProtoCube.class)) - abstract class ImposterProtoChunk_to_ImposterProtoCube_redirects { - } + abstract class ImposterProtoChunk_to_ImposterProtoCube_redirects {} @TypeRedirect(from = @Ref(EmptyLevelChunk.class), to = @Ref(EmptyLevelCube.class)) - abstract class EmptyLevelChunk_to_EmptyLevelCube_redirects { - } + abstract class EmptyLevelChunk_to_EmptyLevelCube_redirects {} // FIXME probably need to move to a client-only set @TypeRedirect(from = @Ref(ClientChunkCache.Storage.class), to = @Ref(ClientCubeCache.Storage.class)) - abstract class ClientChunkCache$Storage_to_ClientCubeCache$Storage_redirects { - } + abstract class ClientChunkCache$Storage_to_ClientCubeCache$Storage_redirects {} @TypeRedirect(from = @Ref(ChunkStatusTask.class), to = @Ref(CubeStatusTask.class)) - interface ChunkStatusTask_to_CubeStatusTask_redirects { - } + interface ChunkStatusTask_to_CubeStatusTask_redirects {} @TypeRedirect(from = @Ref(StaticCache2D.class), to = @Ref(StaticCache3D.class)) - abstract class StaticCache2D_to_StaticCache3D_redirects { - } + abstract class StaticCache2D_to_StaticCache3D_redirects {} @TypeRedirect(from = @Ref(ChunkStep.class), to = @Ref(CubeStep.class)) - abstract class ChunkStep_to_CubeStep_redirects { - } + abstract class ChunkStep_to_CubeStep_redirects {} @TypeRedirect(from = @Ref(ChunkStep.Builder.class), to = @Ref(CubeStep.Builder.class)) - abstract class ChunkStep$Builder_to_CubeStep$Builder_redirects { - } + abstract class ChunkStep$Builder_to_CubeStep$Builder_redirects {} @TypeRedirect(from = @Ref(ChunkPyramid.class), to = @Ref(CubePyramid.class)) - abstract class ChunkPyramid_to_CubePyramid_redirects { - } + abstract class ChunkPyramid_to_CubePyramid_redirects {} @TypeRedirect(from = @Ref(ChunkPyramid.Builder.class), to = @Ref(CubePyramid.Builder.class)) - abstract class ChunkPyramid$Builder_to_CubePyramid$Builder_redirects { - } + abstract class ChunkPyramid$Builder_to_CubePyramid$Builder_redirects {} @TypeRedirect(from = @Ref(ChunkHolder.LevelChangeListener.class), to = @Ref(CubeHolder.LevelChangeListener.class)) interface ChunkHolder$LevelChangeListener_to_CubeHolder$LevelChangeListener_redirects { @@ -186,13 +167,11 @@ interface ChunkHolder$PlayerProvider_to_CubeHolder$PlayerProvider_redirects { @TypeRedirect(from = @Ref(GeneratingChunkMap.class), to = @Ref(GeneratingCubeMap.class)) interface GeneratingChunkMap_to_GeneratingCubeMap_redirects { - @MethodRedirect( - "applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @MethodRedirect("applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") CompletableFuture cc_applyCubeStep(GenerationChunkHolder chunk, CubeStep step, StaticCache3D cache); - @MethodRedirect( - "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + @MethodRedirect("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + "Lnet/minecraft/server/level/ChunkGenerationTask;") ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus targetStatus, CubePos pos); } @@ -204,18 +183,15 @@ abstract class ChunkGenerationTask_redirects { } @TypeRedirect(from = @Ref(LevelChunk.UnsavedListener.class), to = @Ref(LevelCube.UnsavedListener.class)) - interface LevelChunk$UnsavedListener_to_LevelCube$UnsavedListener_redirects { - } + interface LevelChunk$UnsavedListener_to_LevelCube$UnsavedListener_redirects {} @IntraOwnerContainer(@Ref(ChunkHolder.class)) - abstract class ChunkHolder_redirects extends GenerationChunkHolder_redirects { - } + abstract class ChunkHolder_redirects extends GenerationChunkHolder_redirects {} // region [Forge stuff] // TODO move to a forge-specific sourceset @TypeRedirect(from = @Ref(ChunkEvent.Load.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Load_to_Event_redirects { - } + abstract class ChunkEvent$Load_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Load.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Load_delegateConstruction { @@ -224,8 +200,7 @@ abstract class ChunkEvent$Load_delegateConstruction { } @TypeRedirect(from = @Ref(ChunkEvent.Unload.class), to = @Ref(Event.class)) - abstract class ChunkEvent$Unload_to_Event_redirects { - } + abstract class ChunkEvent$Unload_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Unload.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Unload_delegateConstruction { @@ -234,21 +209,17 @@ abstract class ChunkEvent$Unload_delegateConstruction { } @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) - abstract class GenerationChunkHolder_Forge_Jank_redirects { - } + abstract class GenerationChunkHolder_Forge_Jank_redirects {} @IntraOwnerContainer(@Ref(ChunkHolder.class)) - abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects { - } + abstract class ChunkHolder_Forge_Jank_redirects extends GenerationChunkHolder_Forge_Jank_redirects {} // endregion @InterOwnerContainer(from = @Ref(ChunkLevel.class), to = @Ref(CubeLevel.class)) - class ChunkLevel_to_CubeLevel_redirects { - } + class ChunkLevel_to_CubeLevel_redirects {} @InterOwnerContainer(from = @Ref(ChunkStatusTasks.class), to = @Ref(CubeStatusTasks.class)) - class ChunkStatusTasks_to_CubeStatusTasks_redirects { - } + class ChunkStatusTasks_to_CubeStatusTasks_redirects {} @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) class GenerationChunkHolder_redirects { @@ -257,46 +228,35 @@ class GenerationChunkHolder_redirects { } @IntraOwnerContainer(@Ref(ChunkMap.class)) - class ChunkMap_redirects { - } + class ChunkMap_redirects {} @IntraOwnerContainer(@Ref(ServerChunkCache.class)) - class ServerChunkCache_redirects { - } + class ServerChunkCache_redirects {} @IntraOwnerContainer(@Ref(Entity.class)) - class Entity_redirects { - } + class Entity_redirects {} @IntraOwnerContainer(@Ref(ServerPlayer.class)) - class ServerPlayer_redirects extends Entity_redirects { - } + class ServerPlayer_redirects extends Entity_redirects {} @IntraOwnerContainer(@Ref(ClientChunkCache.class)) - class ClientChunkCache_redirects { - } + class ClientChunkCache_redirects {} @IntraOwnerContainer(@Ref(SectionOcclusionGraph.class)) - class SectionOcclusionGraph_redirects { - } + class SectionOcclusionGraph_redirects {} @InterOwnerContainer(from = @Ref(CommonHooks.class), to = @Ref(CCCommonHooks.class)) - class CommonHooks_to_CCCommonHooks_redirects { - } + class CommonHooks_to_CCCommonHooks_redirects {} @IntraOwnerContainer(@Ref(Level.class)) - class Level_redirects { - } + class Level_redirects {} @IntraOwnerContainer(@Ref(ServerLevel.class)) - class ServerLevel_redirects extends Level_redirects { - } + class ServerLevel_redirects extends Level_redirects {} @IntraOwnerContainer(@Ref(LevelRenderer.class)) - class LevelRenderer_redirects { - } + class LevelRenderer_redirects {} @IntraOwnerContainer(@Ref(SectionCopy.class)) - class SectionCopy_redirects { - } + class SectionCopy_redirects {} } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java index 1933f162..9728eadd 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java @@ -31,21 +31,22 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; /** - * Contains redirects that are applied to all DASM transforms.

Redirects should only be added to this set if they are applicable in all + * Contains redirects that are applied to all DASM transforms.
+ *
+ * Redirects should only be added to this set if they are applicable in all * contexts. */ @RedirectSet public interface GlobalSet extends ForgeSet { @IntraOwnerContainer(@Ref(ChunkStatus.class)) abstract class ChunkStatus_redirects { - @MethodRedirect( - "generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;" + @MethodRedirect("generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;" + "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager;" + "Lnet/minecraft/server/level/ThreadedLevelLightEngine;Ljava/util/function/Function;Ljava/util/List;)" + "Ljava/util/concurrent/CompletableFuture;") public abstract CompletableFuture> cc_generate( - Executor exectutor, ServerLevel level, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, - ThreadedLevelLightEngine lightEngine, Function>> task, List cache + Executor exectutor, ServerLevel level, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, + ThreadedLevelLightEngine lightEngine, Function>> task, List cache ); } @@ -59,26 +60,20 @@ interface ChunkProgressListener_to_CloProgressListener_redirects { } @TypeRedirect(from = @Ref(ChunkStatusUpdateListener.class), to = @Ref(CloStatusUpdateListener.class)) - interface ChunkStatusUpdateListener_to_CloStatusUpdateListener_redirects { - } + interface ChunkStatusUpdateListener_to_CloStatusUpdateListener_redirects {} @TypeRedirect(from = @Ref(ChunkTrackingView.class), to = @Ref(CloTrackingView.class)) - interface ChunkTrackingView_to_CloTrackingView_redirects { - } + interface ChunkTrackingView_to_CloTrackingView_redirects {} @TypeRedirect(from = @Ref(ChunkTrackingView.Positioned.class), to = @Ref(CloTrackingView.Positioned.class)) - abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects { - } + abstract class ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects {} @IntraOwnerContainer(@Ref(StoringChunkProgressListener.class)) - class StoringChunkProgressListener_redirects { - } + class StoringChunkProgressListener_redirects {} @IntraOwnerContainer(@Ref(ChunkMap.class)) - class ChunkMap_redirects { - } + class ChunkMap_redirects {} @IntraOwnerContainer(@Ref(ServerChunkCache.class)) - class ServerChunkCache_redirects { - } + class ServerChunkCache_redirects {} } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java index 1bbf6385..cf465331 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java @@ -13,17 +13,14 @@ @Dasm(GlobalSet.class) public class CCCommonHooks { - private CCCommonHooks() { - } + private CCCommonHooks() {} - @AddMethodToSets(containers = ChunkToCubeSet.CommonHooks_to_CCCommonHooks_redirects.class, - method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") + @AddMethodToSets(containers = ChunkToCubeSet.CommonHooks_to_CCCommonHooks_redirects.class, method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") public static void onCubeUnload(PoiManager poiManager, CubeAccess cubeAccess) { // TODO (P2) save/load: once PoiManager cubic methods are implemented, this method can be a dasm copy } - @AddMethodToSets(containers = ChunkToCloSet.CommonHooks_to_CCCommonHooks_redirects.class, - method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") + @AddMethodToSets(containers = ChunkToCloSet.CommonHooks_to_CCCommonHooks_redirects.class, method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") public static void onCloUnload(PoiManager poiManager, CloAccess cloAccess) { if (cloAccess instanceof CubeAccess cubeAccess) { onCubeUnload(poiManager, cubeAccess); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java index d2b2a03a..cee7662c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java @@ -15,16 +15,14 @@ @Dasm(ForgeSet.class) public class CCEventHooks { - private CCEventHooks() { - } + private CCEventHooks() {} // TODO onCreateWorldSpawn? // TODO onTrySpawnPortal? - @AddMethodToSets(containers = ForgeSet.EventHooks_to_CCEventHooks_redirects.class, - method = "fireChunkTicketLevelUpdated(Lnet/minecraft/server/level/ServerLevel;JIILnet/minecraft/server/level/ChunkHolder;)V") + @AddMethodToSets(containers = ForgeSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkTicketLevelUpdated(Lnet/minecraft/server/level/ServerLevel;JIILnet/minecraft/server/level/ChunkHolder;)V") public static void fireChunkTicketLevelUpdated( - ServerLevel level, long cloPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder + ServerLevel level, long cloPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder ) { if (CloPos.isChunk(cloPos)) { EventHooks.fireChunkTicketLevelUpdated(level, cloPos, oldTicketLevel, newTicketLevel, chunkHolder); @@ -34,8 +32,7 @@ public static void fireChunkTicketLevelUpdated( } // TODO do we need a ChunkToCloForgeSet, etc? actually I guess if we only tell dasm about this class on forge then it's fine - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, - method = "fireChunkWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkWatch(ServerPlayer entity, LevelClo clo, ServerLevel level) { if (clo instanceof LevelChunk chunk) { @@ -45,8 +42,7 @@ public static void fireChunkWatch(ServerPlayer entity, LevelClo clo, ServerLevel } } - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, - method = "fireChunkSent(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkSent(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkSent(ServerPlayer entity, LevelClo clo, ServerLevel level) { if (clo instanceof LevelChunk chunk) { @@ -56,8 +52,7 @@ public static void fireChunkSent(ServerPlayer entity, LevelClo clo, ServerLevel } } - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, - method = "fireChunkUnWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;" + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkUnWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;" + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkUnWatch(ServerPlayer entity, CloPos cloPos, ServerLevel level) { if (cloPos.isChunk()) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java index 13dcaddd..7b2ac874 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java @@ -14,36 +14,31 @@ @Dasm(ChunkToCloSet.class) public interface CloTrackingView extends ChunkTrackingView { - @AddFieldToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, - field = "EMPTY:Lnet/minecraft/server/level/ChunkTrackingView;") + @AddFieldToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, field = "EMPTY:Lnet/minecraft/server/level/ChunkTrackingView;") CloTrackingView EMPTY = new CloTrackingView() { @Override public boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks) { return false; } - @Override public void cc_forEach(Consumer action) { - } + @Override public void cc_forEach(Consumer action) {} @Override public boolean contains(int x, int z, boolean searchAllChunks) { return false; } - @Override public void forEach(Consumer action) { - } + @Override public void forEach(Consumer action) {} }; - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, - method = "of(Lnet/minecraft/world/level/ChunkPos;I)Lnet/minecraft/server/level/ChunkTrackingView;") + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "of(Lnet/minecraft/world/level/ChunkPos;I)Lnet/minecraft/server/level/ChunkTrackingView;") static CloTrackingView cc_of(CloPos center, int viewDistanceCubes) { return new CloTrackingView.Positioned(center, viewDistanceCubes); } @SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:JavaNCSS" }) // <-- copies structure of vanilla method - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, - method = "difference(Lnet/minecraft/server/level/ChunkTrackingView;Lnet/minecraft/server/level/ChunkTrackingView;" + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "difference(Lnet/minecraft/server/level/ChunkTrackingView;Lnet/minecraft/server/level/ChunkTrackingView;" + "Ljava/util/function/Consumer;Ljava/util/function/Consumer;)V") static void cc_difference( - CloTrackingView oldCloTrackingView, CloTrackingView newCloTrackingView, Consumer chunkDropper, Consumer chunkMarker + CloTrackingView oldCloTrackingView, CloTrackingView newCloTrackingView, Consumer chunkDropper, Consumer chunkMarker ) { if (!oldCloTrackingView.equals(newCloTrackingView)) { if (oldCloTrackingView instanceof Positioned oldPositioned && newCloTrackingView instanceof Positioned newPositioned) { @@ -123,8 +118,7 @@ static void cc_difference( } } - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, - method = "contains(Lnet/minecraft/world/level/ChunkPos;)Z") + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "contains(Lnet/minecraft/world/level/ChunkPos;)Z") default boolean cc_contains(CloPos cloPos) { if (cloPos.isCube()) { return this.cc_contains(cloPos.getX(), cloPos.getY(), cloPos.getZ()); @@ -139,8 +133,7 @@ default boolean cc_contains(int cubeX, int cubeY, int cubeZ) { boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks); - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, - method = "forEach(Ljava/util/function/Consumer;)V") + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "forEach(Ljava/util/function/Consumer;)V") void cc_forEach(Consumer action); default boolean cc_isInViewDistance(int cubeX, int cubeY, int cubeZ) { @@ -152,8 +145,8 @@ static boolean cc_isInViewDistance(int centerCubeX, int centerCubeY, int centerC } static boolean cc_isWithinDistance( - int centerCubeX, int centerCubeY, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeY, int cubeZ, - boolean includeOuterChunksAdjacentToViewBorder + int centerCubeX, int centerCubeY, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeY, int cubeZ, + boolean includeOuterChunksAdjacentToViewBorder ) { int i = includeOuterChunksAdjacentToViewBorder ? 2 : 1; int dx = Math.max(0, Math.abs(cubeX - centerCubeX) - i); @@ -163,16 +156,15 @@ static boolean cc_isWithinDistance( } static boolean cc_isWithinDistanceCubeColumn( - int centerCubeX, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeZ, boolean includeOuterChunksAdjacentToViewBorder + int centerCubeX, int centerCubeZ, int viewDistanceCubes, int cubeX, int cubeZ, boolean includeOuterChunksAdjacentToViewBorder ) { return cc_isWithinDistance(centerCubeX, 0, centerCubeZ, viewDistanceCubes, cubeX, 0, cubeZ, includeOuterChunksAdjacentToViewBorder); } @Dasm(ChunkToCloSet.class) record Positioned( - CloPos center, - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects.class, - method = "viewDistance()I") int viewDistanceCubes + CloPos center, + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects.class, method = "viewDistance()I") int viewDistanceCubes ) implements CloTrackingView { int minX() { return this.center.getX() - this.viewDistanceCubes - 1; @@ -200,7 +192,7 @@ int maxZ() { @Override public boolean contains(int chunkX, int chunkZ, boolean searchAllChunks) { return cc_isWithinDistanceCubeColumn(this.center.getX(), this.center.getZ(), this.viewDistanceCubes, Coords.sectionToCube(chunkX), - Coords.sectionToCube(chunkZ), searchAllChunks); + Coords.sectionToCube(chunkZ), searchAllChunks); } @Override public void forEach(Consumer action) { @@ -219,7 +211,7 @@ int maxZ() { private boolean cc_cubeIntersects(CloTrackingView.Positioned other) { return this.minX() <= other.maxX() && this.maxX() >= other.minX() && this.minY() <= other.maxY() && this.maxY() >= other.minY() - && this.minZ() <= other.maxZ() && this.maxZ() >= other.minZ(); + && this.minZ() <= other.maxZ() && this.maxZ() >= other.minZ(); } private boolean cc_chunkIntersects(CloTrackingView.Positioned other) { @@ -228,7 +220,7 @@ private boolean cc_chunkIntersects(CloTrackingView.Positioned other) { @Override public boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks) { return cc_isWithinDistance(this.center.getX(), this.center.getY(), this.center.getZ(), this.viewDistanceCubes, cubeX, cubeY, cubeZ, - searchAllChunks); + searchAllChunks); } @Override public void cc_forEach(Consumer action) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java index 0910ab15..35b953b7 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java @@ -18,8 +18,7 @@ */ @Dasm(GlobalSet.class) public class CubeLevel { - private CubeLevel() { - } + private CubeLevel() {} private static final int FULL_CHUNK_LEVEL = 33; private static final CubeStep FULL_CUBE_STEP = CubePyramid.CC_GENERATION_PYRAMID_CUBES.getStepTo(ChunkStatus.FULL); @@ -29,14 +28,12 @@ private CubeLevel() { // is greater. public static final int MAX_LEVEL = FULL_CHUNK_LEVEL + RADIUS_AROUND_FULL_CUBE; - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, - method = "generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") public static @Nullable ChunkStatus cubeGenerationStatus(int level) { return getStatusAroundFullCube(level - FULL_CHUNK_LEVEL, null); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, - method = "getStatusAroundFullChunk(ILnet/minecraft/world/level/chunk/status/ChunkStatus;)" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "getStatusAroundFullChunk(ILnet/minecraft/world/level/chunk/status/ChunkStatus;)" + "Lnet/minecraft/world/level/chunk/status/ChunkStatus;") @Nullable @Contract("_,!null->!null;_,_->_") public static ChunkStatus getStatusAroundFullCube(int distance, @Nullable ChunkStatus chunkStatus) { @@ -47,14 +44,12 @@ public static ChunkStatus getStatusAroundFullCube(int distance, @Nullable ChunkS } } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, - method = "getStatusAroundFullChunk(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "getStatusAroundFullChunk(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") public static ChunkStatus getStatusAroundFullCube(int distance) { return getStatusAroundFullCube(distance, ChunkStatus.EMPTY); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, - method = "byStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "byStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") public static int byCubeStatus(ChunkStatus status) { return FULL_CHUNK_LEVEL + FULL_CUBE_STEP.getAccumulatedRadiusOf(status); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java index c90d145d..b0a2b80c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java @@ -28,8 +28,7 @@ */ @Dasm(ChunkInCubicContextSet.class) public class CCChunkStatusTasks { - private CCChunkStatusTasks() { - } + private CCChunkStatusTasks() {} @AddFieldToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, field = "LOGGER:Lorg/slf4j/Logger;") private static final Logger LOGGER = LogUtils.getLogger(); @@ -38,128 +37,114 @@ private CCChunkStatusTasks() { @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private static native boolean isLighted(ChunkAccess chunk); - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture passThrough( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return CompletableFuture.completedFuture(chunk); } // We skip chunk generation steps in cubic contexts by delegating to passThrough - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureStarts( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture loadStructureStarts( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureReferences( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateBiomes( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateNoise( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSurface( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateCarvers( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateFeatures( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture initializeLight( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture light( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSpawn( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } // We still want to upgrade ProtoChunks to LevelChunks normally @AddTransformToSets(ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), - value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static native CompletableFuture full( - WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ); - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, - method = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") private static void postLoadProtoChunk(ServerLevel level, ValueInput.ValueInputList entityTags) { // Entities should be handled on the cube, not the chunk } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java index 0e131fe6..34400c53 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java @@ -80,8 +80,8 @@ public abstract class CubeAccess implements CloAccess { // Constructor signature matches ChunkAccess for DASM redirect purposes public CubeAccess( - CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, long inhabitedTime, - @Nullable LevelChunkSection[] chunkSections, @Nullable BlendingData blendingData + CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, long inhabitedTime, + @Nullable LevelChunkSection[] chunkSections, @Nullable BlendingData blendingData ) { this.cubePos = cubePos; this.upgradeData = upgradeData; @@ -96,7 +96,7 @@ public CubeAccess( System.arraycopy(chunkSections, 0, this.sections, 0, this.sections.length); } else { CubicChunks.LOGGER.warn("Could not set level cube sections, array length is {} instead of {}", chunkSections.length, - this.sections.length); + this.sections.length); } } @@ -111,12 +111,10 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC } } - @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", - owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", owner = @Ref(ChunkAccess.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); - @TransformFromMethod(owner = @Ref(ChunkAccess.class), - value = "setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)" + @TransformFromMethod(owner = @Ref(ChunkAccess.class), value = "setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)" + "Lnet/minecraft/world/level/block/state/BlockState;") @Override public native @Nullable BlockState setBlockState(BlockPos pos, BlockState state); @@ -150,8 +148,7 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC throw new UnsupportedOperationException(); } - @Override public void setHeightmap(Heightmap.Types type, long[] data) { - } + @Override public void setHeightmap(Heightmap.Types type, long[] data) {} @Override public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Types type) { throw new UnsupportedOperationException(); @@ -174,16 +171,12 @@ public CubePos cc_getCubePos() { return CloPos.cube(cubePos); } - @TransformFromMethod( - value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" - + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;", - owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;", owner = @Ref(ChunkAccess.class)) @Override public native @Nullable StructureStart getStartForStructure(Structure structure); - @TransformFromMethod( - value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" - + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V", - owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" + + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setStartForStructure(Structure structure, StructureStart structureStart); @TransformFromMethod(value = "getAllStarts()Ljava/util/Map;", owner = @Ref(ChunkAccess.class)) @@ -192,13 +185,10 @@ public CubePos cc_getCubePos() { @TransformFromMethod(value = "setAllStarts(Ljava/util/Map;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setAllStarts(Map structureStarts); - @TransformFromMethod( - value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;", - owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;", owner = @Ref(ChunkAccess.class)) @Override public native LongSet getReferencesForStructure(Structure structure); - @TransformFromMethod(value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V", - owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V", owner = @Ref(ChunkAccess.class)) @Override public native void addReferenceForStructure(Structure structure, long reference); @TransformFromMethod(value = "getAllReferences()Ljava/util/Map;", owner = @Ref(ChunkAccess.class)) @@ -259,7 +249,7 @@ public CubePos cc_getCubePos() { @Override public native void findBlocks(Predicate predicate, BiConsumer output); @Override public void findBlocks( - Predicate predicate, java.util.function.BiPredicate fineFilter, BiConsumer output + Predicate predicate, java.util.function.BiPredicate fineFilter, BiConsumer output ) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); @@ -314,8 +304,7 @@ public CubePos cc_getCubePos() { @TransformFromMethod(value = "setInhabitedTime(J)V", owner = @Ref(ChunkAccess.class)) @Override public native void setInhabitedTime(long inhabitedTime); - @TransformFromMethod(value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;", - owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;", owner = @Ref(ChunkAccess.class)) public static native ShortList getOrCreateOffsetList(ShortList[] packedPositions, int index); @TransformFromMethod(value = "isLightCorrect()Z", owner = @Ref(ChunkAccess.class)) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java index 432e9991..a11cb9ab 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java @@ -21,8 +21,7 @@ public ImposterProtoCube(LevelCube wrapped, boolean allowWrites) { } // Method is implemented in MixinImposterProtoCube instead, since DASM clears everything in this class. - @AddMethodToSets(containers = ChunkToCubeSet.ImposterProtoChunk_to_ImposterProtoCube_redirects.class, - method = "Lnet/minecraft/world/level/chunk/ImposterProtoChunk;getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;") + @AddMethodToSets(containers = ChunkToCubeSet.ImposterProtoChunk_to_ImposterProtoCube_redirects.class, method = "getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;") @Override public LevelClo cc_getWrappedClo() { throw new DasmFailedToApply(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java index 9468329d..5f6d92b8 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java @@ -65,8 +65,7 @@ public class LevelCube extends CubeAccess implements LevelClo { // Fields matching LevelChunk static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { - @Override public void tick() { - } + @Override public void tick() {} @Override public boolean isRemoved() { return true; @@ -96,8 +95,8 @@ public LevelCube(Level level, CubePos pos) { } public LevelCube( - Level level, CubePos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, - @Nullable LevelChunkSection[] sections, @Nullable LevelCube.PostLoadProcessor postLoad, @Nullable BlendingData blendingData + Level level, CubePos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, + @Nullable LevelChunkSection[] sections, @Nullable LevelCube.PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { super(pos, data, level, level.registryAccess().lookupOrThrow(Registries.BIOME), inhabitedTime, sections, blendingData); this.level = level; @@ -117,7 +116,7 @@ public LevelCube( public LevelCube(ServerLevel level, ProtoCube cube, @Nullable LevelCube.PostLoadProcessor postLoad) { this(level, cube.cc_getCubePos(), cube.getUpgradeData(), cube.unpackBlockTicks(), cube.unpackFluidTicks(), cube.getInhabitedTime(), - cube.getSections(), postLoad, cube.getBlendingData()); + cube.getSections(), postLoad, cube.getBlendingData()); if (!Collections.disjoint(cube.pendingBlockEntities.keySet(), cube.blockEntities.keySet())) { LOGGER.error("Cube at {} contains duplicated block entities", cube.cc_getCubePos()); @@ -168,22 +167,18 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { @TransformFromMethod(value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", owner = @Ref(LevelChunk.class)) @Override public native ChunkAccess.PackedTicks getTicksForSerialization(long gameTime); // TODO should this actually be dasm'd? - @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", owner = @Ref(LevelChunk.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); // dasm + mixin - @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", owner = @Ref(LevelChunk.class)) @Override public native @NotNull BlockState getBlockState(BlockPos pos); - @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", owner = @Ref(LevelChunk.class)) @Override public native @NotNull FluidState getFluidState(BlockPos pos); // dasm + mixin @@ -211,7 +206,7 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { if (wasOnlyAir != isOnlyAir) { this.level.getChunkSource().getLightEngine().updateSectionStatus(pos, isOnlyAir); this.level.getChunkSource().onSectionEmptinessChanged(SectionPos.blockToSectionCoord(pos.getX()), - SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ()), isOnlyAir); + SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ()), isOnlyAir); } if (LightEngine.hasDifferentLightProperties(this, pos, previousState, state)) { @@ -247,7 +242,7 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { BlockEntity blockentity1 = this.getBlockEntity(pos, LevelChunk.EntityCreationType.CHECK); if (blockentity1 != null && !blockentity1.isValidBlockState(state)) { LOGGER.warn("Found mismatched block entity @ {}: type = {}, state = {}", pos, - blockentity1.getType().builtInRegistryHolder().key().location(), state); + blockentity1.getType().builtInRegistryHolder().key().location(), state); this.removeBlockEntity(pos); blockentity1 = null; } @@ -274,16 +269,14 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { @Deprecated @Override public native void addEntity(Entity entity); - @TransformFromMethod(value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) private native @Nullable BlockEntity createBlockEntity(BlockPos pos); - @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) @Override public native @Nullable BlockEntity getBlockEntity(BlockPos pos); @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" - + "Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) public native @Nullable BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType); @TransformFromMethod(value = "addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) @@ -298,18 +291,14 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { @TransformFromMethod(value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFromMethod( - value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", owner = @Ref(LevelChunk.class)) @Override public native @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); @TransformFromMethod(value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(LevelChunk.class)) @Override public native void removeBlockEntity(BlockPos pos); // TODO maybe shouldn't be dasm - @TransformFromMethod( - value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", owner = @Ref(LevelChunk.class)) private native void removeGameEventListener(T blockEntity, ServerLevel level); // TODO sectionY is definitely wrong here @@ -327,7 +316,7 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { // TODO this should maybe be dasm + mixin, there's a lot of vanilla code duplication here public void replaceWithPacketData( - FriendlyByteBuf buffer, Map map, Consumer outputTagConsumer + FriendlyByteBuf buffer, Map map, Consumer outputTagConsumer ) { this.clearAllBlockEntities(); @@ -344,7 +333,7 @@ public void replaceWithPacketData( BlockEntity blockentity = this.getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && tag != null && blockentity.getType() == blockEntityType) { blockentity.handleUpdateTag(TagValueInput.create(problemreporter$scopedcollector.forChild(blockentity.problemPath()), - this.level.registryAccess(), tag)); + this.level.registryAccess(), tag)); } }); } @@ -377,10 +366,8 @@ public void postProcessGeneration(ServerLevel serverLevel) { this.pendingBlockEntities.clear(); } - @TransformFromMethod( - value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" - + "Lnet/minecraft/world/level/block/entity/BlockEntity;", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) private native @Nullable BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag); @TransformFromMethod(value = "unpackTicks(J)V", owner = @Ref(LevelChunk.class)) @@ -390,14 +377,12 @@ public void postProcessGeneration(ServerLevel serverLevel) { // @TransformFromMethod(value = @MethodSig("registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk // .class)) // public native void registerTickContainerInLevel(ServerLevel level); - public void registerTickContainerInLevel(ServerLevel level) { - } + public void registerTickContainerInLevel(ServerLevel level) {} - // @TransformFromMethod(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref - // (LevelChunk.class)) + // @TransformFromMethod(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref + // (LevelChunk.class)) // public native void unregisterTickContainerFromLevel(ServerLevel level); - public void unregisterTickContainerFromLevel(ServerLevel level) { - } + public void unregisterTickContainerFromLevel(ServerLevel level) {} @TransformFromMethod(value = "getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;", owner = @Ref(LevelChunk.class)) @Override public native ChunkStatus getPersistedStatus(); @@ -416,16 +401,13 @@ public void unregisterTickContainerFromLevel(ServerLevel level) { public native void registerAllBlockEntitiesAfterLevelLoad(); // TODO (P3): GameEvent stuff is a bit concerning - @TransformFromMethod( - value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", - owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", owner = @Ref(LevelChunk.class)) private native void addGameEventListener(T blockEntity, ServerLevel level); @TransformFromMethod(value = "updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) private native void updateBlockEntityTicker(T blockEntity); - @TransformFromMethod(value = - "createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" + @TransformFromMethod(value = "createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;", owner = @Ref(LevelChunk.class)) private native TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker ticker); @@ -474,8 +456,7 @@ public interface PostLoadProcessor { void run(LevelCube cube); } - @TransformFromClass(value = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), - sets = ChunkToCubeSet.class) + @TransformFromClass(value = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper"), sets = ChunkToCubeSet.class) public class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { private TickingBlockEntity ticker; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java index 199e4bc2..9e7a0dc9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java @@ -56,16 +56,16 @@ public class ProtoCube extends CubeAccess implements ProtoClo { // Constructors mirroring vanilla signatures public ProtoCube( - CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CubePos cubePos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { this(cubePos, upgradeData, null, new ProtoChunkTicks(), new ProtoChunkTicks(), levelHeightAccessor, biomeRegistry, blendingData); } public ProtoCube( - CubePos cubePos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, - ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, - @Nullable BlendingData blendingData + CubePos cubePos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, + ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, + @Nullable BlendingData blendingData ) { super(cubePos, upgradeData, levelHeightAccessor, biomeRegistry, 0L, sections, blendingData); this.status = ChunkStatus.EMPTY; @@ -80,18 +80,15 @@ public ProtoCube( @TransformFromMethod(value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(ProtoChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", owner = @Ref(ProtoChunk.class)) @Override public native ChunkAccess.PackedTicks getTicksForSerialization(long todoNameThis); // dasm + mixin - @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", owner = @Ref(ProtoChunk.class)) @Override public native BlockState getBlockState(BlockPos pos); // dasm + mixin - @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", owner = @Ref(ProtoChunk.class)) @Override public native FluidState getFluidState(BlockPos pos); @Override public @Nullable BlockState setBlockState(BlockPos pos, BlockState state, int flags) { @@ -116,8 +113,7 @@ public ProtoCube( @TransformFromMethod(value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(ProtoChunk.class)) @Override public native @Nullable BlockEntity getBlockEntity(BlockPos pos); @TransformFromMethod(value = "getBlockEntities()Ljava/util/Map;", owner = @Ref(ProtoChunk.class)) @@ -146,8 +142,7 @@ public ProtoCube( @TransformFromMethod(value = "packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S", owner = @Ref(ProtoChunk.class)) public static native short packOffsetCoordinates(BlockPos pos); - @TransformFromMethod(value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;", owner = @Ref(ProtoChunk.class)) public static native BlockPos unpackOffsetCoordinates(short packedPos, int yOffset, ChunkPos chunkPos); // dasm + mixin @@ -160,9 +155,7 @@ public ProtoCube( @TransformFromMethod(value = "getBlockEntityNbts()Ljava/util/Map;", owner = @Ref(ProtoChunk.class)) @Override public native Map getBlockEntityNbts(); - @TransformFromMethod( - value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", owner = @Ref(ProtoChunk.class)) @Override public native @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); @TransformFromMethod(value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ProtoChunk.class)) @@ -184,8 +177,7 @@ public ProtoCube( // Below-zero retrogen is unused in CC, hence empty method body } - @TransformFromMethod(value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;", - owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) private static native LevelChunkTicks unpackTicks(ProtoChunkTicks ticks); @TransformFromMethod(value = "unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java index 1172b75d..51212cfb 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java @@ -22,14 +22,12 @@ public CubeStep getStepTo(ChunkStatus status) { return this.steps.get(status.getIndex()); } - @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, - field = "GENERATION_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") + @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = "GENERATION_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") public static CubePyramid CC_GENERATION_PYRAMID_CUBES; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, - field = "LOADING_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") + @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = "LOADING_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") public static CubePyramid CC_LOADING_PYRAMID_CUBES; - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkPyramid.class), value = "()V") + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkPyramid.class), value = "") static void initCubePyramids() { throw new DasmFailedToApply(); } @@ -40,6 +38,5 @@ static void initCubePyramids() { @Dasm(ChunkToCubeSet.class) @TransformFromClass(sets = ChunkToCubeSet.class, value = @Ref(ChunkPyramid.Builder.class)) - public static class Builder { - } + public static class Builder {} } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java index 4fbe57e1..7be761ac 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java @@ -31,8 +31,7 @@ */ @Dasm(ChunkToCubeSet.class) public class CubeStatusTasks { - private CubeStatusTasks() { - } + private CubeStatusTasks() {} @AddFieldToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, field = "LOGGER:Lorg/slf4j/Logger;") private static final Logger LOGGER = LogUtils.getLogger(); @@ -41,60 +40,54 @@ private CubeStatusTasks() { @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private static native boolean isLighted(CubeAccess cube); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture passThrough( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return CompletableFuture.completedFuture(cube); } // TODO (P3) we skip cube generation steps for now by delegating to passThrough - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureStarts( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture loadStructureStarts( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureReferences( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateBiomes( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } @SuppressWarnings("checkstyle:MagicNumber") // hardcoded terrain generation; the constants are arbitrary - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateNoise( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { // Temporary basic sinusoidal terrain, so we can generate a simple test world int amplitude = 20; @@ -108,7 +101,7 @@ public static CompletableFuture generateNoise( for (int x = 0; x < CubicConstants.DIAMETER_IN_BLOCKS; x++) { for (int z = 0; z < CubicConstants.DIAMETER_IN_BLOCKS; z++) { if (y + Math.round((amplitude * (Math.sin((x + cubeX) / 8.0 + (z + cubeZ) / 21.0) + Math.cos((z + cubeZ) / 13.0))) - / 2.0) <= CubicChunks.SUPERFLAT_HEIGHT) { + / 2.0) <= CubicChunks.SUPERFLAT_HEIGHT) { cube.setBlockState(blockPos.set(x, y, z), blockState); } } @@ -117,56 +110,50 @@ public static CompletableFuture generateNoise( return CompletableFuture.completedFuture(cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSurface( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateCarvers( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateFeatures( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture initializeLight( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture light( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, - method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSpawn( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } @@ -174,15 +161,13 @@ public static CompletableFuture generateSpawn( // Upgrade ProtoCube to LevelCube // dasm + mixin @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), - value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static native CompletableFuture full( - WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube + WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ); @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), - value = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") private static native void postLoadProtoCube(ServerLevel level, ValueInput.ValueInputList entityTags); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java index 62801cfc..eb06a06e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java @@ -26,20 +26,20 @@ * {@link ChunkStep} represents a single step in either chunk loading or chunk generation. This class represents a single step in cube loading or * generation. It is identical to {@code ChunkStep}, but stores a {@link CubeStatusTask} instead of a {@link ChunkStatusTask}. * - * @param targetStatus The status that this step corresponds to. - * @param directDependencies The dependencies of this individual step, by radius. Always includes the parent status at radius zero (except for - * EMPTY, which has no parent), and may have additional dependencies. + * @param targetStatus The status that this step corresponds to. + * @param directDependencies The dependencies of this individual step, by radius. Always includes the parent status at radius zero (except for + * EMPTY, which has no parent), and may have additional dependencies. * @param accumulatedDependencies All dependencies needed to reach this step from unloaded, by radius. Effectively a combination of the - * directDependencies of this step and all previous steps. - * @param blockStateWriteRadius The radius of chunks that can receive blockstate writes. 0 if only the center chunk can; -1 if there are no - * blockstate writes. Always -1 for chunk loading. - * @param task The chunk loading or generation task for this step. + * directDependencies of this step and all previous steps. + * @param blockStateWriteRadius The radius of chunks that can receive blockstate writes. 0 if only the center chunk can; -1 if there are no + * blockstate writes. Always -1 for chunk loading. + * @param task The chunk loading or generation task for this step. */ @Dasm(ChunkToCubeSet.class) @TransformFromClass(sets = ChunkToCubeSet.class, value = @Ref(ChunkStep.class)) public record CubeStep( - ChunkStatus targetStatus, ChunkDependencies directDependencies, ChunkDependencies accumulatedDependencies, int blockStateWriteRadius, - CubeStatusTask task + ChunkStatus targetStatus, ChunkDependencies directDependencies, ChunkDependencies accumulatedDependencies, int blockStateWriteRadius, + CubeStatusTask task ) { public int getAccumulatedRadiusOf(ChunkStatus status) { throw new DasmFailedToApply(); @@ -52,13 +52,11 @@ public CompletableFuture apply(WorldGenContext worldGenContext, Stat @Dasm(ChunkToCubeSet.class) public static class Builder { private final ChunkStatus status; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, - field = "parent:Lio/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep;") + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = "parent:Lnet/minecraft/world/level/chunk/status/ChunkStep;") private final @Nullable CubeStep parent; private ChunkStatus[] directDependenciesByRadius; private int blockStateWriteRadius = -1; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, - field = "task:Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;") + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = "task:Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;") private CubeStatusTask task = (worldGenContext, step, cache, cube) -> CompletableFuture.completedFuture(cube); @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @@ -66,8 +64,7 @@ protected Builder(ChunkStatus status) { throw new DasmFailedToApply(); } - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), - value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/status/ChunkStep;)V") + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/status/ChunkStep;)V") protected Builder(ChunkStatus status, CubeStep parent) { throw new DasmFailedToApply(); } @@ -98,19 +95,16 @@ public CubeStep.Builder blockStateWriteRadius(int blockStateWriteRadiusInSection return this; } - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), - value = "setTask(Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;)Lnet/minecraft/world/level/chunk/status/ChunkStep$Builder;") + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "setTask(Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;)Lnet/minecraft/world/level/chunk/status/ChunkStep$Builder;") public native CubeStep.Builder setTask(CubeStatusTask task); @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "build()Lnet/minecraft/world/level/chunk/status/ChunkStep;") public native CubeStep build(); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), - value = "buildAccumulatedDependencies()[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "buildAccumulatedDependencies()[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") private native ChunkStatus[] buildAccumulatedDependencies(); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), - value = "getRadiusOfParent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "getRadiusOfParent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") private native int getRadiusOfParent(ChunkStatus parentStatus); } } From 05cd534d3e51f148d6ec60fc462e6ebc918d48f3 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Fri, 12 Dec 2025 07:59:24 +0000 Subject: [PATCH 3/4] Update to dasm-neoforge 3.2.0 --- .gitignore | 1 + build.gradle | 18 +- .../opencubicchunks/gradle/DasmAutoGen.java | 29 ++ .../gradle/DasmGenExtension.java | 189 ++++++++++++ ....opencubicchunks.gradle.dasmgen.properties | 1 + .../cubicchunks/mixin/ASMConfigPlugin.java | 278 +----------------- .../MixinClientCubeCache$Storage.java | 8 - .../MixinCCCommonHooks.java | 8 - .../MixinCCEventHooks.java | 8 - .../common/server/level/MixinChunkHolder.java | 6 +- .../level/MixinChunkMap$TrackedEntity.java | 2 +- .../common/server/level/MixinChunkMap.java | 16 +- .../MixinCloTrackingView$Positioneed.java | 8 - .../server/level/MixinCloTrackingView.java | 9 - .../common/server/level/MixinCubeLevel.java | 8 - .../server/level/MixinServerChunkCache.java | 12 +- .../network/MixinPlayerChunkSender.java | 4 +- .../chunk/status/MixinCCChunkStatusTasks.java | 8 - .../world/level/cube/MixinCubeAccess.java | 8 - .../world/level/cube/MixinEmptyLevelCube.java | 8 - .../level/cube/MixinImposterProtoCube.java | 1 - ...ixinLevelCube$BoundTickingBlockEntity.java | 7 - ...e$RebindableTickingBlockEntityWrapper.java | 7 - .../world/level/cube/MixinLevelCube.java | 7 +- .../world/level/cube/MixinProtoCube.java | 7 +- .../cube/status/MixinCubePyramid$Builder.java | 8 - .../level/cube/status/MixinCubePyramid.java | 8 - .../cube/status/MixinCubeStatusTasks.java | 3 +- .../cube/status/MixinCubeStep$Builder.java | 8 - .../level/cube/status/MixinCubeStep.java | 1 - .../resources/META-INF/neoforge.mods.toml | 7 +- 31 files changed, 268 insertions(+), 425 deletions(-) create mode 100644 buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java create mode 100644 buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java delete mode 100644 src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java diff --git a/.gitignore b/.gitignore index 3a114d14..320872ba 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ forge*changelog.txt # Cubic Chunks generated files cubicchunks.mixins.*.json +cubicchunks.dasm.json # Dasm .dasm.out diff --git a/build.gradle b/build.gradle index 1b534158..d6f79ca9 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ plugins { id("io.github.opencubicchunks.javaheaders").version("1.2.8") id("io.github.opencubicchunks.gradle.mcGitVersion") id("io.github.opencubicchunks.gradle.mixingen") + id("io.github.opencubicchunks.gradle.dasmgen") } version = mod_version @@ -66,7 +67,16 @@ tasks.register("generatePackageInfo") { tasks.register("genAll") { group = "filegen" - dependsOn(generatePackageInfo, generateMixinConfigs) + dependsOn(generatePackageInfo, generateMixinConfigs, generateDasmConfigs) +} + +dasmGen { + filePattern = "%s.dasm.json" + defaultMinVersion = "0.8" + + config(sourceSets.main, "cubicchunks") { + it.packageName = "io.github.opencubicchunks.cubicchunks" + } } mixinGen { @@ -268,9 +278,9 @@ dependencies { targetConfiguration = "testArchivesOutput" } - libraries("io.github.notstirred:dasm:3.1.0") { - transitive = false - } + compileOnly("io.github.notstirred:dasm:3.2.0:api") + runtimeOnly(jarJar("io.github.notstirred:dasm-neoforge:3.2.0")) + libraries("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT") libraries("org.spongepowered:noise:2.0.0-SNAPSHOT") diff --git a/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java new file mode 100644 index 00000000..f560f67f --- /dev/null +++ b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java @@ -0,0 +1,29 @@ +package io.github.opencubicchunks.gradle; + +import java.io.IOException; +import java.io.UncheckedIOException; + +import javax.annotation.Nonnull; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.plugins.JavaPluginConvention; + +public class DasmAutoGen implements Plugin { + + @Override public void apply(@Nonnull Project target) { + DasmGenExtension dasmExtension = new DasmGenExtension(); + target.getExtensions().add("dasmGen", dasmExtension); + Task generateDasmConfigs = target.getTasks().create("generateDasmConfigs"); + generateDasmConfigs.setGroup("filegen"); + generateDasmConfigs.doLast(task -> { + JavaPluginConvention convention = Utils.getJavaPluginConvention(target); + try { + dasmExtension.generateFiles(convention); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + } +} diff --git a/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java new file mode 100644 index 00000000..1dbd47d9 --- /dev/null +++ b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java @@ -0,0 +1,189 @@ +package io.github.opencubicchunks.gradle; + +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static org.apache.tools.ant.util.StringUtils.removePrefix; +import static org.apache.tools.ant.util.StringUtils.removeSuffix; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.google.gson.stream.JsonWriter; +import org.gradle.api.Action; +import org.gradle.api.file.SourceDirectorySet; +import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.tasks.SourceSet; + +@SuppressWarnings("unused") +public class DasmGenExtension { + + Pattern pattern = Pattern.compile("(? *)@(Dasm|TransformFromClass).+? (interface|class|record) (?\\w+)?", Pattern.DOTALL); + + private final Map>> configsBySourceSet = new HashMap<>(); + + private String filePattern = "dasm.json"; + + private String defaultMinVersion; + + DasmGenExtension() {} + + public void setFilePattern(String pattern) { + this.filePattern = pattern; + } + + public String getFilePattern() { + return this.filePattern; + } + + public String getDefaultMinVersion() { + return defaultMinVersion; + } + + public void setDefaultMinVersion(String defaultMinVersion) { + this.defaultMinVersion = defaultMinVersion; + } + + public void config(SourceSet sourceSet, String name, Action configure) { + configsBySourceSet.computeIfAbsent(sourceSet, s -> new HashMap<>()).put(name, configure); + } + + public static class DasmConfig { + private String packageName; + private String minVersion; + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getMinVersion() { + return minVersion; + } + + public void setMinVersion(String minVersion) { + this.minVersion = minVersion; + } + } + + void generateFiles(JavaPluginConvention convention) throws IOException { + convention.getSourceSets().forEach(sourceSet -> { + Map> configs = configsBySourceSet.get(sourceSet); + if (configs == null) { + return; + } + + Set resourcesSet = sourceSet.getResources().getSrcDirs(); + Path resources; + try { + resources = resourcesSet.iterator().next().getCanonicalFile().toPath(); + } catch (IOException e) { + throw new RuntimeException(e); + } + for (String name : configs.keySet()) { + DasmConfig config = new DasmConfig(); + Action configure = configs.get(name); + if (defaultMinVersion != null) { + config.minVersion = defaultMinVersion; + } + configure.execute(config); + String fileName = String.format(filePattern, name); + + Path path = resources.resolve(fileName); + try { + Files.createDirectories(resources); + try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING))) { + writer.setIndent(" "); + writer.beginObject(); + if (config.packageName != null) { + writer.name("package").value(config.packageName); + } + if (config.minVersion != null) { + writer.name("minVersion").value(config.minVersion); + } + + writeDasm(convention, sourceSet, name, config, writer); + + writer.endObject(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }); + } + + private void writeDasm(JavaPluginConvention convention, SourceSet sourceSet, String name, DasmConfig config, JsonWriter writer) + throws IOException { + Set dasmTypes = getDasmClasses(config, sourceSet.getAllJava()); + + Set classesSet = new HashSet<>(); + Set interfacesSet = new HashSet<>(); + + Path prefixPath = Paths.get(config.packageName.replace('.', '/')); + + Function transform = path -> removePrefix(path.replace(File.separatorChar, '.'), name + "."); + + List types = dasmTypes.stream().map(transform).sorted(Comparator.comparing(a -> a.toLowerCase(Locale.ROOT))).toList(); + + writer.name("dasm").beginArray(); + for (String path : types) { + writer.value(path); + } + writer.endArray(); + } + + private Set getDasmClasses(DasmConfig config, SourceDirectorySet allJava) throws IOException { + System.out.println("GetDasm Classes"); + Set srcPaths = new HashSet<>(); + for (File file : allJava.getSrcDirs()) { + Path toPath = file.getCanonicalFile().toPath(); + System.out.println("GetDasm " + toPath); + + srcPaths.add(toPath); + } + + Set dasmTypes = new HashSet<>(); + for (File it : allJava) { + Path javaClass = it.getCanonicalFile().toPath(); + System.out.println("Class: " + javaClass); + for (Path srcPath : srcPaths) { + if (javaClass.startsWith(srcPath)) { + String relative = srcPath.relativize(javaClass).toString(); + if (relative.replace(File.separatorChar, '.').startsWith(config.packageName) && !relative.endsWith("package-info.java")) { + // This is an abomination. Ideally we'd parse .java files with a library + // This approach works fine for dasm on the outer class and its direct children, any other @Dasm annotation will be + // improperly parsed. (Also assumes our indentation is correct in all java files.) + Matcher matcher = pattern.matcher(Files.readString(javaClass)); + + String clazz = removeSuffix(relative, ".java"); + while (matcher.find()) { + String indent = matcher.group("indent"); + String name = matcher.group("name"); + + String path = indent.isEmpty() ? clazz : clazz + "$" + name; + + dasmTypes.add(path); + } + } + } + } + } + return dasmTypes; + } +} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties new file mode 100644 index 00000000..7c4eaf77 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties @@ -0,0 +1 @@ +implementation-class=io.github.opencubicchunks.gradle.DasmAutoGen diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java index a4d98e54..8ff9c561 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java @@ -2,86 +2,22 @@ import static org.objectweb.asm.Opcodes.*; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Optional; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.annotation.Nullable; -import com.mojang.datafixers.util.Either; -import io.github.notstirred.dasm.annotation.AnnotationParser; -import io.github.notstirred.dasm.annotation.AnnotationUtil; -import io.github.notstirred.dasm.annotation.parse.RefImpl; -import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.transform.ApplicationStage; -import io.github.notstirred.dasm.api.provider.MappingsProvider; -import io.github.notstirred.dasm.exception.DasmException; -import io.github.notstirred.dasm.notify.Notification; -import io.github.notstirred.dasm.transformer.Transformer; -import io.github.notstirred.dasm.transformer.data.ClassTransform; -import io.github.notstirred.dasm.transformer.data.MethodTransform; -import io.github.notstirred.dasm.util.CachingClassProvider; -import io.github.notstirred.dasm.util.Format; -import io.github.notstirred.dasm.util.NotifyStack; -import io.github.notstirred.dasm.util.Pair; import io.github.opencubicchunks.cc_core.annotation.Public; -import io.github.opencubicchunks.cubicchunks.CubicChunks; import io.github.opencubicchunks.cubicchunks.util.asm.FactoryFromConstructor; -import net.minecraft.Util; -import net.neoforged.fml.loading.FMLEnvironment; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; -import org.spongepowered.asm.mixin.transformer.ClassInfo; -import org.spongepowered.asm.service.MixinService; public class ASMConfigPlugin implements IMixinConfigPlugin { - private final Map dasmTransformedInPreApply = new ConcurrentHashMap<>(); - private final Transformer transformer; - private final AnnotationParser annotationParser; - - private final Map>> preApplyTargets = new HashMap<>(); - private final Map>> postApplyTargets = new HashMap<>(); - - private final Logger logger = LogManager.getLogger("dasm"); - - @SuppressWarnings("checkstyle:EmptyCatchBlock") // <-- TODO stirred's problem not mine :) - public ASMConfigPlugin() { - boolean developmentEnvironment = false; - try { - developmentEnvironment = !FMLEnvironment.production; - } catch (Throwable ignored) {} - MappingsProvider mappings = MappingsProvider.IDENTITY; - - // TODO: breaks on fabric (remapped at runtime) - var classProvider = new CachingClassProvider(s -> { - try (var classStream = ASMConfigPlugin.class.getClassLoader().getResourceAsStream(s.replace(".", "/") + ".class")) { - return Optional.ofNullable(classStream.readAllBytes()); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - this.transformer = new Transformer(classProvider, mappings); - this.annotationParser = new AnnotationParser(classProvider); - } + public ASMConfigPlugin() {} @Override public void onLoad(String mixinPackage) {} @@ -89,63 +25,7 @@ public ASMConfigPlugin() { return null; } - @SuppressWarnings("checkstyle:CyclomaticComplexity") // I'm to lazy to fix this as the class is hopefully being deleted soon @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - try { - ClassNode targetClass = MixinService.getService().getBytecodeProvider().getClassNode(targetClassName); - ClassNode mixinClass = MixinService.getService().getBytecodeProvider().getClassNode(mixinClassName); - - // Helpfully crash if dasm target doesn't make sense for a mixin class. This uses a ton of mostly static dasm internals. - AnnotationNode dasmAnnotation = AnnotationUtil.getAnnotationIfPresent(mixinClass.invisibleAnnotations, Dasm.class); - if (dasmAnnotation != null) { - Optional dasmTarget = RefImpl - .parseOptionalRefAnnotation((AnnotationNode) AnnotationUtil.getAnnotationValues(dasmAnnotation, Dasm.class).get("target")); - if (dasmTarget.isEmpty() || dasmTarget.get().equals(Type.getType(Dasm.SELF_TARGET.class))) { - throw new RuntimeException("Mixin class " + Format.formatObjectType(Type.getObjectType(mixinClass.name)) - + " with @Dasm annotation should probably have a @Dasm(value = Set.class, target = ...) targeting the mixin target class"); - } - } - - // PRE_APPLY - handleError(this.annotationParser.findDasmAnnotations(mixinClass)); - var methodTransformsMixin = handleError(this.annotationParser.buildContext().buildMethodTargets(mixinClass, "cc_dasm$")); - handleError(this.annotationParser.findDasmAnnotations(targetClass)); - var classTransform = handleError(this.annotationParser.buildContext().buildClassTarget(targetClass)); - var methodTransformsTarget = handleError(this.annotationParser.buildContext().buildMethodTargets(targetClass, "cc_dasm$")); - - var methodTransforms = Stream.of(methodTransformsTarget, methodTransformsMixin).filter(Optional::isPresent).map(Optional::get) - .flatMap(Collection::stream).toList(); - - String key = mixinClassName + "|" + targetClassName; - if (classTransform.isPresent()) { - // TODO: nice error - assert methodTransformsMixin.isEmpty() && methodTransforms.isEmpty() : "Whole class transform WITH method transforms?"; - ClassTransform transform = classTransform.get(); - if (transform.stage() == ApplicationStage.PRE_APPLY) { - this.preApplyTargets.put(key, Either.left(transform)); - } else { - this.postApplyTargets.put(key, Either.left(transform)); - } - } else { - Collection preTransforms = this.preApplyTargets.computeIfAbsent(key, k -> Either.right(new ArrayList<>())).right() - .get(); - Collection postTransforms = this.postApplyTargets.computeIfAbsent(key, k -> Either.right(new ArrayList<>())).right() - .get(); - methodTransforms.forEach(transform -> { - if (transform.stage() == ApplicationStage.PRE_APPLY) { - preTransforms.add(transform); - } else { - postTransforms.add(transform); - } - }); - } - } catch (DasmException e) { - throw new RuntimeException(e); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } return true; } @@ -155,98 +35,11 @@ public ASMConfigPlugin() { return null; } - @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - boolean wasTransformed; - try { - wasTransformed = transformClass(targetClassName, targetClass, mixinClassName, ApplicationStage.PRE_APPLY); - } catch (DasmException e) { - throw new RuntimeException(e); - } - dasmTransformedInPreApply.put(mixinClassName + "|" + targetClassName, wasTransformed); - - try { - // ugly hack to add class metadata to mixin - // based on - // https://github.com/Chocohead/OptiFabric/blob/54fc2ef7533e43d1982e14bc3302bcf156f590d8/src/main/java/me/modmuss50/optifabric/compat/fabricrendererapi - // /RendererMixinPlugin.java#L25:L44 - Method addMethod = ClassInfo.class.getDeclaredMethod("addMethod", MethodNode.class, boolean.class); - addMethod.setAccessible(true); - - ClassInfo ci = ClassInfo.forName(targetClassName); - Set existingMethods = ci.getMethods().stream().map(x -> x.getName() + x.getDesc()).collect(Collectors.toSet()); - for (MethodNode method : targetClass.methods) { - if (!existingMethods.contains(method.name + method.desc)) { - addMethod.invoke(ci, method, false); - } - } - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - } + @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { doPublicAnnotation(targetClass); doFactoryFromConstructorAnnotation(targetClass); - - // Apply POST_APPLY dasm transforms - boolean wasTransformed; - try { - wasTransformed = transformClass(targetClassName, targetClass, mixinClassName, ApplicationStage.POST_APPLY); - } catch (DasmException e) { - throw new RuntimeException(e); - } - // If no DASM transformation happened to this class, we can skip removing the prefixed methods - if (!(wasTransformed | dasmTransformedInPreApply.get(mixinClassName + "|" + targetClassName))) { - return; - } - - // Find all DASM-added method nodes and their corresponding MixinMerged method nodes - record PrefixMethodPair(MethodNode dasmAddedMethod, MethodNode mixinAddedMethod) {} - List methodPairs = new ArrayList<>(); - for (MethodNode methodNode : targetClass.methods) { - if (methodNode.name.contains("cc_dasm$")) { - var methodNameWithoutPrefix = methodNode.name.substring(methodNode.name.indexOf("$") + 1).replace("__init__", "") - .replace("__clinit__", ""); - - var mixinAddedMethod = targetClass.methods.stream() - .filter(m -> m.name.equals(methodNameWithoutPrefix) && m.desc.equals(methodNode.desc)).findFirst(); - - if (mixinAddedMethod.isEmpty()) { - CubicChunks.LOGGER - .info(String.format("Found DASM added method `%s` without a corresponding MixinMerged method", methodNameWithoutPrefix)); - } - methodPairs.add(new PrefixMethodPair(methodNode, mixinAddedMethod.orElse(null))); - } - } - - // Remove the mixin-added methods and set the dasm-added names - methodPairs.forEach(prefixMethodPair -> { - if (prefixMethodPair.mixinAddedMethod != null) { - targetClass.methods.remove(prefixMethodPair.mixinAddedMethod); - - // Copy annotations and visibility from mixin method - prefixMethodPair.dasmAddedMethod.visibleAnnotations = prefixMethodPair.mixinAddedMethod.visibleAnnotations; - prefixMethodPair.dasmAddedMethod.invisibleAnnotations = prefixMethodPair.mixinAddedMethod.invisibleAnnotations; - prefixMethodPair.dasmAddedMethod.access &= ~(ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED); - prefixMethodPair.dasmAddedMethod.access |= (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED) & prefixMethodPair.mixinAddedMethod.access; - } - - prefixMethodPair.dasmAddedMethod.name = prefixMethodPair.dasmAddedMethod.name.replace("__init__", "").replace("__clinit__", - ""); - - // remove the prefix - prefixMethodPair.dasmAddedMethod.name = prefixMethodPair.dasmAddedMethod.name.substring("cc_dasm$".length()); - }); - - ClassWriter classWriter = new ClassWriter(0); - targetClass.accept(classWriter); - try { - Path path = Path.of(".dasm.out/" + "POSTIER_APPLY" + "/" + targetClassName.replace('.', '/') + ".class").toAbsolutePath(); - Files.createDirectories(path.getParent()); - Files.write(path, classWriter.toByteArray()); - } catch (IOException e) { - throw new RuntimeException(e); - } } private void doPublicAnnotation(ClassNode targetClass) { @@ -303,71 +96,4 @@ private static void transformStubToFactory(MethodNode method) { method.desc.substring(0, method.desc.lastIndexOf(')') + 1) + "V", false); method.visitInsn(ARETURN); } - - /** - * @return Whether any transformation was done to the targetClass - */ - private boolean transformClass(String targetClassName, ClassNode targetClass, String mixinClassName, ApplicationStage stage) - throws DasmException { - Either> target = null; - switch (stage) { - case PRE_APPLY -> { - target = preApplyTargets.get(mixinClassName + "|" + targetClassName); - } - case POST_APPLY -> { - target = postApplyTargets.get(mixinClassName + "|" + targetClassName); - } - default -> throw new IllegalStateException("Unknown enum variant: " + stage); - } - if (target == null) { - return false; - } - - if (target.left().isPresent()) { - this.transformer.transform(targetClass, target.left().get()); - } else { - this.transformer.transform(targetClass, target.right().get()); - } - ClassWriter classWriter = new ClassWriter(0); - targetClass.accept(classWriter); - try { - Path path = Path.of(".dasm.out/" + stage + "/" + targetClassName.replace('.', '/') + ".class").toAbsolutePath(); - Files.createDirectories(path.getParent()); - Files.write(path, classWriter.toByteArray()); - } catch (IOException e) { - throw new RuntimeException(e); - } - - return true; - } - - private T handleError(Pair> result) { - handleError(result.second()); - return result.first(); - } - - private void handleError(NotifyStack notifyStack) { - handleError(notifyStack.notifications()); - } - - private void handleError(List notifications) { - for (var notification : notifications) { - switch (notification.kind) { - case INFO: - logger.info(notification.message); - break; - case WARNING: - logger.warn(notification.message); - break; - case ERROR: - logger.fatal(notification.message); - break; - default: - throw new IllegalStateException("Unknown enum variant: " + notification.kind); - } - } - if (notifications.stream().anyMatch(n -> n.kind == Notification.Kind.ERROR)) { - throw Util.pauseInIde(new RuntimeException("DASM Failure, please see log output")); - } - } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java deleted file mode 100644 index 4b315e95..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.client.multiplayer; - -import io.github.opencubicchunks.cubicchunks.client.multiplayer.ClientCubeCache; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(ClientCubeCache.Storage.class) -public class MixinClientCubeCache$Storage {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java deleted file mode 100644 index 93bdc169..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.movetoforgesourcesetlater; - -import io.github.opencubicchunks.cubicchunks.movetoforgesourcesetlater.CCCommonHooks; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CCCommonHooks.class) -public class MixinCCCommonHooks {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java deleted file mode 100644 index 4fbc0b53..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.movetoforgesourcesetlater; - -import io.github.opencubicchunks.cubicchunks.movetoforgesourcesetlater.CCEventHooks; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CCEventHooks.class) -public class MixinCCEventHooks {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java index 4a8fb6ef..619c2280 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java @@ -108,7 +108,7 @@ public void cc_onBlockChanged(BlockPos pos, CallbackInfoReturnable cir) @TransformFromMethod("blockChanged(Lnet/minecraft/core/BlockPos;)Z") private native boolean cc_blockChanged(BlockPos pos); - @Dynamic @Redirect(method = "cc_dasm$cc_blockChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_blockChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) private int cc_onBlockChanged_sectionIndex(LevelHeightAccessor instance, int y, BlockPos pos) { return Coords.sectionToIndex(Coords.blockToSection(pos.getX()), Coords.blockToSection(pos.getY()), Coords.blockToSection(pos.getZ())); } @@ -130,7 +130,7 @@ public void cc_onSectionLightChanged(LightLayer lightLayer, int sectionY, Callba // TODO (P2) lighting - ClientboundLightUpdatePacket branch is currently never reached; once we have lighting it will have to be a CC packet, and // this.broadcast will need to redirect to a CC method - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instance, int sectionIndex) { // The vanilla method uses SectionPos.of(ChunkPos, sectionY), but we want SectionPos.of(CubePos, sectionIndex). // The easiest way to accomplish this is to turn `getSectionYFromSectionIndex` into a no-op so that we get sectionIndex instead of sectionY. @@ -138,7 +138,7 @@ private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instan return sectionIndex; } - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) + @Dynamic @Redirect(method = "cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) private SectionPos cc_onBroadcastCubeChanges_sectionPos(CubePos cubePos, int sectionIndex) { return Coords.sectionPosByIndex(cubePos, sectionIndex); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java index 6b18d840..5c8ffcd5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java @@ -25,7 +25,7 @@ public abstract class MixinChunkMap$TrackedEntity { @TransformFromMethod("updatePlayer(Lnet/minecraft/server/level/ServerPlayer;)V") public native void cc_updatePlayer(ServerPlayer player); - @Dynamic @Redirect(method = "cc_dasm$cc_updatePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_updatePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_updatePlayer_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z) { // FIXME entity clo position once implemented return false; // ((CubicChunkMap) instance).cc_isChunkTracked(player, this.entity.chunkPosition().x, 0, this.entity.chunkPosition().z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java index 20bb039e..9cd24bd6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java @@ -195,7 +195,7 @@ private native CompletableFuture>> cc_getChunkRangeF * Cubes require different adjacency logic compared to Chunks */ @SuppressWarnings("checkstyle:CyclomaticComplexity") // <-- TODO this method is just a bit of a disaster - @Dynamic @Inject(method = "cc_dasm$cc_getChunkRangeFuture", at = @At("HEAD"), cancellable = true) + @Dynamic @Inject(method = "cc_getChunkRangeFuture", at = @At("HEAD"), cancellable = true) private void cc_onGetChunkRangeFuture( ChunkHolder cloHolder, int radius, IntFunction statusByRadius, CallbackInfoReturnable>>> cir @@ -327,7 +327,7 @@ private CompletableFuture cc_scheduleChunkLoad(CubePos cubePos) { return cc_scheduleChunkLoad(CloPos.cube(cubePos)); } - @Dynamic @Redirect(method = "cc_dasm$cc_scheduleChunkLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)" + @Dynamic @Redirect(method = "cc_scheduleChunkLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)" + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManager instance, CloPos cloPos) { // TODO (P2) save/load - PoiManager @@ -359,7 +359,7 @@ public native CompletableFuture cc_applyCubeStep( GenerationChunkHolder generationchunkholder, CubeStep chunkstep, StaticCache3D cache ); - @Dynamic @Redirect(method = "cc_dasm$cc_applyCubeStep", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) + @Dynamic @Redirect(method = "cc_applyCubeStep", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) private Object cc_onApplyCubeStep_staticCacheGet(StaticCache3D instance, int x, int z, @Local(ordinal = 0) CubePos cubePos) { return instance.get(cubePos.getX(), cubePos.getY(), cubePos.getZ()); } @@ -446,7 +446,7 @@ private boolean cc_save(CloAccess cloAccess) { // /** // * Redirect error logging to log with CloPos // */ -// @Dynamic @Inject(method = "cc_dasm$cc_save", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;getX +// @Dynamic @Inject(method = "cc_save", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;getX // ()I"), cancellable = true) // private void cc_onSave_errorLog(CloAccess cloAccess, CallbackInfoReturnable cir, @Local Exception exception) { // LOGGER.error("Failed to save chunk or cube {}", cloAccess.cc_getCloPos().toString(), exception); @@ -522,7 +522,7 @@ private boolean cc_save(CloAccess cloAccess) { @TransformFromMethod("updateChunkTracking(Lnet/minecraft/server/level/ServerPlayer;)V") private native void cc_updateChunkTracking(ServerPlayer player); - @Dynamic @WrapOperation(method = "cc_dasm$cc_updateChunkTracking", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) + @Dynamic @WrapOperation(method = "cc_updateChunkTracking", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPlayer player, Operation original) { return Coords.sectionToCubeRenderDistance(original.call(instance, player)); } @@ -533,7 +533,7 @@ private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPl @TransformFromMethod("applyChunkTrackingView(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/server/level/ChunkTrackingView;)V") private native void cc_applyChunkTrackingView(ServerPlayer player, CloTrackingView chunkTrackingView); - @Dynamic @Redirect(method = "cc_dasm$cc_applyChunkTrackingView", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) + @Dynamic @Redirect(method = "cc_applyChunkTrackingView", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( ServerGamePacketListenerImpl instance, Packet packet, ServerPlayer player, CloTrackingView cloTrackingView ) { @@ -547,12 +547,12 @@ private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( @TransformFromMethod("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") public native List cc_getPlayers(CloPos pos, boolean boundaryOnly); - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkOnTrackedBorder(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkOnTrackedBorder(player, pos.getX(), pos.getY(), pos.getZ()); } - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkTracked(player, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java deleted file mode 100644 index 7f34ee6e..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; - -import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CloTrackingView.Positioned.class) -public class MixinCloTrackingView$Positioneed {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java deleted file mode 100644 index d8918e84..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; - -import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -// TODO won't be necessary once we have dasm.json -@Mixin(CloTrackingView.class) -public interface MixinCloTrackingView {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java deleted file mode 100644 index b633464f..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; - -import io.github.opencubicchunks.cubicchunks.server.level.CubeLevel; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubeLevel.class) -public class MixinCubeLevel {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java index e8a76dbd..266245e9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java @@ -126,7 +126,7 @@ private void cc_onInit( @Override public native @Nullable CubeAccess cc_getCube(int chunkX, @AddUnusedParam int chunkY, int chunkZ, ChunkStatus requiredStatus, boolean load); // mixin-into-dasm to replace call to getChunk with getCube - @Dynamic @Inject(method = "cc_dasm$cc_getCube", cancellable = true, at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)" + @Dynamic @Inject(method = "cc_getCube", cancellable = true, at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)" + "Ljava/util/concurrent/CompletableFuture;")) private void cc_getCube_supplyAsync( int pChunkX, int pChunkY, int pChunkZ, ChunkStatus pRequiredStatus, boolean pLoad, CallbackInfoReturnable cir @@ -137,14 +137,14 @@ private void cc_getCube_supplyAsync( // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } // The second through fifth params are the params to the call being redirected; the next three params are the x/y/z coordinates in the params of // getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + @Dynamic @Redirect(method = "cc_getCube", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_getCube_getChunkFutureMainThread( ServerChunkCache instance, int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load, int chunkXRepeated, int chunkY, @@ -158,7 +158,7 @@ private CompletableFuture cc_getCube_getChunkFutureMainThread( // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCubeNow - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCubeNow_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } @@ -199,7 +199,7 @@ private native CompletableFuture> cc_getCubeFutureMainTh // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_getCubeFutureMainThread - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } @@ -209,7 +209,7 @@ private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_hasCube - @Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_hasCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java index 51610ed7..925ee9ab 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java @@ -141,12 +141,12 @@ private static void cc_sendChunk(ServerGamePacketListenerImpl packetListener, Se private native List cc_collectChunksToSend(ChunkMap chunkMap, CloPos cloPos); // FIXME these should probably have some kind of reasonable sort order - at the very least, chunks before cubes - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator1(ToIntFunction keyExtractor) { return (a, b) -> 0; } - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator2(ToIntFunction keyExtractor) { return (a, b) -> 0; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java deleted file mode 100644 index 652aca93..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.chunk.status; - -import io.github.opencubicchunks.cubicchunks.world.level.chunk.status.CCChunkStatusTasks; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CCChunkStatusTasks.class) -public class MixinCCChunkStatusTasks {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java deleted file mode 100644 index ed3eaf48..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubeAccess.class) -public class MixinCubeAccess {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java deleted file mode 100644 index c872850c..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.EmptyLevelCube; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(EmptyLevelCube.class) -public abstract class MixinEmptyLevelCube extends MixinLevelCube {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java index 2d85876d..3cfd847f 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java @@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -// Needed for DASM to apply @Mixin(ImposterProtoCube.class) public abstract class MixinImposterProtoCube extends MixinProtoCube implements ImposterProtoClo { // Field generated by DASM diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java deleted file mode 100644 index 2b9bbe3b..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(targets = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity") -public class MixinLevelCube$BoundTickingBlockEntity {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java deleted file mode 100644 index e8284312..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(targets = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper") -public class MixinLevelCube$RebindableTickingBlockEntityWrapper {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java index 1e0b5d4a..c8683c2c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java @@ -8,13 +8,12 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(LevelCube.class) -public abstract class MixinLevelCube extends MixinCubeAccess { +public abstract class MixinLevelCube { /** * Redirect to use cube section indexing instead of chunk section indexing */ - @Dynamic @Redirect(method = "cc_dasm$getBlockState", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube;getSectionIndex(I)I")) + @Dynamic @Redirect(method = "getBlockState", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube;getSectionIndex(I)I")) private int cc_onGetBlockState_SectionIndex(LevelCube instance, int y, BlockPos pos) { return Coords.blockToIndex(pos); } @@ -22,7 +21,7 @@ private int cc_onGetBlockState_SectionIndex(LevelCube instance, int y, BlockPos /** * Redirect to use cube section indexing instead of chunk section indexing */ - @Dynamic @Redirect(method = "cc_dasm$getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + @Dynamic @Redirect(method = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + "/world/level/cube/LevelCube;getSectionIndex(I)I")) private int cc_onGetFluidState_SectionIndex(LevelCube instance, int yUnused, int x, int y, int z) { return Coords.blockToIndex(x, y, z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java index 4743999b..41355c8b 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java @@ -8,14 +8,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(ProtoCube.class) -public abstract class MixinProtoCube extends MixinCubeAccess { +public abstract class MixinProtoCube { /** * Redirect to use cube section indexing instead of chunk section indexing */ - @Dynamic @Redirect(method = { "markPosForPostprocessing", "cc_dasm$getBlockState", - "cc_dasm$getFluidState" }, at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + @Dynamic @Redirect(method = { "markPosForPostprocessing", "getBlockState", + "getFluidState" }, at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + "/world/level/cube/ProtoCube;getSectionIndex(I)I")) private int cc_onGetBlockState_SectionIndex(ProtoCube instance, int i, BlockPos pos) { return Coords.blockToIndex(pos); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java deleted file mode 100644 index 84b6b073..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube.status; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubePyramid; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubePyramid.Builder.class) -public class MixinCubePyramid$Builder {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java deleted file mode 100644 index 5cc74ac9..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube.status; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubePyramid; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubePyramid.class) -public class MixinCubePyramid {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java index a645d17f..fe76b639 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java @@ -11,10 +11,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(CubeStatusTasks.class) public class MixinCubeStatusTasks { - @Dynamic @Redirect(method = "cc_dasm$full", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) + @Dynamic @Redirect(method = "full", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) private static Object onFullCube_cacheGet(StaticCache3D instance, int x, int z, @Local(ordinal = 0) CubePos cubePos) { return instance.get(x, cubePos.getY(), z); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java deleted file mode 100644 index c561169c..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube.status; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubeStep; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubeStep.Builder.class) -public class MixinCubeStep$Builder {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java index 4653b7fc..44e68977 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java @@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(CubeStep.class) public class MixinCubeStep { @Dynamic @Redirect(method = "apply", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/jfr/JvmProfiler;onChunkGenerate(Lio/github/opencubicchunks/cc_core/api/CubePos;Lnet/minecraft/resources/ResourceKey;Ljava/lang/String;)Lnet/minecraft/util/profiling/jfr/callback/ProfiledDuration;")) diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 04866125..bc5ead61 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -73,7 +73,10 @@ description='''${mod_description}''' #[features.${mod_id}] #openGLVersion="[3.2,)" [[mixins]] -config="${mod_id}.mixins.core.json" + config="${mod_id}.mixins.core.json" [[mixins]] -config="${mod_id}.mixins.access.json" \ No newline at end of file + config="${mod_id}.mixins.access.json" + +[[dasm]] + config="${mod_id}.dasm.json" From b347367c121804b3ec0a22b9f2be06c59e752387 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Sun, 14 Dec 2025 01:12:31 +0000 Subject: [PATCH 4/4] Fix dasm in tests --- src/test/resources/META-INF/neoforge.mods.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/resources/META-INF/neoforge.mods.toml b/src/test/resources/META-INF/neoforge.mods.toml index 82714393..2a0dc255 100644 --- a/src/test/resources/META-INF/neoforge.mods.toml +++ b/src/test/resources/META-INF/neoforge.mods.toml @@ -80,3 +80,7 @@ config="${mod_id}.mixins.access.json" [[mixins]] config="${mod_id}.mixins.test.json" + + +[[dasm]] +config="${mod_id}.dasm.json"