mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
removed ViaFabricPlus-Visual, changed Settings screen
added ModMenu implementation
This commit is contained in:
parent
1c30b26a2a
commit
2572e49849
35
README.md
35
README.md
@ -10,7 +10,7 @@ If you just want to talk or need help with ViaFabricPlus feel free to join my
|
||||
|
||||
## Why?
|
||||
ViaFabricPlus implements ViaLegacy/ViaAprilFools clientside and adds a ton of fixes that improve the game experience, <br>
|
||||
as does [MultiConnect](https://github.com/Earthcomputer/multiconnect) from Earthcomputer.
|
||||
as does [multiconnect](https://github.com/Earthcomputer/multiconnect) from Earthcomputer.
|
||||
### Important: The focus on ViaFabricPlus is on client side fixes, so reporting bugs and contributing is welcome.
|
||||
|
||||
## Dependencies
|
||||
@ -25,13 +25,6 @@ as does [MultiConnect](https://github.com/Earthcomputer/multiconnect) from Earth
|
||||
| MC-Structs | https://github.com/Lenni0451/MCStructs |
|
||||
| ViaLoadingBase | https://github.com/FlorianMichael/ViaLoadingBase |
|
||||
|
||||
## Project structure
|
||||
ViaFabricPlus splits into two major parts:
|
||||
| Part | Description |
|
||||
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| ViaFabricPlus | Core of the project, all fixes here are stable and have been tested many times |
|
||||
| ViaFabricPlus-Visual | Addon for the core, it adds only visual changes between the versions like old textures, <br>optional and not necessary for the gameplay, but recommended. |
|
||||
|
||||
## Setting up a Workspace
|
||||
ViaFabricPlus uses Gradle, to make sure that it is installed properly you can check [Gradle's website](https://gradle.org/install/).
|
||||
1. Clone the repository using `git clone https://github.com/FlorianMichael/ViaFabricPlus`.
|
||||
@ -52,18 +45,11 @@ to make a ViaFabricPlus addon you just have to implement the ViaFabricPlusAddon
|
||||
```java
|
||||
package net.example;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlusAddon;
|
||||
|
||||
public class ViaFabricPlusExampleAddon implements ViaFabricPlusAddon {
|
||||
|
||||
@Override
|
||||
public void onPreLoad() {
|
||||
// called directly after Via* is initialized
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostLoad() {
|
||||
// called after Minecraft is initialized
|
||||
public void onLoad() {
|
||||
// called after ViaVersion and Minecraft is initialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,6 +69,21 @@ To load the addon you have to specify the addon main class as entrypoint in your
|
||||
}
|
||||
```
|
||||
|
||||
### Create Setting Group
|
||||
To create a setting group, you can simply use the SettingGroup class:
|
||||
```java
|
||||
public class ExampleSettingGroup extends SettingGroup {
|
||||
public final static ExampleSettingGroup INSTANCE = new ExampleSettingGroup();
|
||||
|
||||
public final BooleanSetting testValue = new BooleanSetting("Test", false);
|
||||
|
||||
public ExampleSettingGroup() {
|
||||
super("Example");
|
||||
ViaFabricPlus.getClassWrapper().loadGroup(this);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Alternatives
|
||||
- [ClientViaVersion](https://github.com/Gerrygames/ClientViaVersion): Discontinued 5zig plugin.
|
||||
- [multiconnect](https://www.curseforge.com/minecraft/mc-mods/multiconnect): Fabric mod for connecting to older
|
||||
|
@ -1,34 +0,0 @@
|
||||
plugins {
|
||||
id "fabric-loom" version "1.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
archivesBaseName = project.archives_base_name + "-visual"
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
implementation "com.viaversion:viaversion:${project.viaversion_version}"
|
||||
|
||||
implementation "com.github.RaphiMC:ViaLegacy:${project.vialegacy_version}"
|
||||
|
||||
implementation project(":")
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package de.florianmichael.viafabricplus_visual;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlusAddon;
|
||||
import de.florianmichael.viafabricplus.platform.ProtocolRange;
|
||||
import de.florianmichael.viafabricplus.value.impl.ProtocolSyncBooleanValue;
|
||||
import de.florianmichael.viafabricplus_visual.definition.c0_30.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus_visual.definition.v1_8_x.ArmorPointsDefinition;
|
||||
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
public class ViaFabricPlusVisual implements ViaFabricPlusAddon {
|
||||
|
||||
// 1.19.2 -> 1.19
|
||||
public final static ProtocolSyncBooleanValue disableSecureChatWarning = new ProtocolSyncBooleanValue("Disable secure chat warning", ProtocolRange.andOlder(ProtocolVersion.v1_19));
|
||||
|
||||
// 1.19 -> 1.18.2
|
||||
public final static ProtocolSyncBooleanValue hideSignatureIndicator = new ProtocolSyncBooleanValue("Hide signature indicator", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
|
||||
|
||||
// 1.16 -> 1.15.2
|
||||
public final static ProtocolSyncBooleanValue removeNewerFeaturesFromJigsawScreen = new ProtocolSyncBooleanValue("Remove newer features from Jigsaw screen", ProtocolRange.andOlder(ProtocolVersion.v1_15_2));
|
||||
|
||||
// 1.13 -> 1.12.2
|
||||
public final static ProtocolSyncBooleanValue replacePetrifiedOakSlab = new ProtocolSyncBooleanValue("Replace petrified oak slab", new ProtocolRange(ProtocolVersion.v1_12_2, LegacyProtocolVersion.r1_3_1tor1_3_2));
|
||||
|
||||
// 1.9 -> 1.8.x
|
||||
public final static ProtocolSyncBooleanValue emulateArmorHud = new ProtocolSyncBooleanValue("Emulate Armor hud", ProtocolRange.andOlder(ProtocolVersion.v1_8));
|
||||
public final static ProtocolSyncBooleanValue removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanValue("Remove newer features from Command block screen", ProtocolRange.andOlder(ProtocolVersion.v1_8));
|
||||
|
||||
// a1_0_15 -> c0_28toc0_30
|
||||
public final static ProtocolSyncBooleanValue replaceCreativeInventory = new ProtocolSyncBooleanValue("Replace creative inventory", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
|
||||
|
||||
@Override
|
||||
public void onPostLoad() {
|
||||
ArmorPointsDefinition.load();
|
||||
ClassicItemSelectionScreen.create(InternalProtocolList.fromProtocolVersion(LegacyProtocolVersion.c0_28toc0_30));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeVersion(ComparableProtocolVersion protocolVersion) {
|
||||
if (ClassicItemSelectionScreen.INSTANCE != null) {
|
||||
ClassicItemSelectionScreen.INSTANCE.reload(protocolVersion);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
@ -1,39 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "viafabricplus-visual",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "ViaFabricPlus Visual",
|
||||
"description": " ViaFabricPlus addon which adds visual fixes",
|
||||
"authors": [
|
||||
"FlorianMichael",
|
||||
"EnZaXD",
|
||||
"JesseUwU"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://github.com/FlorianMichael/",
|
||||
"sources": "https://github.com/FlorianMichael/ViaFabricPlus"
|
||||
},
|
||||
"entrypoints": {
|
||||
"viafabricplus": [
|
||||
"de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual"
|
||||
]
|
||||
},
|
||||
"license": "GPL-v3",
|
||||
"icon": "assets/viafabricplus-visual/icon.png",
|
||||
"environment": "*",
|
||||
"mixins": [
|
||||
"viafabricplus-visual.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.11",
|
||||
"minecraft": "~1.19.3",
|
||||
"java": ">=17",
|
||||
"viafabricplus": "*"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"parent": "viafabricplus"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "de.florianmichael.viafabricplus_visual.injection.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"MixinChatHud",
|
||||
"MixinChatScreen",
|
||||
"MixinClientPlayerEntity",
|
||||
"MixinClientPlayNetworkHandler",
|
||||
"MixinCommandBlockScreen",
|
||||
"MixinItemRenderer",
|
||||
"MixinJigsawBlockScreen"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"client": [
|
||||
"MixinCreativeInventoryScreen"
|
||||
]
|
||||
}
|
@ -23,7 +23,10 @@ allprojects {
|
||||
}
|
||||
maven {
|
||||
name = "ViaVersion"
|
||||
url "https://repo.viaversion.com"
|
||||
url = "https://repo.viaversion.com"
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.terraformersmc.com/releases"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,7 +39,7 @@ dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
include project(":ViaFabricPlus-Visual")
|
||||
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
|
||||
|
||||
libs "com.github.FlorianMichael:ViaLoadingBase:${project.vialoadingbase_version}"
|
||||
|
||||
|
@ -5,7 +5,7 @@ minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.14
|
||||
|
||||
mod_version=1.4.1
|
||||
mod_version=1.5.1
|
||||
maven_group=de.florianmichael
|
||||
archives_base_name=viafabricplus
|
||||
|
||||
@ -16,3 +16,5 @@ vialegacy_version=29a7082d7f
|
||||
viaaprilfools_version=cd4d0a2973
|
||||
|
||||
mcstructs_text_version=2.2.0
|
||||
|
||||
mod_menu_version=5.0.0
|
||||
|
BIN
image/values.png
BIN
image/values.png
Binary file not shown.
Before Width: | Height: | Size: 392 KiB After Width: | Height: | Size: 401 KiB |
@ -8,5 +8,4 @@ pluginManagement {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
include 'ViaFabricPlus-Visual'
|
||||
|
||||
|
@ -9,12 +9,19 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
import de.florianmichael.viafabricplus.definition.ChatLengthDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.ItemReleaseVersionDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.PackFormatsDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.provider.CommandArgumentsProvider;
|
||||
import de.florianmichael.viafabricplus.definition.v1_8_x.ArmorPointsDefinition;
|
||||
import de.florianmichael.viafabricplus.platform.ViaAprilFoolsPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.platform.ViaLegacyPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.provider.*;
|
||||
import de.florianmichael.viafabricplus.util.SavingSystem;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import de.florianmichael.viafabricplus.util.SettingsSave;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
|
||||
import de.florianmichael.vialoadingbase.platform.SubPlatform;
|
||||
import io.netty.channel.DefaultEventLoop;
|
||||
import io.netty.util.AttributeKey;
|
||||
@ -34,6 +41,7 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.G
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -44,6 +52,8 @@ public class ViaFabricPlus {
|
||||
|
||||
private final static ViaFabricPlus self = new ViaFabricPlus();
|
||||
|
||||
private final List<SettingGroup> settingGroups = new ArrayList<>();
|
||||
|
||||
private final SubPlatform SUB_PLATFORM_VIA_LEGACY = new SubPlatform("ViaLegacy", () -> true, ViaLegacyPlatformImpl::new, protocolVersions -> {
|
||||
final List<ProtocolVersion> legacyProtocols = new ArrayList<>(LegacyProtocolVersion.PROTOCOLS);
|
||||
Collections.reverse(legacyProtocols);
|
||||
@ -123,29 +133,40 @@ public class ViaFabricPlus {
|
||||
ChatLengthDefinition.reload(protocolVersion);
|
||||
});
|
||||
builder.build();
|
||||
|
||||
FabricLoader.getInstance().getEntrypoints("viafabricplus", ViaFabricPlusAddon.class).forEach(ViaFabricPlusAddon::onPreLoad);
|
||||
}
|
||||
|
||||
public void postLoad() throws Exception {
|
||||
SavingSystem.setup();
|
||||
FabricLoader.getInstance().getEntrypoints("viafabricplus", ViaFabricPlusAddon.class).forEach(ViaFabricPlusAddon::onLoad);
|
||||
|
||||
loadGroup(
|
||||
GeneralSettings.getClassWrapper(),
|
||||
VisualSettings.getClassWrapper(),
|
||||
DebugSettings.getClassWrapper()
|
||||
);
|
||||
|
||||
SettingsSave.load(this);
|
||||
|
||||
PackFormatsDefinition.load();
|
||||
ItemReleaseVersionDefinition.load();
|
||||
ArmorPointsDefinition.load();
|
||||
|
||||
ClassicItemSelectionScreen.create(InternalProtocolList.fromProtocolVersion(LegacyProtocolVersion.c0_28toc0_30));
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
this.close();
|
||||
SettingsSave.save(this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
|
||||
FabricLoader.getInstance().getEntrypoints("viafabricplus", ViaFabricPlusAddon.class).forEach(ViaFabricPlusAddon::onPostLoad);
|
||||
}
|
||||
|
||||
public void close() throws Exception {
|
||||
SavingSystem.save();
|
||||
public void loadGroup(final SettingGroup... groups) {
|
||||
this.settingGroups.addAll(Arrays.asList(groups));
|
||||
}
|
||||
|
||||
public List<SettingGroup> getSettingGroups() {
|
||||
return settingGroups;
|
||||
}
|
||||
|
||||
public static ViaFabricPlus getClassWrapper() {
|
||||
|
@ -4,11 +4,7 @@ import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
|
||||
|
||||
public interface ViaFabricPlusAddon {
|
||||
|
||||
default void onPreLoad() {
|
||||
}
|
||||
default void onPostLoad() {
|
||||
}
|
||||
|
||||
default void onLoad() {}
|
||||
default void onChangeVersion(final ComparableProtocolVersion protocolVersion) {
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.florianmichael.viafabricplus_visual.definition.c0_30;
|
||||
package de.florianmichael.viafabricplus.definition.c0_30;
|
||||
|
||||
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
|
||||
import net.minecraft.client.MinecraftClient;
|
@ -1,4 +1,4 @@
|
||||
package de.florianmichael.viafabricplus_visual.definition.v1_8_x;
|
||||
package de.florianmichael.viafabricplus.definition.v1_8_x;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
|
||||
import net.minecraft.client.MinecraftClient;
|
@ -12,7 +12,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class MixinMinecraftClient {
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void postLoad(RunArgs args, CallbackInfo ci) throws Exception {
|
||||
public void postLoad(RunArgs args, CallbackInfo ci) {
|
||||
try {
|
||||
ViaFabricPlus.getClassWrapper().postLoad();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -22,7 +22,7 @@ public class MixinMultiplayerScreen extends Screen {
|
||||
public void addProtocolSelectionButton(CallbackInfo ci) {
|
||||
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.open(this));
|
||||
|
||||
final int orientation = ValueHolder.mainButtonOrientation.getIndex();
|
||||
final int orientation = GeneralSettings.getClassWrapper().mainButtonOrientation.getIndex();
|
||||
switch (orientation) {
|
||||
case 0 -> builder = builder.position(0, 0);
|
||||
case 1 -> builder = builder.position(width - 98, 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.screen.ValuesScreen;
|
||||
import de.florianmichael.viafabricplus.screen.settings.ValuesScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -25,7 +25,7 @@ public class MixinCamera {
|
||||
|
||||
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.BEFORE))
|
||||
public void onUpdateHeight(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
||||
if (!ValueHolder.replaceSneaking.getValue() && ValueHolder.sneakInstant.getValue()) {
|
||||
if (!DebugSettings.getClassWrapper().replaceSneaking.getValue() && DebugSettings.getClassWrapper().sneakInstant.getValue()) {
|
||||
cameraY = lastCameraY = focusedEntity.getStandingEyeHeight();
|
||||
}
|
||||
}
|
||||
@ -34,14 +34,14 @@ public class MixinCamera {
|
||||
public void onUpdateEyeHeight(CallbackInfo ci) {
|
||||
if (this.focusedEntity == null) return;
|
||||
|
||||
if (ValueHolder.replaceSneaking.getValue()) {
|
||||
if (DebugSettings.getClassWrapper().replaceSneaking.getValue()) {
|
||||
ci.cancel();
|
||||
this.lastCameraY = this.cameraY;
|
||||
|
||||
if (this.focusedEntity instanceof PlayerEntity player && !player.isSleeping()) {
|
||||
if (player.isSneaking()) {
|
||||
cameraY = 1.54F;
|
||||
} else if (!ValueHolder.longSneaking.getValue()) {
|
||||
} else if (!DebugSettings.getClassWrapper().longSneaking.getValue()) {
|
||||
cameraY = 1.62F;
|
||||
} else if (cameraY < 1.62F) {
|
||||
float delta = 1.62F - cameraY;
|
||||
|
@ -2,7 +2,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.v1_12_2.SyncInputExecutor;
|
||||
import de.florianmichael.viafabricplus.definition.v1_8_x.InventoryPacketSender;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
@ -76,7 +76,7 @@ public abstract class MixinMinecraftClient {
|
||||
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||
ordinal = 4, shift = At.Shift.BEFORE))
|
||||
public void injectTick(CallbackInfo ci) {
|
||||
if (!ValueHolder.executeInputsInSync.getValue()) return;
|
||||
if (!DebugSettings.getClassWrapper().executeInputsInSync.getValue()) return;
|
||||
|
||||
SyncInputExecutor.callback();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import net.minecraft.client.network.PendingUpdateManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -12,7 +12,7 @@ public class MixinPendingUpdateManager {
|
||||
|
||||
@Inject(method = "incrementSequence", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/PendingUpdateManager;pendingSequence:Z", shift = At.Shift.BEFORE), cancellable = true)
|
||||
public void injectIncrementSequence(CallbackInfoReturnable<PendingUpdateManager> cir) {
|
||||
if (ValueHolder.disableSequencing.getValue()) {
|
||||
if (DebugSettings.getClassWrapper().disableSequencing.getValue()) {
|
||||
cir.setReturnValue((PendingUpdateManager) (Object) this);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.definition.v1_8_x.IdlePacketExecutor;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.input.Input;
|
||||
@ -94,7 +94,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(this.getX(), this.getY(), this.getZ(), this.onGround));
|
||||
} else if (bl4) {
|
||||
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(this.getYaw(), this.getPitch(), this.onGround));
|
||||
} else if (this.lastOnGround != this.onGround || ValueHolder.sendIdlePacket.getValue()) {
|
||||
} else if (this.lastOnGround != this.onGround || DebugSettings.getClassWrapper().sendIdlePacket.getValue()) {
|
||||
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(this.onGround));
|
||||
} else {
|
||||
IdlePacketExecutor.skipIdlePacket();
|
||||
|
@ -2,14 +2,12 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.input;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.definition.v1_12_2.SyncInputExecutor;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@ -18,7 +16,7 @@ public class MixinKeyboard {
|
||||
|
||||
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
public void redirectSync(MinecraftClient instance, Runnable runnable) {
|
||||
if (ValueHolder.executeInputsInSync.getValue()) {
|
||||
if (DebugSettings.getClassWrapper().executeInputsInSync.getValue()) {
|
||||
SyncInputExecutor.trackKeyboardInteraction(runnable);
|
||||
return;
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.input;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.v1_12_2.SyncInputExecutor;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@ -15,7 +13,7 @@ public class MixinMouse {
|
||||
|
||||
@Redirect(method = { "method_29615", "method_22685", "method_22684" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
public void redirectSync(MinecraftClient instance, Runnable runnable) {
|
||||
if (ValueHolder.executeInputsInSync.getValue()) {
|
||||
if (DebugSettings.getClassWrapper().executeInputsInSync.getValue()) {
|
||||
SyncInputExecutor.trackMouseInteraction(runnable);
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import net.minecraft.entity.player.ItemCooldownManager;
|
||||
import net.minecraft.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -13,7 +13,7 @@ public class MixinItemCooldownManager {
|
||||
|
||||
@Inject(method = "set", at = @At("HEAD"), cancellable = true)
|
||||
public void injectSet(Item item, int duration, CallbackInfo ci) {
|
||||
if (ValueHolder.removeCooldowns.getValue()) {
|
||||
if (DebugSettings.getClassWrapper().removeCooldowns.getValue()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.ItemReleaseVersionDefinition;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
@ -14,7 +14,7 @@ public class MixinItemGroup_EntriesImpl {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z"))
|
||||
public boolean removeUnknownItems(Item instance, FeatureSet featureSet) {
|
||||
if (!ValueHolder.removeNotAvailableItemsFromCreativeTab.getValue() || MinecraftClient.getInstance().isInSingleplayer()) return instance.isEnabled(featureSet);
|
||||
if (!GeneralSettings.getClassWrapper().removeNotAvailableItemsFromCreativeTab.getValue() || MinecraftClient.getInstance().isInSingleplayer()) return instance.isEnabled(featureSet);
|
||||
if (ItemReleaseVersionDefinition.getCurrentMap().contains(instance)) return instance.isEnabled(featureSet);
|
||||
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
@ -23,12 +23,12 @@ public class MixinItemGroups {
|
||||
|
||||
@Redirect(method = "displayParametersMatch", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/featuretoggle/FeatureSet;equals(Ljava/lang/Object;)Z"))
|
||||
private static boolean adjustLastVersionMatchCheck(FeatureSet instance, Object o) {
|
||||
return instance.equals(o) && viafabricplus_version == ViaLoadingBase.getTargetVersion() && viafabricplus_state == ValueHolder.removeNotAvailableItemsFromCreativeTab.getValue();
|
||||
return instance.equals(o) && viafabricplus_version == ViaLoadingBase.getTargetVersion() && viafabricplus_state == GeneralSettings.getClassWrapper().removeNotAvailableItemsFromCreativeTab.getValue();
|
||||
}
|
||||
|
||||
@Inject(method = "updateDisplayParameters", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemGroups;updateEntries(Lnet/minecraft/resource/featuretoggle/FeatureSet;Z)V", shift = At.Shift.BEFORE))
|
||||
private static void trackLastVersion(FeatureSet enabledFeatures, boolean operatorEnabled, CallbackInfoReturnable<Boolean> cir) {
|
||||
viafabricplus_version = ViaLoadingBase.getTargetVersion();
|
||||
viafabricplus_state = ValueHolder.removeNotAvailableItemsFromCreativeTab.getValue();
|
||||
viafabricplus_state = GeneralSettings.getClassWrapper().removeNotAvailableItemsFromCreativeTab.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.merchant;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.DebugSettings;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@ -34,7 +34,7 @@ public abstract class MixinMerchantScreen extends HandledScreen<MerchantScreenHa
|
||||
|
||||
@Inject(method = "syncRecipeIndex", at = @At("HEAD"))
|
||||
public void smoothOutRecipeIndex(CallbackInfo ci) {
|
||||
if (ValueHolder.smoothOutMerchantScreens.getValue()) {
|
||||
if (DebugSettings.getClassWrapper().smoothOutMerchantScreens.getValue()) {
|
||||
if (protocolhack_previousRecipeIndex != selectedIndex) {
|
||||
int direction = protocolhack_previousRecipeIndex < selectedIndex ? 1 : -1;
|
||||
for (int smooth = protocolhack_previousRecipeIndex + direction /* don't send the page we already are on */; smooth != selectedIndex; smooth += direction) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
@ -13,7 +13,7 @@ public class MixinChatHud {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHudLine$Visible;indicator()Lnet/minecraft/client/gui/hud/MessageIndicator;"), require = 0)
|
||||
public MessageIndicator removeIndicators(ChatHudLine.Visible instance) {
|
||||
if (ViaFabricPlusVisual.hideSignatureIndicator.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().hideSignatureIndicator.getValue()) {
|
||||
return null;
|
||||
}
|
||||
return instance.indicator();
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
import net.minecraft.client.gui.screen.ChatScreen;
|
||||
@ -13,7 +13,7 @@ public class MixinChatScreen {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;getIndicatorAt(DD)Lnet/minecraft/client/gui/hud/MessageIndicator;"))
|
||||
public MessageIndicator removeIndicator(ChatHud instance, double mouseX, double mouseY) {
|
||||
if (ViaFabricPlusVisual.hideSignatureIndicator.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().hideSignatureIndicator.getValue()) {
|
||||
return null;
|
||||
}
|
||||
return instance.getIndicatorAt(mouseX, mouseY);
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.s2c.play.ServerMetadataS2CPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -12,6 +12,6 @@ public class MixinClientPlayNetworkHandler {
|
||||
|
||||
@Redirect(method = "onServerMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ServerMetadataS2CPacket;isSecureChatEnforced()Z"))
|
||||
public boolean removeSecureChatWarning(ServerMetadataS2CPacket instance) {
|
||||
return instance.isSecureChatEnforced() || ViaFabricPlusVisual.disableSecureChatWarning.getValue();
|
||||
return instance.isSecureChatEnforced() || VisualSettings.getClassWrapper().disableSecureChatWarning.getValue();
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus_visual.definition.v1_8_x.ArmorPointsDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.v1_8_x.ArmorPointsDefinition;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
@ -17,7 +17,7 @@ public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||
|
||||
@Override
|
||||
public int getArmor() {
|
||||
if (ViaFabricPlusVisual.emulateArmorHud.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().emulateArmorHud.getValue()) {
|
||||
return ArmorPointsDefinition.sum();
|
||||
}
|
||||
return super.getArmor();
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.client.gui.screen.ingame.CommandBlockScreen;
|
||||
import net.minecraft.client.gui.widget.CyclingButtonWidget;
|
||||
@ -26,7 +26,7 @@ public abstract class MixinCommandBlockScreen {
|
||||
|
||||
@Inject(method = "init", at = @At("TAIL"))
|
||||
private void injectInit(CallbackInfo ci) {
|
||||
if (ViaFabricPlusVisual.removeNewerFeaturesFromCommandBlockScreen.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().removeNewerFeaturesFromCommandBlockScreen.getValue()) {
|
||||
modeButton.visible = false;
|
||||
conditionalModeButton.visible = false;
|
||||
redstoneTriggerButton.visible = false;
|
@ -1,7 +1,7 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus_visual.definition.c0_30.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -14,7 +14,7 @@ public class MixinCreativeInventoryScreen {
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void replaceCreativeMenu(CallbackInfo ci) {
|
||||
if (ViaFabricPlusVisual.replaceCreativeInventory.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().replaceCreativeInventory.getValue()) {
|
||||
MinecraftClient.getInstance().setScreen(ClassicItemSelectionScreen.INSTANCE);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.client.render.item.ItemModels;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
@ -22,7 +22,7 @@ public class MixinItemRenderer {
|
||||
|
||||
@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
|
||||
public void removeModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> cir) {
|
||||
if (ViaFabricPlusVisual.replacePetrifiedOakSlab.getValue() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) {
|
||||
if (VisualSettings.getClassWrapper().replacePetrifiedOakSlab.getValue() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) {
|
||||
cir.setReturnValue(this.models.getModelManager().getMissingModel());
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viafabricplus_visual.injection.mixin;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
|
||||
import de.florianmichael.viafabricplus.setting.groups.VisualSettings;
|
||||
import net.minecraft.block.entity.JigsawBlockEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.JigsawBlockScreen;
|
||||
@ -33,7 +33,7 @@ public class MixinJigsawBlockScreen extends Screen {
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void injectInit(CallbackInfo ci) {
|
||||
if (ViaFabricPlusVisual.removeNewerFeaturesFromJigsawScreen.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().removeNewerFeaturesFromJigsawScreen.getValue()) {
|
||||
nameField.active = false;
|
||||
jointRotationButton.active = false;
|
||||
int index = children().indexOf(jointRotationButton);
|
||||
@ -45,7 +45,7 @@ public class MixinJigsawBlockScreen extends Screen {
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
public void injectRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (ViaFabricPlusVisual.removeNewerFeaturesFromJigsawScreen.getValue()) {
|
||||
if (VisualSettings.getClassWrapper().removeNewerFeaturesFromJigsawScreen.getValue()) {
|
||||
nameField.setText(targetField.getText());
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package de.florianmichael.viafabricplus.integration;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import de.florianmichael.viafabricplus.screen.settings.ValuesScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
public class ModMenuImpl implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return (ConfigScreenFactory<Screen>) parent -> {
|
||||
ValuesScreen.INSTANCE.prevScreen = parent;
|
||||
return ValuesScreen.INSTANCE;
|
||||
};
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.Resources;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
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 +18,7 @@ public class ViaFabricPlusClassicMPPassProvider extends ClassicMPPassProvider {
|
||||
|
||||
@Override
|
||||
public String getMpPass(UserConnection user) {
|
||||
if (ValueHolder.useBetaCraftAuthentication.getValue()) {
|
||||
if (GeneralSettings.getClassWrapper().useBetaCraftAuthentication.getValue()) {
|
||||
final HandshakeStorage handshakeStorage = user.get(HandshakeStorage.class);
|
||||
return getBetaCraftMpPass(user, user.getProtocolInfo().getUsername(), handshakeStorage.getHostname(), handshakeStorage.getPort());
|
||||
} else {
|
||||
|
@ -12,7 +12,6 @@ import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@ -89,7 +88,7 @@ public class ProtocolSelectionScreen extends Screen {
|
||||
matrices.push();
|
||||
matrices.translate(x, y - 1, 0);
|
||||
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
drawCenteredText(matrices, textRenderer, (isSelected ? Formatting.UNDERLINE : "") + this.protocolVersion.getName(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, isSelected ? Color.GREEN.getRGB() : Color.RED.getRGB());
|
||||
drawCenteredText(matrices, textRenderer, this.protocolVersion.getName(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, isSelected ? Color.GREEN.getRGB() : Color.RED.getRGB());
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
@ -1,136 +0,0 @@
|
||||
package de.florianmichael.viafabricplus.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.util.ScreenUtil;
|
||||
import de.florianmichael.viafabricplus.value.AbstractValue;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.value.impl.BooleanValue;
|
||||
import de.florianmichael.viafabricplus.value.impl.ModeValue;
|
||||
import de.florianmichael.viafabricplus.value.impl.ProtocolSyncBooleanValue;
|
||||
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.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.Format;
|
||||
import java.util.Arrays;
|
||||
|
||||
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
|
||||
public class ValuesScreen extends Screen {
|
||||
public final static ValuesScreen INSTANCE = new ValuesScreen();
|
||||
public Screen prevScreen;
|
||||
|
||||
protected ValuesScreen() {
|
||||
super(Text.literal("Values"));
|
||||
}
|
||||
|
||||
public static void open(final Screen current) {
|
||||
INSTANCE.prevScreen = current;
|
||||
MinecraftClient.getInstance().setScreen(INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
|
||||
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height + 5, (textRenderer.fontHeight + 2) * 2));
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(0, height - 20).size(20, 20).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
||||
drawCenteredText(matrices, textRenderer, "Press right mouse button for toggling protocol sync", width / 2, 3, -1);
|
||||
drawCenteredText(matrices, textRenderer, "Press left mouse button for normal toggling", width / 2, textRenderer.fontHeight + 2 + 3, -1);
|
||||
drawCenteredText(matrices, textRenderer, "Values that have sync enabled will be toggled depending on the target version.", width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
client.setScreen(prevScreen);
|
||||
}
|
||||
|
||||
public static class SlotList extends AlwaysSelectedEntryListWidget<ValueSlot> {
|
||||
|
||||
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
|
||||
super(minecraftClient, width, height, top, bottom, entryHeight);
|
||||
|
||||
ValueHolder.values.stream().map(ValueSlot::new).forEach(this::addEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() {
|
||||
return super.getRowWidth() + 140;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarPositionX() {
|
||||
return this.width - 5;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValueSlot extends AlwaysSelectedEntryListWidget.Entry<ValueSlot> {
|
||||
private final AbstractValue<?> value;
|
||||
|
||||
public ValueSlot(AbstractValue<?> value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getNarration() {
|
||||
return Text.literal(this.value.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (value instanceof BooleanValue booleanValue) {
|
||||
booleanValue.setValue(!booleanValue.getValue());
|
||||
ScreenUtil.playClickSound();
|
||||
}
|
||||
if (value instanceof ProtocolSyncBooleanValue protocolSyncBooleanValue) {
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
|
||||
protocolSyncBooleanValue.setSyncWithProtocol(!protocolSyncBooleanValue.isSyncWithProtocol());
|
||||
ScreenUtil.playClickSound();
|
||||
}
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||
protocolSyncBooleanValue.setValue(!protocolSyncBooleanValue.getValue());
|
||||
ScreenUtil.playClickSound();
|
||||
}
|
||||
}
|
||||
if (value instanceof ModeValue modeValue) {
|
||||
final int currentIndex = Arrays.stream(modeValue.getOptions()).toList().indexOf(modeValue.value) + 1;
|
||||
modeValue.setValue(currentIndex > modeValue.getOptions().length - 1 ? 0 : currentIndex);
|
||||
ScreenUtil.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);
|
||||
fill(matrices, 0, 0, entryWidth, entryHeight, Integer.MIN_VALUE);
|
||||
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
if (value instanceof BooleanValue booleanValue) {
|
||||
final boolean isEnabled = booleanValue.getValue();
|
||||
drawStringWithShadow(matrices, textRenderer, booleanValue.getName(), 3, entryHeight / 2 - textRenderer.fontHeight / 2, isEnabled ? Color.GREEN.getRGB() : Color.RED.getRGB());
|
||||
} else if (value instanceof ProtocolSyncBooleanValue protocolSyncBooleanValue) {
|
||||
final boolean isEnabled = protocolSyncBooleanValue.getValue();
|
||||
Color color = isEnabled ? Color.GREEN : Color.RED;
|
||||
if (protocolSyncBooleanValue.isSyncWithProtocol()) {
|
||||
drawStringWithShadow(matrices, textRenderer, "Sync", entryWidth - textRenderer.getWidth("Sync") - 3, entryHeight / 2 - textRenderer.fontHeight / 2, Color.ORANGE.getRGB());
|
||||
}
|
||||
drawStringWithShadow(matrices, textRenderer, protocolSyncBooleanValue.getName(), 3, entryHeight / 2 - textRenderer.fontHeight / 2, color.getRGB());
|
||||
} else if (value instanceof ModeValue modeValue) {
|
||||
drawStringWithShadow(matrices, textRenderer, modeValue.getName() + ": " + Formatting.GOLD + modeValue.getValue(), 3, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.screen.settings;
|
||||
|
||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||
|
||||
public abstract class DummySlot extends AlwaysSelectedEntryListWidget.Entry<DummySlot> {
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package de.florianmichael.viafabricplus.screen.settings;
|
||||
|
||||
import de.florianmichael.viafabricplus.setting.AbstractSetting;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.setting.impl.BooleanSetting;
|
||||
import de.florianmichael.viafabricplus.setting.impl.ModeSetting;
|
||||
import de.florianmichael.viafabricplus.setting.impl.ProtocolSyncBooleanSetting;
|
||||
import de.florianmichael.viafabricplus.util.ScreenUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SettingSlot extends DummySlot {
|
||||
private final AbstractSetting<?> value;
|
||||
|
||||
public SettingSlot(AbstractSetting<?> value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getNarration() {
|
||||
return Text.literal(this.value.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (value instanceof BooleanSetting booleanValue) {
|
||||
booleanValue.setValue(!booleanValue.getValue());
|
||||
ScreenUtil.playClickSound();
|
||||
}
|
||||
if (value instanceof ModeSetting modeValue) {
|
||||
final int currentIndex = Arrays.stream(modeValue.getOptions()).toList().indexOf(modeValue.value) + 1;
|
||||
modeValue.setValue(currentIndex > modeValue.getOptions().length - 1 ? 0 : currentIndex);
|
||||
ScreenUtil.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);
|
||||
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
if (value instanceof BooleanSetting booleanValue) {
|
||||
final String text = booleanValue.getValue() ? "On" : "Off";
|
||||
Color color = booleanValue.getValue() ? Color.GREEN : Color.RED;
|
||||
|
||||
final int length = textRenderer.drawWithShadow(matrices, Formatting.GRAY + booleanValue.getName(), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
|
||||
if (value instanceof ProtocolSyncBooleanSetting protocolSyncBooleanValue) {
|
||||
textRenderer.drawWithShadow(matrices, "(" + protocolSyncBooleanValue.getProtocolRange().toString() + ")", length + 2, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
|
||||
if (GeneralSettings.getClassWrapper().automaticallyChangeValuesBasedOnTheCurrentVersion.getValue()) color = color.darker().darker();
|
||||
}
|
||||
|
||||
textRenderer.drawWithShadow(matrices, text, entryWidth - textRenderer.getWidth(text) - 3 - 3, entryHeight / 2F - textRenderer.fontHeight / 2F, color.getRGB());
|
||||
} else if (value instanceof ModeSetting modeValue) {
|
||||
textRenderer.drawWithShadow(matrices, Formatting.GRAY + modeValue.getName(), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
|
||||
textRenderer.drawWithShadow(matrices, modeValue.getValue(), entryWidth - textRenderer.getWidth(modeValue.getValue()) - 3 - 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package de.florianmichael.viafabricplus.screen.settings;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
public class TitleSlot extends DummySlot {
|
||||
private final String name;
|
||||
|
||||
public TitleSlot(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getNarration() {
|
||||
return Text.literal(this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(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;
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(x, y, 0);
|
||||
textRenderer.drawWithShadow(matrices, Formatting.BOLD + this.name, 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package de.florianmichael.viafabricplus.screen.settings;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.setting.AbstractSetting;
|
||||
import de.florianmichael.viafabricplus.setting.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 ValuesScreen extends Screen {
|
||||
public final static ValuesScreen INSTANCE = new ValuesScreen();
|
||||
public Screen prevScreen;
|
||||
|
||||
protected ValuesScreen() {
|
||||
super(Text.literal("Values"));
|
||||
}
|
||||
|
||||
@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(0, height - 20).size(20, 20).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
||||
matrices.push();
|
||||
matrices.scale(2F, 2F, 2F);
|
||||
drawCenteredText(matrices, textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
|
||||
matrices.pop();
|
||||
drawCenteredText(matrices, textRenderer, "https://github.com/FlorianMichael/ViaFabricPlus", width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
client.setScreen(prevScreen);
|
||||
}
|
||||
|
||||
public static class SlotList extends AlwaysSelectedEntryListWidget<DummySlot> {
|
||||
|
||||
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
|
||||
super(minecraftClient, width, height, top, bottom, entryHeight);
|
||||
|
||||
for (SettingGroup group : ViaFabricPlus.getClassWrapper().getSettingGroups()) {
|
||||
this.addEntry(new TitleSlot(group.getName()));
|
||||
for (AbstractSetting<?> setting : group.getSettings()) {
|
||||
this.addEntry(new SettingSlot(setting));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() {
|
||||
return super.getRowWidth() + 140;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarPositionX() {
|
||||
return this.width - 5;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,20 @@
|
||||
package de.florianmichael.viafabricplus.value;
|
||||
package de.florianmichael.viafabricplus.setting;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public abstract class AbstractValue<T> {
|
||||
public abstract class AbstractSetting<T> {
|
||||
private final String name;
|
||||
private final T defaultValue;
|
||||
|
||||
public T value;
|
||||
|
||||
public AbstractValue(final String name, final T defaultValue) {
|
||||
public AbstractSetting(final SettingGroup parent, final String name, final T defaultValue) {
|
||||
this.name = name;
|
||||
this.defaultValue = defaultValue;
|
||||
|
||||
this.value = defaultValue;
|
||||
|
||||
ValueHolder.values.add(this);
|
||||
parent.getSettings().add(this);
|
||||
}
|
||||
|
||||
public abstract void write(final JsonObject object);
|
@ -0,0 +1,21 @@
|
||||
package de.florianmichael.viafabricplus.setting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SettingGroup {
|
||||
private final List<AbstractSetting<?>> settings = new ArrayList<>();
|
||||
private final String name;
|
||||
|
||||
public SettingGroup(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<AbstractSetting<?>> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package de.florianmichael.viafabricplus.setting.groups;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.platform.ProtocolRange;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.setting.impl.ProtocolSyncBooleanSetting;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
public class DebugSettings extends SettingGroup {
|
||||
public static final DebugSettings self = new DebugSettings();
|
||||
|
||||
// 1.19 -> 1.18.2
|
||||
public final ProtocolSyncBooleanSetting disableSequencing = new ProtocolSyncBooleanSetting(this, "Disable sequencing", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
|
||||
|
||||
// 1.14 -> 1.13.2
|
||||
public final ProtocolSyncBooleanSetting smoothOutMerchantScreens = new ProtocolSyncBooleanSetting(this, "Smooth out merchant screens", ProtocolRange.andOlder(ProtocolVersion.v1_13_2));
|
||||
|
||||
// 1.13 -> 1.12.2
|
||||
public final ProtocolSyncBooleanSetting executeInputsInSync = new ProtocolSyncBooleanSetting(this, "Execute inputs in sync", ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
|
||||
public final ProtocolSyncBooleanSetting sneakInstant = new ProtocolSyncBooleanSetting(this, "Sneak instant", new ProtocolRange(ProtocolVersion.v1_12_2, ProtocolVersion.v1_8));
|
||||
|
||||
// 1.9 -> 1.8.x
|
||||
public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, "Remove cooldowns", ProtocolRange.andOlder(ProtocolVersion.v1_8));
|
||||
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, "Send idle packet", new ProtocolRange(ProtocolVersion.v1_8, LegacyProtocolVersion.r1_3_1tor1_3_2));
|
||||
|
||||
// 1.8.x -> 1.7.6
|
||||
public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, "Replace sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
|
||||
public final ProtocolSyncBooleanSetting longSneaking = new ProtocolSyncBooleanSetting(this, "Long sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
|
||||
|
||||
public DebugSettings() {
|
||||
super("Debug");
|
||||
}
|
||||
|
||||
public static DebugSettings getClassWrapper() {
|
||||
return DebugSettings.self;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package de.florianmichael.viafabricplus.setting.groups;
|
||||
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.setting.impl.BooleanSetting;
|
||||
import de.florianmichael.viafabricplus.setting.impl.ModeSetting;
|
||||
|
||||
public class GeneralSettings extends SettingGroup {
|
||||
private final static GeneralSettings self = new GeneralSettings();
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public static GeneralSettings getClassWrapper() {
|
||||
return GeneralSettings.self;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package de.florianmichael.viafabricplus.setting.groups;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.platform.ProtocolRange;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.setting.impl.ProtocolSyncBooleanSetting;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
public class VisualSettings extends SettingGroup {
|
||||
public final static VisualSettings self = new VisualSettings();
|
||||
|
||||
// 1.19.2 -> 1.19
|
||||
public final ProtocolSyncBooleanSetting disableSecureChatWarning = new ProtocolSyncBooleanSetting(this, "Disable secure chat warning", ProtocolRange.andOlder(ProtocolVersion.v1_19));
|
||||
|
||||
// 1.19 -> 1.18.2
|
||||
public final ProtocolSyncBooleanSetting hideSignatureIndicator = new ProtocolSyncBooleanSetting(this, "Hide signature indicator", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
|
||||
|
||||
// 1.16 -> 1.15.2
|
||||
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromJigsawScreen = new ProtocolSyncBooleanSetting(this, "Remove newer features from Jigsaw screen", ProtocolRange.andOlder(ProtocolVersion.v1_15_2));
|
||||
|
||||
// 1.13 -> 1.12.2
|
||||
public final ProtocolSyncBooleanSetting replacePetrifiedOakSlab = new ProtocolSyncBooleanSetting(this, "Replace petrified oak slab", new ProtocolRange(ProtocolVersion.v1_12_2, LegacyProtocolVersion.r1_3_1tor1_3_2));
|
||||
|
||||
// 1.9 -> 1.8.x
|
||||
public final ProtocolSyncBooleanSetting emulateArmorHud = new ProtocolSyncBooleanSetting(this, "Emulate Armor hud", ProtocolRange.andOlder(ProtocolVersion.v1_8));
|
||||
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanSetting(this, "Remove newer features from Command block screen", ProtocolRange.andOlder(ProtocolVersion.v1_8));
|
||||
|
||||
// a1_0_15 -> c0_28toc0_30
|
||||
public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, "Replace creative inventory", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
|
||||
|
||||
public VisualSettings() {
|
||||
super("Visual");
|
||||
}
|
||||
|
||||
public static VisualSettings getClassWrapper() {
|
||||
return VisualSettings.self;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package de.florianmichael.viafabricplus.setting.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.setting.AbstractSetting;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
|
||||
public class BooleanSetting extends AbstractSetting<Boolean> {
|
||||
|
||||
public BooleanSetting(SettingGroup parent, String name, Boolean defaultValue) {
|
||||
super(parent, name, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonObject object) {
|
||||
object.addProperty(getName(), getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(JsonObject object) {
|
||||
if (!object.has(getName())) return;
|
||||
|
||||
setValue(object.get(getName()).getAsBoolean());
|
||||
}
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
package de.florianmichael.viafabricplus.value.impl;
|
||||
package de.florianmichael.viafabricplus.setting.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.value.AbstractValue;
|
||||
import de.florianmichael.viafabricplus.setting.AbstractSetting;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ModeValue extends AbstractValue<String> {
|
||||
public class ModeSetting extends AbstractSetting<String> {
|
||||
private final String[] options;
|
||||
|
||||
public ModeValue(String name, String... options) {
|
||||
super(name, options[0]);
|
||||
public ModeSetting(SettingGroup parent, String name, String... options) {
|
||||
super(parent, name, options[0]);
|
||||
this.options = options;
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package de.florianmichael.viafabricplus.setting.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.platform.ProtocolRange;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
import de.florianmichael.viafabricplus.setting.groups.GeneralSettings;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
|
||||
public class ProtocolSyncBooleanSetting extends BooleanSetting {
|
||||
private final ProtocolRange protocolRange;
|
||||
|
||||
public ProtocolSyncBooleanSetting(SettingGroup parent, String name, ProtocolRange protocolRange) {
|
||||
super(parent, name, true);
|
||||
|
||||
this.protocolRange = protocolRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonObject object) {
|
||||
object.addProperty(getName(), getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(JsonObject object) {
|
||||
if (!object.has(getName())) return;
|
||||
|
||||
setValue(object.get(getName()).getAsBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
if (GeneralSettings.getClassWrapper().automaticallyChangeValuesBasedOnTheCurrentVersion.getValue()) return this.getProtocolRange().contains(ViaLoadingBase.getTargetVersion());
|
||||
|
||||
return super.getValue();
|
||||
}
|
||||
|
||||
public ProtocolRange getProtocolRange() {
|
||||
return protocolRange;
|
||||
}
|
||||
}
|
@ -4,38 +4,42 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.value.AbstractValue;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.viafabricplus.setting.AbstractSetting;
|
||||
import de.florianmichael.viafabricplus.setting.SettingGroup;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class SavingSystem {
|
||||
public class SettingsSave {
|
||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public final static File CONFIG_FILE = new File(ViaFabricPlus.RUN_DIRECTORY, "settings.json");
|
||||
|
||||
public static void setup() throws FileNotFoundException {
|
||||
public static void load(final ViaFabricPlus viaFabricPlus) throws Exception {
|
||||
if (CONFIG_FILE.exists()) {
|
||||
final JsonObject parentNode = GSON.fromJson(new FileReader(CONFIG_FILE), JsonObject.class).getAsJsonObject();
|
||||
if (parentNode.has("protocol")) {
|
||||
ViaLoadingBase.getClassWrapper().reload(InternalProtocolList.fromProtocolId(parentNode.get("protocol").getAsInt()));
|
||||
}
|
||||
for (AbstractValue<?> value : ValueHolder.values) {
|
||||
value.read(parentNode);
|
||||
for (SettingGroup group : viaFabricPlus.getSettingGroups()) {
|
||||
for (AbstractSetting<?> setting : group.getSettings()) {
|
||||
setting.read(parentNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() throws IOException {
|
||||
public static void save(final ViaFabricPlus viaFabricPlus) throws IOException {
|
||||
CONFIG_FILE.delete();
|
||||
CONFIG_FILE.createNewFile();
|
||||
|
||||
try (final FileWriter fw = new FileWriter(CONFIG_FILE)) {
|
||||
final JsonObject parentNode = new JsonObject();
|
||||
parentNode.addProperty("protocol", ViaLoadingBase.getTargetVersion().getVersion());
|
||||
for (AbstractValue<?> value : ValueHolder.values) {
|
||||
value.write(parentNode);
|
||||
for (SettingGroup group : viaFabricPlus.getSettingGroups()) {
|
||||
for (AbstractSetting<?> setting : group.getSettings()) {
|
||||
setting.write(parentNode);
|
||||
}
|
||||
}
|
||||
fw.write(GSON.toJson(parentNode));
|
||||
fw.flush();
|
@ -1,40 +0,0 @@
|
||||
package de.florianmichael.viafabricplus.value;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.platform.ProtocolRange;
|
||||
import de.florianmichael.viafabricplus.value.impl.BooleanValue;
|
||||
import de.florianmichael.viafabricplus.value.impl.ModeValue;
|
||||
import de.florianmichael.viafabricplus.value.impl.ProtocolSyncBooleanValue;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ValueHolder {
|
||||
public final static List<AbstractValue<?>> values = new ArrayList<>();
|
||||
|
||||
// General settings
|
||||
public static final ModeValue mainButtonOrientation = new ModeValue("Main button orientation", "Left; Top", "Right; Top", "Left; Bottom", "Right: Bottom");
|
||||
public static final BooleanValue removeNotAvailableItemsFromCreativeTab = new BooleanValue("Remove not available items from creative tab", true);
|
||||
|
||||
// 1.19 -> 1.18.2
|
||||
public static final ProtocolSyncBooleanValue disableSequencing = new ProtocolSyncBooleanValue("Disable sequencing", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
|
||||
|
||||
// 1.14 -> 1.13.2
|
||||
public static final ProtocolSyncBooleanValue smoothOutMerchantScreens = new ProtocolSyncBooleanValue("Smooth out merchant screens", ProtocolRange.andOlder(ProtocolVersion.v1_13_2));
|
||||
|
||||
// 1.13 -> 1.12.2
|
||||
public static final ProtocolSyncBooleanValue executeInputsInSync = new ProtocolSyncBooleanValue("Execute inputs in sync", ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
|
||||
public static final ProtocolSyncBooleanValue sneakInstant = new ProtocolSyncBooleanValue("Sneak instant", new ProtocolRange(ProtocolVersion.v1_12_2, ProtocolVersion.v1_8));
|
||||
|
||||
// 1.9 -> 1.8.x
|
||||
public static final ProtocolSyncBooleanValue removeCooldowns = new ProtocolSyncBooleanValue("Remove cooldowns", ProtocolRange.andOlder(ProtocolVersion.v1_8));
|
||||
public static final ProtocolSyncBooleanValue sendIdlePacket = new ProtocolSyncBooleanValue("Send idle packet", new ProtocolRange(ProtocolVersion.v1_8, LegacyProtocolVersion.r1_3_1tor1_3_2));
|
||||
|
||||
// 1.8.x -> 1.7.6
|
||||
public static final ProtocolSyncBooleanValue replaceSneaking = new ProtocolSyncBooleanValue("Replace sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
|
||||
public static final ProtocolSyncBooleanValue longSneaking = new ProtocolSyncBooleanValue("Long sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
|
||||
|
||||
// a1_0_15 -> c0_28toc0_30
|
||||
public static final ProtocolSyncBooleanValue useBetaCraftAuthentication = new ProtocolSyncBooleanValue("Use BetaCraft authentication", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package de.florianmichael.viafabricplus.value.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.value.AbstractValue;
|
||||
|
||||
public class BooleanValue extends AbstractValue<Boolean> {
|
||||
|
||||
public BooleanValue(String name, Boolean defaultValue) {
|
||||
super(name, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonObject object) {
|
||||
object.addProperty(getName(), getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(JsonObject object) {
|
||||
if (!object.has(getName())) return;
|
||||
|
||||
setValue(object.get(getName()).getAsBoolean());
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package de.florianmichael.viafabricplus.value.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.platform.ProtocolRange;
|
||||
import de.florianmichael.viafabricplus.value.AbstractValue;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
|
||||
public class ProtocolSyncBooleanValue extends AbstractValue<Boolean> {
|
||||
private final ProtocolRange protocolRange;
|
||||
|
||||
private boolean syncWithProtocol;
|
||||
|
||||
public ProtocolSyncBooleanValue(String name, ProtocolRange protocolRange) {
|
||||
super(name + " (" + protocolRange.toString() + ")", true);
|
||||
|
||||
this.protocolRange = protocolRange;
|
||||
this.syncWithProtocol = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonObject object) {
|
||||
final JsonObject valueNode = new JsonObject();
|
||||
|
||||
valueNode.addProperty("value", this.getValue());
|
||||
valueNode.addProperty("sync-with-protocol", this.isSyncWithProtocol());
|
||||
|
||||
object.add(getName(), valueNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(JsonObject object) {
|
||||
if (!object.has(getName())) return;
|
||||
final JsonObject valueNode = object.get(getName()).getAsJsonObject();
|
||||
|
||||
setValue(valueNode.get("value").getAsBoolean());
|
||||
setSyncWithProtocol(valueNode.get("sync-with-protocol").getAsBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
if (this.syncWithProtocol) return protocolRange.contains(ViaLoadingBase.getTargetVersion());
|
||||
return super.getValue();
|
||||
}
|
||||
|
||||
public boolean isSyncWithProtocol() {
|
||||
return syncWithProtocol;
|
||||
}
|
||||
|
||||
public void setSyncWithProtocol(boolean syncWithProtocol) {
|
||||
this.syncWithProtocol = syncWithProtocol;
|
||||
}
|
||||
|
||||
public ProtocolRange getProtocolRange() {
|
||||
return protocolRange;
|
||||
}
|
||||
}
|
@ -18,6 +18,11 @@
|
||||
"license": "GPL-v3",
|
||||
"icon": "assets/viafabricplus/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"modmenu": [
|
||||
"de.florianmichael.viafabricplus.integration.ModMenuImpl"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"viafabricplus.mixins.json"
|
||||
],
|
||||
|
@ -133,6 +133,14 @@
|
||||
"base.MixinOptionsScreen",
|
||||
"bridge.MixinConnectScreen",
|
||||
"bridge.MixinDownloadingTerrainScreen",
|
||||
"fixes.screen.MixinChatScreen"
|
||||
"fixes.screen.MixinChatScreen",
|
||||
"fixes.visual.MixinChatHud",
|
||||
"fixes.visual.MixinChatScreen",
|
||||
"fixes.visual.MixinClientPlayerEntity",
|
||||
"fixes.visual.MixinClientPlayNetworkHandler",
|
||||
"fixes.visual.MixinCommandBlockScreen",
|
||||
"fixes.visual.MixinCreativeInventoryScreen",
|
||||
"fixes.visual.MixinItemRenderer",
|
||||
"fixes.visual.MixinJigsawBlockScreen"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user