Fixed critical joining issue, implemented BetaCraft server list

This commit is contained in:
FlorianMichael 2023-03-27 16:21:48 +02:00
parent 8144cc81d6
commit 29237272fd
20 changed files with 239 additions and 85 deletions

View File

@ -83,6 +83,8 @@ dependencies {
libs "net.lenni0451.mcstructs:text:${project.mcstructs_text_version}"
libs "net.lenni0451:Reflect:${project.reflect_version}"
libs "com.github.allinkdev:BetacraftServerListParser:1.2.1"
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
}

View File

@ -27,7 +27,6 @@ import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.provider
import java.net.InetAddress;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
public class BetaCraftImpl {

View File

@ -90,11 +90,12 @@ public class MixinConnectScreen_1 {
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V", ordinal = 1))
public void spoofUserName(ClientConnection instance, Packet<?> packet) {
if (!MPPassSettings.INSTANCE.spoofUserNameIfUsingClassiCube.getValue()) return;
if (ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null && ClassiCubeAccountHandler.INSTANCE.getAccount() != null) {
if (MPPassSettings.INSTANCE.spoofUserNameIfUsingClassiCube.getValue() && ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null && ClassiCubeAccountHandler.INSTANCE.getAccount() != null) {
instance.send(new LoginHelloC2SPacket(ClassiCubeAccountHandler.INSTANCE.getAccount().username, Optional.ofNullable(MinecraftClient.getInstance().getSession().getUuidOrNull())));
return;
}
instance.send(packet);
}
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;"))

View File

@ -0,0 +1,146 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.screen;
import com.github.allinkdev.betacraftserverlistparser.BetacraftServerList;
import com.github.allinkdev.betacraftserverlistparser.Server;
import com.github.allinkdev.betacraftserverlistparser.Version;
import de.florianmichael.viafabricplus.definition.v1_14_4.LegacyServerAddress;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.meta.TitleRenderer;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
import java.util.List;
public class BetaCraftScreen extends Screen {
public static BetacraftServerList SERVER_LIST;
public final static BetaCraftScreen INSTANCE = new BetaCraftScreen();
public Screen prevScreen;
protected BetaCraftScreen() {
super(Text.literal("BetaCraft"));
}
public static BetaCraftScreen get(final Screen prevScreen) {
BetaCraftScreen.INSTANCE.prevScreen = prevScreen;
return BetaCraftScreen.INSTANCE;
}
@Override
protected void init() {
super.init();
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height + 5, (textRenderer.fontHeight + 2) * 3));
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.reset"), button -> {
client.setScreen(prevScreen);
SERVER_LIST = null;
}).position(width - 98 - 5, 5).size(98, 20).build());
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
matrices.push();
matrices.scale(2F, 2F, 2F);
drawCenteredTextWithShadow(matrices, textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
drawCenteredTextWithShadow(matrices, textRenderer, "https://github.com/FlorianMichael/ViaFabricPlus", width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
@Override
public void close() {
client.setScreen(prevScreen);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height, top, bottom, entryHeight);
for (Version value : Version.values()) {
final List<Server> servers = SERVER_LIST.getServersOfVersion(value);
if (servers.isEmpty()) continue;
addEntry(new TitleRenderer(value.name()));
for (Server server : servers) {
addEntry(new ServerSlot(server));
}
}
}
@Override
public int getRowWidth() {
return super.getRowWidth() + 140;
}
@Override
protected int getScrollbarPositionX() {
return this.width - 5;
}
}
public static class ServerSlot extends MappedSlotEntry {
private final Server server;
public ServerSlot(Server server) {
this.server = server;
}
@Override
public Text getNarration() {
return Text.literal(server.getName());
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
final ServerAddress serverAddress = LegacyServerAddress.parse(null, server.getHost() + ":" + server.getPort());
final ServerInfo entry = new ServerInfo(server.getName(), serverAddress.getAddress(), false);
ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry);
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
drawCenteredTextWithShadow(matrices, textRenderer, server.getName() + Formatting.DARK_GRAY + " [" + server.getGameVersion() + "]", entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
if (server.isOnlineMode()) {
drawTextWithShadow(matrices, textRenderer, Text.translatable("words.viafabricplus.online").formatted(Formatting.GREEN), 1, 1, -1);
}
final String playerText = server.getPlayerCount() + "/" + server.getPlayerLimit();
drawTextWithShadow(matrices, textRenderer, playerText, entryWidth - textRenderer.getWidth(playerText) - 4 /* magic value from line 132 */ - 1, 1, -1);
}
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.screen;
import com.github.allinkdev.betacraftserverlistparser.BetacraftServerList;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.definition.c0_30.classicube.ClassiCubeAccountHandler;
@ -30,15 +31,16 @@ import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import java.awt.*;
import java.util.concurrent.CompletableFuture;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class ProtocolSelectionScreen extends Screen {
@ -63,14 +65,39 @@ public class ProtocolSelectionScreen extends Screen {
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.settings"), button -> client.setScreen(SettingsScreen.get(this))).position(width - 98 - 5, 5).size(98, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("ClassiCube"), button -> {
final ClassiCubeAccount classiCubeAccount = ClassiCubeAccountHandler.INSTANCE.getAccount();
final ClassiCubeAccount classiCubeAccount = ClassiCubeAccountHandler.INSTANCE.getAccount();
ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(Text.literal("ClassiCube"), button -> {
if (classiCubeAccount == null || classiCubeAccount.token == null) {
client.setScreen(ClassiCubeLoginScreen.get(this));
return;
}
client.setScreen(ClassiCubeServerListScreen.get(this));
}).position(width - 98 - 5, height - 25).size(98, 20).build());
}).position(width - 98 - 5, height - 25).size(98, 20);
if (classiCubeAccount == null || classiCubeAccount.token == null) {
classiCubeBuilder = classiCubeBuilder.tooltip(Tooltip.of(Text.translatable("classicube.viafabricplus.warning")));
}
this.addDrawableChild(classiCubeBuilder.build());
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(Text.literal("BetaCraft"), button -> {
if (BetaCraftScreen.SERVER_LIST == null) {
CompletableFuture.runAsync(() -> BetacraftServerList.getFuture().whenComplete((betacraftServerList, throwable) -> {
if (throwable != null) {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> RenderSystem.recordRenderCall(() -> client.setScreen(BetaCraftScreen.get(this))), Text.literal("Microsoft Bedrock login"), Text.translatable("betacraft.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
return;
}
BetaCraftScreen.SERVER_LIST = betacraftServerList;
RenderSystem.recordRenderCall(() -> client.setScreen(BetaCraftScreen.get(this)));
}));
button.setMessage(Text.literal("BetaCraft"));
return;
}
button.setMessage(Text.literal("BetaCraft"));
client.setScreen(BetaCraftScreen.get(this));
}).position(5, height - 25).size(98, 20);
if (BetaCraftScreen.SERVER_LIST == null) {
betaCraftBuilder = betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
}
this.addDrawableChild(betaCraftBuilder.build());
}
@Override

View File

@ -15,22 +15,22 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.screen.settings;
package de.florianmichael.viafabricplus.screen.base;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.util.math.MatrixStack;
public abstract class AbstractSettingRenderer extends AlwaysSelectedEntryListWidget.Entry<AbstractSettingRenderer> {
public abstract class MappedSlotEntry extends AlwaysSelectedEntryListWidget.Entry<MappedSlotEntry> {
public abstract void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
public abstract void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
renderSetting(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
mappedRenderer(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
}

View File

@ -25,6 +25,7 @@ import de.florianmichael.viafabricplus.definition.c0_30.classicube.request.serve
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.groups.MPPassSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
@ -59,19 +60,15 @@ public class ClassiCubeServerListScreen extends Screen {
}
public static void open(final Screen prevScreen, final ILoginProcessHandler loginProcessHandler) {
if (ClassiCubeServerListScreen.SERVERS.isEmpty()) {
final ClassiCubeServerListRequest request = new ClassiCubeServerListRequest(ClassiCubeAccountHandler.INSTANCE.getAccount());
request.send().whenComplete((server, throwable) -> {
if (throwable != null) {
loginProcessHandler.handleException(throwable);
return;
}
ClassiCubeServerListScreen.SERVERS.addAll(server.getServers());
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(ClassiCubeServerListScreen.get(prevScreen)));
});
return;
}
MinecraftClient.getInstance().setScreen(ClassiCubeServerListScreen.get(prevScreen));
final ClassiCubeServerListRequest request = new ClassiCubeServerListRequest(ClassiCubeAccountHandler.INSTANCE.getAccount());
request.send().whenComplete((server, throwable) -> {
if (throwable != null) {
loginProcessHandler.handleException(throwable);
return;
}
ClassiCubeServerListScreen.SERVERS.addAll(server.getServers());
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(ClassiCubeServerListScreen.get(prevScreen)));
});
}
public ClassiCubeServerListScreen() {
@ -109,7 +106,7 @@ public class ClassiCubeServerListScreen extends Screen {
drawCenteredTextWithShadow(matrices, textRenderer, Text.literal("ClassiCube Profile: " + ClassiCubeAccountHandler.INSTANCE.getAccount().username), width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<ServerSlot> {
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height, top, bottom, entryHeight);
@ -129,7 +126,7 @@ public class ClassiCubeServerListScreen extends Screen {
}
public static class ServerSlot extends AlwaysSelectedEntryListWidget.Entry<ServerSlot> {
public static class ServerSlot extends MappedSlotEntry {
private final ClassiCubeServerInfo classiCubeServerInfo;
public ServerSlot(ClassiCubeServerInfo classiCubeServerInfo) {
@ -157,20 +154,13 @@ public class ClassiCubeServerListScreen extends Screen {
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
drawCenteredTextWithShadow(matrices, textRenderer, classiCubeServerInfo.name(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
drawTextWithShadow(matrices, textRenderer, classiCubeServerInfo.software().replace('&', Formatting.FORMATTING_CODE_PREFIX), 1, 1, -1);
final String playerText = classiCubeServerInfo.players() + "/" + classiCubeServerInfo.maxplayers();
drawTextWithShadow(matrices, textRenderer, playerText, entryWidth - textRenderer.getWidth(playerText) - 4 /* magic value from line 132 */ - 1, 1, -1);
matrices.pop();
}
}
}

View File

@ -18,17 +18,10 @@
package de.florianmichael.viafabricplus.screen.settings;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.BooleanSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ButtonSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ModeSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ProtocolSyncBooleanSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.meta.TitleRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ButtonSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
@ -37,9 +30,6 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class SettingsScreen extends Screen {
@ -47,7 +37,7 @@ public class SettingsScreen extends Screen {
public Screen prevScreen;
protected SettingsScreen() {
super(Text.literal("Values"));
super(Text.literal("Setting"));
}
public static SettingsScreen get(final Screen prevScreen) {
@ -80,7 +70,7 @@ public class SettingsScreen extends Screen {
client.setScreen(prevScreen);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<AbstractSettingRenderer> {
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height, top, bottom, entryHeight);

View File

@ -17,19 +17,18 @@
*/
package de.florianmichael.viafabricplus.screen.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
public class BooleanSettingRenderer extends AbstractSettingRenderer {
public class BooleanSettingRenderer extends MappedSlotEntry {
private final BooleanSetting value;
public BooleanSettingRenderer(BooleanSetting value) {
@ -49,7 +48,7 @@ public class BooleanSettingRenderer extends AbstractSettingRenderer {
}
@Override
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
final Text text = this.value.getValue() ? Text.translatable("words.viafabricplus.on") : Text.translatable("words.viafabricplus.off");

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.screen.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.ButtonSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import net.minecraft.client.MinecraftClient;
@ -26,7 +26,7 @@ import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class ButtonSettingRenderer extends AbstractSettingRenderer {
public class ButtonSettingRenderer extends MappedSlotEntry {
private final ButtonSetting value;
public ButtonSettingRenderer(ButtonSetting value) {
@ -46,7 +46,7 @@ public class ButtonSettingRenderer extends AbstractSettingRenderer {
}
@Override
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
DrawableHelper.drawCenteredTextWithShadow(matrices, textRenderer, this.value.displayValue(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);

View File

@ -17,19 +17,18 @@
*/
package de.florianmichael.viafabricplus.screen.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.Arrays;
public class ModeSettingRenderer extends AbstractSettingRenderer {
public class ModeSettingRenderer extends MappedSlotEntry {
private final ModeSetting value;
public ModeSettingRenderer(ModeSetting value) {
@ -50,7 +49,7 @@ public class ModeSettingRenderer extends AbstractSettingRenderer {
}
@Override
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
textRenderer.drawWithShadow(matrices, this.value.getName().formatted(Formatting.GRAY), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);

View File

@ -17,20 +17,19 @@
*/
package de.florianmichael.viafabricplus.screen.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
public class ProtocolSyncBooleanSettingRenderer extends AbstractSettingRenderer {
public class ProtocolSyncBooleanSettingRenderer extends MappedSlotEntry {
private final ProtocolSyncBooleanSetting value;
public ProtocolSyncBooleanSettingRenderer(ProtocolSyncBooleanSetting value) {
@ -50,7 +49,7 @@ public class ProtocolSyncBooleanSettingRenderer extends AbstractSettingRenderer
}
@Override
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
final Text text = this.value.getValue() ? Text.translatable("words.viafabricplus.on") : Text.translatable("words.viafabricplus.off");

View File

@ -17,14 +17,14 @@
*/
package de.florianmichael.viafabricplus.screen.settings.settingrenderer.meta;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class TitleRenderer extends AbstractSettingRenderer {
public class TitleRenderer extends MappedSlotEntry {
private final String name;
public TitleRenderer(String name) {
@ -40,12 +40,12 @@ public class TitleRenderer extends AbstractSettingRenderer {
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
renderSetting(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
mappedRenderer(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
@Override
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
textRenderer.drawWithShadow(matrices, Formatting.BOLD + this.name, 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);

View File

@ -18,9 +18,8 @@
package de.florianmichael.viafabricplus.settings.base;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableTextContent;
public abstract class AbstractSetting<T> {
@ -38,7 +37,7 @@ public abstract class AbstractSetting<T> {
parent.getSettings().add(this);
}
public abstract AbstractSettingRenderer makeSettingRenderer();
public abstract MappedSlotEntry makeSettingRenderer();
public abstract void write(final JsonObject object);
public abstract void read(final JsonObject object);

View File

@ -49,9 +49,7 @@ public class BedrockSettings extends SettingGroup {
Util.getOperatingSystem().open(new URI(msaDeviceCode.verificationUri()));
} catch (URISyntaxException e) {
e.printStackTrace();
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> {
Thread.currentThread().interrupt();
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
}
}));
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));

View File

@ -18,12 +18,11 @@
package de.florianmichael.viafabricplus.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.BooleanSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
public class BooleanSetting extends AbstractSetting<Boolean> {
@ -32,7 +31,7 @@ public class BooleanSetting extends AbstractSetting<Boolean> {
}
@Override
public AbstractSettingRenderer makeSettingRenderer() {
public MappedSlotEntry makeSettingRenderer() {
return new BooleanSettingRenderer(this);
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ButtonSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
@ -31,7 +31,7 @@ public class ButtonSetting extends AbstractSetting<Runnable> {
}
@Override
public AbstractSettingRenderer makeSettingRenderer() {
public MappedSlotEntry makeSettingRenderer() {
return new ButtonSettingRenderer(this);
}

View File

@ -18,12 +18,11 @@
package de.florianmichael.viafabricplus.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ModeSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import java.util.Arrays;
@ -36,7 +35,7 @@ public class ModeSetting extends AbstractSetting<MutableText> {
}
@Override
public AbstractSettingRenderer makeSettingRenderer() {
public MappedSlotEntry makeSettingRenderer() {
return new ModeSettingRenderer(this);
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ProtocolSyncBooleanSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
@ -36,7 +36,7 @@ public class ProtocolSyncBooleanSetting extends BooleanSetting {
}
@Override
public AbstractSettingRenderer makeSettingRenderer() {
public MappedSlotEntry makeSettingRenderer() {
return new ProtocolSyncBooleanSettingRenderer(this);
}

View File

@ -9,6 +9,8 @@
"words.viafabricplus.cancel": "Cancel",
"words.viafabricplus.cancelreset": "Cancel and reset",
"words.viafabricplus.logout": "Logout",
"words.viafabricplus.online": "Online Mode",
"words.viafabricplus.reset": "Reset",
"bedrock.viafabricplus.set": "Click to set account for Bedrock edition",
@ -63,5 +65,10 @@
"classicube.viafabricplus.error.username": "Invalid username.",
"classicube.viafabricplus.error.password": "Invalid password.",
"classicube.viafabricplus.error.verification": "User hasn't verified their E-mail address yet.",
"classicube.viafabricplus.error.logincode": "Multi-factor authentication requested. Please check your E-mail."
"classicube.viafabricplus.error.logincode": "Multi-factor authentication requested. Please check your E-mail.",
"classicube.viafabricplus.warning": "This feature will send API requests to the ClassiCube API.",
"betacraft.viafabricplus.warning": "Pressing this button will send API requests to \"betacraft.uk/serverlist\".",
"betacraft.viafabricplus.error": "Something went wrong! Please try again later"
}