Code Monkey home page Code Monkey logo

Comments (13)

lukflug avatar lukflug commented on May 23, 2024

Oh, it might be an oversight when I ported stuff over to newer versions of Minecraft. I can't believe this hasn't been caught earlier.

Add this to your ClickGUI class:

@override
public void render() {
	this.context = insert_current_DrawContext_here;
	super.render();
}

I don't know how exactly the render method gets invoked, so I can't give an exact expression for that. Alternatively:

@override
public void render(DrawContext context) {
	this.context = context;
	super.render();
}

I hope this helps!

from panelstudio.

erxson avatar erxson commented on May 23, 2024

Thanks for the quick response! Sorry, but I don't know how to get the current DrawContext. The first render() option is fine, but I really don't know where to get the DrawContext or what it even is. If this is fixed in some update, then I can just wait, I'm in no hurry. Thanks again!

from panelstudio.

erxson avatar erxson commented on May 23, 2024

It's probably worth saying that when I try to do this.context = new DrawContext(client, null); then the error is completely different. This is good? Like, it’s already complaining that I couldn’t pass vertex things instead of null

from panelstudio.

lukflug avatar lukflug commented on May 23, 2024

Oh yeah, no, that's not how it would be done. I'd have to take a closer look.
Even when I fix it, you'd still need to pass a DrawContext.

from panelstudio.

lukflug avatar lukflug commented on May 23, 2024

https://github.com/desertcod98/OakClient/blob/443b3735eeb1f5c977ba306cc85d6a27d212f8f4/src/main/java/me/leeeaf/oakclient/mixin/InGameHudMixin.java#L16

Iirc the 1.20 equivalent of MatrixStack is DrawContext. That parameter is what you need to pass.

from panelstudio.

erxson avatar erxson commented on May 23, 2024

Yes, I tried to pass it through render method, but... skill issue

from panelstudio.

lukflug avatar lukflug commented on May 23, 2024

A quick and somewhat dirty solution would be to set the context variable of the ClickGUI in the InGameHudMixin.render method. Because it's protected, you might need a setter.

from panelstudio.

lukflug avatar lukflug commented on May 23, 2024

A quick and somewhat dirty solution would be to set the context variable of the ClickGUI in the InGameHudMixin.render method. Because it's protected, you might need a setter.

This would make overriding ClickGUI.render unnecessary.

from panelstudio.

erxson avatar erxson commented on May 23, 2024

I did it and it works!

ClientTickEvents.END_CLIENT_TICK.register((client) -> {
    if (gui == null)
        gui=new ClickGUI();
    if (!inited) {
        if (gui.getContext() != null) {
            HudRenderCallback.EVENT.register((cli, tickDelta) -> gui.render());
            inited = true;
        }
    }
});
@Mixin(InGameHud.class)
public abstract class InGameHudMixin {
    @Inject(method = "render", at = @At(value = "RETURN"))
    public void render(DrawContext context, float tickDelta, CallbackInfo ci) {
        ZXCHack.gui.setContext(context);
        EventBus.getEventBus().post(new HudRenderEvent());
    }
}

ClickGUI.java

	public void setContext(DrawContext context) {
		this.context = context;
	}

	public DrawContext getContext() {
		return this.context;
	}

from panelstudio.

erxson avatar erxson commented on May 23, 2024

But can't interact with TabGUI arrows binds

from panelstudio.

lukflug avatar lukflug commented on May 23, 2024

Is ClickGUI.handleKeyEvent getting invoked?

from panelstudio.

erxson avatar erxson commented on May 23, 2024

No, it replaced with Category.toggleModuleByKeybind in OakClient.

from panelstudio.

erxson avatar erxson commented on May 23, 2024

Sorry. It works now. Thank you very much!

from panelstudio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.