Fabric API

Fabric API

152M Downloads

Mixins don't work on Mojang mappings.

Closed this issue ยท 1 comments

commented

Log

[16:27:52] [main/ERROR]: Mixin apply for mod just-helper failed just-helper.client.mixins.json:DisplayMixin from mod just-helper -> net.minecraft.class_8113: org.spongepowered.asm.mixin.gen.throwables.InvalidAccessorException No candidates were found matching DATA_SCALE_ID:Lnet/minecraft/class_2940; in net/minecraft/class_8113 for just-helper.client.mixins.json:DisplayMixin from mod just-helper->@Accessor[FIELD_GETTER]::getDataScaleID()Lnet/minecraft/class_2940; [ACCESSOR Applicator Phase -> just-helper.client.mixins.json:DisplayMixin from mod just-helper -> Apply Accessors ->  -> Locate -> just-helper.client.mixins.json:DisplayMixin from mod just-helper->@Accessor[FIELD_GETTER]::getDataScaleID()Lnet/minecraft/class_2940;]
org.spongepowered.asm.mixin.gen.throwables.InvalidAccessorException: No candidates were found matching DATA_SCALE_ID:Lnet/minecraft/class_2940; in net/minecraft/class_8113 for just-helper.client.mixins.json:DisplayMixin from mod just-helper->@Accessor[FIELD_GETTER]::getDataScaleID()Lnet/minecraft/class_2940; [ACCESSOR Applicator Phase -> just-helper.client.mixins.json:DisplayMixin from mod just-helper -> Apply Accessors ->  -> Locate -> just-helper.client.mixins.json:DisplayMixin from mod just-helper->@Accessor[FIELD_GETTER]::getDataScaleID()Lnet/minecraft/class_2940;]

Build:

task build.build
received jar: build/libs/just-helper-0.0.1.jar

DisplayMixin.java

package com.prikolz.justhelper.mixin;

import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.entity.Display;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Display.class)
public interface DisplayMixin {
    @Accessor
    static EntityDataAccessor<Vector3f> getDATA_SCALE_ID() { throw new AssertionError(); }
}

The name of the field inside the decompiled class

Image

build.gradle

plugins {
	id 'fabric-loom' version "${loom_version}"
	id 'maven-publish'
}

version = project.mod_version
group = project.maven_group

base {
	archivesName = project.archives_base_name
}

repositories {

}

loom {
	splitEnvironmentSourceSets()

	mods {
		"just-helper" {
			sourceSet sourceSets.main
			sourceSet sourceSets.client
		}
	}

}

dependencies {
	// To change the versions see the gradle.properties file
	minecraft "com.mojang:minecraft:${project.minecraft_version}"
	mappings loom.officialMojangMappings()
	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

	implementation ("net.kyori:adventure-text-minimessage:4.17.0")
	implementation ("net.kyori:adventure-text-serializer-gson:4.17.0")
	implementation ("net.kyori:adventure-text-serializer-legacy:4.17.0")
	implementation ("net.kyori:adventure-api:4.24.0")

	includeInternal ("net.kyori:adventure-text-minimessage:4.17.0")
	includeInternal ("net.kyori:adventure-text-serializer-gson:4.17.0")
	includeInternal ("net.kyori:adventure-text-serializer-legacy:4.17.0")
	includeInternal ("net.kyori:adventure-api:4.24.0")

	//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
	modImplementation 'net.fabricmc.fabric-api:fabric-resource-loader-v0:3.1.10+fa6cb72b9c'
	includeInternal ('net.fabricmc.fabric-api:fabric-resource-loader-v0:3.1.10+fa6cb72b9c')
}

processResources {
	inputs.property "version", project.version

	filesMatching("fabric.mod.json") {
		expand "version": inputs.properties.version
	}
}

tasks.withType(JavaCompile).configureEach {
	it.options.release = 21
}

java {
	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
	// if it is present.
	// If you remove this line, sources will not be generated.
	withSourcesJar()

	sourceCompatibility = JavaVersion.VERSION_21
	targetCompatibility = JavaVersion.VERSION_21
}

jar {
	inputs.property "archivesName", project.base.archivesName

	from("LICENSE") {
		rename { "${it}_${inputs.properties.archivesName}"}
	}
}

// configure the maven publication
publishing {
	publications {
		create("mavenJava", MavenPublication) {
			artifactId = project.archives_base_name
			from components.java
		}
	}

	// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
	repositories {
		// Add repositories to publish to here.
		// Notice: This block does NOT have the same function as the block in the top level.
		// The repositories here will be used for publishing your artifact, not for
		// retrieving dependencies.
	}
}

Mixin json

{
	"required": true,
	"package": "com.prikolz.justhelper.mixin",
	"compatibilityLevel": "JAVA_21",
	"mixins": [
		"MinecraftMixin",
		"ClientPacketListenerMixin",
		"ClientLevelMixin",
		"SpriteContentsMixin",
		"TextDisplayMixin",
		"DisplayMixin",
		"GUIMixin"
	],
	"injectors": {
		"defaultRequire": 1
	}
}

fabric.mod.json

{
	"schemaVersion": 1,
	"id": "just-helper",
	"version": "${version}",
	"name": "Just Helper",
	"description": " ",
	"authors": [
		"2M3V"
	],
	"contact": {
		"homepage": "https://fabricmc.net/",
		"sources": "https://github.com/FabricMC/fabric-example-mod"
	},
	"license": "MIT",
	"icon": "assets/just-helper/icon.png",
	"environment": "client",
	"entrypoints": {
		"client": [
			"com.prikolz.justhelper.JustHelperClient"
		]
	},
	"mixins": [
      "just-helper.client.mixins.json"
	],
	"depends": {
		"fabricloader": ">=0.15.0",
		"minecraft": ">=1.21.8",
		"java": ">=21"
	},
	"suggests": {}
}
commented

Accessors should specify the target field name explicitly. Closing as out-of-scope for this repo.