Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.