Jump to content

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


Recommended Posts

Posted (edited)

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please read the FAQ and post logs as described there.
    • Upon starting the server I get; [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     Framework (framework) has failed to load correctly §7java.lang.NoClassDefFoundError: net/minecraft/client/gui/components/toasts/Toast ] I suspect there is a (possibly a few) client-only mods installed on my server. Any help would be appreciated! (Yes I know there are a lot of mods...) Here is the crash log:   https://paste.ee/p/pRz5mhMl#s=0
    • That's basically what the failure does, my apologies for failing to specify.  It just tries again on the next tick until it detects the entities for that chunk are loaded, and then tries to load the entity.  From there it gets into different failure states depending on what goes wrong, but in short, if the entity fails to load once the entity list becomes available, the request is cleared and must be resubmitted by the end user.  There should be few cases where that actually happens. Yes, that is my understanding of forceloading.  That's why on a successful summon, it removes the forceload.  Otherwise it does just leave the chunks loaded long term. Thank you for your help, any knowledge is useful!  I don't often mess with forceloading and my prior experience is 1.16 so I'm also a bit out of my depth haha.
    • I will have to do more research about 1.18 chunk loading. You were unclear about how your code manages with the entity load failure. If you simply used a loop, I suggest submitting a tick task to the next tick which does the same thing, checking if the entities are loaded and if so teleporting the right one else submitting another tick task etc. Also I think forceloading permanently force loads the chunk, and it only starts to unload when you make a subsequent call to mark the chunk as not forceloaded. I may be completely wrong, I dont know much about 1.18, most of my experience is 1.20. Good luck I hope you figure it out after all this time 😅
    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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