feat: /optionsprofiles command (#34)
This commit is contained in:
parent
e44c57eca2
commit
ebc2948e0f
3 changed files with 21 additions and 8 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
package net.trafficlunar.optionsprofiles;
|
package net.trafficlunar.optionsprofiles;
|
||||||
|
|
||||||
|
import dev.architectury.event.events.common.CommandRegistrationEvent;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.commands.Commands;
|
||||||
|
import net.trafficlunar.optionsprofiles.gui.ProfilesScreen;
|
||||||
import net.trafficlunar.optionsprofiles.profiles.Profiles;
|
import net.trafficlunar.optionsprofiles.profiles.Profiles;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
@ -26,5 +30,15 @@ public class OptionsProfilesMod {
|
||||||
|
|
||||||
// Update / add configuration for existing profiles
|
// Update / add configuration for existing profiles
|
||||||
Profiles.updateProfiles();
|
Profiles.updateProfiles();
|
||||||
|
|
||||||
|
// Add /optionsprofiles command
|
||||||
|
CommandRegistrationEvent.EVENT.register(((dispatcher, buildContext, selection) -> dispatcher.register(
|
||||||
|
Commands
|
||||||
|
.literal("optionsprofiles")
|
||||||
|
.executes(context -> {
|
||||||
|
Minecraft.getInstance().setScreen(new ProfilesScreen(null));
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,20 @@
|
||||||
package net.trafficlunar.optionsprofiles.gui;
|
package net.trafficlunar.optionsprofiles.gui;
|
||||||
|
|
||||||
import net.trafficlunar.optionsprofiles.profiles.Profiles;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.layouts.LinearLayout;
|
import net.minecraft.client.gui.layouts.LinearLayout;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
|
||||||
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
|
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.trafficlunar.optionsprofiles.profiles.Profiles;
|
||||||
|
|
||||||
public class ProfilesScreen extends OptionsSubScreen {
|
public class ProfilesScreen extends OptionsSubScreen {
|
||||||
private Screen optionsLastScreen;
|
private final Screen lastScreen;
|
||||||
public ProfilesList profilesList;
|
public ProfilesList profilesList;
|
||||||
|
|
||||||
public ProfilesScreen(Screen lastScreen, Screen optionsLastScreen) {
|
public ProfilesScreen(Screen lastScreen) {
|
||||||
super(lastScreen, null, Component.translatable("gui.optionsprofiles.profiles-menu"));
|
super(lastScreen, null, Component.translatable("gui.optionsprofiles.profiles-menu"));
|
||||||
this.optionsLastScreen = optionsLastScreen;
|
this.lastScreen = lastScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addOptions() {}
|
protected void addOptions() {}
|
||||||
|
|
@ -45,7 +44,7 @@ public class ProfilesScreen extends OptionsSubScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClose() {
|
public void onClose() {
|
||||||
this.minecraft.setScreen(new OptionsScreen(optionsLastScreen, this.minecraft.options));
|
this.minecraft.setScreen(lastScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void repositionElements() {
|
protected void repositionElements() {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package net.trafficlunar.optionsprofiles.mixin;
|
package net.trafficlunar.optionsprofiles.mixin;
|
||||||
|
|
||||||
import net.trafficlunar.optionsprofiles.gui.ProfilesScreen;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.trafficlunar.optionsprofiles.gui.ProfilesScreen;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
@ -25,7 +25,7 @@ public class MixinOptionsScreen extends Screen {
|
||||||
this.addRenderableWidget(
|
this.addRenderableWidget(
|
||||||
Button.builder(
|
Button.builder(
|
||||||
Component.translatable("gui.optionsprofiles.profiles-menu"),
|
Component.translatable("gui.optionsprofiles.profiles-menu"),
|
||||||
(button) -> this.minecraft.setScreen(new ProfilesScreen(this, lastScreen)))
|
(button) -> this.minecraft.setScreen(new ProfilesScreen(this)))
|
||||||
.width(75)
|
.width(75)
|
||||||
.pos(5, 5)
|
.pos(5, 5)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue