mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
added Bridge settings
added more MP Pass related settings changed Debug Hud format updated ClassicItemSelectionScreen
This commit is contained in:
parent
43fb26bcc2
commit
778c0f2169
@ -8,7 +8,7 @@ yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.14
|
||||
|
||||
# viafabricplus
|
||||
mod_version=1.5.9
|
||||
mod_version=1.6.0
|
||||
maven_group=de.florianmichael
|
||||
archives_base_name=viafabricplus
|
||||
|
||||
|
@ -2,8 +2,6 @@ package de.florianmichael.viafabricplus;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import de.florianmichael.viafabricplus.definition.ChatLengthDefinition;
|
||||
@ -16,9 +14,7 @@ import de.florianmichael.viafabricplus.platform.ViaAprilFoolsPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.platform.ViaLegacyPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.provider.*;
|
||||
import de.florianmichael.viafabricplus.settings.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
|
||||
import de.florianmichael.viafabricplus.settings.groups.*;
|
||||
import de.florianmichael.viafabricplus.util.SettingsSave;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
|
||||
@ -26,8 +22,6 @@ import de.florianmichael.vialoadingbase.platform.SubPlatform;
|
||||
import io.netty.channel.DefaultEventLoop;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.metadata.Person;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
@ -111,6 +105,8 @@ public class ViaFabricPlus {
|
||||
|
||||
loadGroup(
|
||||
GeneralSettings.getClassWrapper(),
|
||||
BridgeSettings.getClassWrapper(),
|
||||
MPPassSettings.getClassWrapper(),
|
||||
VisualSettings.getClassWrapper(),
|
||||
DebugSettings.getClassWrapper()
|
||||
);
|
||||
|
@ -40,7 +40,7 @@ public class ClassicItemSelectionScreen extends Screen {
|
||||
|
||||
public void reload(final ComparableProtocolVersion version) {
|
||||
final List<Item> allowedItems = new ArrayList<>();
|
||||
allowedItems.add(Items.OAK_WOOD);
|
||||
allowedItems.add(Items.OAK_LOG);
|
||||
allowedItems.add(Items.OAK_PLANKS);
|
||||
allowedItems.add(Items.STONE);
|
||||
allowedItems.add(Items.COBBLESTONE);
|
||||
@ -92,6 +92,9 @@ public class ClassicItemSelectionScreen extends Screen {
|
||||
allowedItems.add(Items.COBBLESTONE_SLAB);
|
||||
allowedItems.add(Items.ICE);
|
||||
allowedItems.add(Items.SNOW);
|
||||
allowedItems.add(Items.BEDROCK);
|
||||
allowedItems.add(Items.WATER_BUCKET);
|
||||
allowedItems.add(Items.LAVA_BUCKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.bridge;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.ClassicProgressRenderer;
|
||||
import de.florianmichael.viafabricplus.settings.groups.BridgeSettings;
|
||||
import net.minecraft.client.gui.screen.ConnectScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -13,6 +14,8 @@ public class MixinConnectScreen {
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
public void renderClassicProgress(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (!BridgeSettings.getClassWrapper().showClassicLoadingProgressInConnectScreen.getValue()) return;
|
||||
|
||||
ClassicProgressRenderer.renderProgress(matrices);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package de.florianmichael.viafabricplus.injection.mixin.bridge;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.settings.groups.BridgeSettings;
|
||||
import de.florianmichael.viafabricplus.util.ScreenUtil;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
@ -17,18 +19,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mixin(DebugHud.class)
|
||||
public class MixinDebugHud {
|
||||
|
||||
@Inject(method = "getLeftText", at = @At("RETURN"))
|
||||
public void addViaFabricPlusInformation(CallbackInfoReturnable<List<String>> cir) {
|
||||
if (MinecraftClient.getInstance().isInSingleplayer()) return;
|
||||
if (MinecraftClient.getInstance().isInSingleplayer() || !BridgeSettings.getClassWrapper().showExtraInformationInDebugHud.getValue()) return;
|
||||
|
||||
final List<String> information = new ArrayList<>();
|
||||
if (MinecraftClient.getInstance().getNetworkHandler() != null) {
|
||||
information.add("");
|
||||
information.add(Formatting.GOLD + "[ViaFabricPlus]");
|
||||
final UserConnection userConnection = MinecraftClient.getInstance().getNetworkHandler().getConnection().channel.attr(ViaFabricPlus.LOCAL_VIA_CONNECTION).get();
|
||||
|
||||
information.add("Pipeline count: " + userConnection.getProtocolInfo().getPipeline().pipes().size());
|
||||
@ -58,8 +59,7 @@ public class MixinDebugHud {
|
||||
}
|
||||
}
|
||||
}
|
||||
information.add("");
|
||||
}
|
||||
cir.getReturnValue().addAll(information);
|
||||
cir.getReturnValue().addAll(information.stream().map(ScreenUtil::prefixedMessage).toList());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.bridge;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.ClassicProgressRenderer;
|
||||
import de.florianmichael.viafabricplus.settings.groups.BridgeSettings;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -13,6 +14,8 @@ public class MixinDownloadingTerrainScreen {
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
public void renderClassicProgress(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (!BridgeSettings.getClassWrapper().showClassicLoadingProgressInConnectScreen.getValue()) return;
|
||||
|
||||
ClassicProgressRenderer.renderProgress(matrices);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.bridge;
|
||||
|
||||
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
|
||||
import de.florianmichael.viafabricplus.settings.groups.BridgeSettings;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -23,9 +24,11 @@ public abstract class MixinOptionsScreen {
|
||||
|
||||
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/ClickableWidget;)Lnet/minecraft/client/gui/widget/ClickableWidget;", ordinal = 10, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void addValuesButton(CallbackInfo ci, GridWidget gridWidget, GridWidget.Adder adder) {
|
||||
adder.add(this.createButton(Text.literal("ViaFabricPlus").styled(style -> style.withColor(Formatting.GOLD)).append(" ").append("Settings..."), () -> {
|
||||
SettingsScreen.INSTANCE.prevScreen = (OptionsScreen) (Object) this;
|
||||
return SettingsScreen.INSTANCE;
|
||||
}));
|
||||
if (BridgeSettings.getClassWrapper().optionsButtonInGameOptions.getValue()) {
|
||||
adder.add(this.createButton(Text.literal("ViaFabricPlus").styled(style -> style.withColor(Formatting.GOLD)).append(" ").append("Settings..."), () -> {
|
||||
SettingsScreen.INSTANCE.prevScreen = (OptionsScreen) (Object) this;
|
||||
return SettingsScreen.INSTANCE;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.google.common.io.Resources;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.settings.groups.MPPassSettings;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage;
|
||||
@ -18,7 +19,7 @@ public class ViaFabricPlusClassicMPPassProvider extends ClassicMPPassProvider {
|
||||
|
||||
@Override
|
||||
public String getMpPass(UserConnection user) {
|
||||
if (GeneralSettings.getClassWrapper().useBetaCraftAuthentication.getValue()) {
|
||||
if (MPPassSettings.getClassWrapper().useBetaCraftAuthentication.getValue()) {
|
||||
final HandshakeStorage handshakeStorage = user.get(HandshakeStorage.class);
|
||||
return getBetaCraftMpPass(user, user.getProtocolInfo().getUsername(), handshakeStorage.getHostname(), handshakeStorage.getPort());
|
||||
} else {
|
||||
|
@ -1,15 +1,29 @@
|
||||
package de.florianmichael.viafabricplus.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.settings.groups.MPPassSettings;
|
||||
import de.florianmichael.viafabricplus.util.ScreenUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
|
||||
|
||||
public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
|
||||
|
||||
@Override
|
||||
public void sendAuthRequest(UserConnection user, String serverId) throws Throwable {
|
||||
if (!MPPassSettings.getClassWrapper().allowViaLegacyToCallJoinServerToVerifySession.getValue()) return;
|
||||
|
||||
final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
mc.getSessionService().joinServer(mc.getSession().getProfile(), mc.getSession().getAccessToken(), serverId);
|
||||
try {
|
||||
mc.getSessionService().joinServer(mc.getSession().getProfile(), mc.getSession().getAccessToken(), serverId);
|
||||
} catch (Exception e) {
|
||||
if (MPPassSettings.getClassWrapper().disconnectIfJoinServerCallFails.getValue()) {
|
||||
user.getChannel().attr(ViaFabricPlus.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")));
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package de.florianmichael.viafabricplus.settings.groups;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.settings.impl.BooleanSetting;
|
||||
|
||||
public class BridgeSettings extends SettingGroup {
|
||||
private final static BridgeSettings self = new BridgeSettings();
|
||||
|
||||
public final BooleanSetting optionsButtonInGameOptions = new BooleanSetting(this, "Options button in game options", true);
|
||||
public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, "Show extra information in Debug Hud", true);
|
||||
public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, "Show classic loading progress in connect screen", true);
|
||||
|
||||
public BridgeSettings() {
|
||||
super("Bridge");
|
||||
}
|
||||
|
||||
public static BridgeSettings getClassWrapper() {
|
||||
return BridgeSettings.self;
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ public class GeneralSettings extends SettingGroup {
|
||||
public final ModeSetting mainButtonOrientation = new ModeSetting(this, "Main button orientation", "Left; Top", "Right; Top", "Left; Bottom", "Right: Bottom");
|
||||
public final BooleanSetting removeNotAvailableItemsFromCreativeTab = new BooleanSetting(this, "Remove not available items from creative tab", true);
|
||||
public final BooleanSetting automaticallyChangeValuesBasedOnTheCurrentVersion = new BooleanSetting(this, "Automatically change Settings based on the current version", true);
|
||||
public final BooleanSetting useBetaCraftAuthentication = new BooleanSetting(this, "Use BetaCraft authentication", true);
|
||||
|
||||
public GeneralSettings() {
|
||||
super("General");
|
||||
|
@ -0,0 +1,20 @@
|
||||
package de.florianmichael.viafabricplus.settings.groups;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.settings.impl.BooleanSetting;
|
||||
|
||||
public class MPPassSettings extends SettingGroup {
|
||||
private final static MPPassSettings self = new MPPassSettings();
|
||||
|
||||
public final BooleanSetting useBetaCraftAuthentication = new BooleanSetting(this, "Use BetaCraft authentication", true);
|
||||
public final BooleanSetting allowViaLegacyToCallJoinServerToVerifySession = new BooleanSetting(this, "Allow ViaLegacy to call joinServer() to verify session", true);
|
||||
public final BooleanSetting disconnectIfJoinServerCallFails = new BooleanSetting(this, "Disconnect if joinServer() call fails", true);
|
||||
|
||||
public MPPassSettings() {
|
||||
super("MP Pass");
|
||||
}
|
||||
|
||||
public static MPPassSettings getClassWrapper() {
|
||||
return MPPassSettings.self;
|
||||
}
|
||||
}
|
@ -3,10 +3,15 @@ package de.florianmichael.viafabricplus.util;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
public class ScreenUtil {
|
||||
|
||||
public static void playClickSound() {
|
||||
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
}
|
||||
|
||||
public static String prefixedMessage(final String message) {
|
||||
return Formatting.GOLD + "[ViaFabricPlus] " + Formatting.WHITE + message;
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"client": [
|
||||
"base.MixinOptionsScreen",
|
||||
"bridge.MixinOptionsScreen",
|
||||
"bridge.MixinConnectScreen",
|
||||
"bridge.MixinDownloadingTerrainScreen",
|
||||
"fixes.screen.MixinChatScreen",
|
||||
|
Loading…
Reference in New Issue
Block a user