Search in sources :

Example 1 with PluginScreen

use of org.spongepowered.vanilla.client.gui.screen.PluginScreen in project SpongeCommon by SpongePowered.

the class TitleScreenMixin_Vanilla method vanilla$addPluginsButton.

@Inject(method = "init", at = @At("TAIL"))
private void vanilla$addPluginsButton(final CallbackInfo ci) {
    final Optional<AbstractWidget> realmsButton = this.buttons.stream().filter(b -> b.getMessage().equals(new TranslatableComponent("menu.online"))).findFirst();
    realmsButton.ifPresent(b -> {
        b.setWidth(98);
        b.x = this.width / 2 + 2;
    });
    // Plugins Button
    this.addButton(new Button(this.width / 2 - 100, realmsButton.map(b -> b.y).orElse(0), 98, 20, new TextComponent("Plugins"), b -> this.minecraft.setScreen(new PluginScreen(this))));
}
Also used : Component(net.minecraft.network.chat.Component) Inject(org.spongepowered.asm.mixin.injection.Inject) Screen(net.minecraft.client.gui.screens.Screen) PluginScreen(org.spongepowered.vanilla.client.gui.screen.PluginScreen) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) TextComponent(net.minecraft.network.chat.TextComponent) Mixin(org.spongepowered.asm.mixin.Mixin) Optional(java.util.Optional) AbstractWidget(net.minecraft.client.gui.components.AbstractWidget) TitleScreen(net.minecraft.client.gui.screens.TitleScreen) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) At(org.spongepowered.asm.mixin.injection.At) Button(net.minecraft.client.gui.components.Button) TextComponent(net.minecraft.network.chat.TextComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) PluginScreen(org.spongepowered.vanilla.client.gui.screen.PluginScreen) Button(net.minecraft.client.gui.components.Button) AbstractWidget(net.minecraft.client.gui.components.AbstractWidget) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

Optional (java.util.Optional)1 AbstractWidget (net.minecraft.client.gui.components.AbstractWidget)1 Button (net.minecraft.client.gui.components.Button)1 Screen (net.minecraft.client.gui.screens.Screen)1 TitleScreen (net.minecraft.client.gui.screens.TitleScreen)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 Mixin (org.spongepowered.asm.mixin.Mixin)1 At (org.spongepowered.asm.mixin.injection.At)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 CallbackInfo (org.spongepowered.asm.mixin.injection.callback.CallbackInfo)1 PluginScreen (org.spongepowered.vanilla.client.gui.screen.PluginScreen)1