From 99d6b1b516b006f6aba38c9468ef41cef5abb9c2 Mon Sep 17 00:00:00 2001 From: Aspw-w <0kcabtuo0@gmail.com> Date: Fri, 12 Apr 2024 18:10:06 +0900 Subject: [PATCH] ViaVersion REWORK --- gradle.properties | 10 +++--- .../features/module/impl/combat/AutoHeal.kt | 4 +++ .../module/impl/player/LegitScaffold.kt | 12 +++++-- .../features/module/impl/visual/Interface.kt | 2 +- .../mixins/gui/MixinGuiDisconnected.java | 4 +-- .../forge/mixins/gui/MixinGuiIngameMenu.java | 4 +-- .../forge/mixins/gui/MixinGuiMultiplayer.java | 4 +-- .../mixins/gui/MixinGuiOverlayDebug.java | 4 +-- .../mixins/network/MixinGuiConnecting_1.java | 4 +-- .../mixins/network/MixinNetworkManager.java | 8 ++--- .../forge/mixins/network/MixinServerData.java | 12 +++---- .../aspw/client/protocol/ProtocolBase.java | 34 ++++++------------- .../protocol/api/ExtendedServerData.java | 6 ++-- .../client/protocol/api/ProtocolFixes.java | 18 +++++----- .../client/protocol/api/ProtocolSelector.java | 8 ++--- .../api/ProtocolVLLegacyPipeline.java | 11 ++---- .../protocol/api/ProtocolVersionProvider.java | 5 ++- .../client/protocol/api/VFNetworkManager.java | 6 ++-- 18 files changed, 73 insertions(+), 83 deletions(-) diff --git a/gradle.properties b/gradle.properties index fcf3641c..67df6e66 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,9 +19,9 @@ okhttp_version=4.9.1 snake_yml_version=2.2 slf4j_version=2.0.12 -viaversion_version=4.10.0-24w09a-SNAPSHOT -viabackwards_version=4.10.0-24w09a-SNAPSHOT -viarewind_version=3.0.7-24w09a-SNAPSHOT +viaversion_version=4.9.3 +viabackwards_version=4.9.2 +viarewind_version=3.0.6 +vialoader_version=2.2.12 vialegacy_version=2.2.22-SNAPSHOT -viaaprilfools_version=2.0.11-SNAPSHOT -vialoader_version=2.2.13-SNAPSHOT \ No newline at end of file +viaaprilfools_version=2.0.11-SNAPSHOT \ No newline at end of file diff --git a/src/main/java/net/aspw/client/features/module/impl/combat/AutoHeal.kt b/src/main/java/net/aspw/client/features/module/impl/combat/AutoHeal.kt index 9137b0b1..6a3f55ca 100644 --- a/src/main/java/net/aspw/client/features/module/impl/combat/AutoHeal.kt +++ b/src/main/java/net/aspw/client/features/module/impl/combat/AutoHeal.kt @@ -274,8 +274,12 @@ class AutoHeal : Module() { if (mc.thePlayer.inventory.currentItem == potIndex - 36) { mc.thePlayer.inventory.currentItem = oldSlot mc.playerController.updateController() + potting = false + throwing = false + tickTimer.reset() debug("switch back") } + return } if (throwing && mc.currentScreen !is GuiContainer && mc.inGameHasFocus && Display.isActive() diff --git a/src/main/java/net/aspw/client/features/module/impl/player/LegitScaffold.kt b/src/main/java/net/aspw/client/features/module/impl/player/LegitScaffold.kt index e79dc0e6..91e1f134 100644 --- a/src/main/java/net/aspw/client/features/module/impl/player/LegitScaffold.kt +++ b/src/main/java/net/aspw/client/features/module/impl/player/LegitScaffold.kt @@ -90,9 +90,6 @@ class LegitScaffold : Module() { BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1.0, mc.thePlayer.posZ) ).block === Blocks.air - if (sneakValue.get()) - mc.gameSettings.keyBindSneak.pressed = shouldEagle - if (shouldEagle && (tickTimer.hasTimePassed(delayValue.get()) || !mc.thePlayer.onGround)) { if (mc.thePlayer.heldItem != null && mc.thePlayer.heldItem.item is ItemBlock) KeyBinding.onTick(mc.gameSettings.keyBindUseItem.keyCode) @@ -108,6 +105,15 @@ class LegitScaffold : Module() { return } + val shouldEagle = mc.theWorld.getBlockState( + BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1.0, mc.thePlayer.posZ) + ).block === Blocks.air + + if (sneakValue.get() && shouldEagle || GameSettings.isKeyDown(mc.gameSettings.keyBindSneak)) + mc.gameSettings.keyBindSneak.pressed = true + else if (!GameSettings.isKeyDown(mc.gameSettings.keyBindSneak)) + mc.gameSettings.keyBindSneak.pressed = false + if (stopSprintValue.get()) mc.thePlayer.isSprinting = false diff --git a/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt b/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt index be5db412..3f83f825 100644 --- a/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt +++ b/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt @@ -90,7 +90,7 @@ class Interface : Module() { val connectChecks = if (!APIConnecter.canConnect) " - Disconnected" else "" val fpsChecks = if (watermarkFpsValue.get()) " [" + Minecraft.getDebugFPS() + " FPS]" else "" val protocolChecks = - if (watermarkProtocolValue.get()) " [version: " + (if (!mc.isIntegratedServerRunning) ProtocolBase.getManager().targetVersion.name else "1.8.x") + "]" else "" + if (watermarkProtocolValue.get()) " [version: " + (if (!mc.isIntegratedServerRunning) ProtocolBase.getManager().targetVersion.getName() else "1.8.x") + "]" else "" var firstChar = "" var restOfString = "" if (inputString != "") { diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiDisconnected.java b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiDisconnected.java index 7d11846f..fa3e420c 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiDisconnected.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiDisconnected.java @@ -1,7 +1,6 @@ package net.aspw.client.injection.forge.mixins.gui; import com.google.gson.JsonObject; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.auth.account.CrackedAccount; import net.aspw.client.auth.account.MinecraftAccount; @@ -22,6 +21,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.IChatComponent; import net.minecraft.util.Session; +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; @@ -104,7 +104,7 @@ private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) { @Inject(method = "drawScreen", at = @At("RETURN")) private void drawScreen(CallbackInfo callbackInfo) { - final ProtocolVersion version = ProtocolBase.getManager().getTargetVersion(); + final VersionEnum version = ProtocolBase.getManager().getTargetVersion(); Fonts.minecraftFont.drawStringWithShadow( "§7Username: §d" + mc.getSession().getUsername(), diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiIngameMenu.java b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiIngameMenu.java index 345e725f..af76d510 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiIngameMenu.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiIngameMenu.java @@ -1,6 +1,5 @@ package net.aspw.client.injection.forge.mixins.gui; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.features.api.PacketManager; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.utils.MinecraftInstance; @@ -8,6 +7,7 @@ import net.aspw.client.visual.font.semi.Fonts; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiIngameMenu; +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; @@ -31,7 +31,7 @@ private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) { @Inject(method = "drawScreen", at = @At("RETURN")) private void drawScreen(CallbackInfo callbackInfo) { try { - final ProtocolVersion version = ProtocolBase.getManager().getTargetVersion(); + final VersionEnum version = ProtocolBase.getManager().getTargetVersion(); Fonts.minecraftFont.drawStringWithShadow("§7Username: §d" + mc.getSession().getUsername(), 6f, 6f, 0xffffff); diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiMultiplayer.java b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiMultiplayer.java index e10413b5..dd295754 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiMultiplayer.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiMultiplayer.java @@ -1,6 +1,5 @@ package net.aspw.client.injection.forge.mixins.gui; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.protocol.api.ProtocolSelector; import net.aspw.client.visual.client.altmanager.GuiAltManager; @@ -8,6 +7,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; +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; @@ -27,7 +27,7 @@ private void initGui(CallbackInfo callbackInfo) { @Inject(method = "drawScreen", at = @At("RETURN")) private void drawScreen(CallbackInfo callbackInfo) { - final ProtocolVersion version = ProtocolBase.getManager().getTargetVersion(); + final VersionEnum version = ProtocolBase.getManager().getTargetVersion(); Fonts.minecraftFont.drawStringWithShadow("§7Username: §d" + mc.getSession().getUsername(), 6f, 6f, 0xffffff); diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiOverlayDebug.java b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiOverlayDebug.java index b981ceb0..68c1f6ab 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiOverlayDebug.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiOverlayDebug.java @@ -1,10 +1,10 @@ package net.aspw.client.injection.forge.mixins.gui; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.client.gui.GuiOverlayDebug; +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; @@ -17,7 +17,7 @@ public class MixinGuiOverlayDebug { @Inject(method = "getDebugInfoRight", at = @At(value = "TAIL")) public void addProtocolVersion(CallbackInfoReturnable> cir) { - final ProtocolVersion version = ProtocolBase.getManager().getTargetVersion(); + final VersionEnum version = ProtocolBase.getManager().getTargetVersion(); cir.getReturnValue().add(""); diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinGuiConnecting_1.java b/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinGuiConnecting_1.java index fcce7135..c002195e 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinGuiConnecting_1.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinGuiConnecting_1.java @@ -1,10 +1,10 @@ package net.aspw.client.injection.forge.mixins.network; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.protocol.api.ExtendedServerData; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.network.NetworkManager; +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.Redirect; @@ -17,7 +17,7 @@ public class MixinGuiConnecting_1 { @Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;func_181124_a(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"), remap = false) public NetworkManager trackVersion(InetAddress address, int i, boolean b) { if (MinecraftInstance.mc.getCurrentServerData() instanceof ExtendedServerData) { - final ProtocolVersion version = ((ExtendedServerData) MinecraftInstance.mc.getCurrentServerData()).viaForge$getVersion(); + final VersionEnum version = ((ExtendedServerData) MinecraftInstance.mc.getCurrentServerData()).viaForge$getVersion(); if (version != null) { ProtocolBase.getManager().setTargetVersionSilent(version); } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinNetworkManager.java b/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinNetworkManager.java index 36a6d9cc..666e6b84 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinNetworkManager.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinNetworkManager.java @@ -1,6 +1,5 @@ package net.aspw.client.injection.forge.mixins.network; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import net.aspw.client.Launch; @@ -14,6 +13,7 @@ import net.minecraft.network.Packet; import net.minecraft.network.ThreadQuickExitException; import net.minecraft.util.LazyLoadBase; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -39,7 +39,7 @@ public class MixinNetworkManager implements VFNetworkManager { private INetHandler packetListener; @Unique - private ProtocolVersion viaForge$targetVersion; + private VersionEnum viaForge$targetVersion; @Inject(method = "func_181124_a", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD, remap = false) private static void trackSelfTarget(final InetAddress address, final int serverPort, final boolean useNativeTransport, final CallbackInfoReturnable cir, final NetworkManager networkmanager, final Class oclass, final LazyLoadBase lazyloadbase) { @@ -52,12 +52,12 @@ public void reorderPipeline(final int p_setCompressionTreshold_1_, final Callbac } @Override - public ProtocolVersion viaForge$getTrackedVersion() { + public VersionEnum viaForge$getTrackedVersion() { return viaForge$targetVersion; } @Override - public void viaForge$setTrackedVersion(final ProtocolVersion version) { + public void viaForge$setTrackedVersion(final VersionEnum version) { viaForge$targetVersion = version; } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinServerData.java b/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinServerData.java index 8957a1ad..5409e21a 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinServerData.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/network/MixinServerData.java @@ -1,9 +1,9 @@ package net.aspw.client.injection.forge.mixins.network; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.protocol.api.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; @@ -16,19 +16,19 @@ public class MixinServerData implements ExtendedServerData { @Unique - private ProtocolVersion viaForge$version; + private VersionEnum 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 cir, NBTTagCompound nbttagcompound) { if (viaForge$version != null) { - nbttagcompound.setString("viaForge$version", viaForge$version.getName()); + nbttagcompound.setInteger("viaForge$version", viaForge$version.getVersion()); } } @Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL")) private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable cir) { if (nbtCompound.hasKey("viaForge$version")) { - ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(ProtocolVersion.getClosest(nbtCompound.getString("viaForge$version"))); + ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(nbtCompound.getInteger("viaForge$version"))); } } @@ -40,12 +40,12 @@ public void track(ServerData serverDataIn, CallbackInfo ci) { } @Override - public ProtocolVersion viaForge$getVersion() { + public VersionEnum viaForge$getVersion() { return viaForge$version; } @Override - public void viaForge$setVersion(ProtocolVersion version) { + public void viaForge$setVersion(VersionEnum version) { viaForge$version = version; } diff --git a/src/main/java/net/aspw/client/protocol/ProtocolBase.java b/src/main/java/net/aspw/client/protocol/ProtocolBase.java index 23ca80a7..6f2c9b27 100644 --- a/src/main/java/net/aspw/client/protocol/ProtocolBase.java +++ b/src/main/java/net/aspw/client/protocol/ProtocolBase.java @@ -1,7 +1,6 @@ package net.aspw.client.protocol; 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 io.netty.channel.Channel; @@ -12,19 +11,18 @@ import net.raphimc.vialoader.ViaLoader; import net.raphimc.vialoader.impl.platform.*; import net.raphimc.vialoader.netty.CompressionReorderEvent; -import net.raphimc.vialoader.util.ProtocolVersionList; +import net.raphimc.vialoader.util.VersionEnum; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; public class ProtocolBase { - private ProtocolVersion targetVersion = ProtocolVersion.v1_8; + private VersionEnum targetVersion = VersionEnum.r1_8; public static final AttributeKey LOCAL_VIA_USER = AttributeKey.valueOf("local_via_user"); public static final AttributeKey VF_NETWORK_MANAGER = AttributeKey.valueOf("encryption_setup"); private static ProtocolBase manager; - public static List versions = new ArrayList<>(); + public static List versions = new ArrayList<>(); public ProtocolBase() { } @@ -34,28 +32,18 @@ public static void init(final VFPlatform platform) { return; } - final ProtocolVersion version = ProtocolVersion.getProtocol(platform.getGameVersion()); + final VersionEnum version = VersionEnum.fromProtocolId(platform.getGameVersion()); - if (version == ProtocolVersion.unknown) + if (version == VersionEnum.UNKNOWN) throw new IllegalArgumentException("Unknown Protocol Found (" + platform.getGameVersion() + ")"); manager = new ProtocolBase(); ViaLoader.init(new ViaVersionPlatformImpl(null), new ProtocolVLLoader(platform), new ProtocolVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new); - versions.addAll(ProtocolVersionList.getProtocolsNewToOld()); - - try { - Iterator iterator = versions.iterator(); - while (iterator.hasNext()) { - ProtocolVersion i = iterator.next(); - if (i == ProtocolVersion.unknown || i.olderThan(ProtocolVersion.v1_7_2) || i == ProtocolVersion.v1_20_5) { - iterator.remove(); - ClientUtils.getLogger().info("Removed Protocol (" + i + ")"); - } - } - } catch (Exception ignored) { - } + versions.addAll(VersionEnum.SORTED_VERSIONS); + + versions.removeIf(i -> i == VersionEnum.UNKNOWN || i.isOlderThan(VersionEnum.r1_7_2tor1_7_5)); ClientUtils.getLogger().info("ViaVersion Injected"); } @@ -72,15 +60,15 @@ public void inject(final Channel channel, final VFNetworkManager networkManager) } } - public ProtocolVersion getTargetVersion() { + public VersionEnum getTargetVersion() { return targetVersion; } - public void setTargetVersionSilent(final ProtocolVersion targetVersion) { + public void setTargetVersionSilent(final VersionEnum targetVersion) { this.targetVersion = targetVersion; } - public void setTargetVersion(final ProtocolVersion targetVersion) { + public void setTargetVersion(final VersionEnum targetVersion) { this.targetVersion = targetVersion; } diff --git a/src/main/java/net/aspw/client/protocol/api/ExtendedServerData.java b/src/main/java/net/aspw/client/protocol/api/ExtendedServerData.java index 68e038c5..188b0eef 100644 --- a/src/main/java/net/aspw/client/protocol/api/ExtendedServerData.java +++ b/src/main/java/net/aspw/client/protocol/api/ExtendedServerData.java @@ -1,14 +1,14 @@ package net.aspw.client.protocol.api; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import net.raphimc.vialoader.util.VersionEnum; /** * This interface is used to store the target version for a specific server in the server list. */ public interface ExtendedServerData { - ProtocolVersion viaForge$getVersion(); + VersionEnum viaForge$getVersion(); - void viaForge$setVersion(final ProtocolVersion version); + void viaForge$setVersion(final VersionEnum version); } \ No newline at end of file diff --git a/src/main/java/net/aspw/client/protocol/api/ProtocolFixes.java b/src/main/java/net/aspw/client/protocol/api/ProtocolFixes.java index 6a509f28..63b063c3 100644 --- a/src/main/java/net/aspw/client/protocol/api/ProtocolFixes.java +++ b/src/main/java/net/aspw/client/protocol/api/ProtocolFixes.java @@ -1,12 +1,12 @@ package net.aspw.client.protocol.api; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MovingObjectPosition; +import net.raphimc.vialoader.util.VersionEnum; public class ProtocolFixes { private static final Minecraft mc = MinecraftInstance.mc; @@ -28,34 +28,34 @@ public static void sendFixedAttack(final EntityPlayer entityIn, final Entity tar } public static boolean newerThan1_8() { - return ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThan(VersionEnum.r1_8) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean newerThanOrEqualsTo1_8() { - return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_8) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean newerThanOrEqualsTo1_9() { - return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_9) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_9) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean newerThanOrEqualsTo1_10() { - return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_10) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_10) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean newerThanOrEqualsTo1_13() { - return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_13) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean olderThanOrEqualsTo1_13_2() { - return ProtocolBase.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean newerThanOrEqualsTo1_14() { - return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_14) && !MinecraftInstance.mc.isIntegratedServerRunning(); } public static boolean newerThanOrEqualsTo1_16() { - return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !MinecraftInstance.mc.isIntegratedServerRunning(); + return ProtocolBase.getManager().getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_14) && !MinecraftInstance.mc.isIntegratedServerRunning(); } } \ No newline at end of file diff --git a/src/main/java/net/aspw/client/protocol/api/ProtocolSelector.java b/src/main/java/net/aspw/client/protocol/api/ProtocolSelector.java index a14d2596..46d1b8ec 100644 --- a/src/main/java/net/aspw/client/protocol/api/ProtocolSelector.java +++ b/src/main/java/net/aspw/client/protocol/api/ProtocolSelector.java @@ -1,13 +1,13 @@ package net.aspw.client.protocol.api; import com.mojang.realmsclient.gui.ChatFormatting; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.visual.font.smooth.FontLoaders; 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 java.io.IOException; @@ -94,8 +94,8 @@ protected void drawBackground() { @Override protected void drawSlot(int index, int x, int y, int slotHeight, int mouseX, int mouseY) { - final ProtocolVersion targetVersion = ProtocolBase.getManager().getTargetVersion(); - final ProtocolVersion version = ProtocolBase.versions.get(index); + final VersionEnum targetVersion = ProtocolBase.getManager().getTargetVersion(); + final VersionEnum version = ProtocolBase.versions.get(index); String color; if (targetVersion == version) { @@ -110,7 +110,7 @@ protected void drawSlot(int index, int x, int y, int slotHeight, int mouseX, int public interface FinishedCallback { - void finished(final ProtocolVersion version, final GuiScreen parent); + void finished(final VersionEnum version, final GuiScreen parent); } diff --git a/src/main/java/net/aspw/client/protocol/api/ProtocolVLLegacyPipeline.java b/src/main/java/net/aspw/client/protocol/api/ProtocolVLLegacyPipeline.java index f893c061..a5291aa2 100644 --- a/src/main/java/net/aspw/client/protocol/api/ProtocolVLLegacyPipeline.java +++ b/src/main/java/net/aspw/client/protocol/api/ProtocolVLLegacyPipeline.java @@ -1,22 +1,15 @@ package net.aspw.client.protocol.api; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import io.netty.channel.ChannelHandlerContext; import net.raphimc.vialoader.netty.VLLegacyPipeline; +import net.raphimc.vialoader.util.VersionEnum; public class ProtocolVLLegacyPipeline extends VLLegacyPipeline { - public ProtocolVLLegacyPipeline(UserConnection user, ProtocolVersion version) { + public ProtocolVLLegacyPipeline(UserConnection user, VersionEnum version) { super(user, version); } - @Override - public void handlerAdded(ChannelHandlerContext ctx) { - ctx.pipeline().addBefore(this.packetDecoderName(), VIA_DECODER_NAME, this.createViaDecoder()); - ctx.pipeline().addBefore(this.packetEncoderName(), VIA_ENCODER_NAME, this.createViaEncoder()); - } - @Override protected String decompressName() { return "decompress"; diff --git a/src/main/java/net/aspw/client/protocol/api/ProtocolVersionProvider.java b/src/main/java/net/aspw/client/protocol/api/ProtocolVersionProvider.java index c27b5cf9..ea9e46a7 100644 --- a/src/main/java/net/aspw/client/protocol/api/ProtocolVersionProvider.java +++ b/src/main/java/net/aspw/client/protocol/api/ProtocolVersionProvider.java @@ -1,7 +1,6 @@ package net.aspw.client.protocol.api; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.protocols.base.BaseVersionProvider; import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.utils.MinecraftInstance; @@ -11,9 +10,9 @@ public class ProtocolVersionProvider extends BaseVersionProvider { @Override - public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception { + public int getClosestServerProtocol(UserConnection connection) throws Exception { if (connection.isClientSide() && !MinecraftInstance.mc.isIntegratedServerRunning()) { - return Objects.requireNonNull(connection.getChannel()).attr(ProtocolBase.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion(); + return Objects.requireNonNull(connection.getChannel()).attr(ProtocolBase.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion().getVersion(); } return super.getClosestServerProtocol(connection); } diff --git a/src/main/java/net/aspw/client/protocol/api/VFNetworkManager.java b/src/main/java/net/aspw/client/protocol/api/VFNetworkManager.java index 1a870ba5..589c8817 100644 --- a/src/main/java/net/aspw/client/protocol/api/VFNetworkManager.java +++ b/src/main/java/net/aspw/client/protocol/api/VFNetworkManager.java @@ -1,11 +1,11 @@ package net.aspw.client.protocol.api; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import net.raphimc.vialoader.util.VersionEnum; public interface VFNetworkManager { - ProtocolVersion viaForge$getTrackedVersion(); + VersionEnum viaForge$getTrackedVersion(); - void viaForge$setTrackedVersion(final ProtocolVersion version); + void viaForge$setTrackedVersion(final VersionEnum version); } \ No newline at end of file