#Screen size

4 messages · Page 1 of 1 (latest)

quiet plover
#

yo I made the following class, everything works fine exept for some reason the height and width are always set to the width and heigth of the entire screen instead of the parameters I gave it in its constructor


    private int test;
    private MinecraftClient client = MinecraftClient.getInstance();

    public UserInterface(UserInterfaceData interfaceData) {
        this(interfaceData.title(), interfaceData.height(), interfaceData.width());
    }

    public UserInterface(String title, int height, int width) {
        super(Text.of(title));
        this.height = height;
        this.width = width;
        test = height;
    }

    @Override
    protected void init() {
        super.init();
        addDrawableChild(new TextWidget(title, textRenderer));
        //addDrawable(new TextWidget(Text.of(String.valueOf(height))), textRenderer);
        MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of(String.valueOf(test)));
    }
}```
quiet plover
#

maybe its because I set the interface like so?

fathom python
#

this.width and this.height are always set to the size of the screen, you should probably try making separate variables for them

quiet plover
#

Right, then how do I set the screen to be the width and the size chosen. super.init(MinecraftClient.getInstance(), interfaceWidth, interfaceHeight) crashes my game.