mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2024-11-21 11:55:13 +01:00
24w07a, port to upstream changes (maybe)
This commit is contained in:
parent
d551e52083
commit
25af1896f5
@ -7,8 +7,8 @@ maven_version=3.6.0-SNAPSHOT
|
||||
maven_group=de.florianmichael
|
||||
|
||||
# ViaVersion
|
||||
viaversion_version=4.10.0-24w06a-SNAPSHOT
|
||||
viabackwards_version=4.10.0-24w06a-SNAPSHOT
|
||||
viaversion_version=4.10.0-24w07a-SNAPSHOT
|
||||
viabackwards_version=4.10.0-24w07a-SNAPSHOT
|
||||
viarewind_version=3.0.6-SNAPSHOT
|
||||
vialegacy_version=2.2.22-SNAPSHOT
|
||||
viaaprilfools_version=2.0.11-SNAPSHOT
|
||||
|
@ -19,6 +19,7 @@
|
||||
package de.florianmichael.viaforge.common;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||
import de.florianmichael.viaforge.common.platform.VFPlatform;
|
||||
@ -33,7 +34,6 @@ import io.netty.util.AttributeKey;
|
||||
import net.raphimc.vialoader.ViaLoader;
|
||||
import net.raphimc.vialoader.impl.platform.*;
|
||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -49,7 +49,7 @@ public class ViaForgeCommon {
|
||||
private static ViaForgeCommon manager;
|
||||
|
||||
private final VFPlatform platform;
|
||||
private VersionEnum targetVersion;
|
||||
private ProtocolVersion targetVersion;
|
||||
|
||||
private ViaForgeConfig config;
|
||||
|
||||
@ -66,8 +66,8 @@ public class ViaForgeCommon {
|
||||
if (manager != null) {
|
||||
return; // Already initialized, ignore it then :tm:
|
||||
}
|
||||
final VersionEnum version = VersionEnum.fromProtocolId(platform.getGameVersion());
|
||||
if (version == VersionEnum.UNKNOWN) {
|
||||
final ProtocolVersion version = ProtocolVersion.getProtocol(platform.getGameVersion()); // ViaForge will only load on post-netty versions
|
||||
if (version == ProtocolVersion.unknown) {
|
||||
throw new IllegalArgumentException("Unknown version " + platform.getGameVersion());
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ public class ViaForgeCommon {
|
||||
ViaLoader.init(new ViaVersionPlatformImpl(mainFolder), new ViaForgeVLLoader(platform), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new);
|
||||
manager.config = new ViaForgeConfig(new File(mainFolder, "viaforge.yml"));
|
||||
|
||||
final VersionEnum configVersion = VersionEnum.fromProtocolId(manager.config.getClientSideVersion());
|
||||
if (configVersion != VersionEnum.UNKNOWN) {
|
||||
final ProtocolVersion configVersion = ProtocolVersion.getClosest(manager.config.getClientSideVersion());
|
||||
if (configVersion != null) {
|
||||
manager.setTargetVersion(configVersion);
|
||||
} else {
|
||||
manager.setTargetVersion(version);
|
||||
@ -114,25 +114,25 @@ public class ViaForgeCommon {
|
||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
||||
}
|
||||
|
||||
public VersionEnum getNativeVersion() {
|
||||
return VersionEnum.fromProtocolId(platform.getGameVersion());
|
||||
public ProtocolVersion getNativeVersion() {
|
||||
return ProtocolVersion.getProtocol(platform.getGameVersion());
|
||||
}
|
||||
|
||||
public VersionEnum getTargetVersion() {
|
||||
public ProtocolVersion getTargetVersion() {
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
public void restoreVersion() {
|
||||
this.targetVersion = VersionEnum.fromProtocolId(config.getClientSideVersion());
|
||||
this.targetVersion = ProtocolVersion.getClosest(config.getClientSideVersion());
|
||||
}
|
||||
|
||||
public void setTargetVersionSilent(final VersionEnum targetVersion) {
|
||||
public void setTargetVersionSilent(final ProtocolVersion targetVersion) {
|
||||
this.targetVersion = targetVersion;
|
||||
}
|
||||
|
||||
public void setTargetVersion(final VersionEnum targetVersion) {
|
||||
public void setTargetVersion(final ProtocolVersion targetVersion) {
|
||||
this.targetVersion = targetVersion;
|
||||
config.setClientSideVersion(targetVersion.getVersion());
|
||||
config.setClientSideVersion(targetVersion.getName());
|
||||
}
|
||||
|
||||
public VFPlatform getPlatform() {
|
||||
|
@ -18,15 +18,15 @@
|
||||
|
||||
package de.florianmichael.viaforge.common.gui;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
/**
|
||||
* This interface is used to store the target version for a specific server in the server list.
|
||||
*/
|
||||
public interface ExtendedServerData {
|
||||
|
||||
VersionEnum viaForge$getVersion();
|
||||
ProtocolVersion viaForge$getVersion();
|
||||
|
||||
void viaForge$setVersion(final VersionEnum version);
|
||||
void viaForge$setVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
package de.florianmichael.viaforge.common.platform;
|
||||
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package de.florianmichael.viaforge.common.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
@ -70,11 +71,14 @@ public class ViaForgeConfig extends Config {
|
||||
save(); // Automatically save the config when something changes
|
||||
}
|
||||
|
||||
public int getClientSideVersion() {
|
||||
return getInt(CLIENT_SIDE_VERSION, 0);
|
||||
public String getClientSideVersion() {
|
||||
if (getInt(CLIENT_SIDE_VERSION, -1) != -1) { // Temporary fix for old configs
|
||||
return ProtocolVersion.getProtocol(getInt(CLIENT_SIDE_VERSION, -1)).getName();
|
||||
}
|
||||
return getString(CLIENT_SIDE_VERSION, "");
|
||||
}
|
||||
|
||||
public void setClientSideVersion(final int version) {
|
||||
public void setClientSideVersion(final String version) {
|
||||
set(CLIENT_SIDE_VERSION, version);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package de.florianmichael.viaforge.common.protocolhack.netty;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface VFNetworkManager {
|
||||
|
||||
@ -31,13 +31,13 @@ public interface VFNetworkManager {
|
||||
/**
|
||||
* @return the target version of the connection
|
||||
*/
|
||||
VersionEnum viaForge$getTrackedVersion();
|
||||
ProtocolVersion viaForge$getTrackedVersion();
|
||||
|
||||
/**
|
||||
* Sets the target version of the connection.
|
||||
*
|
||||
* @param version the target version
|
||||
*/
|
||||
void viaForge$setTrackedVersion(final VersionEnum version);
|
||||
void viaForge$setTrackedVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
package de.florianmichael.viaforge.common.protocolhack.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
||||
|
||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
||||
public ViaForgeVLLegacyPipeline(UserConnection user, ProtocolVersion version) {
|
||||
super(user, version);
|
||||
}
|
||||
|
||||
|
@ -19,16 +19,16 @@
|
||||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ViaForgeVersionProvider extends BaseVersionProvider {
|
||||
|
||||
@Override
|
||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
if (connection.isClientSide() && !ViaForgeCommon.getManager().getPlatform().isSingleplayer().get()) {
|
||||
return connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion().getVersion();
|
||||
return connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion();
|
||||
}
|
||||
return super.getClosestServerProtocol(connection);
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ package de.florianmichael.viaforge.gui;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.util.DumpUtil;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSlot;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@ -133,12 +133,12 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return VersionEnum.SORTED_VERSIONS.size();
|
||||
return ProtocolVersion.getProtocols().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int index, boolean b, int i1, int i2) {
|
||||
finishedCallback.finished(VersionEnum.SORTED_VERSIONS.get(index), parent);
|
||||
finishedCallback.finished(ProtocolVersion.getProtocols().get(index), parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,8 +153,8 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int index, int x, int y, int slotHeight, int mouseX, int mouseY, float partialTicks) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(index);
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ProtocolVersion.getProtocols().get(index);
|
||||
|
||||
String color;
|
||||
if (targetVersion == version) {
|
||||
@ -169,7 +169,7 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final GuiScreen parent);
|
||||
void finished(final ProtocolVersion version, final GuiScreen parent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -38,7 +38,7 @@ public class MixinGuiConnecting_1 {
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getMinecraft().getCurrentServerData() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.GuiOverlayDebug;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,13 +35,13 @@ public class MixinGuiOverlayDebug {
|
||||
@Inject(method = "getDebugInfoRight", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiScreenAddServer;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -47,7 +47,7 @@ public class MixinGuiScreenAddServer extends GuiScreen {
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
buttonList.add(new GuiButton(1_000_000_000, pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version"));
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.network.NetHandlerLoginClient;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +42,7 @@ public class MixinNetHandlerLoginClient {
|
||||
|
||||
@Redirect(method = "handleEncryptionRequest", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = networkManager.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -27,8 +27,9 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraft.util.LazyLoadBase;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -51,7 +52,7 @@ public class MixinNetworkManager implements VFNetworkManager {
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$targetVersion;
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
|
||||
@ -64,7 +65,7 @@ public class MixinNetworkManager implements VFNetworkManager {
|
||||
|
||||
@Inject(method = "enableEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(SecretKey key, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -96,12 +97,12 @@ public class MixinNetworkManager implements VFNetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getTrackedVersion() {
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setTrackedVersion(VersionEnum version) {
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,19 +34,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$version;
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "getNBTCompound", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<NBTTagCompound> cir, NBTTagCompound nbttagcompound) {
|
||||
if (viaForge$version != null) {
|
||||
nbttagcompound.setInteger("viaForge$version", viaForge$version.getVersion());
|
||||
nbttagcompound.setString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL"))
|
||||
private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (nbtCompound.hasKey("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(nbtCompound.getInteger("viaForge$version")));
|
||||
ProtocolVersion version;
|
||||
if (nbtCompound.getInteger("viaForge$version") != 0) { // Temporary fix for old versions
|
||||
version = ProtocolVersion.getProtocol(nbtCompound.getInteger("viaForge$version"));
|
||||
} else {
|
||||
version = ProtocolVersion.getClosest(nbtCompound.getString("viaForge$version"));
|
||||
}
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +64,12 @@ public class MixinServerData implements ExtendedServerData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getVersion() {
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(VersionEnum version) {
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,12 @@
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,7 +51,7 @@ public class MixinServerPinger {
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaForge$serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -19,11 +19,11 @@
|
||||
package de.florianmichael.viaforge.mixin.impl.fixes;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.world.World;
|
||||
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;
|
||||
@ -40,7 +40,7 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
||||
|
||||
@Redirect(method = "onUpdateWalkingPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/EntityPlayerSP;prevOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(EntityPlayerSP instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
@ -29,7 +29,7 @@ import net.minecraft.client.gui.widget.list.AbstractList;
|
||||
import net.minecraft.client.gui.widget.list.ExtendedList;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@ -122,44 +122,44 @@ public class GuiProtocolSelector extends Screen {
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height, top, bottom, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends AbstractList.AbstractListEntry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
private final ProtocolVersion ProtocolVersion;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
public SlotEntry(ProtocolVersion ProtocolVersion) {
|
||||
this.ProtocolVersion = ProtocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
GuiProtocolSelector.this.finishedCallback.finished(ProtocolVersion, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int p_230432_2_, int y, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
if (targetVersion == ProtocolVersion) {
|
||||
color = GuiProtocolSelector.this.simple ? TextFormatting.GOLD.toString() : TextFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? TextFormatting.WHITE.toString() : TextFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + ProtocolVersion.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
void finished(final ProtocolVersion version, final Screen parent);
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -53,7 +53,7 @@ public class MixinAddServerScreen extends Screen {
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent(target != null ? target.getName() : "Set Version"), b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
|
@ -25,8 +25,9 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.network.login.ClientLoginNetHandler;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +42,7 @@ public class MixinClientLoginNetHandler {
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -22,7 +22,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -38,7 +38,7 @@ public class MixinConnectingScreen_1 {
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.overlay.DebugOverlayGui;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,13 +35,13 @@ public class MixinDebugOverlayGui {
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
|
@ -27,8 +27,9 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraft.util.LazyValue;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -51,7 +52,7 @@ public class MixinNetworkManager implements VFNetworkManager {
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$targetVersion;
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyValue lazyvalue) {
|
||||
@ -64,7 +65,7 @@ public class MixinNetworkManager implements VFNetworkManager {
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher p_244777_1_, Cipher p_244777_2_, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -96,12 +97,12 @@ public class MixinNetworkManager implements VFNetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getTrackedVersion() {
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setTrackedVersion(VersionEnum version) {
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,19 +34,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$version;
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
|
||||
if (viaForge$version != null) {
|
||||
compoundnbt.putInt("viaForge$version", viaForge$version.getVersion());
|
||||
compoundnbt.putString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
|
||||
ProtocolVersion version;
|
||||
if (compoundnbt.getInt("viaForge$version") != 0) { // Temporary fix for old versions
|
||||
version = ProtocolVersion.getProtocol(compoundnbt.getInt("viaForge$version"));
|
||||
} else {
|
||||
version = ProtocolVersion.getClosest(compoundnbt.getString("viaForge$version"));
|
||||
}
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +64,12 @@ public class MixinServerData implements ExtendedServerData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getVersion() {
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(VersionEnum version) {
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,7 +51,7 @@ public class MixinServerPinger {
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaForge$serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -40,7 +40,7 @@ public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/player/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(ClientPlayerEntity instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
@ -29,7 +29,7 @@ import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -121,49 +121,49 @@ public class GuiProtocolSelector extends Screen {
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height, top, bottom, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends ObjectSelectionList.Entry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
private final ProtocolVersion ProtocolVersion;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
public SlotEntry(ProtocolVersion ProtocolVersion) {
|
||||
this.ProtocolVersion = ProtocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
GuiProtocolSelector.this.finishedCallback.finished(ProtocolVersion, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
return new TextComponent(versionEnum.getName());
|
||||
return new TextComponent(ProtocolVersion.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrices, int p_93524_, int y, int p_93526_, int p_93527_, int p_93528_, int p_93529_, int p_93530_, boolean p_93531_, float p_93532_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
if (targetVersion == ProtocolVersion) {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + ProtocolVersion.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
void finished(final ProtocolVersion version, final Screen parent);
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,9 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +42,7 @@ public class MixinClientHandshakePacketListenerImpl {
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -22,7 +22,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -38,7 +38,7 @@ public class MixinConnectScreen_1 {
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -25,8 +25,9 @@ import net.minecraft.network.CipherDecoder;
|
||||
import net.minecraft.network.CipherEncoder;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -48,7 +49,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$targetVersion;
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) {
|
||||
@ -61,7 +62,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher p_244777_1_, Cipher p_244777_2_, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -93,12 +94,12 @@ public class MixinConnection implements VFNetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getTrackedVersion() {
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setTrackedVersion(VersionEnum version) {
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,13 +35,13 @@ public class MixinDebugScreenOverlay {
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
|
@ -29,7 +29,7 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -55,7 +55,7 @@ public class MixinEditServerScreen extends Screen {
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent(target != null ? target.getName() : "Set Version"), b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,19 +34,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$version;
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundtag) {
|
||||
if (viaForge$version != null) {
|
||||
compoundtag.putInt("viaForge$version", viaForge$version.getVersion());
|
||||
compoundtag.putString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundTag compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
|
||||
ProtocolVersion version;
|
||||
if (compoundnbt.getInt("viaForge$version") != 0) { // Temporary fix for old versions
|
||||
version = ProtocolVersion.getProtocol(compoundnbt.getInt("viaForge$version"));
|
||||
} else {
|
||||
version = ProtocolVersion.getClosest(compoundnbt.getString("viaForge$version"));
|
||||
}
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +64,12 @@ public class MixinServerData implements ExtendedServerData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getVersion() {
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(VersionEnum version) {
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.ServerStatusPinger;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,7 +51,7 @@ public class MixinServerStatusPinger {
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaForge$serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -40,7 +40,7 @@ public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
@ -29,7 +29,7 @@ import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -121,49 +121,49 @@ public class GuiProtocolSelector extends Screen {
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height, top, bottom, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends Entry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
private final ProtocolVersion ProtocolVersion;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
public SlotEntry(ProtocolVersion ProtocolVersion) {
|
||||
this.ProtocolVersion = ProtocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
GuiProtocolSelector.this.finishedCallback.finished(ProtocolVersion, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
return new TextComponent(versionEnum.getName());
|
||||
return new TextComponent(ProtocolVersion.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrices, int p_93524_, int y, int p_93526_, int p_93527_, int p_93528_, int p_93529_, int p_93530_, boolean p_93531_, float p_93532_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
if (targetVersion == ProtocolVersion) {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + ProtocolVersion.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
void finished(final ProtocolVersion version, final Screen parent);
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,9 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +42,7 @@ public class MixinClientHandshakePacketListenerImpl {
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -22,7 +22,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -38,7 +38,7 @@ public class MixinConnectScreen_1 {
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -25,8 +25,9 @@ import net.minecraft.network.CipherDecoder;
|
||||
import net.minecraft.network.CipherEncoder;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -48,7 +49,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$targetVersion;
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) {
|
||||
@ -61,7 +62,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher p_244777_1_, Cipher p_244777_2_, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -93,12 +94,12 @@ public class MixinConnection implements VFNetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getTrackedVersion() {
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setTrackedVersion(VersionEnum version) {
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,13 +35,13 @@ public class MixinDebugScreenOverlay {
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
|
@ -29,7 +29,7 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -55,7 +55,7 @@ public class MixinEditServerScreen extends Screen {
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent(target != null ? target.getName() : "Set Version"), b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,19 +34,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$version;
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundtag) {
|
||||
if (viaForge$version != null) {
|
||||
compoundtag.putInt("viaForge$version", viaForge$version.getVersion());
|
||||
compoundtag.putString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundTag compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
|
||||
ProtocolVersion version;
|
||||
if (compoundnbt.getInt("viaForge$version") != 0) { // Temporary fix for old versions
|
||||
version = ProtocolVersion.getProtocol(compoundnbt.getInt("viaForge$version"));
|
||||
} else {
|
||||
version = ProtocolVersion.getClosest(compoundnbt.getString("viaForge$version"));
|
||||
}
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +64,12 @@ public class MixinServerData implements ExtendedServerData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getVersion() {
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(VersionEnum version) {
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.ServerStatusPinger;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,7 +51,7 @@ public class MixinServerStatusPinger {
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaForge$serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -40,7 +40,7 @@ public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -120,49 +120,49 @@ public class GuiProtocolSelector extends Screen {
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height, top, bottom, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends Entry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
private final ProtocolVersion ProtocolVersion;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
public SlotEntry(ProtocolVersion ProtocolVersion) {
|
||||
this.ProtocolVersion = ProtocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
GuiProtocolSelector.this.finishedCallback.finished(ProtocolVersion, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
return Component.literal(versionEnum.getName());
|
||||
return Component.literal(ProtocolVersion.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrices, int p_93524_, int y, int p_93526_, int p_93527_, int p_93528_, int p_93529_, int p_93530_, boolean p_93531_, float p_93532_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
if (targetVersion == ProtocolVersion) {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
drawCenteredString(matrices, Minecraft.getInstance().font, color + ProtocolVersion.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
void finished(final ProtocolVersion version, final Screen parent);
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,9 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +42,7 @@ public class MixinClientHandshakePacketListenerImpl {
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -22,7 +22,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -38,7 +38,7 @@ public class MixinConnectScreen_1 {
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -25,8 +25,9 @@ import net.minecraft.network.CipherDecoder;
|
||||
import net.minecraft.network.CipherEncoder;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -48,7 +49,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$targetVersion;
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) {
|
||||
@ -61,7 +62,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher p_244777_1_, Cipher p_244777_2_, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -93,12 +94,12 @@ public class MixinConnection implements VFNetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getTrackedVersion() {
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setTrackedVersion(VersionEnum version) {
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,13 +35,13 @@ public class MixinDebugScreenOverlay {
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.client.gui.screens.EditServerScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -54,7 +54,7 @@ public class MixinEditServerScreen extends Screen {
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
addRenderableWidget(Button.builder(Component.literal(target != null ? target.getName() : "Set Version"), b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,19 +34,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$version;
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundtag) {
|
||||
if (viaForge$version != null) {
|
||||
compoundtag.putInt("viaForge$version", viaForge$version.getVersion());
|
||||
compoundtag.putString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundTag compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
|
||||
ProtocolVersion version;
|
||||
if (compoundnbt.getInt("viaForge$version") != 0) { // Temporary fix for old versions
|
||||
version = ProtocolVersion.getProtocol(compoundnbt.getInt("viaForge$version"));
|
||||
} else {
|
||||
version = ProtocolVersion.getClosest(compoundnbt.getString("viaForge$version"));
|
||||
}
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +64,12 @@ public class MixinServerData implements ExtendedServerData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getVersion() {
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(VersionEnum version) {
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.ServerStatusPinger;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,7 +51,7 @@ public class MixinServerStatusPinger {
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaForge$serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -40,7 +40,7 @@ public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -120,49 +120,49 @@ public class GuiProtocolSelector extends Screen {
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height - top - bottom, top, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends Entry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
private final ProtocolVersion ProtocolVersion;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
public SlotEntry(ProtocolVersion ProtocolVersion) {
|
||||
this.ProtocolVersion = ProtocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
GuiProtocolSelector.this.finishedCallback.finished(ProtocolVersion, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
return Component.literal(versionEnum.getName());
|
||||
return Component.literal(ProtocolVersion.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int p_93524_, int y, int p_93526_, int p_93527_, int p_93528_, int p_93529_, int p_93530_, boolean p_93531_, float p_93532_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
if (targetVersion == ProtocolVersion) {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
graphics.drawCenteredString(Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
graphics.drawCenteredString(Minecraft.getInstance().font, color + ProtocolVersion.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
void finished(final ProtocolVersion version, final Screen parent);
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,9 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -42,7 +43,7 @@ public class MixinClientHandshakePacketListenerImpl {
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Ljava/util/UUID;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, UUID uuid, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -30,8 +30,9 @@ import net.minecraft.network.PacketListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.handshake.ClientIntent;
|
||||
import net.minecraft.util.SampleLogger;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -53,7 +54,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$targetVersion;
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Connection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/Connection;)Lio/netty/channel/ChannelFuture;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, SampleLogger p_300093_, CallbackInfoReturnable<Connection> cir, Connection connection) {
|
||||
@ -67,7 +68,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
@Inject(method = "initiateServerboundConnection", at = @At("HEAD"))
|
||||
public void test(String p_300730_, int p_300598_, PacketListener p_298739_, ClientIntent p_297789_, CallbackInfo ci) {
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
@ -80,7 +81,7 @@ public class MixinConnection implements VFNetworkManager {
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher p_244777_1_, Cipher p_244777_2_, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -112,12 +113,12 @@ public class MixinConnection implements VFNetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getTrackedVersion() {
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setTrackedVersion(VersionEnum version) {
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,13 +35,13 @@ public class MixinDebugScreenOverlay {
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.client.gui.screens.EditServerScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -54,7 +54,7 @@ public class MixinEditServerScreen extends Screen {
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
addRenderableWidget(Button.builder(Component.literal(target != null ? target.getName() : "Set Version"), b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viaforge.mixin;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,19 +34,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaForge$version;
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundtag) {
|
||||
if (viaForge$version != null) {
|
||||
compoundtag.putInt("viaForge$version", viaForge$version.getVersion());
|
||||
compoundtag.putString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundTag compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
|
||||
ProtocolVersion version;
|
||||
if (compoundnbt.getInt("viaForge$version") != 0) { // Temporary fix for old versions
|
||||
version = ProtocolVersion.getProtocol(compoundnbt.getInt("viaForge$version"));
|
||||
} else {
|
||||
version = ProtocolVersion.getClosest(compoundnbt.getString("viaForge$version"));
|
||||
}
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +64,12 @@ public class MixinServerData implements ExtendedServerData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaForge$getVersion() {
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(VersionEnum version) {
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.ServerStatusPinger;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.util.SampleLogger;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -52,7 +52,7 @@ public class MixinServerStatusPinger {
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaForge$serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
final ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -40,7 +40,7 @@ public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
Loading…
Reference in New Issue
Block a user