我的clickgui不工作当我点击它的时候

vsmadaxz  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(263)

所以,我从quickdaffy教程中编写了一个minecraft客户端(点击gui在7ep中)。。另外,如果我点击“testmod”按钮,什么都不会发生
本教程的链接:www.youtube.com/watch?v=sr_navttd5o&t
这是click gui(不带导入)的代码:

package moonlight.ui.clickgui;

public class ClickGUI extends GuiScreen {

    ArrayList<ModButton> modButtons = new ArrayList();

    @Override
    public void initGui() {
        super.initGui();
        this.modButtons.add(new ModButton(210, 60, 240, 100, Moonlight.INSTANCE.hudManager.testMod));
    }

    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        ScaledResolution sr = new ScaledResolution(mc);
        super.drawScreen(mouseX, mouseY, partialTicks);

        Gui.drawRect(200, 50, sr.getScaledWidth(), sr.getScaledHeight(), 0x20000000);

        for(ModButton m : modButtons) {
            m.draw();
        }
    }

    @Override
    protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
        super.mouseClicked(mouseX, mouseY, mouseButton);
    }
}

这是gui按钮(不带导入):

package moonlight.ui.clickgui.comp;

public class ModButton {

    public int x, y, w, h;
    public HudMod m;

    public ModButton(int x, int y, int w, int h, HudMod m) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.m = m;
    }

    public void draw() {
        Gui.drawRect(y, x, h, w, 0x20000000);
        Minecraft.getMinecraft().fontRendererObj.drawString(m.name, x + 2, y + 2, getColor());
    }

    private int getColor() {
        if(m.isEnabled()) {
            return new Color(0,255,0,255).getRGB();
        } else {
            return new Color(255,0,0,255).getRGB();
        }

    }

    public void ocClick(int mouseX, int mouseY, int button) {
        if (mouseX >= x && mouseX <= x + w && mouseY >= y && mouseY <= y + h) {
            m.toggle();
            System.out.println("HELLO");
        }
    }

}

莉莉,请帮帮我

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题