mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-10 19:58:03 +01:00
Some cleanup of the last PR.
This commit is contained in:
parent
63f74d503f
commit
6aedfbd291
@ -40,7 +40,7 @@ import java.awt.*;
|
|||||||
*/
|
*/
|
||||||
public class VFPScreen extends Screen {
|
public class VFPScreen extends Screen {
|
||||||
|
|
||||||
private static final String MOD_URL = "https://github.com/ViaVersion/ViaFabricPlus";
|
private final static String MOD_URL = "https://github.com/ViaVersion/ViaFabricPlus";
|
||||||
|
|
||||||
private final boolean backButton;
|
private final boolean backButton;
|
||||||
public Screen prevScreen;
|
public Screen prevScreen;
|
||||||
@ -62,9 +62,19 @@ public class VFPScreen extends Screen {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setupDefaultSubtitle() {
|
public void setupDefaultSubtitle() {
|
||||||
this.setupSubtitle(Text.of(MOD_URL), ConfirmLinkScreen.opening(MOD_URL, this, true));
|
this.setupUrlSubtitle(MOD_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the subtitle and the subtitle press action to the default values
|
||||||
|
*
|
||||||
|
* @param subtitle The subtitle which should be rendered
|
||||||
|
*/
|
||||||
|
public void setupUrlSubtitle(final String subtitle) {
|
||||||
|
this.setupSubtitle(Text.of(subtitle), ConfirmLinkScreen.opening(subtitle, this, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Sets the subtitle and the subtitle press action
|
* Sets the subtitle and the subtitle press action
|
||||||
*
|
*
|
||||||
@ -83,7 +93,8 @@ public class VFPScreen extends Screen {
|
|||||||
public void setupSubtitle(@Nullable final Text subtitle, @Nullable final ButtonWidget.PressAction subtitlePressAction) {
|
public void setupSubtitle(@Nullable final Text subtitle, @Nullable final ButtonWidget.PressAction subtitlePressAction) {
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.subtitlePressAction = subtitlePressAction;
|
this.subtitlePressAction = subtitlePressAction;
|
||||||
if (subtitleWidget != null && subtitlePressAction == null) {
|
|
||||||
|
if (subtitleWidget != null && subtitlePressAction == null) { // Allows to remove the subtitle when calling this method twice.
|
||||||
remove(subtitleWidget);
|
remove(subtitleWidget);
|
||||||
subtitleWidget = null;
|
subtitleWidget = null;
|
||||||
}
|
}
|
||||||
@ -162,7 +173,7 @@ public class VFPScreen extends Screen {
|
|||||||
/**
|
/**
|
||||||
* Opens an error screen with a specific title and throws the given throwable
|
* Opens an error screen with a specific title and throws the given throwable
|
||||||
*
|
*
|
||||||
* @param title The title of the error screen
|
* @param title The title of the error screen
|
||||||
* @param throwable The throwable which should be thrown
|
* @param throwable The throwable which should be thrown
|
||||||
*/
|
*/
|
||||||
public void showErrorScreen(final String title, final Throwable throwable) {
|
public void showErrorScreen(final String title, final Throwable throwable) {
|
||||||
|
@ -25,7 +25,7 @@ import net.minecraft.entity.vehicle.BoatEntity;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class BoatModel_1_8 extends CompositeEntityModel<BoatEntity> {
|
public class BoatModel_1_8 extends CompositeEntityModel<BoatEntity> {
|
||||||
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main");
|
public final static EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main");
|
||||||
private final ImmutableList<ModelPart> parts;
|
private final ImmutableList<ModelPart> parts;
|
||||||
|
|
||||||
public BoatModel_1_8(ModelPart root) {
|
public BoatModel_1_8(ModelPart root) {
|
||||||
|
@ -29,7 +29,7 @@ import net.minecraft.util.math.MathHelper;
|
|||||||
import net.minecraft.util.math.RotationAxis;
|
import net.minecraft.util.math.RotationAxis;
|
||||||
|
|
||||||
public class BoatRenderer_1_8 extends EntityRenderer<BoatEntity> {
|
public class BoatRenderer_1_8 extends EntityRenderer<BoatEntity> {
|
||||||
private static final Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png");
|
private final static Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png");
|
||||||
private final BoatModel_1_8 model;
|
private final BoatModel_1_8 model;
|
||||||
|
|
||||||
public BoatRenderer_1_8(EntityRendererFactory.Context ctx) {
|
public BoatRenderer_1_8(EntityRendererFactory.Context ctx) {
|
||||||
|
@ -28,7 +28,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
public class MixinNamedCompoundTagType {
|
public class MixinNamedCompoundTagType {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final TagLimiter viafabricplus_tag_limiter = new TagLimiter() {
|
private final static TagLimiter viafabricplus_tag_limiter = new TagLimiter() {
|
||||||
private final int maxBytes = 2097152;
|
private final int maxBytes = 2097152;
|
||||||
private int bytes;
|
private int bytes;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class BetaCraftScreen extends VFPScreen {
|
|||||||
public static BCServerList SERVER_LIST;
|
public static BCServerList SERVER_LIST;
|
||||||
public final static BetaCraftScreen INSTANCE = new BetaCraftScreen();
|
public final static BetaCraftScreen INSTANCE = new BetaCraftScreen();
|
||||||
|
|
||||||
private static final String BETA_CRAFT_SERVER_LIST_URL = "https://betacraft.uk/serverlist/";
|
private final static String BETA_CRAFT_SERVER_LIST_URL = "https://betacraft.uk/serverlist/";
|
||||||
|
|
||||||
protected BetaCraftScreen() {
|
protected BetaCraftScreen() {
|
||||||
super("BetaCraft", true);
|
super("BetaCraft", true);
|
||||||
|
@ -34,7 +34,7 @@ import net.minecraft.text.Text;
|
|||||||
public class ClassiCubeLoginScreen extends VFPScreen {
|
public class ClassiCubeLoginScreen extends VFPScreen {
|
||||||
public final static ClassiCubeLoginScreen INSTANCE = new ClassiCubeLoginScreen();
|
public final static ClassiCubeLoginScreen INSTANCE = new ClassiCubeLoginScreen();
|
||||||
|
|
||||||
private static final String CLASSI_CUBE_URL = "https://www.classicube.net/";
|
private final static String CLASSI_CUBE_URL = "https://www.classicube.net/";
|
||||||
|
|
||||||
public ClassiCubeLoginScreen() {
|
public ClassiCubeLoginScreen() {
|
||||||
super("ClassiCube Login", false);
|
super("ClassiCube Login", false);
|
||||||
|
@ -41,14 +41,12 @@ public class ClassiCubeMFAScreen extends VFPScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open(Screen prevScreen) {
|
public void open(Screen prevScreen) {
|
||||||
status = Classic4JImpl.fromError(CCError.LOGIN_CODE);
|
this.setupSubtitle(Classic4JImpl.fromError(CCError.LOGIN_CODE));
|
||||||
super.open(prevScreen);
|
super.open(prevScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextFieldWidget mfaField;
|
private TextFieldWidget mfaField;
|
||||||
|
|
||||||
private Text status;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
@ -58,7 +56,7 @@ public class ClassiCubeMFAScreen extends VFPScreen {
|
|||||||
mfaField.setPlaceholder(Text.literal("MFA"));
|
mfaField.setPlaceholder(Text.literal("MFA"));
|
||||||
|
|
||||||
this.addDrawableChild(ButtonWidget.builder(Text.literal("Login"), button -> {
|
this.addDrawableChild(ButtonWidget.builder(Text.literal("Login"), button -> {
|
||||||
status = Text.translatable("classicube.viafabricplus.loading");
|
this.setupSubtitle(Text.translatable("classicube.viafabricplus.loading"));
|
||||||
final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount();
|
final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount();
|
||||||
|
|
||||||
ClassiCubeHandler.requestAuthentication(account, mfaField.getText(), new LoginProcessHandler() {
|
ClassiCubeHandler.requestAuthentication(account, mfaField.getText(), new LoginProcessHandler() {
|
||||||
@ -74,7 +72,7 @@ public class ClassiCubeMFAScreen extends VFPScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleException(Throwable throwable) {
|
public void handleException(Throwable throwable) {
|
||||||
status = Text.literal(throwable.getMessage());
|
setupSubtitle(Text.literal(throwable.getMessage()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).position(width / 2 - 75, mfaField.getY() + (20 * 4) + 5).size(150, 20).build());
|
}).position(width / 2 - 75, mfaField.getY() + (20 * 4) + 5).size(150, 20).build());
|
||||||
@ -90,7 +88,8 @@ public class ClassiCubeMFAScreen extends VFPScreen {
|
|||||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
this.renderBackground(context, mouseX, mouseY, delta);
|
this.renderBackground(context, mouseX, mouseY, delta);
|
||||||
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 70, 16777215);
|
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 70, 16777215);
|
||||||
context.drawCenteredTextWithShadow(this.textRenderer, this.status, this.width / 2, 1, 16777215);
|
|
||||||
|
this.renderSubtitle(context);
|
||||||
|
|
||||||
super.render(context, mouseX, mouseY, delta);
|
super.render(context, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ package de.florianmichael.viafabricplus.screen.thirdparty.classicube;
|
|||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import de.florianmichael.classic4j.ClassiCubeHandler;
|
import de.florianmichael.classic4j.ClassiCubeHandler;
|
||||||
import de.florianmichael.classic4j.api.LoginProcessHandler;
|
import de.florianmichael.classic4j.api.LoginProcessHandler;
|
||||||
import de.florianmichael.classic4j.model.classicube.account.CCAccount;
|
|
||||||
import de.florianmichael.classic4j.model.classicube.server.CCServerInfo;
|
import de.florianmichael.classic4j.model.classicube.server.CCServerInfo;
|
||||||
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
|
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
|
||||||
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
|
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
|
||||||
@ -32,7 +31,6 @@ import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
|
|||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
|
|
||||||
import net.minecraft.client.gui.screen.ConnectScreen;
|
import net.minecraft.client.gui.screen.ConnectScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||||
@ -50,7 +48,7 @@ public class ClassiCubeServerListScreen extends VFPScreen {
|
|||||||
public final static List<CCServerInfo> SERVER_LIST = new ArrayList<>();
|
public final static List<CCServerInfo> SERVER_LIST = new ArrayList<>();
|
||||||
public final static ClassiCubeServerListScreen INSTANCE = new ClassiCubeServerListScreen();
|
public final static ClassiCubeServerListScreen INSTANCE = new ClassiCubeServerListScreen();
|
||||||
|
|
||||||
private static final String CLASSI_CUBE_SERVER_LIST_URL = "https://www.classicube.net/server/list/";
|
private final static String CLASSICUBE_SERVER_LIST_URL = "https://www.classicube.net/server/list/";
|
||||||
|
|
||||||
public static void open(final Screen prevScreen, final LoginProcessHandler loginProcessHandler) {
|
public static void open(final Screen prevScreen, final LoginProcessHandler loginProcessHandler) {
|
||||||
ClassiCubeHandler.requestServerList(ClassiCubeAccountHandler.INSTANCE.getAccount(), ccServerList -> {
|
ClassiCubeHandler.requestServerList(ClassiCubeAccountHandler.INSTANCE.getAccount(), ccServerList -> {
|
||||||
@ -61,13 +59,10 @@ public class ClassiCubeServerListScreen extends VFPScreen {
|
|||||||
|
|
||||||
public ClassiCubeServerListScreen() {
|
public ClassiCubeServerListScreen() {
|
||||||
super("ClassiCube ServerList", true);
|
super("ClassiCube ServerList", true);
|
||||||
final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount();
|
|
||||||
|
final var account = ClassiCubeAccountHandler.INSTANCE.getAccount();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
this.setupSubtitle(Text.of(CLASSI_CUBE_SERVER_LIST_URL), ConfirmLinkScreen.opening(
|
this.setupUrlSubtitle(CLASSICUBE_SERVER_LIST_URL);
|
||||||
CLASSI_CUBE_SERVER_LIST_URL,
|
|
||||||
this,
|
|
||||||
true
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,22 +89,11 @@ public class ClassiCubeServerListScreen extends VFPScreen {
|
|||||||
this.renderBackground(context, mouseX, mouseY, delta);
|
this.renderBackground(context, mouseX, mouseY, delta);
|
||||||
super.render(context, mouseX, mouseY, delta);
|
super.render(context, mouseX, mouseY, delta);
|
||||||
this.renderTitle(context);
|
this.renderTitle(context);
|
||||||
final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount();
|
|
||||||
|
final var account = ClassiCubeAccountHandler.INSTANCE.getAccount();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
context.drawTextWithShadow(
|
context.drawTextWithShadow(textRenderer, Text.of("ClassiCube Profile:"), 32, 6, -1);
|
||||||
textRenderer,
|
context.drawTextWithShadow(textRenderer, Text.of(account.username()), 32, 16, -1);
|
||||||
Text.of("ClassiCube Profile: "),
|
|
||||||
32,
|
|
||||||
6,
|
|
||||||
-1
|
|
||||||
);
|
|
||||||
context.drawTextWithShadow(
|
|
||||||
textRenderer,
|
|
||||||
Text.of(account.username()),
|
|
||||||
32,
|
|
||||||
16,
|
|
||||||
-1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user