From c183562fec967a8d8486223909ad0ef8b111d20e Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Thu, 25 Jan 2024 02:58:03 +0000 Subject: [PATCH 1/6] Update to dasm `@MethodSig`s --- .../level/MixinChunkTaskPriorityQueue.java | 3 +- .../MixinChunkTaskPriorityQueueSorter.java | 3 +- .../server/level/MixinDistanceManager.java | 15 +- .../server/level/MixinTickingTracker.java | 7 +- .../core/common/world/level/MixinLevel.java | 8 +- .../world/level/cube/CubeAccess.java | 192 ++++++++++++++---- .../world/level/cube/LevelCube.java | 101 +++++---- .../world/level/cube/ProtoCube.java | 138 ++++++++++--- 8 files changed, 335 insertions(+), 132 deletions(-) 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 453f96e4..00247f0f 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 @@ -3,6 +3,7 @@ import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.server.level.ChunkTaskPriorityQueue; import net.minecraft.world.level.ChunkPos; @@ -29,6 +30,6 @@ private void cc_onResortChunkTasks(int queueLevel, ChunkPos chunkPos, int ticket } @UsedFromASM - @TransformFrom("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V") + @TransformFrom(@MethodSig("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V")) protected abstract void resortCubicTasks(int queueLevel, CloPos cloPos, int ticketLevel); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueueSorter.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueueSorter.java index b5d8f768..3907fab5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueueSorter.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueueSorter.java @@ -12,6 +12,7 @@ import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; import io.github.opencubicchunks.cubicchunks.server.level.CubicTaskPriorityQueueSorter; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.server.level.ChunkTaskPriorityQueueSorter; import net.minecraft.world.level.ChunkPos; @@ -48,6 +49,6 @@ private void cc_onChunkOnLevelChange(ChunkPos chunkPos, IntSupplier p_140617_, i @Override @UsedFromASM - @TransformFrom("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") + @TransformFrom(@MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) public abstract void onLevelChange(CloPos cloPos, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinDistanceManager.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinDistanceManager.java index 5941bf8b..1d3e3d69 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinDistanceManager.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinDistanceManager.java @@ -10,6 +10,7 @@ import io.github.opencubicchunks.cubicchunks.server.level.CubicTicketType; import io.github.opencubicchunks.cubicchunks.server.level.CubicTickingTracker; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.core.SectionPos; @@ -57,36 +58,36 @@ private void cc_onUseChunkPos(CallbackInfo ci){ @Override @UsedFromASM - @TransformFrom("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V") + @TransformFrom(@MethodSig("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) public abstract void addTicket(TicketType type, CloPos pos, int level, T value); @Override @UsedFromASM - @TransformFrom("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V") + @TransformFrom(@MethodSig("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) public abstract void removeTicket(TicketType type, CloPos pos, int level, T value); @Override @UsedFromASM - @TransformFrom("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V") + @TransformFrom(@MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) public abstract void addRegionTicket(TicketType type, CloPos pos, int distance, T value); @Override @UsedFromASM - @TransformFrom("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V") + @TransformFrom(@MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V")) public abstract void addRegionTicket(TicketType type, CloPos pos, int distance, T value, boolean forceTicks); @Override @UsedFromASM - @TransformFrom("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V") + @TransformFrom(@MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) public abstract void removeRegionTicket(TicketType type, CloPos pos, int distance, T value); @Override @UsedFromASM - @TransformFrom("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V") + @TransformFrom(@MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V")) public abstract void removeRegionTicket(TicketType type, CloPos pos, int distance, T value, boolean forceTicks); @UsedFromASM - @TransformFrom("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)V") + @TransformFrom(@MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)V")) protected abstract void updateCubeForced(CloPos pos, boolean add); /** diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinTickingTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinTickingTracker.java index fbd3a3dc..4e1c4bcf 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinTickingTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinTickingTracker.java @@ -6,6 +6,7 @@ import io.github.opencubicchunks.cubicchunks.server.level.CubicTicketType; import io.github.opencubicchunks.cubicchunks.server.level.CubicTickingTracker; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.server.level.FullChunkStatus; @@ -67,12 +68,12 @@ private TicketType cc_replaceTicketType(Operation> origi return CubicTicketType.PLAYER; } - @TransformFrom("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V") + @TransformFrom(@MethodSig("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) public abstract void addTicket(TicketType type, CloPos cloPos, int ticketLevel, T key); - @TransformFrom("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V") + @TransformFrom(@MethodSig("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) public abstract void removeTicket(TicketType type, CloPos cloPos, int ticketLevel, T key); - @TransformFrom("getLevel(Lnet/minecraft/world/level/ChunkPos;)I") + @TransformFrom(@MethodSig("getLevel(Lnet/minecraft/world/level/ChunkPos;)I")) public abstract int getLevel(CloPos cloPos); } 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 3fdf9b0c..31d2790f 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 @@ -6,15 +6,15 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; -import io.github.opencubicchunks.cubicchunks.world.level.cube.CubicChunkSource; import io.github.opencubicchunks.cubicchunks.world.level.CubicLevel; import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess; +import io.github.opencubicchunks.cubicchunks.world.level.cube.CubicChunkSource; import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -104,7 +104,7 @@ private boolean cc_replaceLevelChunkInMarkAndNotifyBlock(Level level, BlockPos b return true; } - @TransformFrom("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") + @TransformFrom(@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")) public native void markAndNotifyBlock(BlockPos blockPos, @Nullable LevelCube levelCube, BlockState blockStatePrev, BlockState blockStateNew, int flags, int p_46608_); // getBlockState 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 ff3de75e..bb925a45 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 @@ -16,6 +16,7 @@ import io.github.opencubicchunks.cubicchunks.mixin.CubeAccessAndDescendantsSet; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.Ref; import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; @@ -107,14 +108,17 @@ public CubeAccess( } private static void replaceMissingSections(Registry biomeRegistry, LevelChunkSection[] sections) { - for(int i = 0; i < sections.length; ++i) { + for (int i = 0; i < sections.length; ++i) { if (sections[i] == null) { sections[i] = new LevelChunkSection(biomeRegistry); } } } - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;") + @TransformFrom( + value = @MethodSig("getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); @Override @Nullable public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving); @@ -133,13 +137,22 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return this.getMinBuildHeight(); } - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlockEntitiesPos()Ljava/util/Set;") + @TransformFrom( + value = @MethodSig("getBlockEntitiesPos()Ljava/util/Set;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native Set getBlockEntitiesPos(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;") + @TransformFrom( + value = @MethodSig("getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native LevelChunkSection[] getSections(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;") + @TransformFrom( + value = @MethodSig("getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native LevelChunkSection getSection(int index); // TODO (P2) heightmap methods on cubes @@ -167,31 +180,52 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return cloPos; } - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" - + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;") + @TransformFrom( + value = @MethodSig("getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lnet/minecraft/world/level/levelgen/structure/StructureStart;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override @Nullable public native StructureStart getStartForStructure(Structure structure); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" - + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V") + @TransformFrom( + value = @MethodSig("setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setStartForStructure(Structure structure, StructureStart structureStart); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getAllStarts()Ljava/util/Map;") + @TransformFrom( + value = @MethodSig("getAllStarts()Ljava/util/Map;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native Map getAllStarts(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setAllStarts(Ljava/util/Map;)V") + @TransformFrom( + value = @MethodSig("setAllStarts(Ljava/util/Map;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setAllStarts(Map structureStarts); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" - + "Lit/unimi/dsi/fastutil/longs/LongSet;") + @TransformFrom( + value = @MethodSig("getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native LongSet getReferencesForStructure(Structure structure); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V") + @TransformFrom( + value = @MethodSig("addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void addReferenceForStructure(Structure structure, long reference); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getAllReferences()Ljava/util/Map;") + @TransformFrom( + value = @MethodSig("getAllReferences()Ljava/util/Map;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native Map getAllReferences(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setAllReferences(Ljava/util/Map;)V") + @TransformFrom( + value = @MethodSig("setAllReferences(Ljava/util/Map;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setAllReferences(Map structureReferencesMap); @Override public boolean isYSpaceEmpty(int startY, int endY) { @@ -199,10 +233,16 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return false; } - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setUnsaved(Z)V") + @TransformFrom( + value = @MethodSig("setUnsaved(Z)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setUnsaved(boolean unsaved); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "isUnsaved()Z") + @TransformFrom( + value = @MethodSig("isUnsaved()Z"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native boolean isUnsaved(); @Override public abstract ChunkStatus getStatus(); @@ -214,28 +254,52 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC @Override public abstract void removeBlockEntity(BlockPos pos); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom( + value = @MethodSig("markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void markPosForPostprocessing(BlockPos pos); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;") + @TransformFrom( + value = @MethodSig("getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native ShortList[] getPostProcessing(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "addPackedPostProcess(SI)V") + @TransformFrom( + value = @MethodSig("addPackedPostProcess(SI)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void addPackedPostProcess(short packedPosition, int index); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V") + @TransformFrom( + value = @MethodSig("setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setBlockEntityNbt(CompoundTag tag); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom( + value = @MethodSig("getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override @Nullable public native CompoundTag getBlockEntityNbt(BlockPos pos); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom( + value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override @Nullable public native CompoundTag getBlockEntityNbtForSaving(BlockPos pos); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "findBlockLightSources(Ljava/util/function/BiConsumer;)V") + @TransformFrom( + value = @MethodSig("findBlockLightSources(Ljava/util/function/BiConsumer;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void findBlockLightSources(BiConsumer output); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V") + @TransformFrom( + value = @MethodSig("findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void findBlocks(Predicate predicate, BiConsumer output); @Override public void findBlocks(BiPredicate predicate, BiConsumer output) { @@ -248,9 +312,9 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC if (levelchunksection.maybeHas((state) -> predicate.test(state, BlockPos.ZERO))) { BlockPos blockpos = this.cloPos.cubePos().asSectionPos().offset(x, y, z).origin(); - for(int sectionLocalY = 0; sectionLocalY < SectionPos.SECTION_SIZE; ++sectionLocalY) { - for(int sectionLocalZ = 0; sectionLocalZ < SectionPos.SECTION_SIZE; ++sectionLocalZ) { - for(int sectionLocalX = 0; sectionLocalX < SectionPos.SECTION_SIZE; ++sectionLocalX) { + for (int sectionLocalY = 0; sectionLocalY < SectionPos.SECTION_SIZE; ++sectionLocalY) { + for (int sectionLocalZ = 0; sectionLocalZ < SectionPos.SECTION_SIZE; ++sectionLocalZ) { + for (int sectionLocalX = 0; sectionLocalX < SectionPos.SECTION_SIZE; ++sectionLocalX) { BlockState blockstate = levelchunksection.getBlockState(sectionLocalX, sectionLocalY, sectionLocalZ); mutableBlockPos.setWithOffset(blockpos, sectionLocalX, sectionLocalY, sectionLocalZ); if (predicate.test(blockstate, mutableBlockPos.immutable())) { @@ -271,40 +335,76 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC @Override public abstract ChunkAccess.TicksToSave getTicksForSerialization(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;") + @TransformFrom( + value = @MethodSig("getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native UpgradeData getUpgradeData(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "isOldNoiseGeneration()Z") + @TransformFrom( + value = @MethodSig("isOldNoiseGeneration()Z"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native boolean isOldNoiseGeneration(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;") + @TransformFrom( + value = @MethodSig("getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override @Nullable public native BlendingData getBlendingData(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setBlendingData(Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") + @TransformFrom( + value = @MethodSig("setBlendingData(Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setBlendingData(BlendingData blendingData); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getInhabitedTime()J") + @TransformFrom( + value = @MethodSig("getInhabitedTime()J"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native long getInhabitedTime(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "incrementInhabitedTime(J)V") + @TransformFrom( + value = @MethodSig("incrementInhabitedTime(J)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void incrementInhabitedTime(long amount); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setInhabitedTime(J)V") + @TransformFrom( + value = @MethodSig("setInhabitedTime(J)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setInhabitedTime(long inhabitedTime); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;") + @TransformFrom( + value = @MethodSig("getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;"), + copyFrom = @Ref(ChunkAccess.class) + ) public static native ShortList getOrCreateOffsetList(ShortList[] packedPositions, int index); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "isLightCorrect()Z") + @TransformFrom( + value = @MethodSig("isLightCorrect()Z"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native boolean isLightCorrect(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setLightCorrect(Z)V") + @TransformFrom( + value = @MethodSig("setLightCorrect(Z)V"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native void setLightCorrect(boolean lightCorrect); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getMinBuildHeight()I") + @TransformFrom( + value = @MethodSig("getMinBuildHeight()I"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native int getMinBuildHeight(); - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getHeight()I") + @TransformFrom( + value = @MethodSig("getHeight()I"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native int getHeight(); @Override public NoiseChunk getOrCreateNoiseChunk(Function noiseChunkCreator) { @@ -323,7 +423,10 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC throw new UnsupportedOperationException(); // TODO P3 } - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "hasAnyStructureReferences()Z") + @TransformFrom( + value = @MethodSig("hasAnyStructureReferences()Z"), + copyFrom = @Ref(ChunkAccess.class) + ) @Override public native boolean hasAnyStructureReferences(); @Override @Nullable public BelowZeroRetrogen getBelowZeroRetrogen() { @@ -334,7 +437,10 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return false; // Used for below-zero retrogen; not applicable to cubes } - @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;") + @TransformFrom( + value = @MethodSig("getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;"), + copyFrom = @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/LevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java index 5364666c..56e84248 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,6 +13,7 @@ import io.github.opencubicchunks.cubicchunks.mixin.CubeAccessAndDescendantsSet; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.Ref; import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; @@ -148,28 +149,28 @@ public LevelCube(ServerLevel level, ProtoCube cube, @Nullable PostLoadProcessor this.unsaved = true; } - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom(value = @MethodSig("getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), copyFrom = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getBlockTicks(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom(value = @MethodSig("getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), copyFrom = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;") + @TransformFrom(value = @MethodSig("getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;"), copyFrom = @Ref(LevelChunk.class)) @Override public native ChunkAccess.TicksToSave getTicksForSerialization(); // TODO should this actually be dasm'd? - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;") + @TransformFrom(value = @MethodSig("getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;"), copyFrom = @Ref(LevelChunk.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); // dasm + mixin - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") + @TransformFrom(value = @MethodSig("getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), copyFrom = @Ref(LevelChunk.class)) @Override public native @NotNull BlockState getBlockState(BlockPos pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;") + @TransformFrom(value = @MethodSig("getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), copyFrom = @Ref(LevelChunk.class)) @Override public native @NotNull FluidState getFluidState(BlockPos pos); // dasm + mixin - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;") + @TransformFrom(value = @MethodSig("getFluidState(III)Lnet/minecraft/world/level/material/FluidState;"), copyFrom = @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 @@ -223,53 +224,57 @@ public LevelCube(ServerLevel level, ProtoCube cube, @Nullable PostLoadProcessor } } - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "addEntity(Lnet/minecraft/world/entity/Entity;)V") + @TransformFrom(value = @MethodSig("addEntity(Lnet/minecraft/world/entity/Entity;)V"), copyFrom = @Ref(LevelChunk.class)) @Deprecated @Override public native void addEntity(Entity entity); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom(value = @MethodSig("createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), copyFrom = @Ref(LevelChunk.class)) @Nullable private native BlockEntity createBlockEntity(BlockPos pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), copyFrom = @Ref(LevelChunk.class)) @Override @Nullable public native BlockEntity getBlockEntity(BlockPos pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" - + "Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom( + value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;"), + copyFrom = @Ref(LevelChunk.class) + ) @Nullable public native BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(value = @MethodSig("addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), copyFrom = @Ref(LevelChunk.class)) public native void addAndRegisterBlockEntity(BlockEntity blockEntity); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "isInLevel()Z") + @TransformFrom(value = @MethodSig("isInLevel()Z"), copyFrom = @Ref(LevelChunk.class)) private native boolean isInLevel(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "isTicking(Lnet/minecraft/core/BlockPos;)Z") + @TransformFrom(value = @MethodSig("isTicking(Lnet/minecraft/core/BlockPos;)Z"), copyFrom = @Ref(LevelChunk.class)) public native boolean isTicking(BlockPos pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(value = @MethodSig("setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), copyFrom = @Ref(LevelChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom(value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;"), copyFrom = @Ref(LevelChunk.class)) @Override @Nullable public native CompoundTag getBlockEntityNbtForSaving(BlockPos pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(value = @MethodSig("removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"), copyFrom = @Ref(LevelChunk.class)) @Override public native void removeBlockEntity(BlockPos pos); // TODO maybe shouldn't be dasm - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;" - + "Lnet/minecraft/server/level/ServerLevel;" - + ")V") + @TransformFrom( + value = @MethodSig("removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V"), + copyFrom = @Ref(LevelChunk.class) + ) private native void removeGameEventListener(T blockEntity, ServerLevel level); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeGameEventListenerRegistry(I)V") + @TransformFrom(value = @MethodSig("removeGameEventListenerRegistry(I)V"), copyFrom = @Ref(LevelChunk.class)) private native void removeGameEventListenerRegistry(int p_283355_); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(value = @MethodSig("removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V"), copyFrom = @Ref(LevelChunk.class)) private native void removeBlockEntityTicker(BlockPos pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "runPostLoad()V") + @TransformFrom(value = @MethodSig("runPostLoad()V"), copyFrom = @Ref(LevelChunk.class)) public native void runPostLoad(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "isEmpty()Z") + @TransformFrom(value = @MethodSig("isEmpty()Z"), copyFrom = @Ref(LevelChunk.class)) public native boolean isEmpty(); public void replaceWithPacketData( @@ -293,16 +298,16 @@ public void replaceWithPacketData( }); } - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V") + @TransformFrom(value = @MethodSig("replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V"), copyFrom = @Ref(LevelChunk.class)) public native void replaceBiomes(FriendlyByteBuf buffer); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "setLoaded(Z)V") + @TransformFrom(value = @MethodSig("setLoaded(Z)V"), copyFrom = @Ref(LevelChunk.class)) public native void setLoaded(boolean loaded); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getLevel()Lnet/minecraft/world/level/Level;") + @TransformFrom(value = @MethodSig("getLevel()Lnet/minecraft/world/level/Level;"), copyFrom = @Ref(LevelChunk.class)) public native Level getLevel(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntities()Ljava/util/Map;") + @TransformFrom(value = @MethodSig("getBlockEntities()Ljava/util/Map;"), copyFrom = @Ref(LevelChunk.class)) public native Map getBlockEntities(); // TODO P2 or P3 figure this out later - stub method for now @@ -320,46 +325,52 @@ public void postProcessGeneration() { this.pendingBlockEntities.clear(); } - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" - + "Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom( + value = @MethodSig("promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), + copyFrom = @Ref(LevelChunk.class) + ) @Nullable private native BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "unpackTicks(J)V") + @TransformFrom(value = @MethodSig("unpackTicks(J)V"), copyFrom = @Ref(LevelChunk.class)) public native void unpackTicks(long pos); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V") + @TransformFrom(value = @MethodSig("registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V"), copyFrom = @Ref(LevelChunk.class)) public native void registerTickContainerInLevel(ServerLevel level); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V") + @TransformFrom(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), copyFrom = @Ref(LevelChunk.class)) public native void unregisterTickContainerFromLevel(ServerLevel level); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;") + @TransformFrom(value = @MethodSig("getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;"), copyFrom = @Ref(LevelChunk.class)) @Override public native ChunkStatus getStatus(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;") + @TransformFrom(value = @MethodSig("getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;"), copyFrom = @Ref(LevelChunk.class)) public native FullChunkStatus getFullStatus(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "setFullStatus(Ljava/util/function/Supplier;)V") + @TransformFrom(value = @MethodSig("setFullStatus(Ljava/util/function/Supplier;)V"), copyFrom = @Ref(LevelChunk.class)) public native void setFullStatus(Supplier fullStatus); // TODO a bit concerning - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "clearAllBlockEntities()V") + @TransformFrom(value = @MethodSig("clearAllBlockEntities()V"), copyFrom = @Ref(LevelChunk.class)) public native void clearAllBlockEntities(); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "registerAllBlockEntitiesAfterLevelLoad()V") + @TransformFrom(value = @MethodSig("registerAllBlockEntitiesAfterLevelLoad()V"), copyFrom = @Ref(LevelChunk.class)) public native void registerAllBlockEntitiesAfterLevelLoad(); // TODO (P3): GameEvent stuff is a bit concerning - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;" - + "Lnet/minecraft/server/level/ServerLevel;)V") + @TransformFrom( + value = @MethodSig("addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V"), + copyFrom = @Ref(LevelChunk.class) + ) private native void addGameEventListener(T blockEntity, ServerLevel level); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(value = @MethodSig("updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), copyFrom = @Ref(LevelChunk.class)) private native void updateBlockEntityTicker(T blockEntity); - @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;" - + "Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" - + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;") + @TransformFrom( + value = @MethodSig("createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" + + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;"), + copyFrom = @Ref(LevelChunk.class) + ) private native TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker ticker); // TODO forge stuff 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 0d07a7ad..edcc97a8 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 @@ -10,6 +10,7 @@ import io.github.opencubicchunks.cubicchunks.mixin.CubeAccessAndDescendantsSet; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.ProtoClo; +import io.github.opencubicchunks.dasm.api.MethodSig; import io.github.opencubicchunks.dasm.api.Ref; import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; import io.github.opencubicchunks.dasm.api.transform.TransformFrom; @@ -71,21 +72,36 @@ public ProtoCube(CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSec this.fluidTicks = liquidTicks; } - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom( + value = @MethodSig("getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native TickContainerAccess getBlockTicks(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom( + value = @MethodSig("getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native TickContainerAccess getFluidTicks(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;") + @TransformFrom( + value = @MethodSig("getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native ChunkAccess.TicksToSave getTicksForSerialization(); // dasm + mixin - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") + @TransformFrom( + value = @MethodSig("getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native BlockState getBlockState(BlockPos pos); // dasm + mixin - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;") + @TransformFrom( + value = @MethodSig("getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native FluidState getFluidState(BlockPos pos); @Nullable @@ -108,80 +124,146 @@ public ProtoCube(CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSec } } - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom( + value = @MethodSig("setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void setBlockEntity(BlockEntity pBlockEntity); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom( + value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override @Nullable public native BlockEntity getBlockEntity(BlockPos pPos); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntities()Ljava/util/Map;") + @TransformFrom( + value = @MethodSig("getBlockEntities()Ljava/util/Map;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native Map getBlockEntities(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "addEntity(Lnet/minecraft/nbt/CompoundTag;)V") + @TransformFrom( + value = @MethodSig("addEntity(Lnet/minecraft/nbt/CompoundTag;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void addEntity(CompoundTag pTag); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "addEntity(Lnet/minecraft/world/entity/Entity;)V") + @TransformFrom( + value = @MethodSig("addEntity(Lnet/minecraft/world/entity/Entity;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void addEntity(Entity pEntity); // setStartForStructure: ProtoChunk logic handles below-zero retrogen then calls super, so we don't need to override - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getEntities()Ljava/util/List;") + @TransformFrom( + value = @MethodSig("getEntities()Ljava/util/List;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native List getEntities(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;") + @TransformFrom( + value = @MethodSig("getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native ChunkStatus getStatus(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setStatus(Lnet/minecraft/world/level/chunk/ChunkStatus;)V") + @TransformFrom( + value = @MethodSig("setStatus(Lnet/minecraft/world/level/chunk/ChunkStatus;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void setStatus(ChunkStatus pStatus); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getNoiseBiome(III)Lnet/minecraft/core/Holder;") + @TransformFrom( + value = @MethodSig("getNoiseBiome(III)Lnet/minecraft/core/Holder;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native Holder getNoiseBiome(int pX, int pY, int pZ); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S") + @TransformFrom( + value = @MethodSig("packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S"), + copyFrom = @Ref(ProtoChunk.class) + ) public native static short packOffsetCoordinates(BlockPos pPos); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;") + @TransformFrom( + value = @MethodSig("unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;"), + copyFrom = @Ref(ProtoChunk.class) + ) public native static BlockPos unpackOffsetCoordinates(short pPackedPos, int pYOffset, ChunkPos pChunkPos); // dasm + mixin - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom( + value = @MethodSig("markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void markPosForPostprocessing(BlockPos pPos); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "addPackedPostProcess(SI)V") + @TransformFrom( + value = @MethodSig("addPackedPostProcess(SI)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void addPackedPostProcess(short pPackedPosition, int pIndex); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntityNbts()Ljava/util/Map;") + @TransformFrom( + value = @MethodSig("getBlockEntityNbts()Ljava/util/Map;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native Map getBlockEntityNbts(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom( + value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override @Nullable public native CompoundTag getBlockEntityNbtForSaving(BlockPos pPos); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom( + value = @MethodSig("removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void removeBlockEntity(BlockPos pPos); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;") + @TransformFrom( + value = @MethodSig("getCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;"), + copyFrom = @Ref(ProtoChunk.class)) @Override @Nullable public native CarvingMask getCarvingMask(GenerationStep.Carving pStep); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getOrCreateCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;") + @TransformFrom( + value = @MethodSig("getOrCreateCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;"), + copyFrom = @Ref(ProtoChunk.class)) @Override public native CarvingMask getOrCreateCarvingMask(GenerationStep.Carving pStep); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;Lnet/minecraft/world/level/chunk/CarvingMask;)V") + @TransformFrom( + value = @MethodSig("setCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;Lnet/minecraft/world/level/chunk/CarvingMask;)V"), + copyFrom = @Ref(ProtoChunk.class)) @Override public native void setCarvingMask(GenerationStep.Carving pStep, CarvingMask pCarvingMask); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V") + @TransformFrom( + value = @MethodSig("setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native void setLightEngine(LevelLightEngine pLightEngine); @Override public void setBelowZeroRetrogen(@Nullable BelowZeroRetrogen pBelowZeroRetrogen) { // Below-zero retrogen is unused in CC, hence empty method body } - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;") + @TransformFrom( + value = @MethodSig("unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;"), + copyFrom = @Ref(ProtoChunk.class) + ) private static native LevelChunkTicks unpackTicks(ProtoChunkTicks pTicks); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;") + @TransformFrom( + value = @MethodSig("unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native LevelChunkTicks unpackBlockTicks(); - @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;") + @TransformFrom( + value = @MethodSig("unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;"), + copyFrom = @Ref(ProtoChunk.class) + ) @Override public native LevelChunkTicks unpackFluidTicks(); @Override public LevelHeightAccessor getHeightAccessorForGeneration() { From 236db161c5c8225ada9a54c201b2f930ec2d8e19 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Wed, 24 Jan 2024 09:39:49 +0000 Subject: [PATCH 2/6] Pre-compute dasm TargetClass and redirects before applying any mixins --- build.gradle | 2 +- .../cubicchunks/mixin/ASMConfigPlugin.java | 48 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index e21bd083..f75a268d 100644 --- a/build.gradle +++ b/build.gradle @@ -235,7 +235,7 @@ dependencies { targetConfiguration = "testArchivesOutput" } - libraries("com.github.OpenCubicChunks:dasm:c08e10a63a") { + libraries("com.github.OpenCubicChunks:dasm:feature~add_to_set-SNAPSHOT") { transitive = false } libraries("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT") 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 f6fea3ef..e6bf78f0 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -31,6 +32,9 @@ public class ASMConfigPlugin implements IMixinConfigPlugin { private final Transformer transformer; private final AnnotationParser annotationParser; + private final Map preApplyTargets = new HashMap<>(); + private final Map postApplyTargets = new HashMap<>(); + public ASMConfigPlugin() { boolean developmentEnvironment = false; try { @@ -72,6 +76,32 @@ public ASMConfigPlugin() { } @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + try { + ClassNode targetClass = MixinService.getService().getBytecodeProvider().getClassNode(targetClassName); + ClassNode mixinClass = MixinService.getService().getBytecodeProvider().getClassNode(mixinClassName); + + // PRE_APPLY + var targetPreApply = new TargetClass(targetClassName); + Set redirectSetsPreApply = new HashSet<>(); + this.annotationParser.findRedirectSets(targetClassName, mixinClass, redirectSetsPreApply); + this.annotationParser.buildClassTarget(mixinClass, targetPreApply, TransformFrom.ApplicationStage.PRE_APPLY, "cc_dasm$"); + this.annotationParser.findRedirectSets(targetClassName, targetClass, redirectSetsPreApply); + this.annotationParser.buildClassTarget(targetClass, targetPreApply, TransformFrom.ApplicationStage.PRE_APPLY, "cc_dasm$"); + redirectSetsPreApply.forEach(targetPreApply::addRedirectSet); + this.preApplyTargets.put(mixinClassName + "|" + targetClassName, targetPreApply); + + // POST_APPLY + var targetPostApply = new TargetClass(targetClassName); + Set redirectSetsPostApply = new HashSet<>(); + this.annotationParser.findRedirectSets(targetClassName, mixinClass, redirectSetsPostApply); + this.annotationParser.buildClassTarget(mixinClass, targetPostApply, TransformFrom.ApplicationStage.POST_APPLY, "cc_dasm$"); + this.annotationParser.findRedirectSets(targetClassName, targetClass, redirectSetsPostApply); + this.annotationParser.buildClassTarget(targetClass, targetPostApply, TransformFrom.ApplicationStage.POST_APPLY, "cc_dasm$"); + redirectSetsPostApply.forEach(targetPostApply::addRedirectSet); + this.postApplyTargets.put(mixinClassName + "|" + targetClassName, targetPostApply); + } catch (ClassNotFoundException | IOException e) { + throw new RuntimeException(e); + } return true; } @@ -127,22 +157,12 @@ record PrefixMethodPair(MethodNode dasmAddedMethod, MethodNode mixinAddedMethod) * @return Whether any transformation was done to the targetClass */ private boolean transformClass(String targetClassName, ClassNode targetClass, String mixinClassName, TransformFrom.ApplicationStage stage) { - ClassNode mixinClass; - try { - mixinClass = MixinService.getService().getBytecodeProvider().getClassNode(mixinClassName); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException(e); + TargetClass target = null; + switch (stage) { + case PRE_APPLY -> target = preApplyTargets.get(mixinClassName + "|" + targetClassName); + case POST_APPLY -> target = postApplyTargets.get(mixinClassName + "|" + targetClassName); } - var target = new TargetClass(targetClassName); - Set redirectSets = new HashSet<>(); - - this.annotationParser.findRedirectSets(targetClassName, mixinClass, redirectSets); - this.annotationParser.buildClassTarget(mixinClass, target, stage, "cc_dasm$"); - this.annotationParser.findRedirectSets(targetClassName, targetClass, redirectSets); - this.annotationParser.buildClassTarget(targetClass, target, stage, "cc_dasm$"); - redirectSets.forEach(target::addRedirectSet); - if (target.targetMethods().isEmpty() && target.wholeClass() == null) { return false; } From 6074c8a0accaf55c3cb6c56ee68585d39c516b16 Mon Sep 17 00:00:00 2001 From: CursedFlames <18627001+CursedFlames@users.noreply.github.com> Date: Tue, 13 Feb 2024 01:03:35 +1300 Subject: [PATCH 3/6] switch to new dasm --- .idea/codeStyles/Project.xml | 2 +- build.gradle | 3 +- .../cubicchunks/mixin/ASMConfigPlugin.java | 10 +- .../mixin/CubeAccessAndDescendantsSet.java | 19 ++-- .../cubicchunks/mixin/GeneralSet.java | 15 +-- .../level/MixinChunkTaskPriorityQueue.java | 6 +- .../MixinChunkTaskPriorityQueueSorter.java | 21 ++++- .../server/level/MixinDistanceManager.java | 23 ++--- .../server/level/MixinTickingTracker.java | 15 +-- .../core/common/world/level/MixinLevel.java | 9 +- .../world/level/cube/CubeAccess.java | 82 ++++++++-------- .../world/level/cube/ImposterProtoCube.java | 8 +- .../world/level/cube/LevelCube.java | 94 +++++++++---------- .../world/level/cube/ProtoCube.java | 66 ++++++------- 14 files changed, 194 insertions(+), 179 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 0f16be14..c4f04e83 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -2,7 +2,7 @@