Create field for native version

This commit is contained in:
FlorianMichael 2023-09-03 00:04:35 +02:00
parent 664faa0b37
commit e621ed3d78
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 8 additions and 4 deletions

View File

@ -33,6 +33,7 @@ import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
import de.florianmichael.viafabricplus.mappings.PackFormatsMappings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import net.raphimc.vialoader.util.VersionEnum;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -55,6 +56,8 @@ import java.io.File;
* - Blit-jump is not supported in <= 1.8.9 (https://github.com/ViaVersion/ViaFabricPlus/issues/225)
*/
public class ViaFabricPlus {
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_20tor1_20_1;
public final static Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public final static Logger LOGGER = LogManager.getLogger("ViaFabricPlus");
public final static File RUN_DIRECTORY = new File("ViaFabricPlus");

View File

@ -17,11 +17,11 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.FinishMinecraftLoadCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -41,7 +41,8 @@ public abstract class MixinMinecraftClient {
@Inject(method = "setWorld", at = @At("HEAD"))
public void preSetWorld(CallbackInfo ci) {
if (isInSingleplayer()) {
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(VersionEnum.r1_20tor1_20_1);
// We call this here, so client side fixes are disabled in singleplayer
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(ViaFabricPlus.NATIVE_VERSION);
}
}
}

View File

@ -75,7 +75,7 @@ public class ProtocolHack {
/**
* This field stores the target version that you set in the GUI
*/
public static VersionEnum targetVersion = VersionEnum.r1_20tor1_20_1;
public static VersionEnum targetVersion = ViaFabricPlus.NATIVE_VERSION;
/**
* This method is used when you need the target version after connecting to the server.
@ -114,7 +114,7 @@ public class ProtocolHack {
return channel.attr(FORCED_VERSION).get();
}
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().isInSingleplayer()) return VersionEnum.r1_20tor1_20_1;
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().isInSingleplayer()) return ViaFabricPlus.NATIVE_VERSION;
return targetVersion;
}