#My mixin dosent work

18 messages · Page 1 of 1 (latest)

fringe shard
#

Hi! I'm new to modding and don't know much about Java, and I wanted to ask what I'm doing wrong.
I wrote a simple mixin, specified the classes correctly, but when I try to run the game, it doesn't even attempt to start and gives me an error:
Mixin has no targets
@Mixin(DrawContext.class)
^

package com.danrus.appearanceOfDurability.mixin;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(DrawContext.class)
public class DurabilityRender {
    @Inject(method = "drawItemInSlot", at = @At("HEAD"), cancellable = true)
    private void drawItemInSlot(int x, int y, ItemStack stack, CallbackInfo ci) {
        System.out.println("ItemStack: " + stack);
    }
}
#

....mixin.json

{
  "required": true,
  "minVersion": "0.8",
  "package": "com.danrus.appearanceOfDurability.mixin",
  "compatibilityLevel": "JAVA_21",
  "mixins": [
    "DurabilityRender"
  ],
  "injectors": {
    "defaultRequire": 1
  }
}
fringe shard
# chrome veldt show your fabric.mod.json
{
  "schemaVersion": 1,
  "id": "appearance_of_durability",
  "version": "${version}",
  "name": "appearance of durability",
  "description": "lol",
  "authors": [],
  "contact": {},
  "license": "MIT",
  "icon": "assets/appearance_of_durability/icon.png",
  "environment": "client",
  "entrypoints": {
    "client": [
      "com.danrus.appearance_of_durability.client.Appearance_of_durabilityClient"
    ],
    "main": [
      "com.danrus.appearance_of_durability.Appearance_of_durability"
    ]
  },
  "mixins": [
    "appearance_of_durability.mixins.json",
    {
      "config": "appearance_of_durability.client.mixins.json",
      "environment": "client"
    }
  ],
  "depends": {
    "fabricloader": ">=${loader_version}",
    "fabric": "*",
    "minecraft": "${minecraft_version}"
  }
}
chrome veldt
#

oh

#

i see the error

#

You are using a class that does not exist in that context

#

you need to go to your client package

#

and add the mixin there

#

@fringe shard

fringe shard
#

or src.client.java ?

chrome veldt
#

you need to go here

#

and create the mixin

#

mixin.client.DurabilityRender.java in there

fringe shard
#

thanks. its works