refactor project

This commit is contained in:
FlorianMichael 2023-05-07 20:08:33 +02:00
parent 7eb69e7d49
commit 184d8ea694
102 changed files with 442 additions and 540 deletions

View File

@ -52,32 +52,6 @@ PreLoadCallback.EVENT.register(() -> {
});
```
#### Implementing classic protocol commands:
```java
public class ExampleCommand implements ICommand {
@Override
public String name() {
return "example";
}
@Override
public String description() {
return null;
}
@Override
public void execute(String[] args) {
}
}
```
and then you register the command in your onLoad method:
```java
PreLoadCallback.EVENT.register(() -> {
ClassicProtocolCommands.commands.add(new ExampleCommand());
});
```
#### Implementing custom classic protocol extensions:
```java
public class ExampleExtensionSupport implements ClientModInitializer {

View File

@ -27,7 +27,7 @@ snake_yml_version=2.0
vialegacy_version=2.2.16
viaaprilfools_version=2.0.7-SNAPSHOT
viabedrock_version=0.0.1-SNAPSHOT
minecraftauth_version=2.1.1-SNAPSHOT
minecraftauth_version=2.1.1
# lenni0451 libs
mcstructs_text_version=2.2.5

View File

@ -24,15 +24,15 @@ import de.florianmichael.viafabricplus.definition.v1_12_2.FontCacheFix;
import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
import de.florianmichael.viafabricplus.mappings.PackFormatsMappings;
import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.base.screen.impl.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.definition.c0_30.protocol.CustomClassicProtocolExtensions;
import de.florianmichael.viafabricplus.mappings.ArmorPointsMappings;
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.event.PreLoadCallback;
import de.florianmichael.viafabricplus.information.InformationSystem;
import de.florianmichael.viafabricplus.definition.v1_8.ArmorPointCalculation;
import de.florianmichael.viafabricplus.base.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.base.event.PreLoadCallback;
import de.florianmichael.viafabricplus.base.information.InformationSystem;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.SettingsSystem;
import de.florianmichael.viafabricplus.base.settings.SettingsSystem;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -85,7 +85,7 @@ public class ViaFabricPlus {
// Version related mappings
PackFormatsMappings.load();
ItemReleaseVersionMappings.create();
ArmorPointsMappings.load();
ArmorPointCalculation.load();
});
}

View File

@ -15,7 +15,7 @@
* 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.util;
package de.florianmichael.viafabricplus.base;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.ViaFabricPlus;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.fabric.api.event.Event;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import net.fabricmc.fabric.api.event.Event;

View File

@ -15,7 +15,7 @@
* 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.information;
package de.florianmichael.viafabricplus.base.information;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
@ -31,6 +31,23 @@ public abstract class AbstractInformationGroup {
public abstract void applyInformation(final UserConnection userConnection, final List<String> output);
public String format(double a) {
return String.format("%.2f", a);
}
public String formatBytes(long value) {
if (value < 1024L)
return value + " B";
else if (value < 1024L * 1024L)
return format(((double) value / 1024.0)) + " Kb";
else if (value < 1024L * 1024L * 1024L)
return format(((double) value / 1024.0 / 1024.0)) + " Mb";
else if (value < 1024L * 1024L * 1024L * 1024L)
return format(((double) value / 1024.0 / 1024.0 / 1024.0)) + " Gb";
else
return format(((double) value / 1024.0 / 1024.0 / 1024.0 / 1024.0)) + " Tb";
}
public ProtocolRange getProtocolRange() {
return protocolRange;
}

View File

@ -15,9 +15,9 @@
* 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.information;
package de.florianmichael.viafabricplus.base.information;
import de.florianmichael.viafabricplus.information.impl.*;
import de.florianmichael.viafabricplus.base.information.impl.*;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -15,15 +15,14 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.definition.bedrock.storage.JoinGameStorage;
import de.florianmichael.viafabricplus.definition.bedrock.ModelFormats;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusBlobCacheProvider;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.lenni0451.reflect.stream.RStream;
import net.lenni0451.reflect.stream.field.FieldStream;
@ -58,7 +57,7 @@ public class BedrockInformation extends AbstractInformationGroup {
output.add("Blob Cache:");
}
if (totalSize != 0) output.add("Total size: " + ScreenUtil.formatBytes(totalSize));
if (totalSize != 0) output.add("Total size: " + formatBytes(totalSize));
if (blobCount != 0) output.add("Blob count: " + blobCount);
if (pendingCount != 0) output.add("Pending count: " + pendingCount);
}

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage.SeedStorage;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.storage.EntityTracker;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.storage.EntityTracker;

View File

@ -15,11 +15,11 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.base.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.EntityTracker;

View File

@ -15,7 +15,7 @@
* 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.base;
package de.florianmichael.viafabricplus.base.screen;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
@ -23,14 +23,23 @@ import net.minecraft.client.util.math.MatrixStack;
public abstract class MappedSlotEntry extends AlwaysSelectedEntryListWidget.Entry<MappedSlotEntry> {
public abstract void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
public abstract void mappedRender(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
mappedMouseClicked(mouseX, mouseY, button);
VFPScreen.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@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);
mappedRenderer(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
mappedRender(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
}

View File

@ -0,0 +1,83 @@
/*
* 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.base.screen;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.client.gui.screen.Screen;
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.*;
public class VFPScreen extends Screen {
private final boolean backButton;
public Screen prevScreen;
public VFPScreen(String title, boolean backButton) {
super(Text.of(title));
this.backButton = backButton;
}
public void open(final Screen prevScreen) {
this.prevScreen = prevScreen;
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(this));
}
@Override
protected void init() {
if (backButton) {
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
}
}
@Override
public void close() {
MinecraftClient.getInstance().setScreen(prevScreen);
}
public void renderTitle(final MatrixStack matrices) {
renderTitle(matrices, Text.of("https://github.com/FlorianMichael/ViaFabricPlus"));
}
public void renderTitle(final MatrixStack matrices, final Text subTitle) {
matrices.push();
matrices.scale(2F, 2F, 2F);
drawCenteredTextWithShadow(matrices, textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
drawCenteredTextWithShadow(matrices, textRenderer, subTitle, width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
public static void playClickSound() {
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
public void showErrorScreen(final String title, final Throwable throwable) {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() ->
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(this)), Text.of(title),
Text.translatable("words.viafabricplus.error").append("\n" + throwable.getMessage()),
Text.translatable("words.viafabricplus.cancel"), false)));
}
}

View File

@ -15,19 +15,15 @@
* 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;
package de.florianmichael.viafabricplus.base.screen.impl;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
@ -35,7 +31,7 @@ import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("DataFlowIssue")
public class ClassicItemSelectionScreen extends Screen {
public class ClassicItemSelectionScreen extends VFPScreen {
public static ClassicItemSelectionScreen INSTANCE;
@ -58,7 +54,7 @@ public class ClassicItemSelectionScreen extends Screen {
public ItemStack selectedItem = null;
public ClassicItemSelectionScreen() {
super(Text.literal("Classic item selection"));
super("Classic item selection", false);
}
public void reload(final ComparableProtocolVersion version, final boolean hasCustomBlocksV1) {
@ -138,13 +134,13 @@ public class ClassicItemSelectionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (selectedItem != null) {
this.client.interactionManager.clickCreativeStack(selectedItem, MinecraftClient.getInstance().player.getInventory().selectedSlot + 36); // Beta Inventory Tracker
this.client.interactionManager.clickCreativeStack(selectedItem, client.player.getInventory().selectedSlot + 36); // Beta Inventory Tracker
this.client.player.getInventory().main.set(MinecraftClient.getInstance().player.getInventory().selectedSlot, selectedItem);
this.client.player.getInventory().main.set(client.player.getInventory().selectedSlot, selectedItem);
this.client.player.playerScreenHandler.sendContentUpdates();
this.client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
playClickSound();
this.close();
}
return super.mouseClicked(mouseX, mouseY, button);
@ -175,7 +171,7 @@ public class ClassicItemSelectionScreen extends Screen {
fill(matrices, renderX + x, renderY + y, renderX + x + ITEM_XY_BOX_DIMENSION_CLASSIC, renderY + y + ITEM_XY_BOX_DIMENSION_CLASSIC, Integer.MAX_VALUE);
selectedItem = item.getDefaultStack();
}
MinecraftClient.getInstance().getItemRenderer().renderGuiItemIcon(matrices, item.getDefaultStack(), renderX + x + ITEM_XY_BOX_DIMENSION_MODERN / 4, renderY + y + ITEM_XY_BOX_DIMENSION_MODERN / 4);
client.getItemRenderer().renderGuiItemIcon(matrices, item.getDefaultStack(), renderX + x + ITEM_XY_BOX_DIMENSION_MODERN / 4, renderY + y + ITEM_XY_BOX_DIMENSION_MODERN / 4);
x += ITEM_XY_BOX_DIMENSION_CLASSIC;
}
y += ITEM_XY_BOX_DIMENSION_CLASSIC;

View File

@ -15,32 +15,28 @@
* 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;
package de.florianmichael.viafabricplus.base.screen.impl.base;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
import java.util.function.Consumer;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class ForceVersionScreen extends Screen {
private final Screen prevScreen;
public class ForceVersionScreen extends VFPScreen {
private final Consumer<ComparableProtocolVersion> selectionConsumer;
public ForceVersionScreen(final Screen prevScreen, final Consumer<ComparableProtocolVersion> selectionConsumer) {
super(Text.literal("Force version"));
super("Force version", false);
this.prevScreen = prevScreen;
this.selectionConsumer = selectionConsumer;
@ -58,16 +54,7 @@ public class ForceVersionScreen extends Screen {
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, Text.translatable("forceversion.viafabricplus.title"), width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
@Override
public void close() {
client.setScreen(prevScreen);
this.renderTitle(matrices, Text.translatable("forceversion.viafabricplus.title"));
}
public class SlotList extends AlwaysSelectedEntryListWidget<DummyProtocolSlot> {
@ -94,9 +81,10 @@ public class ForceVersionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ForceVersionScreen.this.selectionConsumer.accept(null);
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
ForceVersionScreen.this.close();
selectionConsumer.accept(null);
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button);
}
@ -121,9 +109,10 @@ public class ForceVersionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ForceVersionScreen.this.selectionConsumer.accept(ViaLoadingBase.fromProtocolVersion(protocolVersion));
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
ForceVersionScreen.this.close();
selectionConsumer.accept(ViaLoadingBase.fromProtocolVersion(protocolVersion));
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button);
}

View File

@ -15,23 +15,21 @@
* 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;
package de.florianmichael.viafabricplus.base.screen.impl.base;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.classic4j.BetaCraftHandler;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.screen.classicube.ClassiCubeLoginScreen;
import de.florianmichael.viafabricplus.screen.classicube.ClassiCubeServerListScreen;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.viafabricplus.base.screen.impl.thirdparty.classicube.ClassiCubeLoginScreen;
import de.florianmichael.viafabricplus.base.screen.impl.thirdparty.classicube.ClassiCubeServerListScreen;
import de.florianmichael.viafabricplus.base.screen.impl.thirdparty.BetaCraftScreen;
import de.florianmichael.viafabricplus.base.screen.impl.settings.SettingsScreen;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
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;
@ -40,73 +38,70 @@ import net.minecraft.text.Text;
import java.awt.*;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class ProtocolSelectionScreen extends Screen {
private final static ProtocolSelectionScreen INSTANCE = new ProtocolSelectionScreen();
public Screen prevScreen;
public class ProtocolSelectionScreen extends VFPScreen {
public final static ProtocolSelectionScreen INSTANCE = new ProtocolSelectionScreen();
private ButtonWidget betaCraftButton;
protected ProtocolSelectionScreen() {
super(Text.literal("Protocol selection"));
}
public static void open(final Screen current) {
INSTANCE.prevScreen = current;
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(INSTANCE));
super("Protocol selection", true);
}
@Override
protected void init() {
super.init();
// List and Settings
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height - 30, textRenderer.fontHeight + 4));
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 -> SettingsScreen.INSTANCE.open(this)).position(width - 98 - 5, 5).size(98, 20).build());
// ClassiCube
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.settings"), button -> client.setScreen(SettingsScreen.get(this))).position(width - 98 - 5, 5).size(98, 20).build());
final CCAccount classiCubeAccount = ClassiCubeAccountHandler.INSTANCE.getAccount();
ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(Text.literal("ClassiCube"), button -> {
if (classiCubeAccount == null || classiCubeAccount.token == null) {
client.setScreen(ClassiCubeLoginScreen.get(this));
ClassiCubeLoginScreen.INSTANCE.open(prevScreen);
return;
}
client.setScreen(ClassiCubeServerListScreen.get(this));
ClassiCubeServerListScreen.INSTANCE.open(prevScreen);
}).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());
// BetaCraft
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(Text.literal("BetaCraft"), button -> {
if (BetaCraftScreen.SERVER_LIST == null) {
BetaCraftHandler.requestServerList(bcServerList -> {
BetaCraftScreen.SERVER_LIST = bcServerList;
betaCraftButton = button;
RenderSystem.recordRenderCall(() -> client.setScreen(BetaCraftScreen.get(this)));
}, throwable -> MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> RenderSystem.recordRenderCall(() -> client.setScreen(this)), Text.literal("Betacraft"), Text.translatable("betacraft.viafabricplus.error").append("\n" + throwable.getMessage()), Text.translatable("words.viafabricplus.cancel"), false))));
} else client.setScreen(BetaCraftScreen.get(this));
BetaCraftHandler.requestServerList(serverList -> {
BetaCraftScreen.SERVER_LIST = serverList;
button.setMessage(Text.literal("BetaCraft"));
BetaCraftScreen.INSTANCE.open(this);
}, throwable -> showErrorScreen("BetaCraft", throwable));
} else {
BetaCraftScreen.INSTANCE.open(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());
super.init();
}
@Override
public void tick() {
if (betaCraftButton != null) betaCraftButton.setMessage(Text.of("Loading..."));
}
@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);
this.renderTitle(matrices);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<ProtocolSlot> {
@ -133,7 +128,7 @@ public class ProtocolSelectionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ViaLoadingBase.getInstance().reload(this.protocolVersion);
ScreenUtil.playClickSound();
playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}

View File

@ -15,42 +15,30 @@
* 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.base.screen.impl.settings;
import de.florianmichael.viafabricplus.ViaFabricPlus;
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.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.meta.TitleRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.client.MinecraftClient;
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.util.math.MatrixStack;
import net.minecraft.text.Text;
import java.awt.*;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class SettingsScreen extends Screen {
public class SettingsScreen extends VFPScreen {
public final static SettingsScreen INSTANCE = new SettingsScreen();
public Screen prevScreen;
protected SettingsScreen() {
super(Text.literal("Setting"));
}
public static SettingsScreen get(final Screen prevScreen) {
SettingsScreen.INSTANCE.prevScreen = prevScreen;
return SettingsScreen.INSTANCE;
public SettingsScreen() {
super("Setting", true);
}
@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) * 2));
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
super.init();
}
@Override
@ -58,16 +46,7 @@ public class SettingsScreen extends Screen {
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);
this.renderTitle(matrices);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {

View File

@ -15,11 +15,10 @@
* 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.settingrenderer;
package de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
@ -41,14 +40,12 @@ public class BooleanSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
this.value.setValue(!this.value.getValue());
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) {
public void mappedRender(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

@ -15,11 +15,10 @@
* 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.settingrenderer;
package de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.ButtonSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.type_impl.ButtonSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
@ -39,14 +38,12 @@ public class ButtonSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
this.value.getValue().run();
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) {
public void mappedRender(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

@ -15,11 +15,10 @@
* 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.settingrenderer;
package de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.type_impl.ModeSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
@ -41,15 +40,13 @@ public class ModeSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
final int currentIndex = Arrays.stream(this.value.getOptions()).toList().indexOf(this.value.value) + 1;
this.value.setValue(currentIndex > this.value.getOptions().length - 1 ? 0 : currentIndex);
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) {
public void mappedRender(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

@ -15,12 +15,11 @@
* 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.settingrenderer;
package de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer;
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 de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
@ -42,14 +41,12 @@ public class ProtocolSyncBooleanSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
this.value.setValue(!this.value.getValue());
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) {
public void mappedRender(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

@ -15,9 +15,9 @@
* 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.settingrenderer.meta;
package de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.meta;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
@ -40,12 +40,12 @@ public class TitleRenderer extends MappedSlotEntry {
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);
mappedRenderer(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
mappedRender(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
@Override
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(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

@ -15,19 +15,18 @@
* 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;
package de.florianmichael.viafabricplus.base.screen.impl.thirdparty;
import de.florianmichael.classic4j.model.betacraft.BCServerInfo;
import de.florianmichael.classic4j.model.betacraft.BCServerList;
import de.florianmichael.classic4j.model.betacraft.BCVersion;
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 de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.meta.TitleRenderer;
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;
@ -36,34 +35,26 @@ 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 class BetaCraftScreen extends VFPScreen {
public static BCServerList 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;
super("BetaCraft", true);
}
@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;
client.setScreen(prevScreen);
}).position(width - 98 - 5, 5).size(98, 20).build());
super.init();
}
@Override
@ -71,19 +62,10 @@ public class BetaCraftScreen extends Screen {
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);
this.renderTitle(matrices);
}
@Override
public void close() {
client.setScreen(prevScreen);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
public 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);
@ -122,17 +104,16 @@ public class BetaCraftScreen extends Screen {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
final ServerAddress serverAddress = LegacyServerAddress.parse(null, server.host() + ":" + server.port());
final ServerInfo entry = new ServerInfo(server.name(), serverAddress.getAddress(), false);
ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry);
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
playClickSound();
}
@Override
public void mappedRenderer(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(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.name() + Formatting.DARK_GRAY + " [" + server.gameVersion() + "]", entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);

View File

@ -15,33 +15,34 @@
* 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.classicube;
package de.florianmichael.viafabricplus.base.screen.impl.thirdparty.classicube;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.classic4j.ClassiCubeHandler;
import de.florianmichael.classic4j.api.LoginProcessHandler;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.base.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import net.minecraft.client.MinecraftClient;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class ClassiCubeLoginScreen extends Screen {
public class ClassiCubeLoginScreen extends VFPScreen {
public final static ClassiCubeLoginScreen INSTANCE = new ClassiCubeLoginScreen();
public Screen prevScreen;
public ClassiCubeLoginScreen() {
super(Text.literal("ClassiCube Login"));
super("ClassiCube Login", false);
}
public static ClassiCubeLoginScreen get(final Screen prevScreen) {
ClassiCubeLoginScreen.INSTANCE.prevScreen = prevScreen;
ClassiCubeLoginScreen.INSTANCE.status = Text.translatable("classicube.viafabricplus.account");
return ClassiCubeLoginScreen.INSTANCE;
@Override
public void open(Screen prevScreen) {
status = Text.translatable("classicube.viafabricplus.account");
super.open(prevScreen);
}
private TextFieldWidget nameField;
@ -76,12 +77,12 @@ public class ClassiCubeLoginScreen extends Screen {
ClassiCubeHandler.requestAuthentication(ClassiCubeAccountHandler.INSTANCE.getAccount(), null, new LoginProcessHandler() {
@Override
public void handleMfa(CCAccount account) {
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(ClassiCubeMFAScreen.get(prevScreen)));
ClassiCubeMFAScreen.INSTANCE.open(prevScreen);
}
@Override
public void handleSuccessfulLogin(CCAccount account) {
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(MinecraftClient.getInstance().currentScreen, this));
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(prevScreen, this));
}
@Override
@ -103,7 +104,7 @@ public class ClassiCubeLoginScreen extends Screen {
@Override
public void close() {
this.client.setScreen(this.prevScreen);
ProtocolSelectionScreen.INSTANCE.open(prevScreen);
}
@Override

View File

@ -15,7 +15,7 @@
* 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.classicube;
package de.florianmichael.viafabricplus.base.screen.impl.thirdparty.classicube;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.classic4j.ClassiCubeHandler;
@ -24,8 +24,8 @@ import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.classic4j.model.classicube.highlevel.CCError;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import net.minecraft.client.MinecraftClient;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.viafabricplus.base.screen.impl.base.ProtocolSelectionScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
@ -34,19 +34,17 @@ import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class ClassiCubeMFAScreen extends Screen {
public class ClassiCubeMFAScreen extends VFPScreen {
public final static ClassiCubeMFAScreen INSTANCE = new ClassiCubeMFAScreen();
public Screen prevScreen;
public ClassiCubeMFAScreen() {
super(Text.literal("ClassiCube MFA"));
super("ClassiCube MFA", true);
}
public static ClassiCubeMFAScreen get(final Screen prevScreen) {
ClassiCubeMFAScreen.INSTANCE.prevScreen = prevScreen;
ClassiCubeMFAScreen.INSTANCE.status = Classic4JImpl.fromError(CCError.LOGIN_CODE);
return ClassiCubeMFAScreen.INSTANCE;
@Override
public void open(Screen prevScreen) {
status = Classic4JImpl.fromError(CCError.LOGIN_CODE);
super.open(prevScreen);
}
private TextFieldWidget mfaField;
@ -73,7 +71,7 @@ public class ClassiCubeMFAScreen extends Screen {
@Override
public void handleSuccessfulLogin(CCAccount account) {
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(MinecraftClient.getInstance().currentScreen, this));
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(prevScreen, this));
}
@Override
@ -93,7 +91,7 @@ public class ClassiCubeMFAScreen extends Screen {
@Override
public void close() {
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));
ProtocolSelectionScreen.INSTANCE.open(prevScreen);
}
@Override

View File

@ -15,27 +15,25 @@
* 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.classicube;
package de.florianmichael.viafabricplus.base.screen.impl.thirdparty.classicube;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.classic4j.ClassiCubeHandler;
import de.florianmichael.classic4j.api.LoginProcessHandler;
import de.florianmichael.classic4j.model.classicube.CCServerInfo;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
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.AuthenticationSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.screen.VFPScreen;
import de.florianmichael.viafabricplus.base.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
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.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ServerAddress;
@ -45,48 +43,40 @@ import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class ClassiCubeServerListScreen extends Screen {
public final static List<CCServerInfo> SERVERS = new ArrayList<>();
private final static ClassiCubeServerListScreen INSTANCE = new ClassiCubeServerListScreen();
public Screen prevScreen;
public static ClassiCubeServerListScreen get(final Screen prevScreen) {
ClassiCubeServerListScreen.INSTANCE.prevScreen = prevScreen;
return ClassiCubeServerListScreen.INSTANCE;
}
public class ClassiCubeServerListScreen extends VFPScreen {
public final static List<CCServerInfo> SERVER_LIST = new ArrayList<>();
public final static ClassiCubeServerListScreen INSTANCE = new ClassiCubeServerListScreen();
public static void open(final Screen prevScreen, final LoginProcessHandler loginProcessHandler) {
ClassiCubeHandler.requestServerList(ClassiCubeAccountHandler.INSTANCE.getAccount(), ccServerList -> {
ClassiCubeServerListScreen.SERVERS.addAll(ccServerList.servers());
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(ClassiCubeServerListScreen.get(prevScreen)));
ClassiCubeServerListScreen.SERVER_LIST.addAll(ccServerList.servers());
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.INSTANCE.open(prevScreen));
}, loginProcessHandler::handleException);
}
public ClassiCubeServerListScreen() {
super(Text.literal("ClassiCube ServerList"));
super("ClassiCube ServerList", true);
}
@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 + 4) * 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.logout"), button -> {
client.setScreen(prevScreen);
close();
ClassiCubeAccountHandler.INSTANCE.setAccount(null);
SERVERS.clear();
SERVER_LIST.clear();
}).position(width - 98 - 5, 5).size(98, 20).build());
super.init();
}
@Override
public void close() {
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));
ProtocolSelectionScreen.INSTANCE.open(prevScreen);
}
@Override
@ -94,11 +84,10 @@ public class ClassiCubeServerListScreen extends Screen {
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, Text.literal("ClassiCube Profile: " + ClassiCubeAccountHandler.INSTANCE.getAccount().username()), width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount();
if (account == null) return;
this.renderTitle(matrices, Text.of("ClassiCube Profile: " + account.username()));
}
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
@ -106,7 +95,7 @@ public class ClassiCubeServerListScreen extends Screen {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height, top, bottom, entryHeight);
SERVERS.forEach(serverInfo -> this.addEntry(new ServerSlot(serverInfo)));
SERVER_LIST.forEach(serverInfo -> this.addEntry(new ServerSlot(serverInfo)));
}
@Override
@ -134,7 +123,7 @@ public class ClassiCubeServerListScreen extends Screen {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
final ServerAddress serverAddress = ServerAddress.parse(classiCubeServerInfo.ip() + ":" + classiCubeServerInfo.port());
final ServerInfo entry = new ServerInfo(classiCubeServerInfo.name(), serverAddress.getAddress(), false);
ViaFabricPlusClassicMPPassProvider.classiCubeMPPass = classiCubeServerInfo.mpPass();
@ -144,12 +133,10 @@ public class ClassiCubeServerListScreen extends Screen {
}
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) {
public void mappedRender(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);

View File

@ -15,14 +15,14 @@
* 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.settings;
package de.florianmichael.viafabricplus.base.settings;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.event.InitializeSettingsCallback;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.*;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.base.event.InitializeSettingsCallback;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.groups.*;
import de.florianmichael.viafabricplus.base.FileSaver;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import java.util.ArrayList;

View File

@ -15,11 +15,10 @@
* 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.settings.base;
package de.florianmichael.viafabricplus.base.settings.base;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.ConfigRemapper;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import net.minecraft.text.MutableText;
import net.minecraft.text.TranslatableTextContent;
@ -48,7 +47,7 @@ public abstract class AbstractSetting<T> {
}
public String getTranslationKey() {
return ConfigRemapper.remapp(((TranslatableTextContent) name.getContent()).getKey());
return ((TranslatableTextContent) name.getContent()).getKey();
}
public T getDefaultValue() {

View File

@ -15,7 +15,7 @@
* 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.settings.base;
package de.florianmichael.viafabricplus.base.settings.base;
import java.util.ArrayList;
import java.util.List;

View File

@ -15,14 +15,14 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
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.base.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.base.screen.impl.settings.SettingsScreen;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.type_impl.ButtonSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.NoticeScreen;
@ -54,7 +54,7 @@ public class AuthenticationSettings extends SettingGroup {
if (consumer) {
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode());
} else {
MinecraftClient.getInstance().setScreen(SettingsScreen.get(new MultiplayerScreen(new TitleScreen())));
SettingsScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen()));
Thread.currentThread().interrupt();
}
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel"))));
@ -66,7 +66,7 @@ public class AuthenticationSettings extends SettingGroup {
}
})));
}
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));
ProtocolSelectionScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen()));
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -15,11 +15,11 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;

View File

@ -15,10 +15,10 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import net.minecraft.text.Text;
public class ExperimentalSettings extends SettingGroup {

View File

@ -15,11 +15,11 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.type_impl.ModeSetting;
import net.minecraft.text.Text;
public class GeneralSettings extends SettingGroup {

View File

@ -15,11 +15,11 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
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 de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.BooleanSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
public class BooleanSetting extends AbstractSetting<Boolean> {

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
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;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.ButtonSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
public class ButtonSetting extends AbstractSetting<Runnable> {

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
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 de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.ModeSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
import java.util.Arrays;

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
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;
import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.screen.impl.settings.settingrenderer.ProtocolSyncBooleanSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.MutableText;

View File

@ -18,8 +18,8 @@
package de.florianmichael.viafabricplus.definition;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import net.minecraft.client.MinecraftClient;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;

View File

@ -19,8 +19,8 @@ package de.florianmichael.viafabricplus.definition.bedrock;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.base.FileSaver;
import net.raphimc.mcauth.MinecraftAuth;
import net.raphimc.mcauth.step.bedrock.StepMCChain;
import net.raphimc.mcauth.util.MicrosoftConstants;
@ -59,7 +59,7 @@ public class BedrockAccountHandler extends FileSaver {
account = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.refresh(httpClient, account);
}
} catch (Exception e) {
ScreenUtil.crash("Failed to log into Bedrock account!", e);
ViaFabricPlus.LOGGER.warn("No Bedrock account could be found");
}
}

View File

@ -20,10 +20,10 @@ package de.florianmichael.viafabricplus.definition.c0_30;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.base.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.FileSaver;
import java.util.Map;
@ -58,7 +58,7 @@ public class ClassiCubeAccountHandler extends FileSaver {
try {
account = CCAccount.fromJson(object);
} catch (Exception e) {
ScreenUtil.crash("Failed to log into ClassiCube account!", e);
ViaFabricPlus.LOGGER.warn("No ClassiCube account could be found");
}
}

View File

@ -18,8 +18,8 @@
package de.florianmichael.viafabricplus.definition.c0_30.protocol;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.base.screen.impl.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import io.netty.buffer.ByteBuf;
import net.lenni0451.reflect.Enums;

View File

@ -19,10 +19,9 @@ package de.florianmichael.viafabricplus.definition.v1_12_2;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.injection.access.IFontStorage;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.loader.api.FabricLoader;

View File

@ -15,7 +15,7 @@
* 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.mappings;
package de.florianmichael.viafabricplus.definition.v1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
import net.minecraft.client.MinecraftClient;
@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ArmorPointsMappings {
public class ArmorPointCalculation {
public final static List<Item> ARMOR_ITEMS_IN_1_8 = Arrays.asList(
Items.LEATHER_HELMET,
Items.LEATHER_CHESTPLATE,
@ -66,6 +66,6 @@ public class ArmorPointsMappings {
}
public static int sum() {
return MinecraftClient.getInstance().player.getInventory().armor.stream().mapToInt(ArmorPointsMappings::getArmorPoints).sum();
return MinecraftClient.getInstance().player.getInventory().armor.stream().mapToInt(ArmorPointCalculation::getArmorPoints).sum();
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.screen.ForceVersionScreen;
import de.florianmichael.viafabricplus.base.screen.impl.base.ForceVersionScreen;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.gui.screen.AddServerScreen;
import net.minecraft.client.gui.screen.Screen;

View File

@ -17,8 +17,8 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLBPipeline;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.definition.c0_30.ClassicProgressRenderer;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;

View File

@ -19,12 +19,12 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.base.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
import net.minecraft.util.Formatting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -45,7 +45,7 @@ public class MixinDebugHud {
final UserConnection userConnection = MinecraftClient.getInstance().getNetworkHandler().getConnection().channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
information.add("");
information.add(ScreenUtil.prefixedMessage("").trim());
information.add(Formatting.GOLD + "[ViaFabricPlus] " + Formatting.WHITE);
for (AbstractInformationGroup group : ViaFabricPlus.INSTANCE.getInformationSystem().getGroups()) {
if (group.getProtocolRange() != null && !group.getProtocolRange().contains(ProtocolHack.getTargetVersion())) continue;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.definition.c0_30.ClassicProgressRenderer;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.base.event.FinishMinecraftLoadCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -19,8 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.definition.v1_14_4.LegacyServerAddress;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
@ -43,7 +43,7 @@ public class MixinMultiplayerScreen extends Screen {
@Inject(method = "init", at = @At("RETURN"))
public void addProtocolSelectionButton(CallbackInfo ci) {
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.open(this));
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this));
final int orientation = GeneralSettings.INSTANCE.mainButtonOrientation.getIndex();
switch (orientation) {

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.screen.classicube.ClassiCubeLoginScreen;
import de.florianmichael.viafabricplus.base.screen.impl.thirdparty.classicube.ClassiCubeLoginScreen;
import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.render.Camera;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;

View File

@ -20,7 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.mojang.authlib.GameProfile;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.JumpingMount;

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemModels;

View File

@ -24,7 +24,7 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.network.PendingUpdateManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;

View File

@ -19,11 +19,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.mojang.authlib.GameProfile;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.mappings.ArmorPointsMappings;
import de.florianmichael.viafabricplus.event.SkipIdlePacketCallback;
import de.florianmichael.viafabricplus.definition.v1_8.ArmorPointCalculation;
import de.florianmichael.viafabricplus.base.event.SkipIdlePacketCallback;
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
@ -221,7 +221,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Override
public int getArmor() {
if (VisualSettings.INSTANCE.emulateArmorHud.getValue()) {
return ArmorPointsMappings.sum();
return ArmorPointCalculation.sum();
}
return super.getArmor();
}

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.Keyboard;
import net.minecraft.client.MinecraftClient;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.entity.player.ItemCooldownManager;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.Item;
import net.minecraft.resource.featuretoggle.FeatureSet;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.item.ItemGroup;

View File

@ -20,7 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
import net.minecraft.entity.attribute.EntityAttribute;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.client.gui.hud.MessageIndicator;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.definition.ChatLengthCalculation;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.gui.screen.ChatScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.block.entity.CommandBlockBlockEntity;
import net.minecraft.client.gui.screen.ingame.CommandBlockScreen;
import net.minecraft.client.gui.widget.CyclingButtonWidget;

View File

@ -28,7 +28,7 @@ import de.florianmichael.viafabricplus.definition.v1_19_0.storage.ChatSession1_1
import de.florianmichael.viafabricplus.definition.v1_19_2.storage.ChatSession1_19_2;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;

View File

@ -17,8 +17,8 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.screen.impl.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.block.entity.JigsawBlockEntity;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.JigsawBlockScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.merchant;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
import net.minecraft.entity.player.PlayerInventory;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.sodium;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialegacy;
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
import org.spongepowered.asm.mixin.Final;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialegacy;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import net.raphimc.vialegacy.ViaLegacyConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialoadingbase;
import com.viaversion.viaversion.configuration.AbstractViaConfig;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.platform.viaversion.VLBViaConfig;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -19,13 +19,15 @@ package de.florianmichael.viafabricplus.integration;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
import net.minecraft.client.gui.screen.Screen;
import de.florianmichael.viafabricplus.base.screen.impl.settings.SettingsScreen;
public class ModMenuImpl implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return (ConfigScreenFactory<Screen>) SettingsScreen::get;
return parent -> {
SettingsScreen.INSTANCE.prevScreen = parent;
return SettingsScreen.INSTANCE;
};
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.mappings;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.model.ProtocolRange;

View File

@ -34,9 +34,9 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.definition.v1_19_0.provider.CommandArgumentsProvider;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.FinishViaLoadingBaseStartupCallback;
import de.florianmichael.viafabricplus.event.ViaLoadingBaseBuilderCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.FinishViaLoadingBaseStartupCallback;
import de.florianmichael.viafabricplus.base.event.ViaLoadingBaseBuilderCallback;
import de.florianmichael.viafabricplus.protocolhack.command.ViaFabricPlusVLBViaCommandHandler;
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLBPipeline;
import de.florianmichael.viafabricplus.protocolhack.platform.ViaAprilFoolsPlatformImpl;

View File

@ -20,12 +20,10 @@ package de.florianmichael.viafabricplus.protocolhack.provider.vialegacy;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.classic4j.JSPBetaCraftHandler;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage;
import java.util.concurrent.atomic.AtomicReference;
public class ViaFabricPlusClassicMPPassProvider extends ClassicMPPassProvider {
public static String classiCubeMPPass;

View File

@ -19,10 +19,10 @@ package de.florianmichael.viafabricplus.protocolhack.provider.vialegacy;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
@ -37,7 +37,8 @@ public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
mc.getSessionService().joinServer(mc.getSession().getProfile(), mc.getSession().getAccessToken(), serverId);
} catch (Exception e) {
if (AuthenticationSettings.INSTANCE.disconnectIfJoinServerCallFails.getValue()) {
user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get().disconnect(Text.literal(ScreenUtil.prefixedMessage("ViaLegacy fails to verify your session! Please log in into an Account or disable the BetaCraft authentication in the ViaFabricPlus Settings")));
user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get().
disconnect(Text.literal(Formatting.GOLD + "[ViaFabricPlus] " + Formatting.WHITE + Text.translatable("authentication.viafabricplus.error")));
} else {
e.printStackTrace();
}

View File

@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.provider.VLBBaseVersionProvider;

View File

@ -1,34 +0,0 @@
/*
* 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.settings;
@Deprecated
public class ConfigRemapper {
/**
* Remaps the old config format to the new one, will be removed in the future
*/
public static String remapp(String key) {
if (key.equals("bedrock.viafabricplus.set")) key = "authentication.viafabricplus.bedrock";
if (key.startsWith("mppass")) key = key.replace("mppass", "authentication");
if (key.equals("visual.viafabricplus.chunkborderfix")) key = "experimental.viafabricplus.chunkborderfix";
if (key.startsWith("bridge")) key = key.replace("bridge", "general");
return key;
}
}

Some files were not shown because too many files have changed in this diff Show More