diff --git a/build.gradle b/build.gradle index f5e4fa65..204f60db 100644 --- a/build.gradle +++ b/build.gradle @@ -213,7 +213,7 @@ dependencies { targetConfiguration = "testArchivesOutput" } - libraries("com.github.OpenCubicChunks:dasm:4ff381c5a3") { + libraries("com.github.OpenCubicChunks:dasm:c08e10a63a") { 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 a3c54636..f6fea3ef 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java @@ -1,13 +1,8 @@ package io.github.opencubicchunks.cubicchunks.mixin; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -15,17 +10,16 @@ import javax.annotation.Nullable; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import io.github.opencubicchunks.cubicchunks.CubicChunks; -import io.github.opencubicchunks.dasm.MappingsProvider; -import io.github.opencubicchunks.dasm.RedirectsParseException; -import io.github.opencubicchunks.dasm.RedirectsParser; +import io.github.opencubicchunks.dasm.AnnotationParser; import io.github.opencubicchunks.dasm.Transformer; +import io.github.opencubicchunks.dasm.api.provider.CachingClassProvider; +import io.github.opencubicchunks.dasm.api.provider.ClassProvider; +import io.github.opencubicchunks.dasm.api.provider.MappingsProvider; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; +import io.github.opencubicchunks.dasm.transformer.redirect.RedirectSet; +import io.github.opencubicchunks.dasm.transformer.target.TargetClass; import net.neoforged.fml.loading.FMLEnvironment; -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; @@ -34,10 +28,8 @@ public class ASMConfigPlugin implements IMixinConfigPlugin { private final Map dasmTransformedInPreApply = new ConcurrentHashMap<>(); - private final Map redirectSetByName = new HashMap<>(); - private final Throwable constructException; - private final Transformer transformer; + private final AnnotationParser annotationParser; public ASMConfigPlugin() { boolean developmentEnvironment = false; @@ -61,33 +53,18 @@ public ASMConfigPlugin() { }; // TODO: breaks on fabric (remapped at runtime) - this.transformer = new Transformer(mappings, s -> { - try (var classStream = ASMConfigPlugin.class.getClassLoader().getResourceAsStream(s.replace(".", "/") + ".class")){ + ClassProvider classProvider = new CachingClassProvider(s -> { + try (var classStream = ASMConfigPlugin.class.getClassLoader().getResourceAsStream(s.replace(".", "/") + ".class")) { return classStream.readAllBytes(); } catch (IOException e) { throw new RuntimeException(e); } - }, developmentEnvironment); - - List redirectSets; - try { - //TODO: add easy use of multiple set and target json files - redirectSets = loadSetsFile("dasm/sets/sets.dasm"); - - for (RedirectsParser.RedirectSet redirectSet : redirectSets) { - redirectSetByName.put(redirectSet.getName(), redirectSet); - } - } catch (Throwable e) { - constructException = e; // Annoying because mixin catches Throwable for creating a config plugin >:( - return; - } - constructException = null; + }); + this.transformer = new Transformer(mappings, classProvider, developmentEnvironment); + this.annotationParser = new AnnotationParser(classProvider, GeneralSet.class); } @Override public void onLoad(String mixinPackage) { - if (this.constructException != null) { - throw new Error(this.constructException); // throw error because Mixin catches Exception for onLoad - } } @Override public String getRefMapperConfig() { @@ -157,226 +134,24 @@ private boolean transformClass(String targetClassName, ClassNode targetClass, St throw new RuntimeException(e); } - var target = new RedirectsParser.ClassTarget(targetClassName); - Set redirectSets = new HashSet<>(); + var target = new TargetClass(targetClassName); + Set redirectSets = new HashSet<>(); - findRedirectSets(targetClassName, mixinClass, redirectSets); - buildClassTarget(mixinClass, target, stage, "cc_dasm$"); - findRedirectSets(targetClassName, targetClass, redirectSets); - buildClassTarget(targetClass, target, stage, "cc_dasm$"); + 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.getTargetMethods().isEmpty() && target.wholeClass() == null) { + if (target.targetMethods().isEmpty() && target.wholeClass() == null) { return false; } if (target.wholeClass() != null) { - this.transformer.transformClass(targetClass, target, redirectSets.stream().toList()); + this.transformer.transformClass(targetClass, target); } else { - this.transformer.transformClass(targetClass, target, redirectSets.stream().toList()); + this.transformer.transformClass(targetClass, target); } return true; } - - private void findRedirectSets(String targetClassName, ClassNode targetClass, Set redirectSets) { - if (targetClass.invisibleAnnotations == null) { - return; - } - for (AnnotationNode ann : targetClass.invisibleAnnotations) { - if (!ann.desc.equals("Lio/github/opencubicchunks/cubicchunks/mixin/DasmRedirect;")) { - continue; - } - // The name value pairs of this annotation. Each name value pair is stored as two consecutive - // elements in the list. The name is a String, and the value may be a - // Byte, Boolean, Character, Short, Integer, Long, Float, Double, String or org.objectweb.asm.Type, - // or a two elements String array (for enumeration values), an AnnotationNode, - // or a List of values of one of the preceding types. The list may be null if there is no name value pair. - List values = ann.values; - if (values == null) { - redirectSets.add(redirectSetByName.get("general")); - continue; - } - List useSets = null; - for (int i = 0, valuesSize = values.size(); i < valuesSize; i += 2) { - String name = (String) values.get(i); - Object value = values.get(i + 1); - if (name.equals("value")) { - useSets = (List) value; - } - } - if (useSets == null) { - redirectSets.add(redirectSetByName.get("general")); - continue; - } - for (String useSet : useSets) { - RedirectsParser.RedirectSet redirectSet = redirectSetByName.get(useSet); - if (redirectSet == null) { - throw new IllegalArgumentException("No redirect set " + useSet + ", targetClass=" + targetClassName); - } - redirectSets.add(redirectSet); - } - } - } - - private static void buildClassTarget(ClassNode targetClass, RedirectsParser.ClassTarget classTarget, TransformFrom.ApplicationStage stage, String methodPrefix) { - if (targetClass.invisibleAnnotations == null) { - return; - } - for (AnnotationNode ann : targetClass.invisibleAnnotations) { - if (!ann.desc.equals("Lio/github/opencubicchunks/cubicchunks/mixin/TransformFromClass;") || ann.values == null) { - continue; - } - - List values = ann.values; - Type srcClass = null; - TransformFrom.ApplicationStage requestedStage = TransformFrom.ApplicationStage.PRE_APPLY; - for (int i = 0, valuesSize = values.size(); i < valuesSize; i += 2) { - String name = (String) values.get(i); - Object value = values.get(i + 1); - if (name.equals("value")) { - srcClass = parseCopyFromAnnotation((AnnotationNode) value); - } else if (name.equals("stage")) { - var parts = ((String[]) value); - requestedStage = TransformFrom.ApplicationStage.valueOf(parts[1]); - } - } - if (stage != requestedStage) { - continue; - } - classTarget.targetWholeClass(srcClass); - } - - for (Iterator iterator = targetClass.methods.iterator(); iterator.hasNext(); ) { - MethodNode method = iterator.next(); - if (method.invisibleAnnotations == null) { - continue; - } - - for (AnnotationNode ann : method.invisibleAnnotations) { - if (!ann.desc.equals("Lio/github/opencubicchunks/cubicchunks/mixin/TransformFrom;")) { - continue; - } - iterator.remove(); - - // The name value pairs of this annotation. Each name value pair is stored as two consecutive - // elements in the list. The name is a String, and the value may be a - // Byte, Boolean, Character, Short, Integer, Long, Float, Double, String or org.objectweb.asm.Type, - // or a two elements String array (for enumeration values), an AnnotationNode, - // or a List of values of one of the preceding types. The list may be null if there is no name value pair. - List values = ann.values; - String targetName = null; - boolean makeSyntheticAccessor = false; - String desc = null; - TransformFrom.ApplicationStage requestedStage = TransformFrom.ApplicationStage.PRE_APPLY; - Type srcOwner = null; - for (int i = 0, valuesSize = values.size(); i < valuesSize; i += 2) { - String name = (String) values.get(i); - Object value = values.get(i + 1); - switch (name) { - case "value" -> targetName = (String) value; - case "makeSyntheticAccessor" -> makeSyntheticAccessor = (Boolean) value; - case "signature" -> desc = parseMethodDescriptor((AnnotationNode) value); - case "stage" -> { - var parts = ((String[]) value); - requestedStage = TransformFrom.ApplicationStage.valueOf(parts[1]); - } - case "copyFrom" -> srcOwner = parseCopyFromAnnotation((AnnotationNode) value); - } - } - if (stage != requestedStage) { - continue; - } - - if (desc == null) { - int split = targetName.indexOf('('); - desc = targetName.substring(split); - targetName = targetName.substring(0, split); - } - RedirectsParser.ClassTarget.TargetMethod targetMethod; - if (srcOwner == null) { - targetMethod = new RedirectsParser.ClassTarget.TargetMethod( - new Transformer.ClassMethod(Type.getObjectType(targetClass.name), new org.objectweb.asm.commons.Method(targetName, desc)), - methodPrefix + method.name, // Name is modified here to prevent mixin from overwriting it. We remove this prefix in postApply. - true, makeSyntheticAccessor - ); - } else { - targetMethod = new RedirectsParser.ClassTarget.TargetMethod( - srcOwner, - new Transformer.ClassMethod(Type.getObjectType(targetClass.name), new org.objectweb.asm.commons.Method(targetName, desc)), - methodPrefix + method.name, // Name is modified here to prevent mixin from overwriting it. We remove this prefix in postApply. - true, makeSyntheticAccessor - ); - } - if (classTarget.getTargetMethods().stream().anyMatch(t -> t.method().method.equals(targetMethod.method().method))) { - throw new RuntimeException(String.format("Trying to add duplicate TargetMethod to %s:\n\t\t\t\t%s | %s", classTarget.getClassName(), targetMethod.method().owner, - targetMethod.method().method)); - } - classTarget.addTarget(targetMethod); - } - } - } - - private static Type parseCopyFromAnnotation(AnnotationNode copyFromAnnotation) { - assert copyFromAnnotation.values.size() == 2 : "CopyFrom annotation has multiple targeting fields"; - - if ((copyFromAnnotation.values.get(0)).equals("clazz")) { - return (Type) copyFromAnnotation.values.get(1); - } else if ((copyFromAnnotation.values.get(0)).equals("string")) { - return Type.getObjectType((String) copyFromAnnotation.values.get(1)); - } - return Type.getType(Object.class); - } - - private static String parseMethodDescriptor(AnnotationNode ann) { - if (ann == null) { - return null; - } - List values = ann.values; - - Type ret = null; - List args = null; - boolean useFromString = false; - for (int i = 0, valuesSize = values.size(); i < valuesSize; i += 2) { - String name = (String) values.get(i); - Object value = values.get(i + 1); - switch (name) { - case "ret" -> ret = (Type) value; - case "args" -> args = (List) value; - case "useFromString" -> useFromString = (Boolean) value; - } - } - if (useFromString) { - return null; - } - return Type.getMethodDescriptor(ret, args.toArray(new Type[0])); - } - - private JsonElement parseFileAsJson(String fileName) { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - try (InputStream is = classloader.getResourceAsStream(fileName)) { - return new JsonParser().parse(new InputStreamReader(is, StandardCharsets.UTF_8)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private List loadTargetsFile(String fileName) throws RedirectsParseException { - RedirectsParser redirectsParser = new RedirectsParser(); - - JsonElement targetsJson = parseFileAsJson(fileName); - return redirectsParser.parseClassTargets(targetsJson.getAsJsonObject()); - } - - private List loadSetsFile(String fileName) throws RedirectsParseException { - RedirectsParser redirectsParser = new RedirectsParser(); - - JsonObject setsJson = parseFileAsJson(fileName).getAsJsonObject(); - JsonElement sets = setsJson.get("sets"); - JsonElement globalImports = setsJson.get("imports"); - - if (globalImports == null) { - return redirectsParser.parseRedirectSet(sets.getAsJsonObject()); - } else { - return redirectsParser.parseRedirectSet(sets.getAsJsonObject(), globalImports); - } - } } \ No newline at end of file diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/CopyFrom.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/CopyFrom.java deleted file mode 100644 index c38b7952..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/CopyFrom.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin; - -public @interface CopyFrom { - Class clazz() default Object.class; - - String string() default ""; -} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/CubeAccessAndDescendantsSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/CubeAccessAndDescendantsSet.java new file mode 100644 index 00000000..769871d2 --- /dev/null +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/CubeAccessAndDescendantsSet.java @@ -0,0 +1,53 @@ +package io.github.opencubicchunks.cubicchunks.mixin; + +import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess; +import io.github.opencubicchunks.cubicchunks.world.level.cube.ImposterProtoCube; +import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; +import io.github.opencubicchunks.cubicchunks.world.level.cube.ProtoCube; +import io.github.opencubicchunks.dasm.api.Ref; +import io.github.opencubicchunks.dasm.api.redirect.DasmRedirectSet; +import io.github.opencubicchunks.dasm.api.redirect.FieldRedirect; +import io.github.opencubicchunks.dasm.api.redirect.MethodRedirect; +import io.github.opencubicchunks.dasm.api.redirect.TypeRedirect; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ImposterProtoChunk; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.ProtoChunk; + +@DasmRedirectSet +public interface CubeAccessAndDescendantsSet extends GeneralSet { + @TypeRedirect(from = @Ref(ChunkAccess.class), to = @Ref(CubeAccess.class)) + abstract class ChunkAccessToCubeAccessRedirects { + @FieldRedirect("cloPos") protected ChunkPos chunkPos; + + @MethodRedirect("cc_getCloPos") public native ChunkPos getPos(); + } + + @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelCube.class)) + abstract class LevelChunkToLevelCubeRedirects { } + + @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$BoundTickingBlockEntityToLevelCube$BoundTickingBlockEntityRedirects { } + + @TypeRedirect( + from = @Ref(string = "net.minecraft.world.level.chunk.LevelChunk$PostLoadProcessor"), + to = @Ref(string = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$PostLoadProcessor") + ) + abstract class LevelChunk$PostLoadProcessorToLevelCube$PostLoadProcessorRedirects { } + + @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$RebindableTickingBlockEntityWrapperToLevelCube$RebindableTickingBlockEntityWrapperRedirects { } + + @TypeRedirect(from = @Ref(ProtoChunk.class), to = @Ref(ProtoCube.class)) + abstract class ProtoChunkToProtoCubeRedirects { } + + @TypeRedirect(from = @Ref(ImposterProtoChunk.class), to = @Ref(ImposterProtoCube.class)) + abstract class ImposterProtoChunkToImposterProtoCubeRedirects { } +} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/DasmRedirect.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/DasmRedirect.java deleted file mode 100644 index 5afa7705..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/DasmRedirect.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.CLASS) -public @interface DasmRedirect { - String[] value() default { "general" }; -} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/GeneralSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/GeneralSet.java new file mode 100644 index 00000000..5654b1cc --- /dev/null +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/GeneralSet.java @@ -0,0 +1,27 @@ +package io.github.opencubicchunks.cubicchunks.mixin; + +import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloAccess; +import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo; +import io.github.opencubicchunks.dasm.api.Ref; +import io.github.opencubicchunks.dasm.api.redirect.DasmRedirectSet; +import io.github.opencubicchunks.dasm.api.redirect.MethodRedirect; +import io.github.opencubicchunks.dasm.api.redirect.TypeRedirect; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; + +@DasmRedirectSet +public interface GeneralSet { + @TypeRedirect(from = @Ref(ChunkPos.class), to = @Ref(CloPos.class)) + abstract class ChunkPosToCloPosRedirects { } + + @TypeRedirect(from = @Ref(ChunkAccess.class), to = @Ref(CloAccess.class)) + abstract class ChunkAccessToCloAccessRedirects { + @MethodRedirect("cc_getCloPos") + public native ChunkPos getPos(); + } + + @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelClo.class)) + abstract class LevelChunkToLevelCloRedirects { } +} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/TransformFrom.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/TransformFrom.java deleted file mode 100644 index 02f38d68..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/TransformFrom.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) -@Retention(RetentionPolicy.CLASS) -public @interface TransformFrom { - - String value(); - - CopyFrom copyFrom() default @CopyFrom(); - - Signature signature() default @Signature(fromString = true); - - ApplicationStage stage() default ApplicationStage.PRE_APPLY; - - boolean makeSyntheticAccessor() default false; - - @interface Signature { - Class[] args() default {}; - Class ret() default void.class; - boolean fromString() default false; - } - - enum ApplicationStage { - PRE_APPLY, - POST_APPLY - } -} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/TransformFromClass.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/TransformFromClass.java deleted file mode 100644 index 2d849285..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/TransformFromClass.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin; - -public @interface TransformFromClass { - CopyFrom value(); - - TransformFrom.ApplicationStage stage() default TransformFrom.ApplicationStage.PRE_APPLY; -} 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 4afff4d0..2fa52ddb 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,9 +2,8 @@ import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; -import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.server.level.ChunkTaskPriorityQueue; import net.minecraft.world.level.ChunkPos; import org.spongepowered.asm.mixin.Mixin; 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 88b68a39..e02ffbc1 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 @@ -10,9 +10,9 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; import io.github.opencubicchunks.cubicchunks.server.level.CubicTaskPriorityQueueSorter; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.server.level.ChunkTaskPriorityQueueSorter; import net.minecraft.world.level.ChunkPos; import org.spongepowered.asm.mixin.Mixin; 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 9432bde4..fe30e80b 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 @@ -6,12 +6,12 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; -import io.github.opencubicchunks.cubicchunks.mixin.DasmRedirect; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; import io.github.opencubicchunks.cubicchunks.server.level.CubicDistanceManager; 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.transform.DasmRedirect; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.core.SectionPos; import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.TicketType; 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 2ff92a58..e68439cf 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 @@ -1,19 +1,11 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; -import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cubicchunks.MarkableAsCubic; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; import io.github.opencubicchunks.cubicchunks.server.level.CubicServerLevel; -import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ServerLevel.class) public abstract class MixinServerLevel extends Level implements CubicServerLevel, MarkableAsCubic { 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 5d7afc96..fbd3a3dc 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 @@ -3,11 +3,11 @@ import com.llamalad7.mixinextras.injector.WrapWithCondition; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import io.github.opencubicchunks.cubicchunks.mixin.DasmRedirect; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; 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.transform.DasmRedirect; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.TicketType; import net.minecraft.server.level.TickingTracker; 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 bb7c5194..ff3de75e 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 @@ -13,11 +13,12 @@ import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; import io.github.opencubicchunks.cubicchunks.CubicChunks; -import io.github.opencubicchunks.cubicchunks.mixin.CopyFrom; -import io.github.opencubicchunks.cubicchunks.mixin.DasmRedirect; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; +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.Ref; +import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import it.unimi.dsi.fastutil.longs.LongSet; import it.unimi.dsi.fastutil.shorts.ShortList; import net.minecraft.core.BlockPos; @@ -50,7 +51,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.jetbrains.annotations.Nullable; -@DasmRedirect({ "cubeAccessAndDescendants" }) +@DasmRedirect(CubeAccessAndDescendantsSet.class) public abstract class CubeAccess implements CloAccess { // Fields copied from ChunkAccess, except ChunkPos -> CloPos protected final ShortList[] postProcessing; @@ -113,8 +114,8 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC } } - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;") - @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;") + @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); @Override @Nullable public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving); @@ -132,13 +133,13 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return this.getMinBuildHeight(); } - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getBlockEntitiesPos()Ljava/util/Set;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlockEntitiesPos()Ljava/util/Set;") @Override public native Set getBlockEntitiesPos(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;") @Override public native LevelChunkSection[] getSections(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;") @Override public native LevelChunkSection getSection(int index); // TODO (P2) heightmap methods on cubes @@ -166,31 +167,31 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return cloPos; } - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;") @Override @Nullable public native StructureStart getStartForStructure(Structure structure); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V") @Override public native void setStartForStructure(Structure structure, StructureStart structureStart); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getAllStarts()Ljava/util/Map;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getAllStarts()Ljava/util/Map;") @Override public native Map getAllStarts(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setAllStarts(Ljava/util/Map;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setAllStarts(Ljava/util/Map;)V") @Override public native void setAllStarts(Map structureStarts); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + "Lit/unimi/dsi/fastutil/longs/LongSet;") @Override public native LongSet getReferencesForStructure(Structure structure); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V") @Override public native void addReferenceForStructure(Structure structure, long reference); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getAllReferences()Ljava/util/Map;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getAllReferences()Ljava/util/Map;") @Override public native Map getAllReferences(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setAllReferences(Ljava/util/Map;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setAllReferences(Ljava/util/Map;)V") @Override public native void setAllReferences(Map structureReferencesMap); @Override public boolean isYSpaceEmpty(int startY, int endY) { @@ -198,10 +199,10 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return false; } - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setUnsaved(Z)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setUnsaved(Z)V") @Override public native void setUnsaved(boolean unsaved); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "isUnsaved()Z") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "isUnsaved()Z") @Override public native boolean isUnsaved(); @Override public abstract ChunkStatus getStatus(); @@ -213,28 +214,28 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC @Override public abstract void removeBlockEntity(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V") @Override public native void markPosForPostprocessing(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;") @Override public native ShortList[] getPostProcessing(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "addPackedPostProcess(SI)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "addPackedPostProcess(SI)V") @Override public native void addPackedPostProcess(short packedPosition, int index); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V") @Override public native void setBlockEntityNbt(CompoundTag tag); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") @Override @Nullable public native CompoundTag getBlockEntityNbt(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") @Override @Nullable public native CompoundTag getBlockEntityNbtForSaving(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "findBlockLightSources(Ljava/util/function/BiConsumer;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "findBlockLightSources(Ljava/util/function/BiConsumer;)V") @Override public native void findBlockLightSources(BiConsumer output); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V") @Override public native void findBlocks(Predicate predicate, BiConsumer output); @Override public void findBlocks(BiPredicate predicate, BiConsumer output) { @@ -270,40 +271,40 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC @Override public abstract ChunkAccess.TicksToSave getTicksForSerialization(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;") @Override public native UpgradeData getUpgradeData(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "isOldNoiseGeneration()Z") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "isOldNoiseGeneration()Z") @Override public native boolean isOldNoiseGeneration(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;") @Override @Nullable public native BlendingData getBlendingData(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setBlendingData(Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setBlendingData(Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") @Override public native void setBlendingData(BlendingData blendingData); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getInhabitedTime()J") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getInhabitedTime()J") @Override public native long getInhabitedTime(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "incrementInhabitedTime(J)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "incrementInhabitedTime(J)V") @Override public native void incrementInhabitedTime(long amount); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setInhabitedTime(J)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setInhabitedTime(J)V") @Override public native void setInhabitedTime(long inhabitedTime); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;") public static native ShortList getOrCreateOffsetList(ShortList[] packedPositions, int index); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "isLightCorrect()Z") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "isLightCorrect()Z") @Override public native boolean isLightCorrect(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "setLightCorrect(Z)V") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "setLightCorrect(Z)V") @Override public native void setLightCorrect(boolean lightCorrect); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getMinBuildHeight()I") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getMinBuildHeight()I") @Override public native int getMinBuildHeight(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getHeight()I") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getHeight()I") @Override public native int getHeight(); @Override public NoiseChunk getOrCreateNoiseChunk(Function noiseChunkCreator) { @@ -322,7 +323,7 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC throw new UnsupportedOperationException(); // TODO P3 } - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "hasAnyStructureReferences()Z") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "hasAnyStructureReferences()Z") @Override public native boolean hasAnyStructureReferences(); @Override @Nullable public BelowZeroRetrogen getBelowZeroRetrogen() { @@ -333,7 +334,7 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return false; // Used for below-zero retrogen; not applicable to cubes } - @TransformFrom(copyFrom = @CopyFrom(clazz = ChunkAccess.class), value = "getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;") + @TransformFrom(copyFrom = @Ref(ChunkAccess.class), value = "getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;") @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 e721e976..f7ba42d2 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,15 +1,16 @@ package io.github.opencubicchunks.cubicchunks.world.level.cube; -import io.github.opencubicchunks.cubicchunks.mixin.CopyFrom; -import io.github.opencubicchunks.cubicchunks.mixin.DasmRedirect; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFromClass; +import io.github.opencubicchunks.cubicchunks.mixin.CubeAccessAndDescendantsSet; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.ImposterProtoClo; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo; +import io.github.opencubicchunks.dasm.api.Ref; +import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; +import io.github.opencubicchunks.dasm.api.transform.TransformFromClass; import net.minecraft.world.level.chunk.ImposterProtoChunk; // Whole class redirect -@DasmRedirect({ "cubeAccessAndDescendants" }) -@TransformFromClass(@CopyFrom(clazz = ImposterProtoChunk.class)) +@DasmRedirect(CubeAccessAndDescendantsSet.class) +@TransformFromClass(@Ref(ImposterProtoChunk.class)) public class ImposterProtoCube extends ProtoCube implements ImposterProtoClo { // Field cleared and re-generated by DASM; we just need it here because otherwise mixin does not detect that the field exists. private LevelCube wrapped; 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 0398e348..5364666c 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 @@ -10,12 +10,13 @@ import com.google.common.collect.Maps; import com.mojang.logging.LogUtils; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cubicchunks.mixin.CopyFrom; -import io.github.opencubicchunks.cubicchunks.mixin.DasmRedirect; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFromClass; +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.Ref; +import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; +import io.github.opencubicchunks.dasm.api.transform.TransformFromClass; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.core.BlockPos; @@ -48,7 +49,7 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; -@DasmRedirect({ "cubeAccessAndDescendants" }) +@DasmRedirect(CubeAccessAndDescendantsSet.class) public class LevelCube extends CubeAccess implements LevelClo { // Fields matching LevelChunk static final Logger LOGGER = LogUtils.getLogger(); @@ -147,28 +148,28 @@ public LevelCube(ServerLevel level, ProtoCube cube, @Nullable PostLoadProcessor this.unsaved = true; } - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") @Override public native TickContainerAccess getBlockTicks(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") @Override public native TickContainerAccess getFluidTicks(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;") @Override public native ChunkAccess.TicksToSave getTicksForSerialization(); // TODO should this actually be dasm'd? - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;") @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); // dasm + mixin - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") @Override public native @NotNull BlockState getBlockState(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;") @Override public native @NotNull FluidState getFluidState(BlockPos pos); // dasm + mixin - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;") @Override public native FluidState getFluidState(int x, int y, int z); // TODO might be dasm-able eventually, if we get more powerful mixin tools @@ -222,53 +223,53 @@ public LevelCube(ServerLevel level, ProtoCube cube, @Nullable PostLoadProcessor } } - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "addEntity(Lnet/minecraft/world/entity/Entity;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "addEntity(Lnet/minecraft/world/entity/Entity;)V") @Deprecated @Override public native void addEntity(Entity entity); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") @Nullable private native BlockEntity createBlockEntity(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") @Override @Nullable public native BlockEntity getBlockEntity(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" + @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;") @Nullable public native BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") public native void addAndRegisterBlockEntity(BlockEntity blockEntity); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "isInLevel()Z") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "isInLevel()Z") private native boolean isInLevel(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "isTicking(Lnet/minecraft/core/BlockPos;)Z") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "isTicking(Lnet/minecraft/core/BlockPos;)Z") public native boolean isTicking(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") @Override @Nullable public native CompoundTag getBlockEntityNbtForSaving(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V") @Override public native void removeBlockEntity(BlockPos pos); // TODO maybe shouldn't be dasm - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;" + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;" + "Lnet/minecraft/server/level/ServerLevel;" + ")V") private native void removeGameEventListener(T blockEntity, ServerLevel level); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "removeGameEventListenerRegistry(I)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeGameEventListenerRegistry(I)V") private native void removeGameEventListenerRegistry(int p_283355_); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V") private native void removeBlockEntityTicker(BlockPos pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "runPostLoad()V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "runPostLoad()V") public native void runPostLoad(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "isEmpty()Z") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "isEmpty()Z") public native boolean isEmpty(); public void replaceWithPacketData( @@ -292,16 +293,16 @@ public void replaceWithPacketData( }); } - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V") public native void replaceBiomes(FriendlyByteBuf buffer); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "setLoaded(Z)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "setLoaded(Z)V") public native void setLoaded(boolean loaded); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getLevel()Lnet/minecraft/world/level/Level;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getLevel()Lnet/minecraft/world/level/Level;") public native Level getLevel(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getBlockEntities()Ljava/util/Map;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getBlockEntities()Ljava/util/Map;") public native Map getBlockEntities(); // TODO P2 or P3 figure this out later - stub method for now @@ -319,44 +320,44 @@ public void postProcessGeneration() { this.pendingBlockEntities.clear(); } - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" + "Lnet/minecraft/world/level/block/entity/BlockEntity;") @Nullable private native BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "unpackTicks(J)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "unpackTicks(J)V") public native void unpackTicks(long pos); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V") public native void registerTickContainerInLevel(ServerLevel level); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V") public native void unregisterTickContainerFromLevel(ServerLevel level); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;") @Override public native ChunkStatus getStatus(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;") public native FullChunkStatus getFullStatus(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "setFullStatus(Ljava/util/function/Supplier;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "setFullStatus(Ljava/util/function/Supplier;)V") public native void setFullStatus(Supplier fullStatus); // TODO a bit concerning - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "clearAllBlockEntities()V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "clearAllBlockEntities()V") public native void clearAllBlockEntities(); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "registerAllBlockEntitiesAfterLevelLoad()V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "registerAllBlockEntitiesAfterLevelLoad()V") public native void registerAllBlockEntitiesAfterLevelLoad(); // TODO (P3): GameEvent stuff is a bit concerning - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;" + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;" + "Lnet/minecraft/server/level/ServerLevel;)V") private native void addGameEventListener(T blockEntity, ServerLevel level); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(copyFrom = @Ref(LevelChunk.class), value = "updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") private native void updateBlockEntityTicker(T blockEntity); - @TransformFrom(copyFrom = @CopyFrom(clazz = LevelChunk.class), value = "createTicker(Lnet/minecraft/world/level/block/entity/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;") private native TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker ticker); @@ -383,8 +384,8 @@ public void postProcessGeneration() { // } // FORGE END - @DasmRedirect({ "cubeAccessAndDescendants" }) - @TransformFromClass(@CopyFrom(string = "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity")) + @DasmRedirect(CubeAccessAndDescendantsSet.class) + @TransformFromClass(@Ref(string = "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity")) class BoundTickingBlockEntity implements TickingBlockEntity { private final T blockEntity; private final BlockEntityTicker ticker; @@ -410,8 +411,8 @@ public interface PostLoadProcessor { void run(LevelCube cube); } - @DasmRedirect({ "cubeAccessAndDescendants" }) - @TransformFromClass(@CopyFrom(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper")) + @DasmRedirect(CubeAccessAndDescendantsSet.class) + @TransformFromClass(@Ref(string = "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper")) 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 a7a68bdd..0d07a7ad 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,11 +7,12 @@ import com.google.common.collect.Lists; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cubicchunks.mixin.CopyFrom; -import io.github.opencubicchunks.cubicchunks.mixin.DasmRedirect; -import io.github.opencubicchunks.cubicchunks.mixin.TransformFrom; +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.Ref; +import io.github.opencubicchunks.dasm.api.transform.DasmRedirect; +import io.github.opencubicchunks.dasm.api.transform.TransformFrom; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; @@ -42,7 +43,7 @@ import net.minecraft.world.ticks.ProtoChunkTicks; import net.minecraft.world.ticks.TickContainerAccess; -@DasmRedirect({ "cubeAccessAndDescendants" }) +@DasmRedirect(CubeAccessAndDescendantsSet.class) public class ProtoCube extends CubeAccess implements ProtoClo { // Fields matching ProtoChunk @Nullable @@ -70,21 +71,21 @@ public ProtoCube(CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSec this.fluidTicks = liquidTicks; } - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") @Override public native TickContainerAccess getBlockTicks(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;") @Override public native TickContainerAccess getFluidTicks(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getTicksForSerialization()Lnet/minecraft/world/level/chunk/ChunkAccess$TicksToSave;") @Override public native ChunkAccess.TicksToSave getTicksForSerialization(); // dasm + mixin - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") @Override public native BlockState getBlockState(BlockPos pos); // dasm + mixin - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;") @Override public native FluidState getFluidState(BlockPos pos); @Nullable @@ -107,80 +108,80 @@ public ProtoCube(CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSec } } - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V") @Override public native void setBlockEntity(BlockEntity pBlockEntity); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;") @Override @Nullable public native BlockEntity getBlockEntity(BlockPos pPos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getBlockEntities()Ljava/util/Map;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntities()Ljava/util/Map;") @Override public native Map getBlockEntities(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "addEntity(Lnet/minecraft/nbt/CompoundTag;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "addEntity(Lnet/minecraft/nbt/CompoundTag;)V") @Override public native void addEntity(CompoundTag pTag); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "addEntity(Lnet/minecraft/world/entity/Entity;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "addEntity(Lnet/minecraft/world/entity/Entity;)V") @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 = @CopyFrom(clazz = ProtoChunk.class), value = "getEntities()Ljava/util/List;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getEntities()Ljava/util/List;") @Override public native List getEntities(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getStatus()Lnet/minecraft/world/level/chunk/ChunkStatus;") @Override public native ChunkStatus getStatus(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "setStatus(Lnet/minecraft/world/level/chunk/ChunkStatus;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setStatus(Lnet/minecraft/world/level/chunk/ChunkStatus;)V") @Override public native void setStatus(ChunkStatus pStatus); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getNoiseBiome(III)Lnet/minecraft/core/Holder;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getNoiseBiome(III)Lnet/minecraft/core/Holder;") @Override public native Holder getNoiseBiome(int pX, int pY, int pZ); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S") public native static short packOffsetCoordinates(BlockPos pPos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;") public native static BlockPos unpackOffsetCoordinates(short pPackedPos, int pYOffset, ChunkPos pChunkPos); // dasm + mixin - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V") @Override public native void markPosForPostprocessing(BlockPos pPos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "addPackedPostProcess(SI)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "addPackedPostProcess(SI)V") @Override public native void addPackedPostProcess(short pPackedPosition, int pIndex); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getBlockEntityNbts()Ljava/util/Map;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntityNbts()Ljava/util/Map;") @Override public native Map getBlockEntityNbts(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;") @Override @Nullable public native CompoundTag getBlockEntityNbtForSaving(BlockPos pPos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V") @Override public native void removeBlockEntity(BlockPos pPos); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;") @Override @Nullable public native CarvingMask getCarvingMask(GenerationStep.Carving pStep); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "getOrCreateCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "getOrCreateCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)Lnet/minecraft/world/level/chunk/CarvingMask;") @Override public native CarvingMask getOrCreateCarvingMask(GenerationStep.Carving pStep); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "setCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;Lnet/minecraft/world/level/chunk/CarvingMask;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setCarvingMask(Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;Lnet/minecraft/world/level/chunk/CarvingMask;)V") @Override public native void setCarvingMask(GenerationStep.Carving pStep, CarvingMask pCarvingMask); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V") @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 = @CopyFrom(clazz = ProtoChunk.class), value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;") private static native LevelChunkTicks unpackTicks(ProtoChunkTicks pTicks); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;") @Override public native LevelChunkTicks unpackBlockTicks(); - @TransformFrom(copyFrom = @CopyFrom(clazz = ProtoChunk.class), value = "unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;") + @TransformFrom(copyFrom = @Ref(ProtoChunk.class), value = "unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;") @Override public native LevelChunkTicks unpackFluidTicks(); @Override public LevelHeightAccessor getHeightAccessorForGeneration() { diff --git a/src/main/resources/dasm/sets/sets.dasm b/src/main/resources/dasm/sets/sets.dasm deleted file mode 100644 index 6c94eb27..00000000 --- a/src/main/resources/dasm/sets/sets.dasm +++ /dev/null @@ -1,55 +0,0 @@ -{ - "imports": [ - "io.github.opencubicchunks.cc_core.api.CubePos", - "io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos", - "net.minecraft.world.level.ChunkPos", - "net.minecraft.world.level.chunk.LevelChunk", - "net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity", - "net.minecraft.world.level.chunk.LevelChunk$PostLoadProcessor", - "net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper", - "net.minecraft.world.level.chunk.ChunkAccess", - "net.minecraft.world.level.chunk.ProtoChunk", - "net.minecraft.world.level.chunk.ImposterProtoChunk", - "io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloAccess", - "io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo", - "io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess", - "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube", - "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity", - "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$PostLoadProcessor", - "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper", - "io.github.opencubicchunks.cubicchunks.world.level.cube.ProtoCube", - "io.github.opencubicchunks.cubicchunks.world.level.cube.ImposterProtoCube" - ], - "sets": { - "general": { - "typeRedirects": { - "ChunkPos": "CloPos", - "ChunkAccess": "CloAccess", - "LevelChunk": "LevelClo" - }, - "fieldRedirects": { - }, - "methodRedirects": { - "ChunkAccess | ChunkPos getPos()": "cc_getCloPos" - } - }, - "cubeAccessAndDescendants": { - "typeRedirects": { - "ChunkPos": "CloPos", - "ChunkAccess": "CubeAccess", - "LevelChunk": "LevelCube", - "LevelChunk$BoundTickingBlockEntity": "LevelCube$BoundTickingBlockEntity", - "LevelChunk$PostLoadProcessor": "LevelCube$PostLoadProcessor", - "LevelChunk$RebindableTickingBlockEntityWrapper": "LevelCube$RebindableTickingBlockEntityWrapper", - "ProtoChunk": "ProtoCube", - "ImposterProtoChunk": "ImposterProtoCube" - }, - "fieldRedirects": { - "ChunkAccess | ChunkPos chunkPos": "cloPos" - }, - "methodRedirects": { - "ChunkAccess | ChunkPos getPos()": "cc_getCloPos" - } - } - } -} \ No newline at end of file