use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.
the class ViaConfigScreen method onClickClientSide.
private void onClickClientSide(ButtonWidget widget) {
if (!ViaFabric.config.isClientSideEnabled()) {
MinecraftClient.getInstance().openScreen(new ConfirmScreen(answer -> {
if (answer) {
ViaFabric.config.setClientSideEnabled(true);
// AUTO
ViaFabric.config.setClientSideVersion(-2);
ViaFabric.config.saveConfig();
widget.setMessage(getClientSideText().asString());
}
MinecraftClient.getInstance().openScreen(this);
}, new TranslatableText("gui.enable_client_side.question"), new TranslatableText("gui.enable_client_side.warning"), new TranslatableText("gui.enable_client_side.enable").asString(), new TranslatableText("gui.cancel").asString()));
} else {
ViaFabric.config.setClientSideEnabled(false);
ViaFabric.config.saveConfig();
}
widget.setMessage(getClientSideText().asString());
}
use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.
the class ViaFabricClient method registerGui.
private void registerGui() {
try {
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
if (!(screen instanceof MultiplayerScreen))
return;
ButtonWidget enableClientSideViaVersion = new TexturedButtonWidget(scaledWidth / 2 + 113, 10, // Size
40, // Size
20, // Start pos of texture
0, // Start pos of texture
0, // v Hover offset
20, new Identifier("viafabric:textures/gui/widgets.png"), // Texture size
256, // Texture size
256, it -> MinecraftClient.getInstance().setScreen(new ViaConfigScreen(screen)), new TranslatableText("gui.via_button"));
if (ViaFabric.config.isHideButton())
enableClientSideViaVersion.visible = false;
Screens.getButtons(screen).add(enableClientSideViaVersion);
});
} catch (NoClassDefFoundError ignored) {
ViaFabric.JLOGGER.info("Couldn't register screen handler as Fabric Screen isn't installed");
}
}
use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.
the class ViaConfigScreen method onClickClientSide.
private void onClickClientSide(ButtonWidget widget) {
if (!ViaFabric.config.isClientSideEnabled()) {
MinecraftClient.getInstance().openScreen(new ConfirmScreen(answer -> {
if (answer) {
ViaFabric.config.setClientSideEnabled(true);
// AUTO
ViaFabric.config.setClientSideVersion(-2);
ViaFabric.config.saveConfig();
widget.setMessage(getClientSideText());
}
MinecraftClient.getInstance().openScreen(this);
}, new TranslatableText("gui.enable_client_side.question"), new TranslatableText("gui.enable_client_side.warning"), new TranslatableText("gui.enable_client_side.enable"), new TranslatableText("gui.cancel")));
} else {
ViaFabric.config.setClientSideEnabled(false);
ViaFabric.config.saveConfig();
}
widget.setMessage(getClientSideText());
}
use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.
the class MixinMultiplayerScreen method onInit.
@Inject(method = "init", at = @At("TAIL"), remap = false)
private void onInit(CallbackInfo ci) {
ButtonWidget enableClientSideViaVersion = new TexturedButtonWidget(this.width / 2 + 113, 10, // Size
40, // Size
20, // Start pos of texture
0, // Start pos of texture
0, // v Hover offset
20, new Identifier("viafabric:textures/gui/widgets.png"), // Texture size
256, // Texture size
256, it -> MinecraftClient.getInstance().openScreen(new ViaConfigScreen(this)), new TranslatableText("gui.via_button").asString());
if (ViaFabric.config.isHideButton())
enableClientSideViaVersion.visible = false;
addButton(enableClientSideViaVersion);
}
use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.
the class ViaConfigScreen method onClickClientSide.
private void onClickClientSide(ButtonWidget widget) {
if (!ViaFabric.config.isClientSideEnabled()) {
MinecraftClient.getInstance().openScreen(new ConfirmScreen(answer -> {
if (answer) {
ViaFabric.config.setClientSideEnabled(true);
// AUTO
ViaFabric.config.setClientSideVersion(-2);
ViaFabric.config.saveConfig();
widget.setMessage(getClientSideText().asString());
}
MinecraftClient.getInstance().openScreen(this);
}, new TranslatableText("gui.enable_client_side.question"), new TranslatableText("gui.enable_client_side.warning"), new TranslatableText("gui.enable_client_side.enable").asString(), new TranslatableText("gui.cancel").asString()));
} else {
ViaFabric.config.setClientSideEnabled(false);
ViaFabric.config.saveConfig();
}
widget.setMessage(getClientSideText().asString());
}
Aggregations