diff --git a/.gitignore b/.gitignore index 3a114d14..320872ba 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ forge*changelog.txt # Cubic Chunks generated files cubicchunks.mixins.*.json +cubicchunks.dasm.json # Dasm .dasm.out diff --git a/build.gradle b/build.gradle index 7fb172af..d6f79ca9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ import io.github.opencubicchunks.gradle.FixAnnotationsFormatterStep import io.github.opencubicchunks.gradle.GeneratePackageInfo -import org.gradle.api.tasks.testing.logging.TestExceptionFormat buildscript { dependencies { @@ -18,6 +17,7 @@ plugins { id("io.github.opencubicchunks.javaheaders").version("1.2.8") id("io.github.opencubicchunks.gradle.mcGitVersion") id("io.github.opencubicchunks.gradle.mixingen") + id("io.github.opencubicchunks.gradle.dasmgen") } version = mod_version @@ -67,7 +67,16 @@ tasks.register("generatePackageInfo") { tasks.register("genAll") { group = "filegen" - dependsOn(generatePackageInfo, generateMixinConfigs) + dependsOn(generatePackageInfo, generateMixinConfigs, generateDasmConfigs) +} + +dasmGen { + filePattern = "%s.dasm.json" + defaultMinVersion = "0.8" + + config(sourceSets.main, "cubicchunks") { + it.packageName = "io.github.opencubicchunks.cubicchunks" + } } mixinGen { @@ -229,10 +238,10 @@ neoForge { enable() // Configure which mod is being tested. // This allows NeoForge to load the test/ classes and resources as belonging to the mod. - testedMod = mods.cubicchunks // must match the name in the mods { } block. - // Configure which mods are loaded in the test environment, if the default (all declared mods) is not appropriate. - // This must contain testedMod, and can include other mods as well. - // loadedMods = [mods., mods.] + testedMod = mods.cubicchunks // must match the name in the mods { } block. + // Configure which mods are loaded in the test environment, if the default (all declared mods) is not appropriate. + // This must contain testedMod, and can include other mods as well. + // loadedMods = [mods., mods.] } } @@ -269,9 +278,9 @@ dependencies { targetConfiguration = "testArchivesOutput" } - libraries("io.github.notstirred:dasm:2.5.4") { - transitive = false - } + compileOnly("io.github.notstirred:dasm:3.2.0:api") + runtimeOnly(jarJar("io.github.notstirred:dasm-neoforge:3.2.0")) + libraries("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT") libraries("org.spongepowered:noise:2.0.0-SNAPSHOT") diff --git a/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java new file mode 100644 index 00000000..f560f67f --- /dev/null +++ b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmAutoGen.java @@ -0,0 +1,29 @@ +package io.github.opencubicchunks.gradle; + +import java.io.IOException; +import java.io.UncheckedIOException; + +import javax.annotation.Nonnull; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.plugins.JavaPluginConvention; + +public class DasmAutoGen implements Plugin { + + @Override public void apply(@Nonnull Project target) { + DasmGenExtension dasmExtension = new DasmGenExtension(); + target.getExtensions().add("dasmGen", dasmExtension); + Task generateDasmConfigs = target.getTasks().create("generateDasmConfigs"); + generateDasmConfigs.setGroup("filegen"); + generateDasmConfigs.doLast(task -> { + JavaPluginConvention convention = Utils.getJavaPluginConvention(target); + try { + dasmExtension.generateFiles(convention); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + } +} diff --git a/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java new file mode 100644 index 00000000..1dbd47d9 --- /dev/null +++ b/buildSrc/src/main/java/io/github/opencubicchunks/gradle/DasmGenExtension.java @@ -0,0 +1,189 @@ +package io.github.opencubicchunks.gradle; + +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static org.apache.tools.ant.util.StringUtils.removePrefix; +import static org.apache.tools.ant.util.StringUtils.removeSuffix; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.google.gson.stream.JsonWriter; +import org.gradle.api.Action; +import org.gradle.api.file.SourceDirectorySet; +import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.tasks.SourceSet; + +@SuppressWarnings("unused") +public class DasmGenExtension { + + Pattern pattern = Pattern.compile("(? *)@(Dasm|TransformFromClass).+? (interface|class|record) (?\\w+)?", Pattern.DOTALL); + + private final Map>> configsBySourceSet = new HashMap<>(); + + private String filePattern = "dasm.json"; + + private String defaultMinVersion; + + DasmGenExtension() {} + + public void setFilePattern(String pattern) { + this.filePattern = pattern; + } + + public String getFilePattern() { + return this.filePattern; + } + + public String getDefaultMinVersion() { + return defaultMinVersion; + } + + public void setDefaultMinVersion(String defaultMinVersion) { + this.defaultMinVersion = defaultMinVersion; + } + + public void config(SourceSet sourceSet, String name, Action configure) { + configsBySourceSet.computeIfAbsent(sourceSet, s -> new HashMap<>()).put(name, configure); + } + + public static class DasmConfig { + private String packageName; + private String minVersion; + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getMinVersion() { + return minVersion; + } + + public void setMinVersion(String minVersion) { + this.minVersion = minVersion; + } + } + + void generateFiles(JavaPluginConvention convention) throws IOException { + convention.getSourceSets().forEach(sourceSet -> { + Map> configs = configsBySourceSet.get(sourceSet); + if (configs == null) { + return; + } + + Set resourcesSet = sourceSet.getResources().getSrcDirs(); + Path resources; + try { + resources = resourcesSet.iterator().next().getCanonicalFile().toPath(); + } catch (IOException e) { + throw new RuntimeException(e); + } + for (String name : configs.keySet()) { + DasmConfig config = new DasmConfig(); + Action configure = configs.get(name); + if (defaultMinVersion != null) { + config.minVersion = defaultMinVersion; + } + configure.execute(config); + String fileName = String.format(filePattern, name); + + Path path = resources.resolve(fileName); + try { + Files.createDirectories(resources); + try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING))) { + writer.setIndent(" "); + writer.beginObject(); + if (config.packageName != null) { + writer.name("package").value(config.packageName); + } + if (config.minVersion != null) { + writer.name("minVersion").value(config.minVersion); + } + + writeDasm(convention, sourceSet, name, config, writer); + + writer.endObject(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }); + } + + private void writeDasm(JavaPluginConvention convention, SourceSet sourceSet, String name, DasmConfig config, JsonWriter writer) + throws IOException { + Set dasmTypes = getDasmClasses(config, sourceSet.getAllJava()); + + Set classesSet = new HashSet<>(); + Set interfacesSet = new HashSet<>(); + + Path prefixPath = Paths.get(config.packageName.replace('.', '/')); + + Function transform = path -> removePrefix(path.replace(File.separatorChar, '.'), name + "."); + + List types = dasmTypes.stream().map(transform).sorted(Comparator.comparing(a -> a.toLowerCase(Locale.ROOT))).toList(); + + writer.name("dasm").beginArray(); + for (String path : types) { + writer.value(path); + } + writer.endArray(); + } + + private Set getDasmClasses(DasmConfig config, SourceDirectorySet allJava) throws IOException { + System.out.println("GetDasm Classes"); + Set srcPaths = new HashSet<>(); + for (File file : allJava.getSrcDirs()) { + Path toPath = file.getCanonicalFile().toPath(); + System.out.println("GetDasm " + toPath); + + srcPaths.add(toPath); + } + + Set dasmTypes = new HashSet<>(); + for (File it : allJava) { + Path javaClass = it.getCanonicalFile().toPath(); + System.out.println("Class: " + javaClass); + for (Path srcPath : srcPaths) { + if (javaClass.startsWith(srcPath)) { + String relative = srcPath.relativize(javaClass).toString(); + if (relative.replace(File.separatorChar, '.').startsWith(config.packageName) && !relative.endsWith("package-info.java")) { + // This is an abomination. Ideally we'd parse .java files with a library + // This approach works fine for dasm on the outer class and its direct children, any other @Dasm annotation will be + // improperly parsed. (Also assumes our indentation is correct in all java files.) + Matcher matcher = pattern.matcher(Files.readString(javaClass)); + + String clazz = removeSuffix(relative, ".java"); + while (matcher.find()) { + String indent = matcher.group("indent"); + String name = matcher.group("name"); + + String path = indent.isEmpty() ? clazz : clazz + "$" + name; + + dasmTypes.add(path); + } + } + } + } + } + return dasmTypes; + } +} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties new file mode 100644 index 00000000..7c4eaf77 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.github.opencubicchunks.gradle.dasmgen.properties @@ -0,0 +1 @@ +implementation-class=io.github.opencubicchunks.gradle.DasmAutoGen diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java index 2a6e4479..37c7588e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/client/multiplayer/ClientCubeCache.java @@ -9,7 +9,6 @@ import javax.annotation.Nullable; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -161,7 +160,7 @@ public boolean inRange(int x, int y, int z) { && Math.abs(z - this.viewCenterZ) <= this.cubeRadius; } - @TransformFromMethod(owner = @Ref(ClientChunkCache.Storage.class), value = @MethodSig("getChunk(I)Lnet/minecraft/world/level/chunk/LevelChunk;"), visibility = PUBLIC) + @TransformFromMethod(owner = @Ref(ClientChunkCache.Storage.class), value = "getChunk(I)Lnet/minecraft/world/level/chunk/LevelChunk;", visibility = PUBLIC) public native @Nullable LevelCube getChunk(int chunkIndex); public void dumpChunks(String filePath) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java index a4d98e54..8ff9c561 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/ASMConfigPlugin.java @@ -2,86 +2,22 @@ import static org.objectweb.asm.Opcodes.*; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Optional; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.annotation.Nullable; -import com.mojang.datafixers.util.Either; -import io.github.notstirred.dasm.annotation.AnnotationParser; -import io.github.notstirred.dasm.annotation.AnnotationUtil; -import io.github.notstirred.dasm.annotation.parse.RefImpl; -import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.transform.ApplicationStage; -import io.github.notstirred.dasm.api.provider.MappingsProvider; -import io.github.notstirred.dasm.exception.DasmException; -import io.github.notstirred.dasm.notify.Notification; -import io.github.notstirred.dasm.transformer.Transformer; -import io.github.notstirred.dasm.transformer.data.ClassTransform; -import io.github.notstirred.dasm.transformer.data.MethodTransform; -import io.github.notstirred.dasm.util.CachingClassProvider; -import io.github.notstirred.dasm.util.Format; -import io.github.notstirred.dasm.util.NotifyStack; -import io.github.notstirred.dasm.util.Pair; import io.github.opencubicchunks.cc_core.annotation.Public; -import io.github.opencubicchunks.cubicchunks.CubicChunks; import io.github.opencubicchunks.cubicchunks.util.asm.FactoryFromConstructor; -import net.minecraft.Util; -import net.neoforged.fml.loading.FMLEnvironment; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; -import org.spongepowered.asm.mixin.transformer.ClassInfo; -import org.spongepowered.asm.service.MixinService; public class ASMConfigPlugin implements IMixinConfigPlugin { - private final Map dasmTransformedInPreApply = new ConcurrentHashMap<>(); - private final Transformer transformer; - private final AnnotationParser annotationParser; - - private final Map>> preApplyTargets = new HashMap<>(); - private final Map>> postApplyTargets = new HashMap<>(); - - private final Logger logger = LogManager.getLogger("dasm"); - - @SuppressWarnings("checkstyle:EmptyCatchBlock") // <-- TODO stirred's problem not mine :) - public ASMConfigPlugin() { - boolean developmentEnvironment = false; - try { - developmentEnvironment = !FMLEnvironment.production; - } catch (Throwable ignored) {} - MappingsProvider mappings = MappingsProvider.IDENTITY; - - // TODO: breaks on fabric (remapped at runtime) - var classProvider = new CachingClassProvider(s -> { - try (var classStream = ASMConfigPlugin.class.getClassLoader().getResourceAsStream(s.replace(".", "/") + ".class")) { - return Optional.ofNullable(classStream.readAllBytes()); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - this.transformer = new Transformer(classProvider, mappings); - this.annotationParser = new AnnotationParser(classProvider); - } + public ASMConfigPlugin() {} @Override public void onLoad(String mixinPackage) {} @@ -89,63 +25,7 @@ public ASMConfigPlugin() { return null; } - @SuppressWarnings("checkstyle:CyclomaticComplexity") // I'm to lazy to fix this as the class is hopefully being deleted soon @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - try { - ClassNode targetClass = MixinService.getService().getBytecodeProvider().getClassNode(targetClassName); - ClassNode mixinClass = MixinService.getService().getBytecodeProvider().getClassNode(mixinClassName); - - // Helpfully crash if dasm target doesn't make sense for a mixin class. This uses a ton of mostly static dasm internals. - AnnotationNode dasmAnnotation = AnnotationUtil.getAnnotationIfPresent(mixinClass.invisibleAnnotations, Dasm.class); - if (dasmAnnotation != null) { - Optional dasmTarget = RefImpl - .parseOptionalRefAnnotation((AnnotationNode) AnnotationUtil.getAnnotationValues(dasmAnnotation, Dasm.class).get("target")); - if (dasmTarget.isEmpty() || dasmTarget.get().equals(Type.getType(Dasm.SELF_TARGET.class))) { - throw new RuntimeException("Mixin class " + Format.formatObjectType(Type.getObjectType(mixinClass.name)) - + " with @Dasm annotation should probably have a @Dasm(value = Set.class, target = ...) targeting the mixin target class"); - } - } - - // PRE_APPLY - handleError(this.annotationParser.findDasmAnnotations(mixinClass)); - var methodTransformsMixin = handleError(this.annotationParser.buildContext().buildMethodTargets(mixinClass, "cc_dasm$")); - handleError(this.annotationParser.findDasmAnnotations(targetClass)); - var classTransform = handleError(this.annotationParser.buildContext().buildClassTarget(targetClass)); - var methodTransformsTarget = handleError(this.annotationParser.buildContext().buildMethodTargets(targetClass, "cc_dasm$")); - - var methodTransforms = Stream.of(methodTransformsTarget, methodTransformsMixin).filter(Optional::isPresent).map(Optional::get) - .flatMap(Collection::stream).toList(); - - String key = mixinClassName + "|" + targetClassName; - if (classTransform.isPresent()) { - // TODO: nice error - assert methodTransformsMixin.isEmpty() && methodTransforms.isEmpty() : "Whole class transform WITH method transforms?"; - ClassTransform transform = classTransform.get(); - if (transform.stage() == ApplicationStage.PRE_APPLY) { - this.preApplyTargets.put(key, Either.left(transform)); - } else { - this.postApplyTargets.put(key, Either.left(transform)); - } - } else { - Collection preTransforms = this.preApplyTargets.computeIfAbsent(key, k -> Either.right(new ArrayList<>())).right() - .get(); - Collection postTransforms = this.postApplyTargets.computeIfAbsent(key, k -> Either.right(new ArrayList<>())).right() - .get(); - methodTransforms.forEach(transform -> { - if (transform.stage() == ApplicationStage.PRE_APPLY) { - preTransforms.add(transform); - } else { - postTransforms.add(transform); - } - }); - } - } catch (DasmException e) { - throw new RuntimeException(e); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } return true; } @@ -155,98 +35,11 @@ public ASMConfigPlugin() { return null; } - @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - boolean wasTransformed; - try { - wasTransformed = transformClass(targetClassName, targetClass, mixinClassName, ApplicationStage.PRE_APPLY); - } catch (DasmException e) { - throw new RuntimeException(e); - } - dasmTransformedInPreApply.put(mixinClassName + "|" + targetClassName, wasTransformed); - - try { - // ugly hack to add class metadata to mixin - // based on - // https://github.com/Chocohead/OptiFabric/blob/54fc2ef7533e43d1982e14bc3302bcf156f590d8/src/main/java/me/modmuss50/optifabric/compat/fabricrendererapi - // /RendererMixinPlugin.java#L25:L44 - Method addMethod = ClassInfo.class.getDeclaredMethod("addMethod", MethodNode.class, boolean.class); - addMethod.setAccessible(true); - - ClassInfo ci = ClassInfo.forName(targetClassName); - Set existingMethods = ci.getMethods().stream().map(x -> x.getName() + x.getDesc()).collect(Collectors.toSet()); - for (MethodNode method : targetClass.methods) { - if (!existingMethods.contains(method.name + method.desc)) { - addMethod.invoke(ci, method, false); - } - } - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - } + @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { doPublicAnnotation(targetClass); doFactoryFromConstructorAnnotation(targetClass); - - // Apply POST_APPLY dasm transforms - boolean wasTransformed; - try { - wasTransformed = transformClass(targetClassName, targetClass, mixinClassName, ApplicationStage.POST_APPLY); - } catch (DasmException e) { - throw new RuntimeException(e); - } - // If no DASM transformation happened to this class, we can skip removing the prefixed methods - if (!(wasTransformed | dasmTransformedInPreApply.get(mixinClassName + "|" + targetClassName))) { - return; - } - - // Find all DASM-added method nodes and their corresponding MixinMerged method nodes - record PrefixMethodPair(MethodNode dasmAddedMethod, MethodNode mixinAddedMethod) {} - List methodPairs = new ArrayList<>(); - for (MethodNode methodNode : targetClass.methods) { - if (methodNode.name.contains("cc_dasm$")) { - var methodNameWithoutPrefix = methodNode.name.substring(methodNode.name.indexOf("$") + 1).replace("__init__", "") - .replace("__clinit__", ""); - - var mixinAddedMethod = targetClass.methods.stream() - .filter(m -> m.name.equals(methodNameWithoutPrefix) && m.desc.equals(methodNode.desc)).findFirst(); - - if (mixinAddedMethod.isEmpty()) { - CubicChunks.LOGGER - .info(String.format("Found DASM added method `%s` without a corresponding MixinMerged method", methodNameWithoutPrefix)); - } - methodPairs.add(new PrefixMethodPair(methodNode, mixinAddedMethod.orElse(null))); - } - } - - // Remove the mixin-added methods and set the dasm-added names - methodPairs.forEach(prefixMethodPair -> { - if (prefixMethodPair.mixinAddedMethod != null) { - targetClass.methods.remove(prefixMethodPair.mixinAddedMethod); - - // Copy annotations and visibility from mixin method - prefixMethodPair.dasmAddedMethod.visibleAnnotations = prefixMethodPair.mixinAddedMethod.visibleAnnotations; - prefixMethodPair.dasmAddedMethod.invisibleAnnotations = prefixMethodPair.mixinAddedMethod.invisibleAnnotations; - prefixMethodPair.dasmAddedMethod.access &= ~(ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED); - prefixMethodPair.dasmAddedMethod.access |= (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED) & prefixMethodPair.mixinAddedMethod.access; - } - - prefixMethodPair.dasmAddedMethod.name = prefixMethodPair.dasmAddedMethod.name.replace("__init__", "").replace("__clinit__", - ""); - - // remove the prefix - prefixMethodPair.dasmAddedMethod.name = prefixMethodPair.dasmAddedMethod.name.substring("cc_dasm$".length()); - }); - - ClassWriter classWriter = new ClassWriter(0); - targetClass.accept(classWriter); - try { - Path path = Path.of(".dasm.out/" + "POSTIER_APPLY" + "/" + targetClassName.replace('.', '/') + ".class").toAbsolutePath(); - Files.createDirectories(path.getParent()); - Files.write(path, classWriter.toByteArray()); - } catch (IOException e) { - throw new RuntimeException(e); - } } private void doPublicAnnotation(ClassNode targetClass) { @@ -303,71 +96,4 @@ private static void transformStubToFactory(MethodNode method) { method.desc.substring(0, method.desc.lastIndexOf(')') + 1) + "V", false); method.visitInsn(ARETURN); } - - /** - * @return Whether any transformation was done to the targetClass - */ - private boolean transformClass(String targetClassName, ClassNode targetClass, String mixinClassName, ApplicationStage stage) - throws DasmException { - Either> target = null; - switch (stage) { - case PRE_APPLY -> { - target = preApplyTargets.get(mixinClassName + "|" + targetClassName); - } - case POST_APPLY -> { - target = postApplyTargets.get(mixinClassName + "|" + targetClassName); - } - default -> throw new IllegalStateException("Unknown enum variant: " + stage); - } - if (target == null) { - return false; - } - - if (target.left().isPresent()) { - this.transformer.transform(targetClass, target.left().get()); - } else { - this.transformer.transform(targetClass, target.right().get()); - } - ClassWriter classWriter = new ClassWriter(0); - targetClass.accept(classWriter); - try { - Path path = Path.of(".dasm.out/" + stage + "/" + targetClassName.replace('.', '/') + ".class").toAbsolutePath(); - Files.createDirectories(path.getParent()); - Files.write(path, classWriter.toByteArray()); - } catch (IOException e) { - throw new RuntimeException(e); - } - - return true; - } - - private T handleError(Pair> result) { - handleError(result.second()); - return result.first(); - } - - private void handleError(NotifyStack notifyStack) { - handleError(notifyStack.notifications()); - } - - private void handleError(List notifications) { - for (var notification : notifications) { - switch (notification.kind) { - case INFO: - logger.info(notification.message); - break; - case WARNING: - logger.warn(notification.message); - break; - case ERROR: - logger.fatal(notification.message); - break; - default: - throw new IllegalStateException("Unknown enum variant: " + notification.kind); - } - } - if (notifications.stream().anyMatch(n -> n.kind == Notification.Kind.ERROR)) { - throw Util.pauseInIde(new RuntimeException("DASM Failure, please see log output")); - } - } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java index efcbb29f..8877dfc4 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientChunkCache.java @@ -10,7 +10,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; @@ -38,13 +37,13 @@ /** * The vanilla {@link ClientChunkCache} class stores all loaded chunks on the client and has methods to update and unload them, as well as change the - * center and range of the chunk storage. - * This mixin adds versions of these methods for cubes, meaning that this class now stores both cubes and chunks. + * center and range of the chunk storage. This mixin adds versions of these methods for cubes, meaning that this class now stores both cubes and + * chunks. */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ClientChunkCache.class)) @Mixin(ClientChunkCache.class) public abstract class MixinClientChunkCache extends MixinChunkSource implements ClientCubeCache { - @AddFieldToSets(containers = ChunkToCubeSet.ClientChunkCache_redirects.class, field = @FieldSig(type = @Ref(ClientChunkCache.Storage.class), name = "storage")) + @AddFieldToSets(containers = ChunkToCubeSet.ClientChunkCache_redirects.class, field = "storage:Lnet/minecraft/client/multiplayer/ClientChunkCache$Storage;") volatile ClientCubeCache.Storage cc_cubeStorage; private LevelCube cc_emptyCube; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java deleted file mode 100644 index 4b315e95..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/multiplayer/MixinClientCubeCache$Storage.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.client.multiplayer; - -import io.github.opencubicchunks.cubicchunks.client.multiplayer.ClientCubeCache; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(ClientCubeCache.Storage.class) -public class MixinClientCubeCache$Storage {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java index 846af3d3..d7a7946c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinLevelRenderer.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -15,6 +14,6 @@ @Mixin(LevelRenderer.class) public abstract class MixinLevelRenderer implements CubicLevelRenderer { @AddTransformToSets(ChunkToCubeSet.LevelRenderer_redirects.class) - @TransformFromMethod(@MethodSig("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_onCubeReadyToRender(CubePos cubePos); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java index 5026cf5c..e4506ab8 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/MixinSectionOcclusionGraph.java @@ -7,7 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -43,10 +42,10 @@ private void cc_onWaitAndReset(@Nullable ViewArea viewArea, CallbackInfo ci) { } @AddTransformToSets(ChunkToCubeSet.SectionOcclusionGraph_redirects.class) - @TransformFromMethod(@MethodSig("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("onChunkReadyToRender(Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_onCubeReadyToRender(CubePos cubePos); - @AddMethodToSets(containers = ChunkToCubeSet.SectionOcclusionGraph_redirects.class, method = @MethodSig("addNeighbors(Lnet/minecraft/client/renderer/SectionOcclusionGraph$GraphEvents;Lnet/minecraft/world/level/ChunkPos;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.SectionOcclusionGraph_redirects.class, method = "addNeighbors(Lnet/minecraft/client/renderer/SectionOcclusionGraph$GraphEvents;Lnet/minecraft/world/level/ChunkPos;)V") private void cc_addNeighbors(SectionOcclusionGraph.GraphEvents graphEvents, CubePos cubePos) { var access = ((SectionOcclusionGraph$GraphEventsAccess) (Object) graphEvents); int cubeX = cubePos.getX(); @@ -64,7 +63,8 @@ private void cc_addNeighbors(SectionOcclusionGraph.GraphEvents graphEvents, Cube } } - @WrapOperation(method = "initializeQueueForFullUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ViewArea;getRenderSection(J)Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection;")) + @WrapOperation(method = "initializeQueueForFullUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ViewArea;getRenderSection(J)" + + "Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection;")) private @Nullable SectionRenderDispatcher.RenderSection cc_onInitializeQueueForFullUpdate_getRenderSectionAt( ViewArea instance, long sectionPos, Operation original ) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java index 5d5ae755..71a3cf5e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/renderer/chunk/MixinSectionCopy.java @@ -3,31 +3,28 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.exception.DasmFailedToApply; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; import net.minecraft.client.renderer.chunk.SectionCopy; -import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; import org.spongepowered.asm.mixin.Mixin; /** - * The vanilla {@link SectionCopy} stores block data of a {@link LevelChunkSection} and is used for rendering that section. - * We simply add a constructor that creates the {@code SectionCopy} from a cube instead of a chunk. + * The vanilla {@link SectionCopy} stores block data of a {@link LevelChunkSection} and is used for rendering that section. We simply add a + * constructor that creates the {@code SectionCopy} from a cube instead of a chunk. */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(SectionCopy.class)) @Mixin(SectionCopy.class) public class MixinSectionCopy { // TODO is this field on the vanilla class actually used anywhere? based on snowblower output not having it, it seems like neoforge is adding it? - @AddFieldToSets(containers = ChunkToCubeSet.SectionCopy_redirects.class, field = @FieldSig(type = @Ref(LevelChunk.class), name = "wrapped")) + @AddFieldToSets(containers = ChunkToCubeSet.SectionCopy_redirects.class, field = "wrapped:Lnet/minecraft/world/level/chunk/LevelChunk;") final LevelCube cc_wrapped; @AddTransformToSets(ChunkToCubeSet.SectionCopy_redirects.class) - @TransformFromMethod(@MethodSig("(Lnet/minecraft/world/level/chunk/LevelChunk;I)V")) + @TransformFromMethod("(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") public MixinSectionCopy(LevelCube wrapped, int sectionIndex) { throw new DasmFailedToApply(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java deleted file mode 100644 index 93bdc169..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCCommonHooks.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.movetoforgesourcesetlater; - -import io.github.opencubicchunks.cubicchunks.movetoforgesourcesetlater.CCCommonHooks; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CCCommonHooks.class) -public class MixinCCCommonHooks {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java deleted file mode 100644 index 4fbc0b53..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinCCEventHooks.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.movetoforgesourcesetlater; - -import io.github.opencubicchunks.cubicchunks.movetoforgesourcesetlater.CCEventHooks; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CCEventHooks.class) -public class MixinCCEventHooks {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java index 05b3eb1a..db420547 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/movetoforgesourcesetlater/MixinGenerationChunkHolder_Forge.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; @@ -21,7 +20,7 @@ public class MixinGenerationChunkHolder_Forge { @Shadow public LevelChunk currentlyLoading; // Corresponds to field added by Forge - @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_Forge_Jank_redirects.class, field = @FieldSig(name = "currentlyLoading", type = @Ref(LevelChunk.class))) + @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_Forge_Jank_redirects.class, field = "currentlyLoading:Lnet/minecraft/world/level/chunk/LevelChunk;") public LevelCube cc_currentlyLoadingCube; public LevelClo cc_getCurrentlyLoading() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java index 23a98d7c..213138db 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkGenerationTask.java @@ -5,8 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.annotation.Public; @@ -45,8 +43,7 @@ * chunks as required. *

* We modify it to support cube loading as well, loading both neighboring cubes and chunks as required, and preserving chunk-cube load order - * invariants - * (cube status never exceeds the status of any chunks intersecting it) + * invariants (cube status never exceeds the status of any chunks intersecting it) */ @Dasm(value = GlobalSet.class, target = @Ref(ChunkGenerationTask.class)) @Mixin(ChunkGenerationTask.class) @@ -57,13 +54,13 @@ public abstract class MixinChunkGenerationTask implements CloGenerationTask { @Shadow @Final public ChunkStatus targetStatus; @Shadow private volatile boolean markedForCancellation; @Shadow @Final private StaticCache2D cache; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = @FieldSig(type = @Ref(ChunkPos.class), name = "pos")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = "pos:Lnet/minecraft/world/level/ChunkPos;") private CubePos cc_cubePos; // scheduledChunkStatus must be one status higher than the scheduled status for cubes until the target status is reached, to ensure load order // invariants are preserved // we use the vanilla field for cube status, since that is the status of the actual cube that is being generated public @Nullable ChunkStatus cc_scheduledChunkStatus; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = @FieldSig(type = @Ref(StaticCache2D.class), name = "cache")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, field = "cache:Lnet/minecraft/util/StaticCache2D;") private StaticCache3D cc_cubeCache; private GeneratingCubeMap cc_getGeneratingCubeMap() { @@ -80,7 +77,8 @@ private GeneratingCubeMap cc_getGeneratingCubeMap() { /** * Factory method to create a {@code ChunkGenerationTask} for a cube. */ - @AddMethodToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, method = @MethodSig("create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkGenerationTask_redirects.class, method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;") @Public private static ChunkGenerationTask cc_createCubeGenerationTask(GeneratingChunkMap chunkMap, ChunkStatus targetStatus, CubePos pos) { int cubeRadius = CubePyramid.CC_GENERATION_PYRAMID_CUBES.getStepTo(targetStatus).getAccumulatedRadiusOf(ChunkStatus.EMPTY); int cubeDiameter = cubeRadius * 2 + 1; @@ -97,7 +95,8 @@ private GeneratingCubeMap cc_getGeneratingCubeMap() { return chunkGenerationTask; } - @AddMethodToSets(containers = ChunkToCloSet.ChunkGenerationTask_redirects.class, method = @MethodSig("create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkGenerationTask_redirects.class, method = "create(Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;") @Public private static ChunkGenerationTask cc_createCubeGenerationTask(GeneratingChunkMap chunkMap, ChunkStatus targetStatus, CloPos pos) { if (pos.isCube()) { return cc_createCubeGenerationTask(chunkMap, targetStatus, pos.cubePos()); @@ -115,9 +114,8 @@ private void cc_onScheduleNextLayer(CallbackInfo ci) { } /** - * Cube equivalent to {@code scheduleNextLayer}. - * Loads chunks one status higher than cubes until chunks have reached the target status, as otherwise cubes could reach a status before their - * intersecting chunks do. + * Cube equivalent to {@code scheduleNextLayer}. Loads chunks one status higher than cubes until chunks have reached the target status, as + * otherwise cubes could reach a status before their intersecting chunks do. */ private void cc_scheduleNextLayer() { ChunkStatus nextChunkStatus; @@ -272,7 +270,7 @@ private void cc_onScheduleLayer(ChunkStatus status, boolean needsGeneration, Cal throw new IllegalStateException("shouldn't call vanilla scheduleLayer for cube generation task"); } - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = @MethodSig("getRadiusForLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Z)I")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = "getRadiusForLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Z)I") private native int cc_getCubeRadiusForLayer(ChunkStatus status, boolean needsGeneration); @Shadow protected abstract boolean scheduleChunkInLayer(ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk); @@ -294,6 +292,6 @@ private void cc_onScheduleChunkInLayer( } } - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = @MethodSig("scheduleChunkInLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;ZLnet/minecraft/server/level/GenerationChunkHolder;)Z")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkGenerationTask.class), value = "scheduleChunkInLayer(Lnet/minecraft/world/level/chunk/status/ChunkStatus;ZLnet/minecraft/server/level/GenerationChunkHolder;)Z") private native boolean cc_scheduleCubeInLayer(ChunkStatus status, boolean needsGeneration, GenerationChunkHolder chunk); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java index c15d7c4f..619c2280 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkHolder.java @@ -11,8 +11,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -47,9 +45,8 @@ /** * The vanilla {@link ChunkHolder} class extends {@link GenerationChunkHolder} to have methods for getting a fully loaded chunk, and handle saving - * dependencies and broadcasting updates to clients. - * This mixin adds cubic chunks equivalents for methods where necessary, to allow GenerationChunkHolder to dynamically wrap either a chunk or a cube - * (i.e. a CLO). + * dependencies and broadcasting updates to clients. This mixin adds cubic chunks equivalents for methods where necessary, to allow + * GenerationChunkHolder to dynamically wrap either a chunk or a cube (i.e. a CLO). */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ChunkHolder.class)) @Mixin(ChunkHolder.class) @@ -57,14 +54,16 @@ public abstract class MixinChunkHolder extends MixinGenerationChunkHolder implem @Shadow private boolean hasChangedSections; @Shadow @Final private ShortSet[] changedBlocksPerSection; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = @FieldSig(type = @Ref(ChunkHolder.LevelChangeListener.class), name = "onLevelChange")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = "onLevelChange:Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;") private final LevelChangeListener cc_onLevelChange; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = @FieldSig(type = @Ref(ChunkHolder.PlayerProvider.class), name = "playerProvider")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkHolder_redirects.class, field = "playerProvider:Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;") private final PlayerProvider cc_playerProvider; @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("(Lnet/minecraft/world/level/ChunkPos;ILnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/world/level/lighting/LevelLightEngine;Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "(Lnet/minecraft/world/level/ChunkPos;ILnet/minecraft/world/level/LevelHeightAccessor;" + + "Lnet/minecraft/world/level/lighting/LevelLightEngine;Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;" + + "Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V") public MixinChunkHolder() { throw new DasmFailedToApply(); } @@ -72,10 +71,10 @@ public MixinChunkHolder() { @Shadow public abstract @Nullable LevelChunk getTickingChunk(); @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;") public native @Nullable LevelCube cc_getTickingCube(); - @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = @MethodSig("getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = "getTickingChunk()Lnet/minecraft/world/level/chunk/LevelChunk;") public @Nullable LevelClo cc_getTickingClo() { if (cc_cubePos != null) { return cc_getTickingCube(); @@ -86,11 +85,11 @@ public MixinChunkHolder() { @Shadow public abstract @Nullable LevelChunk getChunkToSend(); @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;") public native @Nullable LevelCube cc_getCubeToSend(); @AddTransformToSets(ChunkToCloSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "getChunkToSend()Lnet/minecraft/world/level/chunk/LevelChunk;") public @Nullable LevelClo cc_getCloToSend() { if (cc_cubePos != null) { return cc_getCubeToSend(); @@ -106,10 +105,10 @@ public void cc_onBlockChanged(BlockPos pos, CallbackInfoReturnable cir) } // region [cc_blockChanged dasm + mixin] - @TransformFromMethod(@MethodSig("blockChanged(Lnet/minecraft/core/BlockPos;)Z")) + @TransformFromMethod("blockChanged(Lnet/minecraft/core/BlockPos;)Z") private native boolean cc_blockChanged(BlockPos pos); - @Dynamic @Redirect(method = "cc_dasm$cc_blockChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_blockChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionIndex(I)I")) private int cc_onBlockChanged_sectionIndex(LevelHeightAccessor instance, int y, BlockPos pos) { return Coords.sectionToIndex(Coords.blockToSection(pos.getX()), Coords.blockToSection(pos.getY()), Coords.blockToSection(pos.getZ())); } @@ -126,12 +125,12 @@ public void cc_onSectionLightChanged(LightLayer lightLayer, int sectionY, Callba // region [cc_broadcastCubeChanges dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = @MethodSig("broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod(owner = @Ref(ChunkHolder.class), value = "broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_broadcastCubeChanges(LevelCube cube); // TODO (P2) lighting - ClientboundLightUpdatePacket branch is currently never reached; once we have lighting it will have to be a CC packet, and // this.broadcast will need to redirect to a CC method - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) + @Dynamic @Redirect(method = "cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionYFromSectionIndex(I)I")) private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instance, int sectionIndex) { // The vanilla method uses SectionPos.of(ChunkPos, sectionY), but we want SectionPos.of(CubePos, sectionIndex). // The easiest way to accomplish this is to turn `getSectionYFromSectionIndex` into a no-op so that we get sectionIndex instead of sectionY. @@ -139,13 +138,13 @@ private int cc_onBroadcastCubeChanges_indexToSectionY(LevelHeightAccessor instan return sectionIndex; } - @Dynamic @Redirect(method = "cc_dasm$cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) + @Dynamic @Redirect(method = "cc_broadcastCubeChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lio/github/opencubicchunks/cc_core/api/CubePos;I)Lnet/minecraft/core/SectionPos;")) private SectionPos cc_onBroadcastCubeChanges_sectionPos(CubePos cubePos, int sectionIndex) { return Coords.sectionPosByIndex(cubePos, sectionIndex); } // endregion - @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = @MethodSig("broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkHolder_redirects.class, method = "broadcastChanges(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public void cc_broadcastCloChanges(LevelClo clo) { if (cc_cubePos != null) { cc_broadcastCubeChanges((LevelCube) clo); @@ -155,7 +154,8 @@ public void cc_broadcastCloChanges(LevelClo clo) { } @WrapOperation(method = { "lambda$scheduleFullChunkPromotion$4", - "demoteFullChunk" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V")) + "demoteFullChunk" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;" + + "Lnet/minecraft/server/level/FullChunkStatus;)V")) private void cc_onCallChunkMapOnFullChunkStatusChange( ChunkMap instance, ChunkPos chunkPos, FullChunkStatus fullChunkStatus, Operation original ) { @@ -166,7 +166,8 @@ private void cc_onCallChunkMapOnFullChunkStatusChange( } } - @WrapOperation(method = "updateFutures", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @WrapOperation(method = "updateFutures", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkHolder$LevelChangeListener;onLevelChange(Lnet/minecraft/world/level/ChunkPos;" + + "Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) protected void cc_onUpdateFutures_onCallOnLevelChange( ChunkHolder.LevelChangeListener instance, ChunkPos chunkPos, IntSupplier intSupplier, int i, IntConsumer intConsumer, Operation original diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java index d5e81778..5c8ffcd5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap$TrackedEntity.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; @@ -23,10 +22,10 @@ public abstract class MixinChunkMap$TrackedEntity { // region [cc_updatePlayer dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap$TrackedEntity_redirects.class) - @TransformFromMethod(@MethodSig("updatePlayer(Lnet/minecraft/server/level/ServerPlayer;)V")) + @TransformFromMethod("updatePlayer(Lnet/minecraft/server/level/ServerPlayer;)V") public native void cc_updatePlayer(ServerPlayer player); - @Dynamic @Redirect(method = "cc_dasm$cc_updatePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_updatePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_updatePlayer_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z) { // FIXME entity clo position once implemented return false; // ((CubicChunkMap) instance).cc_isChunkTracked(player, this.entity.chunkPosition().x, 0, this.entity.chunkPosition().z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java index fcd300fd..9cd24bd6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java @@ -23,8 +23,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -92,8 +90,8 @@ /** * The vanilla {@link ChunkMap} class stores all loaded chunks for a world and handles loading and unloading them, including dependencies on - * neighboring chunks. - * This mixin adds cubic chunks equivalents for methods where necessary, to allow ChunkMap to work with CLOs (i.e. both chunks and cubes). + * neighboring chunks. This mixin adds cubic chunks equivalents for methods where necessary, to allow ChunkMap to work with CLOs (i.e. both chunks and + * cubes). */ @Dasm(value = ChunkToCloSet.class, target = @Ref(ChunkMap.class)) @Mixin(ChunkMap.class) @@ -113,9 +111,9 @@ public abstract class MixinChunkMap extends MixinChunkStorage implements Generat } // TODO this one being on GlobalSet is a bit jank - @AddFieldToSets(containers = GlobalSet.ChunkMap_redirects.class, field = @FieldSig(type = @Ref(ChunkProgressListener.class), name = "progressListener")) + @AddFieldToSets(containers = GlobalSet.ChunkMap_redirects.class, field = "progressListener:Lnet/minecraft/server/level/progress/ChunkProgressListener;") private CloProgressListener cc_progressListener; - @AddFieldToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, field = @FieldSig(type = @Ref(ChunkStatusUpdateListener.class), name = "chunkStatusListener")) + @AddFieldToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, field = "chunkStatusListener:Lnet/minecraft/world/level/entity/ChunkStatusUpdateListener;") private CloStatusUpdateListener cc_cloStatusListener; // TODO once we can target non-return locations in constructors, do this when the vanilla field is set @@ -136,13 +134,13 @@ private void cc_onInit( } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("setChunkUnsaved(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("setChunkUnsaved(Lnet/minecraft/world/level/ChunkPos;)V") private native void cc_setCloUnsaved(CloPos cloPos); /** * Returns the squared distance to the center of the cube. */ - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = @MethodSig("euclideanDistanceSquared(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/phys/Vec3;)D")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = "euclideanDistanceSquared(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/phys/Vec3;)D") private static double cc_euclideanDistanceSquared(CloPos cloPos, Vec3 vec3) { if (cloPos.isChunk()) { // FIXME we shouldn't be getting euclidean distance for chunks, as this doesn't make sense in context @@ -186,17 +184,18 @@ private boolean cc_isChunkOnTrackedBorder(ServerPlayer player, int x, int y, int // region [cc_getChunkRangeFuture dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getChunkRangeFuture(Lnet/minecraft/server/level/ChunkHolder;ILjava/util/function/IntFunction;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("getChunkRangeFuture(Lnet/minecraft/server/level/ChunkHolder;ILjava/util/function/IntFunction;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture>> cc_getChunkRangeFuture( ChunkHolder cloHolder, int radius, IntFunction statusByRadius ); // TODO this could be substantially improved probably hopefully + /** * Cubes require different adjacency logic compared to Chunks */ @SuppressWarnings("checkstyle:CyclomaticComplexity") // <-- TODO this method is just a bit of a disaster - @Dynamic @Inject(method = "cc_dasm$cc_getChunkRangeFuture", at = @At("HEAD"), cancellable = true) + @Dynamic @Inject(method = "cc_getChunkRangeFuture", at = @At("HEAD"), cancellable = true) private void cc_onGetChunkRangeFuture( ChunkHolder cloHolder, int radius, IntFunction statusByRadius, CallbackInfoReturnable>>> cir @@ -277,7 +276,7 @@ private void cc_onGetChunkRangeFuture( // region [cc_updateCubeScheduling dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkMap_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = @MethodSig("updateChunkScheduling(JILnet/minecraft/server/level/ChunkHolder;I)Lnet/minecraft/server/level/ChunkHolder;")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = "updateChunkScheduling(JILnet/minecraft/server/level/ChunkHolder;I)Lnet/minecraft/server/level/ChunkHolder;") public native @Nullable ChunkHolder cc_updateCubeScheduling(long cubePos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); @Inject(method = "updateChunkScheduling", at = @At("HEAD"), cancellable = true) @@ -289,16 +288,16 @@ private void cc_onUpdateChunkScheduling(long cloPos, int newLevel, ChunkHolder h // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @TransformFromMethod("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") private native void cc_onLevelChange(CloPos cloPos, IntSupplier intsupplier, int i, IntConsumer intconsumer); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") public void cc_onCubeLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter) { cc_onLevelChange(CloPos.cube(cubePos), queueLevelGetter, ticketLevel, queueLevelSetter); } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("saveAllChunks(Z)V")) + @TransformFromMethod("saveAllChunks(Z)V") public native void cc_saveAllChunks(boolean flush); @Inject(method = "saveAllChunks", at = @At("HEAD"), cancellable = true) @@ -310,25 +309,26 @@ private void cc_onSaveAllChunks(boolean flush, CallbackInfo ci) { } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("saveChunksEagerly(Ljava/util/function/BooleanSupplier;)V")) + @TransformFromMethod("saveChunksEagerly(Ljava/util/function/BooleanSupplier;)V") private native void cc_saveClosEagerly(BooleanSupplier hasMoreTime); - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = @MethodSig("scheduleUnload(JLnet/minecraft/server/level/ChunkHolder;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = "scheduleUnload(JLnet/minecraft/server/level/ChunkHolder;)V") private void cc_scheduleUnload(long chunkPos, ChunkHolder chunkHolder) { // TODO (P2) save/load } // region [cc_scheduleChunkLoad dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture cc_scheduleChunkLoad(CloPos cloPos); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "scheduleChunkLoad(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private CompletableFuture cc_scheduleChunkLoad(CubePos cubePos) { return cc_scheduleChunkLoad(CloPos.cube(cubePos)); } - @Dynamic @Redirect(method = "cc_dasm$cc_scheduleChunkLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)Ljava/util/concurrent/CompletableFuture;")) + @Dynamic @Redirect(method = "cc_scheduleChunkLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;prefetch(Lio/github/opencubicchunks/cc_core/world/level/CloPos;)" + + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManager instance, CloPos cloPos) { // TODO (P2) save/load - PoiManager return CompletableFuture.completedFuture(null); @@ -336,46 +336,49 @@ private CompletableFuture cc_onScheduleChunkLoad_poiManagerPreFetch(PoiManage // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("handleChunkLoadFailure(Ljava/lang/Throwable;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod("handleChunkLoadFailure(Ljava/lang/Throwable;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;") private native ChunkResult cc_handleChunkLoadFailure(Throwable exception, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("createEmptyChunk(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(value = "createEmptyChunk(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;") private native CloAccess cc_createEmptyChunk(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markPositionReplaceable(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("markPositionReplaceable(Lnet/minecraft/world/level/ChunkPos;)V") private native void cc_markPositionReplaceable(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markPosition(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkType;)B")) + @TransformFromMethod("markPosition(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkType;)B") private native byte cc_markPosition(CloPos cloPos, ChunkType chunkType); // region [cc_applyCubeStep dasm + mixin] @AddTransformToSets(ChunkToCubeSet.ChunkMap_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = @MethodSig("applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, value = "applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture cc_applyCubeStep( GenerationChunkHolder generationchunkholder, CubeStep chunkstep, StaticCache3D cache ); - @Dynamic @Redirect(method = "cc_dasm$cc_applyCubeStep", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) + @Dynamic @Redirect(method = "cc_applyCubeStep", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) private Object cc_onApplyCubeStep_staticCacheGet(StaticCache3D instance, int x, int z, @Local(ordinal = 0) CubePos cubePos) { return instance.get(cubePos.getX(), cubePos.getY(), cubePos.getZ()); } // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @TransformFromMethod("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + + "Lnet/minecraft/server/level/ChunkGenerationTask;") public native ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus chunkstatus, CloPos cloPos); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + + "Lnet/minecraft/server/level/ChunkGenerationTask;") public ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus chunkstatus, CubePos cubePos) { return cc_scheduleGenerationTask(chunkstatus, CloPos.cube(cubePos)); } // region [cc_runGenerationTask dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("runGenerationTask(Lnet/minecraft/server/level/ChunkGenerationTask;)V")) + @TransformFromMethod("runGenerationTask(Lnet/minecraft/server/level/ChunkGenerationTask;)V") private native void cc_runGenerationTask(ChunkGenerationTask chunkgenerationtask); // Delegate to the cube method for cubes @@ -389,7 +392,7 @@ private void cc_onVanillaRunGenerationTask(ChunkGenerationTask task, CallbackInf // endregion @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("prepareEntityTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("prepareEntityTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture> cc_prepareEntityTickingChunk(ChunkHolder holder); @Inject(method = "prepareEntityTickingChunk", at = @At("HEAD"), cancellable = true) @@ -400,7 +403,7 @@ private void cc_onVanillaPrepareEntityTickingChunk(ChunkHolder chunk, CallbackIn } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("prepareTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("prepareTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture> cc_prepareTickingChunk(ChunkHolder holder); @Inject(method = "prepareTickingChunk", at = @At("HEAD"), cancellable = true) @@ -411,11 +414,11 @@ private void cc_onVanillaPrepareTickingChunk(ChunkHolder chunk, CallbackInfoRetu } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("onChunkReadyToSend(Lnet/minecraft/server/level/ChunkHolder;Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod("onChunkReadyToSend(Lnet/minecraft/server/level/ChunkHolder;Lnet/minecraft/world/level/chunk/LevelChunk;)V") private native void cc_onChunkReadyToSend(ChunkHolder chunkholder, LevelClo cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("prepareAccessibleChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("prepareAccessibleChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;") public native CompletableFuture> cc_prepareAccessibleChunk(ChunkHolder holder); @Inject(method = "prepareAccessibleChunk", at = @At("HEAD"), cancellable = true) @@ -426,23 +429,25 @@ private void cc_onVanillaPrepareAccessibleChunk(ChunkHolder chunk, CallbackInfoR } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("saveChunkIfNeeded(Lnet/minecraft/server/level/ChunkHolder;J)Z")) + @TransformFromMethod("saveChunkIfNeeded(Lnet/minecraft/server/level/ChunkHolder;J)Z") private native boolean cc_saveChunkIfNeeded(ChunkHolder holder, long gameTime); // TODO (P2): for now we just don't save (requires more things to be CC-ified to not crash) - @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = @MethodSig("save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkMap_redirects.class, method = "save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private boolean cc_save(CloAccess cloAccess) { return false; } // //region [cc_save dasm + mixin] -// @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) @TransformFromMethod(@MethodSig("save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) +// @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) @TransformFromMethod(@MethodSig("save +// (Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) // private native boolean cc_save(CloAccess cloAccess); // // /** // * Redirect error logging to log with CloPos // */ -// @Dynamic @Inject(method = "cc_dasm$cc_save", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;getX()I"), cancellable = true) +// @Dynamic @Inject(method = "cc_save", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;getX +// ()I"), cancellable = true) // private void cc_onSave_errorLog(CloAccess cloAccess, CallbackInfoReturnable cir, @Local Exception exception) { // LOGGER.error("Failed to save chunk or cube {}", cloAccess.cc_getCloPos().toString(), exception); // cir.setReturnValue(false); @@ -451,23 +456,23 @@ private boolean cc_save(CloAccess cloAccess) { // This calls ChunkSerializer.getChunkTypeFromTag, which could be an issue? @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("isExistingChunkFull(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("isExistingChunkFull(Lnet/minecraft/world/level/ChunkPos;)Z") private native boolean cc_isExistingChunkFull(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") private native void cc_markChunkPendingToSend(ServerPlayer player, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod("markChunkPendingToSend(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;)V") private static native void cc_markChunkPendingToSend(ServerPlayer player, LevelClo clo); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") private static native void cc_dropChunk(ServerPlayer player, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getChunkToSend(J)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod("getChunkToSend(J)Lnet/minecraft/world/level/chunk/LevelChunk;") public native LevelClo cc_getChunkToSend(long cloPos); // dumpChunks (low prio) @@ -477,47 +482,47 @@ private boolean cc_save(CloAccess cloAccess) { // TODO (P2) readChunk: this.upgradeChunkTag might need a dasm redirect? @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("readChunk(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("readChunk(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture> cc_readChunk(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("collectSpawningChunks(Ljava/util/List;)V")) + @TransformFromMethod("collectSpawningChunks(Ljava/util/List;)V") native void cc_collectSpawningClos(List list); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("forEachBlockTickingChunk(Ljava/util/function/Consumer;)V")) + @TransformFromMethod("forEachBlockTickingChunk(Ljava/util/function/Consumer;)V") native void cc_forEachBlockTickingClo(Consumer consumer); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z") public native boolean cc_anyPlayerCloseEnoughForSpawning(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("anyPlayerCloseEnoughForSpawningInternal(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("anyPlayerCloseEnoughForSpawningInternal(Lnet/minecraft/world/level/ChunkPos;)Z") private native boolean cc_anyPlayerCloseEnoughForSpawningInternal(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getPlayersCloseForSpawning(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;")) + @TransformFromMethod("getPlayersCloseForSpawning(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;") public native List cc_getPlayersCloseForSpawning(CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("playerIsCloseEnoughForSpawning(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod("playerIsCloseEnoughForSpawning(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)Z") private native boolean cc_playerIsCloseEnoughForSpawning(ServerPlayer player, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("updatePlayerStatus(Lnet/minecraft/server/level/ServerPlayer;Z)V")) + @TransformFromMethod("updatePlayerStatus(Lnet/minecraft/server/level/ServerPlayer;Z)V") public native void cc_updatePlayerStatus(ServerPlayer player, boolean track); @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("move(Lnet/minecraft/server/level/ServerPlayer;)V")) + @TransformFromMethod("move(Lnet/minecraft/server/level/ServerPlayer;)V") public native void cc_move(ServerPlayer player); // region [cc_updateChunkTracking dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("updateChunkTracking(Lnet/minecraft/server/level/ServerPlayer;)V")) + @TransformFromMethod("updateChunkTracking(Lnet/minecraft/server/level/ServerPlayer;)V") private native void cc_updateChunkTracking(ServerPlayer player); - @Dynamic @WrapOperation(method = "cc_dasm$cc_updateChunkTracking", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) + @Dynamic @WrapOperation(method = "cc_updateChunkTracking", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;getPlayerViewDistance(Lnet/minecraft/server/level/ServerPlayer;)I")) private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPlayer player, Operation original) { return Coords.sectionToCubeRenderDistance(original.call(instance, player)); } @@ -525,10 +530,10 @@ private int cc_onUpdateChunkTracking_getViewDistance(ChunkMap instance, ServerPl // region [cc_applyChunkTrackingView dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("applyChunkTrackingView(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/server/level/ChunkTrackingView;)V")) + @TransformFromMethod("applyChunkTrackingView(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/server/level/ChunkTrackingView;)V") private native void cc_applyChunkTrackingView(ServerPlayer player, CloTrackingView chunkTrackingView); - @Dynamic @Redirect(method = "cc_dasm$cc_applyChunkTrackingView", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) + @Dynamic @Redirect(method = "cc_applyChunkTrackingView", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( ServerGamePacketListenerImpl instance, Packet packet, ServerPlayer player, CloTrackingView cloTrackingView ) { @@ -539,51 +544,50 @@ private void cc_onApplyChunkTrackingView_setChunkCacheCenterPacket( // region [cc_getPlayers dasm + mixin] @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;")) + @TransformFromMethod("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") public native List cc_getPlayers(CloPos pos, boolean boundaryOnly); - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkOnTrackedBorder(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkOnTrackedBorder(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkOnTrackedBorder(player, pos.getX(), pos.getY(), pos.getZ()); } - @Dynamic @Redirect(method = "cc_dasm$cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) + @Dynamic @Redirect(method = "cc_getPlayers", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;isChunkTracked(Lnet/minecraft/server/level/ServerPlayer;II)Z")) private boolean cc_getPlayers_isChunkTracked(ChunkMap instance, ServerPlayer player, int x, int z, @Local CloPos pos) { return this.cc_isChunkTracked(player, pos.getX(), pos.getY(), pos.getZ()); } // endregion - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") @Override public List cc_getPlayers(CubePos pos, boolean boundaryOnly) { return cc_getPlayers(CloPos.cube(pos), boundaryOnly); } // Replace `SectionPos.chunk()` with `SectionPos.cc_cube()` unconditionally here @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("tick(Ljava/util/function/BooleanSupplier;)V"), useRedirectSets = { ChunkToCloSet.class, - SectionPosToCubeSet.class }) + @TransformFromMethod(value = "tick(Ljava/util/function/BooleanSupplier;)V", useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) protected native void cc_tick(BooleanSupplier hasMoreTime); @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("tick()V"), useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) + @TransformFromMethod(value = "tick()V", useRedirectSets = { ChunkToCloSet.class, SectionPosToCubeSet.class }) public native void cc_tick(); @AddTransformToSets(GlobalSet.ChunkMap_redirects.class) - @TransformFromMethod(value = @MethodSig("processUnloads(Ljava/util/function/BooleanSupplier;)V")) + @TransformFromMethod(value = "processUnloads(Ljava/util/function/BooleanSupplier;)V") private native void cc_processUnloads(BooleanSupplier hasMoreTime); // TODO resendBiomesForChunks - only used for FillBiomeCommand @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V")) + @TransformFromMethod("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") public native void cc_onFullChunkStatusChange(CloPos cloPos, FullChunkStatus fullChunkStatus); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = @MethodSig("onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkMap_redirects.class, method = "onFullChunkStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/FullChunkStatus;)V") public void cc_onFullChunkStatusChange(CubePos cubePos, FullChunkStatus fullChunkStatus) { cc_onFullChunkStatusChange(CloPos.cube(cubePos), fullChunkStatus); } @AddTransformToSets(ChunkToCloSet.ChunkMap_redirects.class) - @TransformFromMethod(@MethodSig("waitForLightBeforeSending(Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod("waitForLightBeforeSending(Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_waitForLightBeforeSending(CloPos cloPos, int radius); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java index e0f5f15a..300a2c08 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskDispatcher.java @@ -5,7 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -20,7 +19,7 @@ @Mixin(ChunkTaskDispatcher.class) public class MixinChunkTaskDispatcher implements CubeHolder.LevelChangeListener, CloTaskDispatcher { @AddTransformToSets(ChunkToCloSet.ChunkTaskDispatcher_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkTaskDispatcher.class), value = @MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @TransformFromMethod(owner = @Ref(ChunkTaskDispatcher.class), value = "onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") @Override public native void cc_onLevelChange(CloPos cloPos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter); public void cc_onLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java index 69a6dee2..ab4f5c80 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkTaskPriorityQueue.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; @@ -36,6 +35,6 @@ private void cc_onResortChunkTasks(int queueLevel, ChunkPos chunkPos, int ticket @UsedFromASM @AddTransformToSets(ChunkToCloSet.ChunkTaskPriorityQueue_redirects.class) - @TransformFromMethod(@MethodSig("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V") public native void cc_resortCubicTasks(int queueLevel, CloPos cloPos, int ticketLevel); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java deleted file mode 100644 index 7f34ee6e..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView$Positioneed.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; - -import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CloTrackingView.Positioned.class) -public class MixinCloTrackingView$Positioneed {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java deleted file mode 100644 index d8918e84..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCloTrackingView.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; - -import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -// TODO won't be necessary once we have dasm.json -@Mixin(CloTrackingView.class) -public interface MixinCloTrackingView {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java deleted file mode 100644 index b633464f..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinCubeLevel.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level; - -import io.github.opencubicchunks.cubicchunks.server.level.CubeLevel; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubeLevel.class) -public class MixinCubeLevel {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java index c9f487a8..7d8d6ed6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinGenerationChunkHolder.java @@ -11,8 +11,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -45,9 +43,8 @@ /** * The vanilla {@link GenerationChunkHolder} class wraps completable futures for different statuses (load levels) of a single chunk and handles logic - * for scheduling generation of that chunk. - * This mixin adds cubic chunks equivalents for methods where necessary, to allow GenerationChunkHolder to dynamically wrap either a chunk or a cube - * (i.e. a CLO). + * for scheduling generation of that chunk. This mixin adds cubic chunks equivalents for methods where necessary, to allow GenerationChunkHolder to + * dynamically wrap either a chunk or a cube (i.e. a CLO). */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(GenerationChunkHolder.class)) @Mixin(GenerationChunkHolder.class) @@ -56,10 +53,10 @@ public abstract class MixinGenerationChunkHolder implements GenerationCloHolder @Shadow @Final private AtomicReferenceArray>> futures; @Shadow @Final private static ChunkResult NOT_DONE_YET; - @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_redirects.class, field = @FieldSig(name = "pos", type = @Ref(ChunkPos.class))) + @AddFieldToSets(containers = ChunkToCubeSet.GenerationChunkHolder_redirects.class, field = "pos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cc_cubePos; - @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = @MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = "getPos()Lnet/minecraft/world/level/ChunkPos;") @Override public CloPos cc_getCloPos() { if (cc_cubePos != null) { return CloPos.cube(cc_cubePos); @@ -68,13 +65,14 @@ public abstract class MixinGenerationChunkHolder implements GenerationCloHolder } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "(Lnet/minecraft/world/level/ChunkPos;)V") public MixinGenerationChunkHolder() { throw new DasmFailedToApply(); } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("applyStep(Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/server/level/GeneratingChunkMap;Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "applyStep(Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/server/level/GeneratingChunkMap;" + + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") native CompletableFuture> cc_applyCubeStep( CubeStep step, GeneratingChunkMap chunkMap, StaticCache3D cache ); @@ -88,10 +86,11 @@ native CompletableFuture> cc_applyCubeStep( } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V") public native void cc_replaceProtoCube(ImposterProtoCube cube); - @WrapOperation(method = "rescheduleChunkTask", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @WrapOperation(method = "rescheduleChunkTask", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;" + + "Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( ChunkMap instance, ChunkStatus status, ChunkPos chunkPos, Operation original ) { @@ -102,24 +101,24 @@ private ChunkGenerationTask cc_onRescheduleChunkTask_scheduleGenerationTask( } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("completeFuture(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/ChunkAccess;)V")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "completeFuture(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") private native void cc_completeFuture(ChunkStatus targetStatus, CubeAccess cubeAccess); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getChunkIfPresentUnchecked(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getChunkIfPresentUnchecked(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getCubeIfPresentUnchecked(ChunkStatus status); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getChunkIfPresent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getChunkIfPresent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getCubeIfPresent(ChunkStatus status); @Shadow public abstract @Nullable ChunkAccess getLatestChunk(); @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") public native @Nullable CubeAccess cc_getLatestCube(); - @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = @MethodSig("getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @AddMethodToSets(containers = ChunkToCloSet.GenerationChunkHolder_redirects.class, method = "getLatestChunk()Lnet/minecraft/world/level/chunk/ChunkAccess;") public @Nullable CloAccess cc_getLatestClo() { if (cc_cubePos != null) { return cc_getLatestCube(); @@ -140,7 +139,7 @@ public void cc_onGetPersistedStatus(CallbackInfoReturnable cir) { } @AddTransformToSets(ChunkToCubeSet.GenerationChunkHolder_redirects.class) - @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = @MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @TransformFromMethod(owner = @Ref(GenerationChunkHolder.class), value = "getPos()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_getCubePos(); // TODO getLatestStatus - only used for vanilla debug code diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java index a18d33c9..266245e9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerChunkCache.java @@ -15,8 +15,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.AddUnusedParam; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -29,7 +27,6 @@ import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet; import io.github.opencubicchunks.cubicchunks.server.level.ServerCubeCache; -import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo; import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess; import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; @@ -68,8 +65,8 @@ /** * The vanilla {@link ServerChunkCache} class stores all loaded chunks on the server and has methods for getting chunks, ticking all chunks, handling - * block+light updates, managing chunkloading tickets, etc. - * This mixin adds versions of these methods for cubes, meaning that this class now stores and manages both cubes and chunks. + * block+light updates, managing chunkloading tickets, etc. This mixin adds versions of these methods for cubes, meaning that this class now stores + * and manages both cubes and chunks. */ @Dasm(value = ChunkToCubeSet.class, target = @Ref(ServerChunkCache.class)) @Mixin(ServerChunkCache.class) @@ -77,16 +74,16 @@ public abstract class MixinServerChunkCache extends MixinChunkSource implements // Cube equivalents for cached chunks @Shadow @Final private static int CACHE_SIZE; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(long[].class), name = "lastChunkPos")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunkPos:[J") private final long[] cc_lastCubePos = new long[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(ChunkStatus[].class), name = "lastChunkStatus")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunkStatus:[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") private final ChunkStatus[] cc_lastCubeStatus = new ChunkStatus[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(CloAccess[].class), name = "lastChunk")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "lastChunk:[Lnet/minecraft/world/level/chunk/ChunkAccess;") private final CubeAccess[] cc_lastCube = new CubeAccess[CACHE_SIZE]; - @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = @FieldSig(type = @Ref(List.class), name = "spawningChunks")) + @AddFieldToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, field = "spawningChunks:Ljava/util/List;") private final List cc_spawningCubes = new ObjectArrayList<>(); @Shadow @Final public ServerLevel level; @@ -122,14 +119,15 @@ private void cc_onInit( } @AddTransformToSets(ChunkToCubeSet.ServerChunkCache_redirects.class) - @TransformFromMethod(@MethodSig("storeInCache(JLnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("storeInCache(JLnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") private native void cc_storeInCache(long pChunkPos, CubeAccess pChunk, ChunkStatus pChunkStatus); - @TransformFromMethod(@MethodSig("getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;")) + @TransformFromMethod("getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;") @Override public native @Nullable CubeAccess cc_getCube(int chunkX, @AddUnusedParam int chunkY, int chunkZ, ChunkStatus requiredStatus, boolean load); // mixin-into-dasm to replace call to getChunk with getCube - @Dynamic @Inject(method = "cc_dasm$cc_getCube", cancellable = true, at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) + @Dynamic @Inject(method = "cc_getCube", cancellable = true, at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)" + + "Ljava/util/concurrent/CompletableFuture;")) private void cc_getCube_supplyAsync( int pChunkX, int pChunkY, int pChunkZ, ChunkStatus pRequiredStatus, boolean pLoad, CallbackInfoReturnable cir ) { @@ -139,14 +137,15 @@ private void cc_getCube_supplyAsync( // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } // The second through fifth params are the params to the call being redirected; the next three params are the x/y/z coordinates in the params of // getCube - @Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;")) + @Dynamic @Redirect(method = "cc_getCube", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + + "Ljava/util/concurrent/CompletableFuture;")) private CompletableFuture cc_getCube_getChunkFutureMainThread( ServerChunkCache instance, int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load, int chunkXRepeated, int chunkY, int chunkZRepeated @@ -154,19 +153,19 @@ private CompletableFuture cc_getCube_getChunkFutureMainThread( return this.cc_getCubeFutureMainThread(chunkX, chunkY, chunkZ, requiredStatus, load); } - @TransformFromMethod(@MethodSig("getChunkNow(II)Lnet/minecraft/world/level/chunk/LevelChunk;")) + @TransformFromMethod("getChunkNow(II)Lnet/minecraft/world/level/chunk/LevelChunk;") @Override public native @Nullable LevelCube cc_getCubeNow(int pChunkX, @AddUnusedParam int chunkY, int pChunkZ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of getCubeNow - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) + @Dynamic @Redirect(method = "cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J")) private long cc_getCubeNow_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CloPos.cubeAsLong(pX, pY, pZ); } // Note that we don't add this to any redirect sets; we just need it for the below mixin // (Whenever clearing caches, we want to clear all caches, not just cubes or chunks specifically) - @TransformFromMethod(@MethodSig("clearCache()V")) + @TransformFromMethod("clearCache()V") private native void cc_clearCache(); /** @@ -193,24 +192,24 @@ private void cc_onClearCache(CallbackInfo ci) { return completablefuture; } - @TransformFromMethod(@MethodSig("getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod("getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;") private native CompletableFuture> cc_getCubeFutureMainThread( int pX, @AddUnusedParam int chunkY, int pZ, ChunkStatus pChunkStatus, boolean pLoad ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_getCubeFutureMainThread - @Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } - @TransformFromMethod(@MethodSig("hasChunk(II)Z")) + @TransformFromMethod("hasChunk(II)Z") public native boolean cc_hasCube(int pX, @AddUnusedParam int y, int pZ); // The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the // params of cc_hasCube - @Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) + @Dynamic @Redirect(method = "cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;")) private CubePos cc_hasCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) { return CubePos.of(pX, pY, pZ); } @@ -229,11 +228,11 @@ private void cc_onTick(BooleanSupplier hasTimeLeft, boolean tickChunks, Callback } @AddTransformToSets(GlobalSet.ServerChunkCache_redirects.class) - @TransformFromMethod(@MethodSig("tick(Ljava/util/function/BooleanSupplier;Z)V")) + @TransformFromMethod("tick(Ljava/util/function/BooleanSupplier;Z)V") public native void cc_tick(BooleanSupplier hasTimeLeft, boolean tickChunks); @AddTransformToSets(GlobalSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("broadcastChangedChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "broadcastChangedChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V") private native void cc_broadcastChangedClos(ProfilerFiller profiler); @Inject(method = "broadcastChangedChunks", at = @At("HEAD"), cancellable = true) @@ -245,7 +244,7 @@ private void cc_onVanillaBroadcastChangedChunks(ProfilerFiller profiler, Callbac } @AddTransformToSets(GlobalSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V") private native void cc_tickClos(ProfilerFiller profiler, long timeInhabited); @Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V", at = @At("HEAD"), cancellable = true) @@ -256,7 +255,8 @@ private void cc_onVanillaTickChunks(ProfilerFiller profiler, long timeInhabited, } } - @AddMethodToSets(containers = ChunkToCloSet.ServerChunkCache_redirects.class, method = @MethodSig("tickSpawningChunk(Lnet/minecraft/world/level/chunk/LevelChunk;JLjava/util/List;Lnet/minecraft/world/level/NaturalSpawner$SpawnState;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ServerChunkCache_redirects.class, method = "tickSpawningChunk(Lnet/minecraft/world/level/chunk/LevelChunk;JLjava/util/List;" + + "Lnet/minecraft/world/level/NaturalSpawner$SpawnState;)V") private void cc_tickSpawningClo(LevelClo levelClo, long timeInhabited, List spawnCategories, NaturalSpawner.SpawnState spawnState) { // TODO (P2) } @@ -284,50 +284,50 @@ private void cc_onVanillaOnLightUpdate(LightLayer type, SectionPos pos, Callback } } - @Override @AddMethodToSets(containers = GlobalSet.ServerChunkCache_redirects.class, method = @MethodSig("onLightUpdate(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/SectionPos;)V")) + @Override @AddMethodToSets(containers = GlobalSet.ServerChunkCache_redirects.class, method = "onLightUpdate(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/SectionPos;)V") public void cc_onLightUpdate(LightLayer pType, SectionPos pPos) { // TODO (P2) lighting } @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_addTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_addTicketWithRadius(TicketType ticket, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_removeTicketWithRadius(TicketType ticket, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z")) + @TransformFromMethod(useRedirectSets = ChunkToCloSet.class, value = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z") public native boolean cc_updateCloForced(CloPos pPos, boolean pAdd); // Cube-specific methods that delegate to the corresponding Clo methods - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public void cc_addTicket(Ticket ticket, CubePos cubePos) { cc_addTicket(ticket, CloPos.cube(cubePos)); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public void cc_addTicketWithRadius(TicketType ticket, CubePos cubePos, int radius) { cc_addTicketWithRadius(ticket, CloPos.cube(cubePos), radius); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public void cc_removeTicketWithRadius(TicketType ticket, CubePos cubePos, int radius) { cc_removeTicketWithRadius(ticket, CloPos.cube(cubePos), radius); } - @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z\"")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerChunkCache_redirects.class, method = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z\"") @Override public boolean cc_updateCubeForced(CubePos cubePos, boolean forced) { return cc_updateCloForced(CloPos.cube(cubePos), forced); } // TODO should probably be implemented properly, but is low priority (debug) @AddTransformToSets(ChunkToCloSet.ServerChunkCache_redirects.class) - @TransformFromMethod(@MethodSig("getChunkDebugData(Lnet/minecraft/world/level/ChunkPos;)Ljava/lang/String;")) + @TransformFromMethod("getChunkDebugData(Lnet/minecraft/world/level/ChunkPos;)Ljava/lang/String;") public native String cc_getChunkDebugData(CloPos pChunkPos); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java index cc5c834f..6230b0a3 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerLevel.java @@ -8,7 +8,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -57,10 +56,11 @@ private void cc_onInit( } @AddTransformToSets(ChunkToCloSet.ServerLevel_redirects.class) - @TransformFromMethod(@MethodSig("startTickingChunk(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod("startTickingChunk(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_startTickingClo(LevelClo chunk); - @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + + "Lnet/minecraft/world/level/ChunkPos;I)V")) private void cc_onSetDefaultSpawnPos_removeTicketWithRadius( ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos ) { @@ -71,7 +71,8 @@ private void cc_onSetDefaultSpawnPos_removeTicketWithRadius( } } - @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @WrapOperation(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;addTicketWithRadius(Lnet/minecraft/server/level/TicketType;" + + "Lnet/minecraft/world/level/ChunkPos;I)V")) private void cc_onSetDefaultSpawnPos_addicketWithRadius( ServerChunkCache instance, TicketType ticket, ChunkPos chunkPos, int radius, Operation original, BlockPos pos ) { @@ -82,7 +83,7 @@ private void cc_onSetDefaultSpawnPos_addicketWithRadius( } } - @AddMethodToSets(containers = ChunkToCloSet.ServerLevel_redirects.class, method = @MethodSig("tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V")) + @AddMethodToSets(containers = ChunkToCloSet.ServerLevel_redirects.class, method = "tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") public void cc_tickClo(LevelClo levelClo, int randomTickSpeed) { if (levelClo instanceof LevelCube levelCube) { cc_tickCube(levelCube, randomTickSpeed); @@ -91,7 +92,7 @@ public void cc_tickClo(LevelClo levelClo, int randomTickSpeed) { } } - @AddMethodToSets(containers = ChunkToCubeSet.ServerLevel_redirects.class, method = @MethodSig("tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V")) + @AddMethodToSets(containers = ChunkToCubeSet.ServerLevel_redirects.class, method = "tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V") public void cc_tickCube(LevelCube levelCube, int randomTickSpeed) { // TODO (P2) cube ticking } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java index 1cf243ba..8dc6dab6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinServerPlayer.java @@ -3,30 +3,27 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.mixin.core.common.world.entity.MixinEntity; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; import io.github.opencubicchunks.cubicchunks.server.level.CCServerPlayer; import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; -import net.minecraft.server.level.ChunkTrackingView; import net.minecraft.server.level.ServerPlayer; import org.spongepowered.asm.mixin.Mixin; @Dasm(value = ChunkToCloSet.class, target = @Ref(ServerPlayer.class)) @Mixin(ServerPlayer.class) public abstract class MixinServerPlayer extends MixinEntity implements CCServerPlayer { - @AddFieldToSets(containers = ChunkToCloSet.ServerPlayer_redirects.class, field = @FieldSig(type = @Ref(ChunkTrackingView.class), name = "chunkTrackingView")) + @AddFieldToSets(containers = ChunkToCloSet.ServerPlayer_redirects.class, field = "chunkTrackingView:Lnet/minecraft/server/level/ChunkTrackingView;") private CloTrackingView cc_cloTrackingView = CloTrackingView.EMPTY; @AddTransformToSets(ChunkToCloSet.ServerPlayer_redirects.class) - @TransformFromMethod(@MethodSig("getChunkTrackingView()Lnet/minecraft/server/level/ChunkTrackingView;")) + @TransformFromMethod("getChunkTrackingView()Lnet/minecraft/server/level/ChunkTrackingView;") public native CloTrackingView cc_getCloTrackingView(); @AddTransformToSets(ChunkToCloSet.ServerPlayer_redirects.class) - @TransformFromMethod(@MethodSig("setChunkTrackingView(Lnet/minecraft/server/level/ChunkTrackingView;)V")) + @TransformFromMethod("setChunkTrackingView(Lnet/minecraft/server/level/ChunkTrackingView;)V") public native void cc_setCloTrackingView(CloTrackingView chunkTrackingView); // TODO P3 :: findDimensionEntryPoint diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java index 6924d56e..677df330 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinSimulationChunkTracker.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -18,7 +17,7 @@ @Mixin(SimulationChunkTracker.class) public abstract class MixinSimulationChunkTracker extends MixinChunkTracker implements SimulationCloTracker { @AddTransformToSets(ChunkToCloSet.SimulationChunkTracker_redirects.class) - @TransformFromMethod(owner = @Ref(SimulationChunkTracker.class), value = @MethodSig("getLevel(Lnet/minecraft/world/level/ChunkPos;)I")) + @TransformFromMethod(owner = @Ref(SimulationChunkTracker.class), value = "getLevel(Lnet/minecraft/world/level/ChunkPos;)I") public native int cc_getLevel(CloPos cloPos); @Inject(method = "setLevel", at = @At("HEAD")) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java index c7e37e51..9c4449de 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinLoggerChunkProgressListener.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -17,10 +16,10 @@ @Mixin(LoggerChunkProgressListener.class) public abstract class MixinLoggerChunkProgressListener implements CloProgressListener { @AddTransformToSets(ChunkToCloSet.LoggerChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") @Override public native void cc_updateSpawnPos(CloPos center); @AddTransformToSets(ChunkToCloSet.LoggerChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @Override public native void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java index 57e7dfa2..2835613d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinProcessorChunkProgressListener.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -26,7 +24,7 @@ @Mixin(ProcessorChunkProgressListener.class) public abstract class MixinProcessorChunkProgressListener implements CloProgressListener { // We need a field referencing the delegate as a CloProgressListener, otherwise we end up trying to access a field of the wrong type - @AddFieldToSets(containers = ChunkToCloSet.ProcessorChunkProgressListener_redirects.class, field = @FieldSig(type = @Ref(ChunkProgressListener.class), name = "delegate")) + @AddFieldToSets(containers = ChunkToCloSet.ProcessorChunkProgressListener_redirects.class, field = "delegate:Lnet/minecraft/server/level/progress/ChunkProgressListener;") private CloProgressListener cc_delegate; @Inject(method = "", at = @At("RETURN")) @@ -35,10 +33,10 @@ private void cc_onInit(ChunkProgressListener delegate, Executor dispatcher, Call } @AddTransformToSets(ChunkToCloSet.ProcessorChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") @Override public native void cc_updateSpawnPos(CloPos center); @AddTransformToSets(ChunkToCloSet.ProcessorChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @Override public native void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java index 6c4de990..4697a488 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/progress/MixinStoringChunkProgressListener.java @@ -5,8 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -18,7 +16,6 @@ import io.github.opencubicchunks.cubicchunks.server.level.progress.StoringCloProgressListener; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.server.level.progress.StoringChunkProgressListener; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.status.ChunkStatus; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -29,15 +26,15 @@ public abstract class MixinStoringChunkProgressListener implements CloProgressListener, StoringCloProgressListener { @Shadow @Final private Long2ObjectOpenHashMap statuses; @Shadow @Final private int radius; - @AddFieldToSets(containers = GlobalSet.StoringChunkProgressListener_redirects.class, field = @FieldSig(type = @Ref(ChunkPos.class), name = "spawnPos")) + @AddFieldToSets(containers = GlobalSet.StoringChunkProgressListener_redirects.class, field = "spawnPos:Lnet/minecraft/world/level/ChunkPos;") private CloPos cc_spawnPos; @AddTransformToSets(ChunkToCloSet.StoringChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") @Override public native void cc_updateSpawnPos(CloPos center); @AddTransformToSets(ChunkToCloSet.StoringChunkProgressListener_redirects.class) - @TransformFromMethod(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") @Override public native void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); @Override @Nullable public ChunkStatus cc_getStatus(int cubeX, int cubeY, int cubeZ) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java index 2d0f6a7b..925ee9ab 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/network/MixinPlayerChunkSender.java @@ -7,7 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -53,10 +52,10 @@ public class MixinPlayerChunkSender { @Shadow @Final private LongSet pendingChunks; @AddTransformToSets(ChunkToCloSet.PlayerChunkSender_redirects.class) - @TransformFromMethod(value = @MethodSig("markChunkPendingToSend(Lnet/minecraft/world/level/chunk/LevelChunk;)V")) + @TransformFromMethod(value = "markChunkPendingToSend(Lnet/minecraft/world/level/chunk/LevelChunk;)V") public native void cc_markCloPendingToSend(LevelClo clo); - @AddMethodToSets(containers = ChunkToCloSet.PlayerChunkSender_redirects.class, method = @MethodSig("dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V")) + @AddMethodToSets(containers = ChunkToCloSet.PlayerChunkSender_redirects.class, method = "dropChunk(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)V") public void cc_dropClo(ServerPlayer player, CloPos cloPos) { if (!this.pendingChunks.remove(cloPos.toLong()) && player.isAlive()) { PacketDistributor.sendToPlayer(player, new CCClientboundForgetLevelCloPacket(cloPos)); @@ -138,16 +137,16 @@ private static void cc_sendChunk(ServerGamePacketListenerImpl packetListener, Se // net.neoforged.neoforge.event.EventHooks.fireChunkSent(packetListener.player, chunk, level); } - @TransformFromMethod(value = @MethodSig("collectChunksToSend(Lnet/minecraft/server/level/ChunkMap;Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;")) + @TransformFromMethod(value = "collectChunksToSend(Lnet/minecraft/server/level/ChunkMap;Lnet/minecraft/world/level/ChunkPos;)Ljava/util/List;") private native List cc_collectChunksToSend(ChunkMap chunkMap, CloPos cloPos); // FIXME these should probably have some kind of reasonable sort order - at the very least, chunks before cubes - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_collectChunksToSend", at = @At(ordinal = 0, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator1(ToIntFunction keyExtractor) { return (a, b) -> 0; } - @Dynamic @Redirect(method = "cc_dasm$cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) + @Dynamic @Redirect(method = "cc_collectChunksToSend", at = @At(ordinal = 1, value = "INVOKE", target = "Ljava/util/Comparator;comparingInt(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;")) private Comparator cc_onCollectChunksToSend_comparator2(ToIntFunction keyExtractor) { return (a, b) -> 0; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java index 5ce4ac76..4ebfe854 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java @@ -4,8 +4,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -19,7 +17,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import org.objectweb.asm.Opcodes; @@ -48,14 +45,14 @@ public abstract class MixinEntity implements EntityCubePosGetter { @Shadow public abstract int getId(); - @AddFieldToSets(containers = ChunkToCubeSet.Entity_redirects.class, field = @FieldSig(type = @Ref(ChunkPos.class), name = "chunkPosition")) + @AddFieldToSets(containers = ChunkToCubeSet.Entity_redirects.class, field = "chunkPosition:Lnet/minecraft/world/level/ChunkPos;") private CubePos cc_cubePosition = CubePos.of(0, 0, 0); @AddTransformToSets(ChunkToCubeSet.Entity_redirects.class) - @TransformFromMethod(@MethodSig("chunkPosition()Lnet/minecraft/world/level/ChunkPos;")) + @TransformFromMethod("chunkPosition()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_cubePosition(); - @AddMethodToSets(containers = ChunkToCloSet.Entity_redirects.class, method = @MethodSig("chunkPosition()Lnet/minecraft/world/level/ChunkPos;")) + @AddMethodToSets(containers = ChunkToCloSet.Entity_redirects.class, method = "chunkPosition()Lnet/minecraft/world/level/ChunkPos;") public CloPos cc_cubePositionAsClo() { return CloPos.cube(cc_cubePosition()); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java index 694f7add..663d2e33 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinLevel.java @@ -10,7 +10,6 @@ import com.llamalad7.mixinextras.sugar.ref.LocalRef; import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.utils.Coords; @@ -102,7 +101,8 @@ private LevelChunk cc_replaceLevelChunkInGetChunkAt( return original.call(level, blockPos); } - @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Lnet/minecraft/world/level/block/state/BlockState;")) + @WrapOperation(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;setBlockState(Lnet/minecraft/core/BlockPos;" + + "Lnet/minecraft/world/level/block/state/BlockState;I)Lnet/minecraft/world/level/block/state/BlockState;")) private BlockState cc_replaceLevelChunkInSetBlockState( LevelChunk levelChunk, BlockPos blockPos, BlockState blockState, int flags, Operation original, @Share("levelCube") LocalRef levelCubeLocalRef @@ -113,7 +113,8 @@ private BlockState cc_replaceLevelChunkInSetBlockState( return original.call(levelChunk, blockPos, blockState, flags); } - @WrapWithCondition(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) + @WrapWithCondition(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) private boolean cc_replaceLevelChunkInMarkAndNotifyBlock( Level level, BlockPos blockPos, LevelChunk levelChunk, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft, @Share("levelCube") LocalRef levelCubeLocalRef @@ -127,7 +128,8 @@ private boolean cc_replaceLevelChunkInMarkAndNotifyBlock( @AddTransformToSets(ChunkToCubeSet.Level_redirects.class) @TransformFromMethod(useRedirectSets = { - ChunkToCubeSet.class }, value = @MethodSig("markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V")) + ChunkToCubeSet.class }, value = "markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V") public native void cc_markAndNotifyBlock( BlockPos blockPos, @Nullable LevelCube levelCube, BlockState blockStatePrev, BlockState blockStateNew, int flags, int recursionLeft ); @@ -166,7 +168,8 @@ private void cc_replaceGetChunkAtInSetBlockEntity(BlockPos blockPos, CallbackInf // getFluidState // Replaces LevelChunk with a LevelCube to call getFluidState - @WrapOperation(method = "getFluidState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;")) + @WrapOperation(method = "getFluidState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunk;getFluidState(Lnet/minecraft/core/BlockPos;)" + + "Lnet/minecraft/world/level/material/FluidState;")) private FluidState cc_replaceGetChunkAtInGetFluidState(LevelChunk levelChunk, BlockPos blockPos, Operation original) { if (cc_isCubic) { return this.cc_getCubeAt(blockPos).getFluidState(blockPos); @@ -222,7 +225,8 @@ private boolean cc_replaceHasChunkInIsLoaded(ChunkSource chunkSource, int x, int // loadedAndEntityCanStandOnFace // Uses an inject here since the entire second half of the method needs to be replaced anyways - @Inject(method = "loadedAndEntityCanStandOnFace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)Lnet/minecraft/world/level/chunk/ChunkAccess;"), cancellable = true) + @Inject(method = "loadedAndEntityCanStandOnFace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getChunk(IILnet/minecraft/world/level/chunk/status/ChunkStatus;Z)" + + "Lnet/minecraft/world/level/chunk/ChunkAccess;"), cancellable = true) private void cc_replaceGetChunkAtInLoadedAndEntityCanStandOnFace( BlockPos blockPos, Entity entity, Direction direction, CallbackInfoReturnable cir ) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java index 4a813fc4..721bd6de 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/MixinTicketStorage.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -19,27 +18,27 @@ public class MixinTicketStorage implements CubicTicketStorage { // TODO (P2) codec nonsense for save/load @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "addTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_addTicketWithRadius(TicketType ticketType, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "addTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_addTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "removeTicketWithRadius(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;I)V") public native void cc_removeTicketWithRadius(TicketType ticketType, CloPos cloPos, int radius); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("removeTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "removeTicket(Lnet/minecraft/server/level/Ticket;Lnet/minecraft/world/level/ChunkPos;)V") public native void cc_removeTicket(Ticket ticket, CloPos cloPos); @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)Z") public native boolean cc_updateChunkForced(CloPos cloPos, boolean add); // TODO move to neoforge-specific mixin @AddTransformToSets(ChunkToCloSet.TicketStorage_redirects.class) - @TransformFromMethod(owner = @Ref(TicketStorage.class), value = @MethodSig("shouldForceNaturalSpawning(Lnet/minecraft/world/level/ChunkPos;)Z")) + @TransformFromMethod(owner = @Ref(TicketStorage.class), value = "shouldForceNaturalSpawning(Lnet/minecraft/world/level/ChunkPos;)Z") public native boolean cc_shouldForceNaturalSpawning(CloPos cloPos); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java deleted file mode 100644 index 652aca93..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/status/MixinCCChunkStatusTasks.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.chunk.status; - -import io.github.opencubicchunks.cubicchunks.world.level.chunk.status.CCChunkStatusTasks; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CCChunkStatusTasks.class) -public class MixinCCChunkStatusTasks {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java index 286f40de..cbf81678 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/chunk/storage/MixinChunkStorage.java @@ -5,7 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; @@ -16,18 +15,18 @@ @Dasm(value = ChunkToCloSet.class, target = @Ref(ChunkStorage.class)) @Mixin(ChunkStorage.class) public abstract class MixinChunkStorage { - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = @MethodSig("isOldChunkAround(Lnet/minecraft/world/level/ChunkPos;I)Z")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = "isOldChunkAround(Lnet/minecraft/world/level/ChunkPos;I)Z") public boolean cc_isOldChunkAround(CloPos pos, int radius) { return false; // TODO (P2) should be dasm'd once IOWorker is done } - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = @MethodSig("read(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = "read(Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;") public CompletableFuture> cc_read(CloPos cloPos) { // TODO (P2) loading - this method should be dasm'd return CompletableFuture.completedFuture(Optional.empty()); } - @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = @MethodSig("write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkStorage_redirects.class, method = "write(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/Supplier;)Ljava/util/concurrent/CompletableFuture;") public void cc_write(CloPos cloPos, CompoundTag chunkData) { // TODO (P2) loading/unloading } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java deleted file mode 100644 index ed3eaf48..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinCubeAccess.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubeAccess.class) -public class MixinCubeAccess {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java deleted file mode 100644 index c872850c..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinEmptyLevelCube.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.EmptyLevelCube; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(EmptyLevelCube.class) -public abstract class MixinEmptyLevelCube extends MixinLevelCube {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java index 2d85876d..3cfd847f 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinImposterProtoCube.java @@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -// Needed for DASM to apply @Mixin(ImposterProtoCube.class) public abstract class MixinImposterProtoCube extends MixinProtoCube implements ImposterProtoClo { // Field generated by DASM diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java deleted file mode 100644 index 2b9bbe3b..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$BoundTickingBlockEntity.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(targets = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity") -public class MixinLevelCube$BoundTickingBlockEntity {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java deleted file mode 100644 index e8284312..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube$RebindableTickingBlockEntityWrapper.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube; - -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(targets = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper") -public class MixinLevelCube$RebindableTickingBlockEntityWrapper {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java index 1e0b5d4a..c8683c2c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinLevelCube.java @@ -8,13 +8,12 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(LevelCube.class) -public abstract class MixinLevelCube extends MixinCubeAccess { +public abstract class MixinLevelCube { /** * Redirect to use cube section indexing instead of chunk section indexing */ - @Dynamic @Redirect(method = "cc_dasm$getBlockState", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube;getSectionIndex(I)I")) + @Dynamic @Redirect(method = "getBlockState", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube;getSectionIndex(I)I")) private int cc_onGetBlockState_SectionIndex(LevelCube instance, int y, BlockPos pos) { return Coords.blockToIndex(pos); } @@ -22,7 +21,7 @@ private int cc_onGetBlockState_SectionIndex(LevelCube instance, int y, BlockPos /** * Redirect to use cube section indexing instead of chunk section indexing */ - @Dynamic @Redirect(method = "cc_dasm$getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + @Dynamic @Redirect(method = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + "/world/level/cube/LevelCube;getSectionIndex(I)I")) private int cc_onGetFluidState_SectionIndex(LevelCube instance, int yUnused, int x, int y, int z) { return Coords.blockToIndex(x, y, z); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java index 4743999b..41355c8b 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/MixinProtoCube.java @@ -8,14 +8,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(ProtoCube.class) -public abstract class MixinProtoCube extends MixinCubeAccess { +public abstract class MixinProtoCube { /** * Redirect to use cube section indexing instead of chunk section indexing */ - @Dynamic @Redirect(method = { "markPosForPostprocessing", "cc_dasm$getBlockState", - "cc_dasm$getFluidState" }, at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + @Dynamic @Redirect(method = { "markPosForPostprocessing", "getBlockState", + "getFluidState" }, at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks" + "/world/level/cube/ProtoCube;getSectionIndex(I)I")) private int cc_onGetBlockState_SectionIndex(ProtoCube instance, int i, BlockPos pos) { return Coords.blockToIndex(pos); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java deleted file mode 100644 index 84b6b073..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid$Builder.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube.status; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubePyramid; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubePyramid.Builder.class) -public class MixinCubePyramid$Builder {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java deleted file mode 100644 index 5cc74ac9..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubePyramid.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube.status; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubePyramid; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubePyramid.class) -public class MixinCubePyramid {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java index a645d17f..fe76b639 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStatusTasks.java @@ -11,10 +11,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(CubeStatusTasks.class) public class MixinCubeStatusTasks { - @Dynamic @Redirect(method = "cc_dasm$full", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) + @Dynamic @Redirect(method = "full", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/util/StaticCache3D;get(II)Ljava/lang/Object;")) private static Object onFullCube_cacheGet(StaticCache3D instance, int x, int z, @Local(ordinal = 0) CubePos cubePos) { return instance.get(x, cubePos.getY(), z); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java deleted file mode 100644 index c561169c..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep$Builder.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube.status; - -import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubeStep; -import org.spongepowered.asm.mixin.Mixin; - -// Needed for DASM to apply -@Mixin(CubeStep.Builder.class) -public class MixinCubeStep$Builder {} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java index 4653b7fc..44e68977 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/level/cube/status/MixinCubeStep.java @@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -// Needed for DASM to apply @Mixin(CubeStep.class) public class MixinCubeStep { @Dynamic @Redirect(method = "apply", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/jfr/JvmProfiler;onChunkGenerate(Lio/github/opencubicchunks/cc_core/api/CubePos;Lnet/minecraft/resources/ResourceKey;Ljava/lang/String;)Lnet/minecraft/util/profiling/jfr/callback/ProfiledDuration;")) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java index c2bcdb65..f4749eaa 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCloSet.java @@ -10,9 +10,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.sets.InterOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.ConstructorMethodSig; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.exception.DasmFailedToApply; @@ -66,58 +63,58 @@ import net.neoforged.neoforge.event.level.ChunkEvent; /** - * Should be used for DASM transforms that work with Clos (i.e. work with both Chunks and Cubes) + * Should be used for DASM transforms that work with Clos (i.e. work with both Chunks and Cubes)
*
- *
- * Clo-related field and type redirects, and method redirects containing Clo-related types in the signature or return type should be added to this - * set. - *
- * Other redirects may also be added to this set if they should only be applied in contexts working with both Chunks and Cubes. - * Redirects applicable in all contexts should be added to {@link GlobalSet}. + * Clo-related field and type redirects, and + * method redirects containing Clo-related types in the signature or return type should be added to this set.
+ * Other redirects may also be added + * to this set if they should only be applied in contexts working with both Chunks and Cubes. Redirects applicable in all contexts should be added to + * {@link GlobalSet}. */ @RedirectSet public interface ChunkToCloSet extends GlobalSet { @TypeRedirect(from = @Ref(ChunkPos.class), to = @Ref(CloPos.class)) abstract class ChunkPos_to_CloPos_redirects { - @FieldRedirect(@FieldSig(type = @Ref(long.class), name = "INVALID_CHUNK_POS")) + @FieldRedirect("INVALID_CHUNK_POS:J") static final long INVALID_CLO_POS = Long.MAX_VALUE; - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "x")) + @FieldToMethodRedirect("x:I") native int getX(); - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "z")) + @FieldToMethodRedirect("z:I") native int getZ(); // Note that this relies on ChunkPos and CloPos encoding to longs in the same way - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(long.class) })) + @ConstructorToFactoryRedirect("(J)V") static native CloPos fromLong(long cloPos); - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(int.class), @Ref(int.class) })) + @ConstructorToFactoryRedirect("(II)V") static native CloPos chunk(int x, int z); - @MethodRedirect(@MethodSig("asLong(II)J")) + @MethodRedirect("asLong(II)J") static native long chunkAsLong(int x, int z); } @TypeRedirect(from = @Ref(ChunkAccess.class), to = @Ref(CloAccess.class)) interface ChunkAccess_to_CloAccess_redirects { - @MethodRedirect(@MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("getPos()Lnet/minecraft/world/level/ChunkPos;") CloPos cc_getCloPos(); - @MethodRedirect(@MethodSig("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @MethodRedirect("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;") ChunkStatus getPersistedStatus(); } @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelClo.class)) interface LevelChunk_to_LevelClo_redirects extends ChunkAccess_to_CloAccess_redirects { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(Level.class), @Ref(CloPos.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;)V") static LevelClo create(Level level, ChunkPos pos) { throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(Level.class), @Ref(ChunkPos.class), @Ref(UpgradeData.class), - @Ref(LevelChunkTicks.class), @Ref(LevelChunkTicks.class), @Ref(long.class), @Ref(LevelChunkSection[].class), - @Ref(LevelChunk.PostLoadProcessor.class), @Ref(BlendingData.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + + "Lnet/minecraft/world/ticks/LevelChunkTicks;Lnet/minecraft/world/ticks/LevelChunkTicks;" + + "J[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;" + + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static LevelClo create( Level level, CloPos pos, UpgradeData data, LevelChunkTicks blockTicks, LevelChunkTicks fluidTicks, long inhabitedTime, @Nullable LevelChunkSection[] sections, @Nullable LevelClo.PostLoadProcessor postLoad, @Nullable BlendingData blendingData @@ -125,8 +122,8 @@ static LevelClo create( throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(ServerLevel.class), @Ref(ProtoChunk.class), - @Ref(LevelChunk.PostLoadProcessor.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;" + + "Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;)V") static LevelClo create(ServerLevel level, ProtoClo clo, @Nullable LevelClo.PostLoadProcessor postLoad) { throw new DasmFailedToApply(); } @@ -137,8 +134,9 @@ interface LevelChunk$PostLoadProcessor_to_LevelClo$PostLoadProcessor_redirects { @TypeRedirect(from = @Ref(ProtoChunk.class), to = @Ref(ProtoClo.class)) interface ProtoChunk_to_ProtoClo_redirects extends ChunkAccess_to_CloAccess_redirects { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(ChunkPos.class), @Ref(UpgradeData.class), @Ref(LevelHeightAccessor.class), - @Ref(Registry.class), @Ref(BlendingData.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + + "Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/core/Registry;" + + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static ProtoClo create( CloPos cloPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, @Nullable BlendingData blendingData @@ -146,9 +144,10 @@ static ProtoClo create( throw new DasmFailedToApply(); } - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(ChunkPos.class), @Ref(UpgradeData.class), @Ref(LevelChunkSection[].class), - @Ref(ProtoChunkTicks.class), @Ref(ProtoChunkTicks.class), @Ref(LevelHeightAccessor.class), @Ref(Registry.class), - @Ref(BlendingData.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;" + + "[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/ticks/ProtoChunkTicks;" + + "Lnet/minecraft/world/ticks/ProtoChunkTicks;Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/core/Registry;" + + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V") static ProtoClo create( CloPos cloPos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTicks, ProtoChunkTicks liquidTicks, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, @@ -160,12 +159,12 @@ static ProtoClo create( @TypeRedirect(from = @Ref(ImposterProtoChunk.class), to = @Ref(ImposterProtoClo.class)) interface ImposterProtoChunk_to_ImposterProtoClo_redirects { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class), @Ref(boolean.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;Z)V") static ImposterProtoClo create(LevelClo wrapped, boolean allowWrites) { throw new DasmFailedToApply(); } - @MethodRedirect(@MethodSig("getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @MethodRedirect("getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;") LevelClo cc_getWrappedClo(); } @@ -182,7 +181,7 @@ abstract class ChunkEvent$Load_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Load.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Load_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class), @Ref(boolean.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;Z)V") static native Event create_ChunkEvent$Load(LevelCube levelCube, boolean newChunk); } @@ -191,13 +190,13 @@ abstract class ChunkEvent$Unload_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Unload.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Unload_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;)V") static native Event create_ChunkEvent$Unload(LevelCube levelCube); } @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) abstract class GenerationChunkHolder_Forge_Jank_redirects { - @FieldToMethodRedirect(value = @FieldSig(name = "currentlyLoading", type = @Ref(LevelChunk.class)), setter = "cc_setCurrentlyLoading") + @FieldToMethodRedirect(value = "currentlyLoading:Lnet/minecraft/world/level/chunk/LevelChunk;", setter = "cc_setCurrentlyLoading") public native LevelClo cc_getCurrentlyLoading(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java index 3180ed31..60ac0f05 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/ChunkToCubeSet.java @@ -13,9 +13,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.sets.InterOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.ConstructorMethodSig; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.client.multiplayer.ClientCubeCache; @@ -66,46 +63,45 @@ import net.neoforged.neoforge.event.level.ChunkEvent; /** - * Should be used for DASM transforms that work with only Cubes (as opposed to working with both Chunks and Cubes) + * Should be used for DASM transforms that work with only Cubes (as opposed to working with both Chunks and Cubes)
*
- *
- * Cube-related field and type redirects, and method redirects containing Cube-related types in the signature or return type should be added to this - * set. - *
- * Other redirects may also be added to this set if they should only be applied in contexts working with only Cubes. - * Redirects applicable in all contexts should be added to {@link GlobalSet}. + * Cube-related field and + * type redirects, and method redirects containing Cube-related types in the signature or return type should be added to this set.
+ * Other + * redirects may also be added to this set if they should only be applied in contexts working with only Cubes. Redirects applicable in all contexts + * should be added to {@link GlobalSet}. */ @RedirectSet public interface ChunkToCubeSet extends GlobalSet { @TypeRedirect(from = @Ref(ChunkPos.class), to = @Ref(CubePos.class)) abstract class ChunkPos_to_CubePos_redirects { - @FieldRedirect(@FieldSig(type = @Ref(long.class), name = "INVALID_CHUNK_POS")) + @FieldRedirect("INVALID_CHUNK_POS:J") static final long INVALID_CUBE_POS = Long.MAX_VALUE; - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "x")) + @FieldToMethodRedirect("x:I") native int getX(); - @FieldToMethodRedirect(@FieldSig(type = @Ref(int.class), name = "z")) + @FieldToMethodRedirect("z:I") native int getZ(); - @MethodRedirect(@MethodSig("toLong()J")) + @MethodRedirect("toLong()J") native long asLong(); // Dummy methods that throw errors; these should be manually redirected to the correct x,y,z methods using mixin. // (See: MixinCubePos) - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(int.class), @Ref(int.class) })) + @ConstructorToFactoryRedirect("(II)V") static native CubePos dummy_fromChunkCoords(int x, int z); - @MethodRedirect(@MethodSig("asLong(II)J")) + @MethodRedirect("asLong(II)J") static native long dummy_chunkAsLong(int x, int z); } @TypeRedirect(from = @Ref(ChunkAccess.class), to = @Ref(CubeAccess.class)) abstract class ChunkAccess_to_CubeAccess_redirects { - @FieldRedirect(@FieldSig(type = @Ref(ChunkPos.class), name = "chunkPos")) + @FieldRedirect("chunkPos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cubePos; - @MethodRedirect(@MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("getPos()Lnet/minecraft/world/level/ChunkPos;") public native CubePos cc_getCubePos(); } @@ -115,13 +111,7 @@ abstract class ChunkAccess$ChunkPathElement_to_CubeAccess$CubePathElement_redire } @TypeRedirect(from = @Ref(LevelChunk.class), to = @Ref(LevelCube.class)) - abstract class LevelChunk_to_LevelCube_redirects { - @FieldRedirect(@FieldSig(type = @Ref(ChunkPos.class), name = "chunkPos")) - protected CubePos cubePos; - - @MethodRedirect(@MethodSig("getPos()Lnet/minecraft/world/level/ChunkPos;")) - public native CubePos cc_getCubePos(); - } + abstract class LevelChunk_to_LevelCube_redirects extends ChunkAccess_to_CubeAccess_redirects {} @TypeRedirect(from = @Ref(LevelChunk.PostLoadProcessor.class), to = @Ref(LevelCube.PostLoadProcessor.class)) interface LevelChunk$PostLoadProcessor_to_LevelCube$PostLoadProcessor_redirects {} @@ -165,28 +155,30 @@ abstract class ChunkPyramid$Builder_to_CubePyramid$Builder_redirects {} @TypeRedirect(from = @Ref(ChunkHolder.LevelChangeListener.class), to = @Ref(CubeHolder.LevelChangeListener.class)) interface ChunkHolder$LevelChangeListener_to_CubeHolder$LevelChangeListener_redirects { - @MethodRedirect(@MethodSig("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")) + @MethodRedirect("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V") void cc_onLevelChange(CubePos cubePos, IntSupplier queueLevelGetter, int ticketLevel, IntConsumer queueLevelSetter); } @TypeRedirect(from = @Ref(ChunkHolder.PlayerProvider.class), to = @Ref(CubeHolder.PlayerProvider.class)) interface ChunkHolder$PlayerProvider_to_CubeHolder$PlayerProvider_redirects { - @MethodRedirect(@MethodSig("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;")) + @MethodRedirect("getPlayers(Lnet/minecraft/world/level/ChunkPos;Z)Ljava/util/List;") List cc_getPlayers(CubePos pos, boolean boundaryOnly); } @TypeRedirect(from = @Ref(GeneratingChunkMap.class), to = @Ref(GeneratingCubeMap.class)) interface GeneratingChunkMap_to_GeneratingCubeMap_redirects { - @MethodRedirect(@MethodSig("applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;")) + @MethodRedirect("applyStep(Lnet/minecraft/server/level/GenerationChunkHolder;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;)Ljava/util/concurrent/CompletableFuture;") CompletableFuture cc_applyCubeStep(GenerationChunkHolder chunk, CubeStep step, StaticCache3D cache); - @MethodRedirect(@MethodSig("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/server/level/ChunkGenerationTask;")) + @MethodRedirect("scheduleGenerationTask(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/ChunkPos;)" + + "Lnet/minecraft/server/level/ChunkGenerationTask;") ChunkGenerationTask cc_scheduleGenerationTask(ChunkStatus targetStatus, CubePos pos); } @IntraOwnerContainer(@Ref(ChunkGenerationTask.class)) abstract class ChunkGenerationTask_redirects { - @FieldToMethodRedirect(@FieldSig(type = @Ref(GeneratingChunkMap.class), name = "chunkMap")) + @FieldToMethodRedirect("chunkMap:Lnet/minecraft/server/level/GeneratingChunkMap;") private native GeneratingCubeMap cc_getGeneratingCubeMap(); } @@ -203,7 +195,7 @@ abstract class ChunkEvent$Load_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Load.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Load_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class), @Ref(boolean.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;Z)V") static native Event create_ChunkEvent$Load(LevelCube levelCube, boolean newChunk); } @@ -212,7 +204,7 @@ abstract class ChunkEvent$Unload_to_Event_redirects {} @InterOwnerContainer(from = @Ref(ChunkEvent.Unload.class), to = @Ref(EventConstructorDelegates.class)) abstract class ChunkEvent$Unload_delegateConstruction { - @ConstructorToFactoryRedirect(@ConstructorMethodSig(args = { @Ref(LevelChunk.class) })) + @ConstructorToFactoryRedirect("(Lnet/minecraft/world/level/chunk/LevelChunk;)V") static native Event create_ChunkEvent$Unload(LevelCube levelCube); } @@ -231,7 +223,7 @@ class ChunkStatusTasks_to_CubeStatusTasks_redirects {} @IntraOwnerContainer(@Ref(GenerationChunkHolder.class)) class GenerationChunkHolder_redirects { - @FieldRedirect(@FieldSig(name = "pos", type = @Ref(ChunkPos.class))) + @FieldRedirect("pos:Lnet/minecraft/world/level/ChunkPos;") protected CubePos cc_cubePos; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java index b6ec1b21..9728eadd 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/GlobalSet.java @@ -11,7 +11,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.TypeRedirect; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.server.level.CloTrackingView; @@ -32,16 +31,19 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; /** - * Contains redirects that are applied to all DASM transforms. + * Contains redirects that are applied to all DASM transforms.
*
- *
- * Redirects should only be added to this set if they are applicable in all contexts. + * Redirects should only be added to this set if they are applicable in all + * contexts. */ @RedirectSet public interface GlobalSet extends ForgeSet { @IntraOwnerContainer(@Ref(ChunkStatus.class)) abstract class ChunkStatus_redirects { - @MethodRedirect(@MethodSig("generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager;Lnet/minecraft/server/level/ThreadedLevelLightEngine;Ljava/util/function/Function;Ljava/util/List;)Ljava/util/concurrent/CompletableFuture;")) + @MethodRedirect("generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;" + + "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager;" + + "Lnet/minecraft/server/level/ThreadedLevelLightEngine;Ljava/util/function/Function;Ljava/util/List;)" + + "Ljava/util/concurrent/CompletableFuture;") public abstract CompletableFuture> cc_generate( Executor exectutor, ServerLevel level, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, ThreadedLevelLightEngine lightEngine, Function>> task, List cache @@ -50,10 +52,10 @@ public abstract CompletableFuture> cc_generate( @TypeRedirect(from = @Ref(ChunkProgressListener.class), to = @Ref(CloProgressListener.class)) interface ChunkProgressListener_to_CloProgressListener_redirects { - @MethodRedirect(@MethodSig("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V")) + @MethodRedirect("updateSpawnPos(Lnet/minecraft/world/level/ChunkPos;)V") void cc_updateSpawnPos(CloPos center); - @MethodRedirect(@MethodSig("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @MethodRedirect("onStatusChange(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") void cc_onStatusChange(CloPos chunkPosition, @Nullable ChunkStatus newStatus); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java index 817b079d..ff9d9030 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToChunkSet.java @@ -3,7 +3,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.MethodRedirect; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import net.minecraft.core.SectionPos; @@ -15,7 +14,7 @@ public interface SectionPosToChunkSet { @IntraOwnerContainer(@Ref(SectionPos.class)) abstract class SectionPos_redirects { - @MethodRedirect(@MethodSig("chunk()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("chunk()Lnet/minecraft/world/level/ChunkPos;") public native CloPos cc_chunk(); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java index 5de45fdd..c57e4394 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/dasmsets/SectionPosToCubeSet.java @@ -3,7 +3,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.MethodRedirect; import io.github.notstirred.dasm.api.annotations.redirect.sets.IntraOwnerContainer; import io.github.notstirred.dasm.api.annotations.redirect.sets.RedirectSet; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.world.level.CloPos; import net.minecraft.core.SectionPos; @@ -15,7 +14,7 @@ public interface SectionPosToCubeSet { @IntraOwnerContainer(@Ref(SectionPos.class)) abstract class SectionPos_redirects { - @MethodRedirect(@MethodSig("chunk()Lnet/minecraft/world/level/ChunkPos;")) + @MethodRedirect("chunk()Lnet/minecraft/world/level/ChunkPos;") public native CloPos cc_cube(); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java index 7c386621..cf465331 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCCommonHooks.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet; @@ -16,12 +15,12 @@ public class CCCommonHooks { private CCCommonHooks() {} - @AddMethodToSets(containers = ChunkToCubeSet.CommonHooks_to_CCCommonHooks_redirects.class, method = @MethodSig("onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V")) + @AddMethodToSets(containers = ChunkToCubeSet.CommonHooks_to_CCCommonHooks_redirects.class, method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") public static void onCubeUnload(PoiManager poiManager, CubeAccess cubeAccess) { // TODO (P2) save/load: once PoiManager cubic methods are implemented, this method can be a dasm copy } - @AddMethodToSets(containers = ChunkToCloSet.CommonHooks_to_CCCommonHooks_redirects.class, method = @MethodSig("onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V")) + @AddMethodToSets(containers = ChunkToCloSet.CommonHooks_to_CCCommonHooks_redirects.class, method = "onChunkUnload(Lnet/minecraft/world/entity/ai/village/poi/PoiManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V") public static void onCloUnload(PoiManager poiManager, CloAccess cloAccess) { if (cloAccess instanceof CubeAccess cubeAccess) { onCubeUnload(poiManager, cubeAccess); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java index eff053c3..cee7662c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/movetoforgesourcesetlater/CCEventHooks.java @@ -2,7 +2,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.opencubicchunks.cc_core.world.level.CloPos; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ForgeSet; @@ -21,7 +20,7 @@ private CCEventHooks() {} // TODO onCreateWorldSpawn? // TODO onTrySpawnPortal? - @AddMethodToSets(containers = ForgeSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkTicketLevelUpdated(Lnet/minecraft/server/level/ServerLevel;JIILnet/minecraft/server/level/ChunkHolder;)V")) + @AddMethodToSets(containers = ForgeSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkTicketLevelUpdated(Lnet/minecraft/server/level/ServerLevel;JIILnet/minecraft/server/level/ChunkHolder;)V") public static void fireChunkTicketLevelUpdated( ServerLevel level, long cloPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder ) { @@ -33,7 +32,8 @@ public static void fireChunkTicketLevelUpdated( } // TODO do we need a ChunkToCloForgeSet, etc? actually I guess if we only tell dasm about this class on forge then it's fine - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/server/level/ServerLevel;)V")) + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkWatch(ServerPlayer entity, LevelClo clo, ServerLevel level) { if (clo instanceof LevelChunk chunk) { EventHooks.fireChunkWatch(entity, chunk, level); @@ -42,7 +42,8 @@ public static void fireChunkWatch(ServerPlayer entity, LevelClo clo, ServerLevel } } - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkSent(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/server/level/ServerLevel;)V")) + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkSent(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/chunk/LevelChunk;" + + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkSent(ServerPlayer entity, LevelClo clo, ServerLevel level) { if (clo instanceof LevelChunk chunk) { EventHooks.fireChunkSent(entity, chunk, level); @@ -51,7 +52,8 @@ public static void fireChunkSent(ServerPlayer entity, LevelClo clo, ServerLevel } } - @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = @MethodSig("fireChunkUnWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/ServerLevel;)V")) + @AddMethodToSets(containers = ChunkToCloSet.EventHooks_to_CCEventHooks_redirects.class, method = "fireChunkUnWatch(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;" + + "Lnet/minecraft/server/level/ServerLevel;)V") public static void fireChunkUnWatch(ServerPlayer entity, CloPos cloPos, ServerLevel level) { if (cloPos.isChunk()) { EventHooks.fireChunkUnWatch(entity, cloPos.chunkPos(), level); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java index 9faa865f..7b2ac874 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CloTrackingView.java @@ -5,9 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; -import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; import io.github.opencubicchunks.cc_core.world.level.CloPos; @@ -17,7 +14,7 @@ @Dasm(ChunkToCloSet.class) public interface CloTrackingView extends ChunkTrackingView { - @AddFieldToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, field = @FieldSig(type = @Ref(ChunkTrackingView.class), name = "EMPTY")) + @AddFieldToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, field = "EMPTY:Lnet/minecraft/server/level/ChunkTrackingView;") CloTrackingView EMPTY = new CloTrackingView() { @Override public boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks) { return false; @@ -32,13 +29,14 @@ public interface CloTrackingView extends ChunkTrackingView { @Override public void forEach(Consumer action) {} }; - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("of(Lnet/minecraft/world/level/ChunkPos;I)Lnet/minecraft/server/level/ChunkTrackingView;")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "of(Lnet/minecraft/world/level/ChunkPos;I)Lnet/minecraft/server/level/ChunkTrackingView;") static CloTrackingView cc_of(CloPos center, int viewDistanceCubes) { return new CloTrackingView.Positioned(center, viewDistanceCubes); } @SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:JavaNCSS" }) // <-- copies structure of vanilla method - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("difference(Lnet/minecraft/server/level/ChunkTrackingView;Lnet/minecraft/server/level/ChunkTrackingView;Ljava/util/function/Consumer;Ljava/util/function/Consumer;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "difference(Lnet/minecraft/server/level/ChunkTrackingView;Lnet/minecraft/server/level/ChunkTrackingView;" + + "Ljava/util/function/Consumer;Ljava/util/function/Consumer;)V") static void cc_difference( CloTrackingView oldCloTrackingView, CloTrackingView newCloTrackingView, Consumer chunkDropper, Consumer chunkMarker ) { @@ -120,7 +118,7 @@ static void cc_difference( } } - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("contains(Lnet/minecraft/world/level/ChunkPos;)Z")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "contains(Lnet/minecraft/world/level/ChunkPos;)Z") default boolean cc_contains(CloPos cloPos) { if (cloPos.isCube()) { return this.cc_contains(cloPos.getX(), cloPos.getY(), cloPos.getZ()); @@ -135,7 +133,7 @@ default boolean cc_contains(int cubeX, int cubeY, int cubeZ) { boolean cc_contains(int cubeX, int cubeY, int cubeZ, boolean searchAllChunks); - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = @MethodSig("forEach(Ljava/util/function/Consumer;)V")) + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView_to_CloTrackingView_redirects.class, method = "forEach(Ljava/util/function/Consumer;)V") void cc_forEach(Consumer action); default boolean cc_isInViewDistance(int cubeX, int cubeY, int cubeZ) { @@ -166,7 +164,7 @@ static boolean cc_isWithinDistanceCubeColumn( @Dasm(ChunkToCloSet.class) record Positioned( CloPos center, - @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects.class, method = @MethodSig("viewDistance()I")) int viewDistanceCubes + @AddMethodToSets(containers = ChunkToCloSet.ChunkTrackingView$Positioned_to_CloTrackingView$Positioned_redirects.class, method = "viewDistance()I") int viewDistanceCubes ) implements CloTrackingView { int minX() { return this.center.getX() - this.viewDistanceCubes - 1; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java index 2d199f5c..35b953b7 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeLevel.java @@ -5,9 +5,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; -import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet; import io.github.opencubicchunks.cubicchunks.world.level.cube.status.CubePyramid; @@ -25,18 +22,19 @@ private CubeLevel() {} private static final int FULL_CHUNK_LEVEL = 33; private static final CubeStep FULL_CUBE_STEP = CubePyramid.CC_GENERATION_PYRAMID_CUBES.getStepTo(ChunkStatus.FULL); - @AddFieldToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, field = @FieldSig(type = @Ref(int.class), name = "RADIUS_AROUND_FULL_CHUNK")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, field = "RADIUS_AROUND_FULL_CHUNK:I") public static final int RADIUS_AROUND_FULL_CUBE = FULL_CUBE_STEP.accumulatedDependencies().getRadius(); // TODO not sure if this one should actually be redirected? in some cases we want this MAX_LEVEL, in some cases we want the true MAX_LEVEL, which // is greater. public static final int MAX_LEVEL = FULL_CHUNK_LEVEL + RADIUS_AROUND_FULL_CUBE; - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "generationStatus(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") public static @Nullable ChunkStatus cubeGenerationStatus(int level) { return getStatusAroundFullCube(level - FULL_CHUNK_LEVEL, null); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("getStatusAroundFullChunk(ILnet/minecraft/world/level/chunk/status/ChunkStatus;)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "getStatusAroundFullChunk(ILnet/minecraft/world/level/chunk/status/ChunkStatus;)" + + "Lnet/minecraft/world/level/chunk/status/ChunkStatus;") @Nullable @Contract("_,!null->!null;_,_->_") public static ChunkStatus getStatusAroundFullCube(int distance, @Nullable ChunkStatus chunkStatus) { if (distance > RADIUS_AROUND_FULL_CUBE) { @@ -46,17 +44,17 @@ public static ChunkStatus getStatusAroundFullCube(int distance, @Nullable ChunkS } } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("getStatusAroundFullChunk(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "getStatusAroundFullChunk(I)Lnet/minecraft/world/level/chunk/status/ChunkStatus;") public static ChunkStatus getStatusAroundFullCube(int distance) { return getStatusAroundFullCube(distance, ChunkStatus.EMPTY); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("byStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "byStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") public static int byCubeStatus(ChunkStatus status) { return FULL_CHUNK_LEVEL + FULL_CUBE_STEP.getAccumulatedRadiusOf(status); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = @MethodSig("isLoaded(I)Z")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkLevel_to_CubeLevel_redirects.class, method = "isLoaded(I)Z") public static boolean isLoadedCube(int level) { return level <= MAX_LEVEL; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java index 54a36ee7..b0a2b80c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/status/CCChunkStatusTasks.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkInCubicContextSet; @@ -32,14 +30,15 @@ public class CCChunkStatusTasks { private CCChunkStatusTasks() {} - @AddFieldToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, field = @FieldSig(type = @Ref(Logger.class), name = "LOGGER")) + @AddFieldToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, field = "LOGGER:Lorg/slf4j/Logger;") private static final Logger LOGGER = LogUtils.getLogger(); @AddTransformToSets(ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private static native boolean isLighted(ChunkAccess chunk); - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture passThrough( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { @@ -47,77 +46,90 @@ public static CompletableFuture passThrough( } // We skip chunk generation steps in cubic contexts by delegating to passThrough - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureStarts( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture loadStructureStarts( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureReferences( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateBiomes( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateNoise( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSurface( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateCarvers( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateFeatures( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture initializeLight( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture light( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { return passThrough(worldGenContext, step, cache, chunk); } - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSpawn( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ) { @@ -126,12 +138,13 @@ public static CompletableFuture generateSpawn( // We still want to upgrade ProtoChunks to LevelChunks normally @AddTransformToSets(ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static native CompletableFuture full( WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk ); - @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = @MethodSig("postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V")) + @AddMethodToSets(containers = ChunkInCubicContextSet.ChunkStatusTasks_to_CCChunkStatusTasks_redirects.class, method = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") private static void postLoadProtoChunk(ServerLevel level, ValueInput.ValueInputList entityTags) { // Entities should be handled on the cube, not the chunk } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java index 91b3ea52..34400c53 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/CubeAccess.java @@ -10,7 +10,6 @@ import com.google.common.collect.Maps; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -112,10 +111,11 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC } } - @TransformFromMethod(value = @MethodSig("getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", owner = @Ref(ChunkAccess.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); - @TransformFromMethod(owner = @Ref(ChunkAccess.class), value = @MethodSig("setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/state/BlockState;")) + @TransformFromMethod(owner = @Ref(ChunkAccess.class), value = "setBlockState(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)" + + "Lnet/minecraft/world/level/block/state/BlockState;") @Override public native @Nullable BlockState setBlockState(BlockPos pos, BlockState state); @Override public abstract @Nullable BlockState setBlockState(BlockPos pos, BlockState state, int flags); @@ -134,13 +134,13 @@ private static void replaceMissingSections(Registry biomeRegistry, LevelC return this.getMinY(); } - @TransformFromMethod(value = @MethodSig("getBlockEntitiesPos()Ljava/util/Set;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getBlockEntitiesPos()Ljava/util/Set;", owner = @Ref(ChunkAccess.class)) @Override public native Set getBlockEntitiesPos(); - @TransformFromMethod(value = @MethodSig("getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getSections()[Lnet/minecraft/world/level/chunk/LevelChunkSection;", owner = @Ref(ChunkAccess.class)) @Override public native LevelChunkSection[] getSections(); - @TransformFromMethod(value = @MethodSig("getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getSection(I)Lnet/minecraft/world/level/chunk/LevelChunkSection;", owner = @Ref(ChunkAccess.class)) @Override public native LevelChunkSection getSection(int index); // TODO (P2) heightmap methods on cubes @@ -171,28 +171,30 @@ public CubePos cc_getCubePos() { return CloPos.cube(cubePos); } - @TransformFromMethod(value = @MethodSig("getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lnet/minecraft/world/level/levelgen/structure/StructureStart;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)" + + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;", owner = @Ref(ChunkAccess.class)) @Override public native @Nullable StructureStart getStartForStructure(Structure structure); - @TransformFromMethod(value = @MethodSig("setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setStartForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;" + + "Lnet/minecraft/world/level/levelgen/structure/StructureStart;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setStartForStructure(Structure structure, StructureStart structureStart); - @TransformFromMethod(value = @MethodSig("getAllStarts()Ljava/util/Map;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getAllStarts()Ljava/util/Map;", owner = @Ref(ChunkAccess.class)) @Override public native Map getAllStarts(); - @TransformFromMethod(value = @MethodSig("setAllStarts(Ljava/util/Map;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setAllStarts(Ljava/util/Map;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setAllStarts(Map structureStarts); - @TransformFromMethod(value = @MethodSig("getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getReferencesForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;)Lit/unimi/dsi/fastutil/longs/LongSet;", owner = @Ref(ChunkAccess.class)) @Override public native LongSet getReferencesForStructure(Structure structure); - @TransformFromMethod(value = @MethodSig("addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "addReferenceForStructure(Lnet/minecraft/world/level/levelgen/structure/Structure;J)V", owner = @Ref(ChunkAccess.class)) @Override public native void addReferenceForStructure(Structure structure, long reference); - @TransformFromMethod(value = @MethodSig("getAllReferences()Ljava/util/Map;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getAllReferences()Ljava/util/Map;", owner = @Ref(ChunkAccess.class)) @Override public native Map getAllReferences(); - @TransformFromMethod(value = @MethodSig("setAllReferences(Ljava/util/Map;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setAllReferences(Ljava/util/Map;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setAllReferences(Map structureReferencesMap); @Override public boolean isYSpaceEmpty(int startY, int endY) { @@ -205,13 +207,13 @@ public CubePos cc_getCubePos() { return false; } - @TransformFromMethod(value = @MethodSig("markUnsaved()V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "markUnsaved()V", owner = @Ref(ChunkAccess.class)) @Override public native void markUnsaved(); - @TransformFromMethod(value = @MethodSig("tryMarkSaved()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "tryMarkSaved()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean tryMarkSaved(); - @TransformFromMethod(value = @MethodSig("isUnsaved()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "isUnsaved()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean isUnsaved(); @Override public abstract ChunkStatus getPersistedStatus(); @@ -223,27 +225,27 @@ public CubePos cc_getCubePos() { @Override public abstract void removeBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ChunkAccess.class)) @Override public native void markPosForPostprocessing(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getPostProcessing()[Lit/unimi/dsi/fastutil/shorts/ShortList;", owner = @Ref(ChunkAccess.class)) @Override public native ShortList[] getPostProcessing(); - @TransformFromMethod(value = @MethodSig("addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V", owner = @Ref(ChunkAccess.class)) @Override public native void addPackedPostProcess(ShortList offsets, int index); - @TransformFromMethod(value = @MethodSig("setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setBlockEntityNbt(Lnet/minecraft/nbt/CompoundTag;)V", owner = @Ref(ChunkAccess.class)) @Override public native void setBlockEntityNbt(CompoundTag tag); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getBlockEntityNbt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/nbt/CompoundTag;", owner = @Ref(ChunkAccess.class)) @Override public native @Nullable CompoundTag getBlockEntityNbt(BlockPos pos); @Override public abstract @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); - @TransformFromMethod(value = @MethodSig("findBlockLightSources(Ljava/util/function/BiConsumer;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "findBlockLightSources(Ljava/util/function/BiConsumer;)V", owner = @Ref(ChunkAccess.class)) @Override public native void findBlockLightSources(BiConsumer output); - @TransformFromMethod(value = @MethodSig("findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "findBlocks(Ljava/util/function/Predicate;Ljava/util/function/BiConsumer;)V", owner = @Ref(ChunkAccess.class)) @Override public native void findBlocks(Predicate predicate, BiConsumer output); @Override public void findBlocks( @@ -279,46 +281,46 @@ public CubePos cc_getCubePos() { @Override public abstract TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = @MethodSig("canBeSerialized()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "canBeSerialized()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean canBeSerialized(); @Override public abstract ChunkAccess.PackedTicks getTicksForSerialization(long todoNameThis); - @TransformFromMethod(value = @MethodSig("getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getUpgradeData()Lnet/minecraft/world/level/chunk/UpgradeData;", owner = @Ref(ChunkAccess.class)) @Override public native UpgradeData getUpgradeData(); - @TransformFromMethod(value = @MethodSig("isOldNoiseGeneration()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "isOldNoiseGeneration()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean isOldNoiseGeneration(); - @TransformFromMethod(value = @MethodSig("getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getBlendingData()Lnet/minecraft/world/level/levelgen/blending/BlendingData;", owner = @Ref(ChunkAccess.class)) @Override public native @Nullable BlendingData getBlendingData(); - @TransformFromMethod(value = @MethodSig("getInhabitedTime()J"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getInhabitedTime()J", owner = @Ref(ChunkAccess.class)) @Override public native long getInhabitedTime(); - @TransformFromMethod(value = @MethodSig("incrementInhabitedTime(J)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "incrementInhabitedTime(J)V", owner = @Ref(ChunkAccess.class)) @Override public native void incrementInhabitedTime(long amount); - @TransformFromMethod(value = @MethodSig("setInhabitedTime(J)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setInhabitedTime(J)V", owner = @Ref(ChunkAccess.class)) @Override public native void setInhabitedTime(long inhabitedTime); - @TransformFromMethod(value = @MethodSig("getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getOrCreateOffsetList([Lit/unimi/dsi/fastutil/shorts/ShortList;I)Lit/unimi/dsi/fastutil/shorts/ShortList;", owner = @Ref(ChunkAccess.class)) public static native ShortList getOrCreateOffsetList(ShortList[] packedPositions, int index); - @TransformFromMethod(value = @MethodSig("isLightCorrect()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "isLightCorrect()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean isLightCorrect(); - @TransformFromMethod(value = @MethodSig("setLightCorrect(Z)V"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "setLightCorrect(Z)V", owner = @Ref(ChunkAccess.class)) @Override public native void setLightCorrect(boolean lightCorrect); - @TransformFromMethod(value = @MethodSig("getMinY()I"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getMinY()I", owner = @Ref(ChunkAccess.class)) @Override public native int getMinY(); // these are two semantically different methods that happen to share a name; // one is for accessing heightmaps, and the other for getting height of the world. // we match the method ordering of the vanilla ChunkAccess class, which doesn't group them. @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder") - @TransformFromMethod(value = @MethodSig("getHeight()I"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getHeight()I", owner = @Ref(ChunkAccess.class)) @Override public native int getHeight(); @Override public NoiseChunk getOrCreateNoiseChunk(Function noiseChunkCreator) { @@ -337,7 +339,7 @@ public CubePos cc_getCubePos() { throw new UnsupportedOperationException(); // TODO P3 } - @TransformFromMethod(value = @MethodSig("hasAnyStructureReferences()Z"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "hasAnyStructureReferences()Z", owner = @Ref(ChunkAccess.class)) @Override public native boolean hasAnyStructureReferences(); @Override public @Nullable BelowZeroRetrogen getBelowZeroRetrogen() { @@ -348,7 +350,7 @@ public CubePos cc_getCubePos() { return false; // Used for below-zero retrogen; not applicable to cubes } - @TransformFromMethod(value = @MethodSig("getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;"), owner = @Ref(ChunkAccess.class)) + @TransformFromMethod(value = "getHeightAccessorForGeneration()Lnet/minecraft/world/level/LevelHeightAccessor;", owner = @Ref(ChunkAccess.class)) @Override public native LevelHeightAccessor getHeightAccessorForGeneration(); @Override public void initializeLightSources() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java index 2227f0bf..a11cb9ab 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ImposterProtoCube.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.world.level.cube; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.opencubicchunks.cubicchunks.exception.DasmFailedToApply; @@ -22,7 +21,7 @@ public ImposterProtoCube(LevelCube wrapped, boolean allowWrites) { } // Method is implemented in MixinImposterProtoCube instead, since DASM clears everything in this class. - @AddMethodToSets(containers = ChunkToCubeSet.ImposterProtoChunk_to_ImposterProtoCube_redirects.class, method = @MethodSig("Lnet/minecraft/world/level/chunk/ImposterProtoChunk;getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;")) + @AddMethodToSets(containers = ChunkToCubeSet.ImposterProtoChunk_to_ImposterProtoCube_redirects.class, method = "getWrapped()Lnet/minecraft/world/level/chunk/LevelChunk;") @Override public LevelClo cc_getWrappedClo() { throw new DasmFailedToApply(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java index 989e82f8..5f6d92b8 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube.java @@ -13,7 +13,6 @@ import com.google.common.collect.Maps; import com.mojang.logging.LogUtils; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -159,31 +158,31 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { this.setUnsavedListener(cubePos -> unsavedListener.setUnsaved(CloPos.cube(cubePos))); } - @TransformFromMethod(value = @MethodSig("markUnsaved()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "markUnsaved()V", owner = @Ref(LevelChunk.class)) @Override public native void markUnsaved(); - @TransformFromMethod(value = @MethodSig("getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getBlockTicks(); - @TransformFromMethod(value = @MethodSig("getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(LevelChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = @MethodSig("getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", owner = @Ref(LevelChunk.class)) @Override public native ChunkAccess.PackedTicks getTicksForSerialization(long gameTime); // TODO should this actually be dasm'd? - @TransformFromMethod(value = @MethodSig("getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getListenerRegistry(I)Lnet/minecraft/world/level/gameevent/GameEventListenerRegistry;", owner = @Ref(LevelChunk.class)) @Override public native GameEventListenerRegistry getListenerRegistry(int sectionY); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", owner = @Ref(LevelChunk.class)) @Override public native @NotNull BlockState getBlockState(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", owner = @Ref(LevelChunk.class)) @Override public native @NotNull FluidState getFluidState(BlockPos pos); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getFluidState(III)Lnet/minecraft/world/level/material/FluidState;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", owner = @Ref(LevelChunk.class)) @Override public native FluidState getFluidState(int x, int y, int z); // TODO might be dasm-able eventually, if we get more powerful mixin tools @@ -266,53 +265,53 @@ public void setUnsavedListener(LevelCube.UnsavedListener unsavedListener) { } } - @TransformFromMethod(value = @MethodSig("addEntity(Lnet/minecraft/world/entity/Entity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "addEntity(Lnet/minecraft/world/entity/Entity;)V", owner = @Ref(LevelChunk.class)) @Deprecated @Override public native void addEntity(Entity entity); - @TransformFromMethod(value = @MethodSig("createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "createBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) private native @Nullable BlockEntity createBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) @Override public native @Nullable BlockEntity getBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" - + "Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;)" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) public native @Nullable BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType); - @TransformFromMethod(value = @MethodSig("addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "addAndRegisterBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) public native void addAndRegisterBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = @MethodSig("isInLevel()Z"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "isInLevel()Z", owner = @Ref(LevelChunk.class)) private native boolean isInLevel(); - @TransformFromMethod(value = @MethodSig("isTicking(Lnet/minecraft/core/BlockPos;)Z"), owner = @Ref(LevelChunk.class), visibility = PUBLIC) + @TransformFromMethod(value = "isTicking(Lnet/minecraft/core/BlockPos;)Z", owner = @Ref(LevelChunk.class), visibility = PUBLIC) public native boolean isTicking(BlockPos pos); - @TransformFromMethod(value = @MethodSig("setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", owner = @Ref(LevelChunk.class)) @Override public native @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); - @TransformFromMethod(value = @MethodSig("removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(LevelChunk.class)) @Override public native void removeBlockEntity(BlockPos pos); // TODO maybe shouldn't be dasm - @TransformFromMethod(value = @MethodSig("removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", owner = @Ref(LevelChunk.class)) private native void removeGameEventListener(T blockEntity, ServerLevel level); // TODO sectionY is definitely wrong here - @TransformFromMethod(value = @MethodSig("removeGameEventListenerRegistry(I)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeGameEventListenerRegistry(I)V", owner = @Ref(LevelChunk.class)) private native void removeGameEventListenerRegistry(int sectionY); - @TransformFromMethod(value = @MethodSig("removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "removeBlockEntityTicker(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(LevelChunk.class)) private native void removeBlockEntityTicker(BlockPos pos); - @TransformFromMethod(value = @MethodSig("runPostLoad()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "runPostLoad()V", owner = @Ref(LevelChunk.class)) public native void runPostLoad(); - @TransformFromMethod(value = @MethodSig("isEmpty()Z"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "isEmpty()Z", owner = @Ref(LevelChunk.class)) public native boolean isEmpty(); // TODO this should maybe be dasm + mixin, there's a lot of vanilla code duplication here @@ -340,16 +339,16 @@ public void replaceWithPacketData( } } - @TransformFromMethod(value = @MethodSig("replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "replaceBiomes(Lnet/minecraft/network/FriendlyByteBuf;)V", owner = @Ref(LevelChunk.class)) public native void replaceBiomes(FriendlyByteBuf buffer); - @TransformFromMethod(value = @MethodSig("setLoaded(Z)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "setLoaded(Z)V", owner = @Ref(LevelChunk.class)) public native void setLoaded(boolean loaded); - @TransformFromMethod(value = @MethodSig("getLevel()Lnet/minecraft/world/level/Level;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getLevel()Lnet/minecraft/world/level/Level;", owner = @Ref(LevelChunk.class)) public native Level getLevel(); - @TransformFromMethod(value = @MethodSig("getBlockEntities()Ljava/util/Map;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getBlockEntities()Ljava/util/Map;", owner = @Ref(LevelChunk.class)) public native Map getBlockEntities(); // TODO P2 or P3 figure this out later - stub method for now @@ -367,51 +366,55 @@ public void postProcessGeneration(ServerLevel serverLevel) { this.pendingBlockEntities.clear(); } - @TransformFromMethod(value = @MethodSig("promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "promotePendingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/nbt/CompoundTag;)" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(LevelChunk.class)) private native @Nullable BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag); - @TransformFromMethod(value = @MethodSig("unpackTicks(J)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "unpackTicks(J)V", owner = @Ref(LevelChunk.class)) public native void unpackTicks(long pos); // TODO (P2 or P3) ticks are disabled for now; stub methods as placeholders -// @TransformFromMethod(value = @MethodSig("registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) +// @TransformFromMethod(value = @MethodSig("registerTickContainerInLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk +// .class)) // public native void registerTickContainerInLevel(ServerLevel level); public void registerTickContainerInLevel(ServerLevel level) {} -// @TransformFromMethod(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) + // @TransformFromMethod(value = @MethodSig("unregisterTickContainerFromLevel(Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref + // (LevelChunk.class)) // public native void unregisterTickContainerFromLevel(ServerLevel level); public void unregisterTickContainerFromLevel(ServerLevel level) {} - @TransformFromMethod(value = @MethodSig("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;", owner = @Ref(LevelChunk.class)) @Override public native ChunkStatus getPersistedStatus(); - @TransformFromMethod(value = @MethodSig("getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "getFullStatus()Lnet/minecraft/server/level/FullChunkStatus;", owner = @Ref(LevelChunk.class)) public native FullChunkStatus getFullStatus(); - @TransformFromMethod(value = @MethodSig("setFullStatus(Ljava/util/function/Supplier;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "setFullStatus(Ljava/util/function/Supplier;)V", owner = @Ref(LevelChunk.class)) public native void setFullStatus(Supplier fullStatus); // TODO a bit concerning - @TransformFromMethod(value = @MethodSig("clearAllBlockEntities()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "clearAllBlockEntities()V", owner = @Ref(LevelChunk.class)) public native void clearAllBlockEntities(); - @TransformFromMethod(value = @MethodSig("registerAllBlockEntitiesAfterLevelLoad()V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "registerAllBlockEntitiesAfterLevelLoad()V", owner = @Ref(LevelChunk.class)) public native void registerAllBlockEntitiesAfterLevelLoad(); // TODO (P3): GameEvent stuff is a bit concerning - @TransformFromMethod(value = @MethodSig("addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "addGameEventListener(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/server/level/ServerLevel;)V", owner = @Ref(LevelChunk.class)) private native void addGameEventListener(T blockEntity, ServerLevel level); - @TransformFromMethod(value = @MethodSig("updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "updateBlockEntityTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(LevelChunk.class)) private native void updateBlockEntityTicker(T blockEntity); - @TransformFromMethod(value = @MethodSig("createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" - + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;"), owner = @Ref(LevelChunk.class)) + @TransformFromMethod(value = "createTicker(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/level/block/entity/BlockEntityTicker;)" + + "Lnet/minecraft/world/level/block/entity/TickingBlockEntity;", owner = @Ref(LevelChunk.class)) private native TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker ticker); // TODO forge stuff // FORGE START -// private final net.neoforged.neoforge.attachment.AttachmentHolder.AsField attachmentHolder = new net.neoforged.neoforge.attachment.AttachmentHolder.AsField(); +// private final net.neoforged.neoforge.attachment.AttachmentHolder.AsField attachmentHolder = new net.neoforged.neoforge.attachment +// .AttachmentHolder.AsField(); // // @Override public boolean hasData(net.neoforged.neoforge.attachment.AttachmentType type) { // return attachmentHolder.hasData(type); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java index 18504004..9e7a0dc9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/ProtoCube.java @@ -7,7 +7,6 @@ import com.google.common.collect.Lists; import io.github.notstirred.dasm.api.annotations.Dasm; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubePos; @@ -75,21 +74,21 @@ public ProtoCube( this.fluidTicks = liquidTicks; } - @TransformFromMethod(value = @MethodSig("getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(ProtoChunk.class)) @Override public native TickContainerAccess getBlockTicks(); - @TransformFromMethod(value = @MethodSig("getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getFluidTicks()Lnet/minecraft/world/ticks/TickContainerAccess;", owner = @Ref(ProtoChunk.class)) @Override public native TickContainerAccess getFluidTicks(); - @TransformFromMethod(value = @MethodSig("getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getTicksForSerialization(J)Lnet/minecraft/world/level/chunk/ChunkAccess$PackedTicks;", owner = @Ref(ProtoChunk.class)) @Override public native ChunkAccess.PackedTicks getTicksForSerialization(long todoNameThis); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", owner = @Ref(ProtoChunk.class)) @Override public native BlockState getBlockState(BlockPos pos); // dasm + mixin - @TransformFromMethod(value = @MethodSig("getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;", owner = @Ref(ProtoChunk.class)) @Override public native FluidState getFluidState(BlockPos pos); @Override public @Nullable BlockState setBlockState(BlockPos pos, BlockState state, int flags) { @@ -111,80 +110,80 @@ public ProtoCube( } } - @TransformFromMethod(value = @MethodSig("setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setBlockEntity(BlockEntity blockEntity); - @TransformFromMethod(value = @MethodSig("getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", owner = @Ref(ProtoChunk.class)) @Override public native @Nullable BlockEntity getBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getBlockEntities()Ljava/util/Map;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntities()Ljava/util/Map;", owner = @Ref(ProtoChunk.class)) @Override public native Map getBlockEntities(); - @TransformFromMethod(value = @MethodSig("addEntity(Lnet/minecraft/nbt/CompoundTag;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "addEntity(Lnet/minecraft/nbt/CompoundTag;)V", owner = @Ref(ProtoChunk.class)) @Override public native void addEntity(CompoundTag tag); - @TransformFromMethod(value = @MethodSig("addEntity(Lnet/minecraft/world/entity/Entity;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "addEntity(Lnet/minecraft/world/entity/Entity;)V", owner = @Ref(ProtoChunk.class)) @Override public native void addEntity(Entity entity); // setStartForStructure: ProtoChunk logic handles below-zero retrogen then calls super, so we don't need to override - @TransformFromMethod(value = @MethodSig("getEntities()Ljava/util/List;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getEntities()Ljava/util/List;", owner = @Ref(ProtoChunk.class)) @Override public native List getEntities(); - @TransformFromMethod(value = @MethodSig("getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getPersistedStatus()Lnet/minecraft/world/level/chunk/status/ChunkStatus;", owner = @Ref(ProtoChunk.class)) @Override public native ChunkStatus getPersistedStatus(); - @TransformFromMethod(value = @MethodSig("setPersistedStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setPersistedStatus(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setPersistedStatus(ChunkStatus status); - @TransformFromMethod(value = @MethodSig("getNoiseBiome(III)Lnet/minecraft/core/Holder;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getNoiseBiome(III)Lnet/minecraft/core/Holder;", owner = @Ref(ProtoChunk.class)) @Override public native Holder getNoiseBiome(int x, int y, int z); - @TransformFromMethod(value = @MethodSig("packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "packOffsetCoordinates(Lnet/minecraft/core/BlockPos;)S", owner = @Ref(ProtoChunk.class)) public static native short packOffsetCoordinates(BlockPos pos); - @TransformFromMethod(value = @MethodSig("unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackOffsetCoordinates(SILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/core/BlockPos;", owner = @Ref(ProtoChunk.class)) public static native BlockPos unpackOffsetCoordinates(short packedPos, int yOffset, ChunkPos chunkPos); // dasm + mixin - @TransformFromMethod(value = @MethodSig("markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ProtoChunk.class)) @Override public native void markPosForPostprocessing(BlockPos pos); - @TransformFromMethod(value = @MethodSig("addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "addPackedPostProcess(Lit/unimi/dsi/fastutil/shorts/ShortList;I)V", owner = @Ref(ProtoChunk.class)) @Override public native void addPackedPostProcess(ShortList offsets, int index); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbts()Ljava/util/Map;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntityNbts()Ljava/util/Map;", owner = @Ref(ProtoChunk.class)) @Override public native Map getBlockEntityNbts(); - @TransformFromMethod(value = @MethodSig("getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getBlockEntityNbtForSaving(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;", owner = @Ref(ProtoChunk.class)) @Override public native @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos pos, HolderLookup.Provider provider); - @TransformFromMethod(value = @MethodSig("removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "removeBlockEntity(Lnet/minecraft/core/BlockPos;)V", owner = @Ref(ProtoChunk.class)) @Override public native void removeBlockEntity(BlockPos pos); - @TransformFromMethod(value = @MethodSig("getCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;", owner = @Ref(ProtoChunk.class)) @Override public native @Nullable CarvingMask getCarvingMask(); - @TransformFromMethod(value = @MethodSig("getOrCreateCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "getOrCreateCarvingMask()Lnet/minecraft/world/level/chunk/CarvingMask;", owner = @Ref(ProtoChunk.class)) @Override public native CarvingMask getOrCreateCarvingMask(); - @TransformFromMethod(value = @MethodSig("setCarvingMask(Lnet/minecraft/world/level/chunk/CarvingMask;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setCarvingMask(Lnet/minecraft/world/level/chunk/CarvingMask;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setCarvingMask(CarvingMask carvingMask); - @TransformFromMethod(value = @MethodSig("setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "setLightEngine(Lnet/minecraft/world/level/lighting/LevelLightEngine;)V", owner = @Ref(ProtoChunk.class)) @Override public native void setLightEngine(LevelLightEngine lightEngine); @Override public void setBelowZeroRetrogen(@Nullable BelowZeroRetrogen belowZeroRetrogen) { // Below-zero retrogen is unused in CC, hence empty method body } - @TransformFromMethod(value = @MethodSig("unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackTicks(Lnet/minecraft/world/ticks/ProtoChunkTicks;)Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) private static native LevelChunkTicks unpackTicks(ProtoChunkTicks ticks); - @TransformFromMethod(value = @MethodSig("unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackBlockTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) @Override public native LevelChunkTicks unpackBlockTicks(); - @TransformFromMethod(value = @MethodSig("unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;"), owner = @Ref(ProtoChunk.class)) + @TransformFromMethod(value = "unpackFluidTicks()Lnet/minecraft/world/ticks/LevelChunkTicks;", owner = @Ref(ProtoChunk.class)) @Override public native LevelChunkTicks unpackFluidTicks(); @Override public LevelHeightAccessor getHeightAccessorForGeneration() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java index 7d446101..51212cfb 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubePyramid.java @@ -3,8 +3,6 @@ import com.google.common.collect.ImmutableList; import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -24,12 +22,12 @@ public CubeStep getStepTo(ChunkStatus status) { return this.steps.get(status.getIndex()); } - @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = @FieldSig(type = @Ref(ChunkPyramid.class), name = "GENERATION_PYRAMID")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = "GENERATION_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") public static CubePyramid CC_GENERATION_PYRAMID_CUBES; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = @FieldSig(type = @Ref(ChunkPyramid.class), name = "LOADING_PYRAMID")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkPyramid_to_CubePyramid_redirects.class, field = "LOADING_PYRAMID:Lnet/minecraft/world/level/chunk/status/ChunkPyramid;") public static CubePyramid CC_LOADING_PYRAMID_CUBES; - @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkPyramid.class), value = @MethodSig("()V")) + @TransformFromMethod(useRedirectSets = ChunkToCubeSet.class, owner = @Ref(ChunkPyramid.class), value = "") static void initCubePyramids() { throw new DasmFailedToApply(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java index f811067e..7be761ac 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStatusTasks.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; import io.github.opencubicchunks.cc_core.api.CubicConstants; @@ -35,14 +33,15 @@ public class CubeStatusTasks { private CubeStatusTasks() {} - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, field = @FieldSig(type = @Ref(Logger.class), name = "LOGGER")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, field = "LOGGER:Lorg/slf4j/Logger;") private static final Logger LOGGER = LogUtils.getLogger(); @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "isLighted(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z") private static native boolean isLighted(CubeAccess cube); - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "passThrough(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture passThrough( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { @@ -50,28 +49,34 @@ public static CompletableFuture passThrough( } // TODO (P3) we skip cube generation steps for now by delegating to passThrough - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureStarts( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "loadStructureStarts(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture loadStructureStarts( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateStructureReferences(Lnet/minecraft/world/level/chunk/status/WorldGenContext;" + + "Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateStructureReferences( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateBiomes(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateBiomes( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { @@ -79,7 +84,8 @@ public static CompletableFuture generateBiomes( } @SuppressWarnings("checkstyle:MagicNumber") // hardcoded terrain generation; the constants are arbitrary - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateNoise(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateNoise( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { @@ -104,42 +110,48 @@ public static CompletableFuture generateNoise( return CompletableFuture.completedFuture(cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateSurface(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSurface( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateCarvers(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateCarvers( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateFeatures(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateFeatures( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "initializeLight(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture initializeLight( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "light(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture light( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { return passThrough(worldGenContext, step, cache, cube); } - @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = @MethodSig("generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @AddMethodToSets(containers = ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class, method = "generateSpawn(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static CompletableFuture generateSpawn( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ) { @@ -149,12 +161,13 @@ public static CompletableFuture generateSpawn( // Upgrade ProtoCube to LevelCube // dasm + mixin @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "full(Lnet/minecraft/world/level/chunk/status/WorldGenContext;Lnet/minecraft/world/level/chunk/status/ChunkStep;" + + "Lnet/minecraft/util/StaticCache2D;Lnet/minecraft/world/level/chunk/ChunkAccess;)Ljava/util/concurrent/CompletableFuture;") public static native CompletableFuture full( WorldGenContext worldGenContext, CubeStep step, StaticCache3D cache, CubeAccess cube ); @AddTransformToSets(ChunkToCubeSet.ChunkStatusTasks_to_CubeStatusTasks_redirects.class) - @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = @MethodSig("postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V")) + @TransformFromMethod(owner = @Ref(ChunkStatusTasks.class), value = "postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V") private static native void postLoadProtoCube(ServerLevel level, ValueInput.ValueInputList entityTags); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java index c695e368..eb06a06e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/cube/status/CubeStep.java @@ -7,8 +7,6 @@ import io.github.notstirred.dasm.api.annotations.Dasm; import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets; -import io.github.notstirred.dasm.api.annotations.selector.FieldSig; -import io.github.notstirred.dasm.api.annotations.selector.MethodSig; import io.github.notstirred.dasm.api.annotations.selector.Ref; import io.github.notstirred.dasm.api.annotations.transform.TransformFromClass; import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod; @@ -25,16 +23,14 @@ import net.minecraft.world.level.chunk.status.WorldGenContext; /** - * {@link ChunkStep} represents a single step in either chunk loading or chunk generation. - * This class represents a single step in cube loading or generation. It is identical to {@code ChunkStep}, but stores a {@link CubeStatusTask} - * instead of a {@link ChunkStatusTask}. - * + * {@link ChunkStep} represents a single step in either chunk loading or chunk generation. This class represents a single step in cube loading or + * generation. It is identical to {@code ChunkStep}, but stores a {@link CubeStatusTask} instead of a {@link ChunkStatusTask}. + * * @param targetStatus The status that this step corresponds to. - * @param directDependencies The dependencies of this individual step, by radius. - * Always includes the parent status at radius zero (except for EMPTY, which has no parent), and may have additional - * dependencies. - * @param accumulatedDependencies All dependencies needed to reach this step from unloaded, by radius. - * Effectively a combination of the directDependencies of this step and all previous steps. + * @param directDependencies The dependencies of this individual step, by radius. Always includes the parent status at radius zero (except for + * EMPTY, which has no parent), and may have additional dependencies. + * @param accumulatedDependencies All dependencies needed to reach this step from unloaded, by radius. Effectively a combination of the + * directDependencies of this step and all previous steps. * @param blockStateWriteRadius The radius of chunks that can receive blockstate writes. 0 if only the center chunk can; -1 if there are no * blockstate writes. Always -1 for chunk loading. * @param task The chunk loading or generation task for this step. @@ -56,19 +52,19 @@ public CompletableFuture apply(WorldGenContext worldGenContext, Stat @Dasm(ChunkToCubeSet.class) public static class Builder { private final ChunkStatus status; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = @FieldSig(type = @Ref(CubeStep.class), name = "parent")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = "parent:Lnet/minecraft/world/level/chunk/status/ChunkStep;") private final @Nullable CubeStep parent; private ChunkStatus[] directDependenciesByRadius; private int blockStateWriteRadius = -1; - @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = @FieldSig(type = @Ref(ChunkStatusTask.class), name = "task")) + @AddFieldToSets(containers = ChunkToCubeSet.ChunkStep$Builder_to_CubeStep$Builder_redirects.class, field = "task:Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;") private CubeStatusTask task = (worldGenContext, step, cache, cube) -> CompletableFuture.completedFuture(cube); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)V") protected Builder(ChunkStatus status) { throw new DasmFailedToApply(); } - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/status/ChunkStep;)V")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "(Lnet/minecraft/world/level/chunk/status/ChunkStatus;Lnet/minecraft/world/level/chunk/status/ChunkStep;)V") protected Builder(ChunkStatus status, CubeStep parent) { throw new DasmFailedToApply(); } @@ -99,16 +95,16 @@ public CubeStep.Builder blockStateWriteRadius(int blockStateWriteRadiusInSection return this; } - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("setTask(Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;)Lnet/minecraft/world/level/chunk/status/ChunkStep$Builder;")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "setTask(Lnet/minecraft/world/level/chunk/status/ChunkStatusTask;)Lnet/minecraft/world/level/chunk/status/ChunkStep$Builder;") public native CubeStep.Builder setTask(CubeStatusTask task); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("build()Lnet/minecraft/world/level/chunk/status/ChunkStep;")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "build()Lnet/minecraft/world/level/chunk/status/ChunkStep;") public native CubeStep build(); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("buildAccumulatedDependencies()[Lnet/minecraft/world/level/chunk/status/ChunkStatus;")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "buildAccumulatedDependencies()[Lnet/minecraft/world/level/chunk/status/ChunkStatus;") private native ChunkStatus[] buildAccumulatedDependencies(); - @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = @MethodSig("getRadiusOfParent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I")) + @TransformFromMethod(owner = @Ref(ChunkStep.Builder.class), value = "getRadiusOfParent(Lnet/minecraft/world/level/chunk/status/ChunkStatus;)I") private native int getRadiusOfParent(ChunkStatus parentStatus); } } diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 04866125..bc5ead61 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -73,7 +73,10 @@ description='''${mod_description}''' #[features.${mod_id}] #openGLVersion="[3.2,)" [[mixins]] -config="${mod_id}.mixins.core.json" + config="${mod_id}.mixins.core.json" [[mixins]] -config="${mod_id}.mixins.access.json" \ No newline at end of file + config="${mod_id}.mixins.access.json" + +[[dasm]] + config="${mod_id}.dasm.json" diff --git a/src/test/resources/META-INF/neoforge.mods.toml b/src/test/resources/META-INF/neoforge.mods.toml index 82714393..2a0dc255 100644 --- a/src/test/resources/META-INF/neoforge.mods.toml +++ b/src/test/resources/META-INF/neoforge.mods.toml @@ -80,3 +80,7 @@ config="${mod_id}.mixins.access.json" [[mixins]] config="${mod_id}.mixins.test.json" + + +[[dasm]] +config="${mod_id}.dasm.json"