Jump to content

[1.16.5] @Shadow field was not located in the target class. No refMap loaded.


Skyriis

Recommended Posts

Hi Guys,

i'm trying to mixin into the KeyEntry class and add 2 Buttons there. In my test env everything works but as soon as i try it in a normal minecraft forge instance i'll get a MixinTransformerError which is caused by @Shadow field keybinding was not located in the target class net.minecraft.client.gui.widget.list.KeyBindingList$KeyEntry. No refMap loaded.

Here is my mixin class:

Spoiler

 


@Mixin(KeyBindingList.KeyEntry.class)
public class MixinKeyBindingListKeyEntry {
    @Shadow
    @Final
    private KeyBinding keybinding;
    @Shadow
    @Final
    private Button btnChangeKeyBinding;
    @Shadow
    @Final
    private Button btnReset;
    //Custom Buttons
    private final ToggleIconButton cloudButton = new ToggleIconButton(() -> SyncHandler.isSyncedKeybinding(this.keybinding), "cloud", "trash", (button) -> SyncHandler.addOrRemoveSync(this.keybinding));
    private final ToggleIconButton blackListButton = new ToggleIconButton(() -> BlacklistHandler.isBlacklisted(this.keybinding), "blacklist", "whitelist", p_onPress_1_ -> BlacklistHandler.addOrRemoveKeybinding(this.keybinding));

    @Inject(at = @At("HEAD"), method = "render(Lcom/mojang/blaze3d/matrix/MatrixStack;IIIIIIIZF)V")
    public void render(MatrixStack matrixStack, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean isMouseOver, float partialTicks, CallbackInfo ci) {
        this.cloudButton.x = left + 105 - 40;
        this.cloudButton.y = top;
        this.cloudButton.render(matrixStack, mouseX, mouseY, partialTicks);

        this.blackListButton.x = left + 105 - 20;
        this.blackListButton.y = top;
        this.blackListButton.render(matrixStack, mouseX, mouseY, partialTicks);
    }

    @Inject(at = @At("RETURN"), method = "getEventListeners()Ljava/util/List;", cancellable = true)
    public void guiEventListeners(CallbackInfoReturnable<List<? extends IGuiEventListener>> cir) {
        cir.setReturnValue(ImmutableList.of(this.btnChangeKeyBinding, this.btnReset, this.cloudButton, this.blackListButton));
    }

    @Inject(at = @At("HEAD"), method = "mouseClicked(DDI)Z", cancellable = true)
    public void onMouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
        if (this.cloudButton.mouseClicked(mouseX, mouseY, button)) {
            cir.setReturnValue(true);
        } else {
            if (this.blackListButton.mouseClicked(mouseX, mouseY, button)) {
                cir.setReturnValue(true);
            } else {
                if (this.btnChangeKeyBinding.mouseClicked(mouseX, mouseY, button)) {
                    cir.setReturnValue(true);
                } else {
                    cir.setReturnValue(this.btnReset.mouseClicked(mouseX, mouseY, button));
                }
            }
        }
    }

    @Inject(at = @At("HEAD"), method = "mouseReleased(DDI)Z", cancellable = true)
    public void onMouseReleased(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
        cir.setReturnValue(this.cloudButton.mouseReleased(mouseX, mouseY, button) || this.blackListButton.mouseReleased(mouseX, mouseY, button) || this.btnChangeKeyBinding.mouseReleased(mouseX, mouseY, button) || this.btnReset.mouseReleased(mouseX, mouseY, button));
    }
}

How can i fix that?

Do i need to add an refMap.json somehow?

Edited by Skyriis
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.