From e37e83334adc893f2c7bba16c9dd268590b9daad Mon Sep 17 00:00:00 2001 From: Aspw-w <0kcabtuo0@gmail.com> Date: Sat, 6 Apr 2024 21:22:37 +0900 Subject: [PATCH] =?UTF-8?q?via=E3=81=AE=E3=82=A2=E3=83=97=E3=83=87?= =?UTF-8?q?=E3=81=B8=E3=81=AE=E5=AF=BE=E5=BF=9C=E3=82=92=E6=A5=BD=E3=81=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/features/api/McUpdatesHandler.java | 19 +++++------ .../client/features/api/PacketManager.java | 13 ++++--- .../features/module/impl/combat/KillAura.kt | 13 ++++--- .../features/module/impl/combat/TPAura.kt | 7 ++-- .../forge/mixins/block/MixinBlockLadder.java | 6 ++-- .../forge/mixins/block/MixinBlockLilyPad.java | 6 ++-- .../forge/mixins/client/MixinMinecraft.java | 4 +-- .../forge/mixins/entity/MixinEntity.java | 7 ++-- .../mixins/entity/MixinEntityLivingBase.java | 6 ++-- .../mixins/entity/MixinEntityPlayer.java | 9 +++-- .../mixins/entity/MixinEntityPlayerSP.java | 5 ++- .../forge/mixins/item/MixinItemBlock.java | 5 ++- .../mixins/render/MixinLayerArmorBase.java | 5 ++- .../forge/mixins/render/MixinModelBiped.java | 5 ++- .../client/protocol/api/ProtocolFixes.java | 34 ++++++++++++++++++- 15 files changed, 79 insertions(+), 65 deletions(-) diff --git a/src/main/java/net/aspw/client/features/api/McUpdatesHandler.java b/src/main/java/net/aspw/client/features/api/McUpdatesHandler.java index 1d2c8460..1f219e8d 100644 --- a/src/main/java/net/aspw/client/features/api/McUpdatesHandler.java +++ b/src/main/java/net/aspw/client/features/api/McUpdatesHandler.java @@ -1,8 +1,7 @@ package net.aspw.client.features.api; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.event.*; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.AnimationUtils; import net.aspw.client.utils.MinecraftInstance; import net.aspw.client.utils.render.RenderUtils; @@ -46,7 +45,7 @@ private static void resetAll() { @EventTarget public void onPushOut(PushOutEvent event) { - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !mc.isIntegratedServerRunning() && (shouldAnimation() || mc.thePlayer.isSneaking())) + if (ProtocolFixes.newerThanOrEqualsTo1_13() && (shouldAnimation() || mc.thePlayer.isSneaking())) event.cancelEvent(); } @@ -57,7 +56,7 @@ public void onWorld(WorldEvent event) { @EventTarget public void onMotion(MotionEvent event) { - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !mc.isIntegratedServerRunning()) { + if (ProtocolFixes.newerThanOrEqualsTo1_13()) { float START_HEIGHT = 1.62f; float END_HEIGHT; @@ -81,7 +80,7 @@ public void onMotion(MotionEvent event) { @EventTarget public void onUpdate(UpdateEvent event) { - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !mc.isIntegratedServerRunning()) { + if (ProtocolFixes.newerThanOrEqualsTo1_13()) { if (isSwimming()) { if (mc.thePlayer.motionX < -0.4D) { mc.thePlayer.motionX = -0.39F; @@ -120,9 +119,9 @@ public void onUpdate(UpdateEvent event) { float sneakLength; - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_9) && ProtocolBase.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2) && !mc.isIntegratedServerRunning()) + if (ProtocolFixes.newerThanOrEqualsTo1_9() && ProtocolFixes.olderThanOrEqualsTo1_13_2()) sneakLength = 1.65f; - else if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !mc.isIntegratedServerRunning()) + else if (ProtocolFixes.newerThanOrEqualsTo1_14()) sneakLength = 1.5f; else sneakLength = 1.8f; @@ -135,12 +134,12 @@ else if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(Protoco float newHeight; float newWidth; - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !mc.isIntegratedServerRunning() && isSwimmingOrCrawling && underWater() && mc.thePlayer.rotationPitch >= 0.0) { + if (ProtocolFixes.newerThanOrEqualsTo1_13() && isSwimmingOrCrawling && underWater() && mc.thePlayer.rotationPitch >= 0.0) { newHeight = 0.6f; newWidth = 0.6f; isSwimmingOrCrawling = true; mc.thePlayer.setEntityBoundingBox(setThrough); - } else if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !mc.isIntegratedServerRunning() && (isSwimming() && underWater() || !mc.theWorld.getCollisionBoxes(crawl).isEmpty())) { + } else if (ProtocolFixes.newerThanOrEqualsTo1_13() && (isSwimming() && underWater() || !mc.theWorld.getCollisionBoxes(crawl).isEmpty())) { newHeight = 0.6f; newWidth = 0.6f; isSwimmingOrCrawling = true; @@ -157,7 +156,7 @@ else if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(Protoco mc.thePlayer.setEntityBoundingBox(setThrough); } - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_9) && !mc.isIntegratedServerRunning() && mc.thePlayer.onGround && !mc.thePlayer.isSneaking() && !underWater() && (mc.thePlayer.height == sneakLength || mc.thePlayer.height == 0.6F) && !mc.theWorld.getCollisionBoxes(sneak).isEmpty()) { + if (ProtocolFixes.newerThanOrEqualsTo1_9() && mc.thePlayer.onGround && !mc.thePlayer.isSneaking() && !underWater() && (mc.thePlayer.height == sneakLength || mc.thePlayer.height == 0.6F) && !mc.theWorld.getCollisionBoxes(sneak).isEmpty()) { mc.gameSettings.keyBindSneak.pressed = true; } else if (!GameSettings.isKeyDown(mc.gameSettings.keyBindSneak) && mc.theWorld.getCollisionBoxes(sneak).isEmpty()) { mc.gameSettings.keyBindSneak.pressed = false; diff --git a/src/main/java/net/aspw/client/features/api/PacketManager.java b/src/main/java/net/aspw/client/features/api/PacketManager.java index 045aa893..15b2cf92 100644 --- a/src/main/java/net/aspw/client/features/api/PacketManager.java +++ b/src/main/java/net/aspw/client/features/api/PacketManager.java @@ -1,6 +1,5 @@ package net.aspw.client.features.api; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.event.*; import net.aspw.client.features.module.impl.combat.KillAura; @@ -9,7 +8,7 @@ import net.aspw.client.features.module.impl.other.BrandSpoofer; import net.aspw.client.features.module.impl.visual.Animations; import net.aspw.client.features.module.impl.visual.SilentRotations; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.AnimationUtils; import net.aspw.client.utils.MinecraftInstance; import net.aspw.client.utils.RotationUtils; @@ -60,16 +59,16 @@ public void onMotion(MotionEvent event) { lastEyeHeight = eyeHeight; - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_9) && ProtocolBase.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2) && !mc.isIntegratedServerRunning()) + if (ProtocolFixes.newerThanOrEqualsTo1_9() && ProtocolFixes.olderThanOrEqualsTo1_13_2()) END_HEIGHT = 1.47f; - else if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !mc.isIntegratedServerRunning()) + else if (ProtocolFixes.newerThanOrEqualsTo1_14()) END_HEIGHT = 1.32f; else END_HEIGHT = 1.54f; float delta; - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_9) && ProtocolBase.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2) && !mc.isIntegratedServerRunning()) + if (ProtocolFixes.newerThanOrEqualsTo1_9() && ProtocolFixes.olderThanOrEqualsTo1_13_2()) delta = 0.147f; - else if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !mc.isIntegratedServerRunning()) + else if (ProtocolFixes.newerThanOrEqualsTo1_14()) delta = 0.132f; else delta = 0.154f; @@ -136,7 +135,7 @@ public void onPacket(PacketEvent event) { packetCountTimer.reset(); } - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_10)) { + if (ProtocolFixes.newerThanOrEqualsTo1_10()) { if (packet instanceof C08PacketPlayerBlockPlacement) { ((C08PacketPlayerBlockPlacement) packet).facingX = 0.5F; ((C08PacketPlayerBlockPlacement) packet).facingY = 0.5F; diff --git a/src/main/java/net/aspw/client/features/module/impl/combat/KillAura.kt b/src/main/java/net/aspw/client/features/module/impl/combat/KillAura.kt index 76ac6ab9..9eebfc35 100644 --- a/src/main/java/net/aspw/client/features/module/impl/combat/KillAura.kt +++ b/src/main/java/net/aspw/client/features/module/impl/combat/KillAura.kt @@ -4,7 +4,6 @@ import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9 import com.viaversion.viarewind.utils.PacketUtil import com.viaversion.viaversion.api.Via import com.viaversion.viaversion.api.protocol.packet.PacketWrapper -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.type.Type import net.aspw.client.Launch import net.aspw.client.event.* @@ -19,7 +18,7 @@ import net.aspw.client.features.module.impl.player.LegitScaffold import net.aspw.client.features.module.impl.player.Scaffold import net.aspw.client.features.module.impl.targets.AntiBots import net.aspw.client.features.module.impl.targets.AntiTeams -import net.aspw.client.protocol.ProtocolBase +import net.aspw.client.protocol.api.ProtocolFixes import net.aspw.client.utils.* import net.aspw.client.utils.extensions.getDistanceToEntityBox import net.aspw.client.utils.extensions.getNearestPointBB @@ -428,7 +427,7 @@ class KillAura : Module() { if (multiCombo.get()) { event.targetEntity ?: return repeat(amountValue.get()) { - if (ProtocolBase.getManager().targetVersion.newerThan(ProtocolVersion.v1_8)) + if (ProtocolFixes.newerThan1_8()) mc.netHandler.addToSendQueue( C02PacketUseEntity( event.targetEntity, @@ -438,7 +437,7 @@ class KillAura : Module() { mc.netHandler.addToSendQueue(C0APacketAnimation()) - if (!ProtocolBase.getManager().targetVersion.newerThan(ProtocolVersion.v1_8)) + if (!ProtocolFixes.newerThan1_8()) mc.netHandler.addToSendQueue( C02PacketUseEntity( event.targetEntity, @@ -624,7 +623,7 @@ class KillAura : Module() { } // Attack target - if (ProtocolBase.getManager().targetVersion.newerThan(ProtocolVersion.v1_8)) + if (ProtocolFixes.newerThan1_8()) mc.netHandler.addToSendQueue(C02PacketUseEntity(entity, C02PacketUseEntity.Action.ATTACK)) when (swingValue.get().lowercase(Locale.getDefault())) { @@ -638,7 +637,7 @@ class KillAura : Module() { "packet" -> mc.netHandler.addToSendQueue(C0APacketAnimation()) } - if (!ProtocolBase.getManager().targetVersion.newerThan(ProtocolVersion.v1_8)) + if (!ProtocolFixes.newerThan1_8()) mc.netHandler.addToSendQueue(C02PacketUseEntity(entity, C02PacketUseEntity.Action.ATTACK)) when (particleValue.get().lowercase()) { @@ -795,7 +794,7 @@ class KillAura : Module() { } "1.9+" -> { - if (ProtocolBase.getManager().targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) { + if (ProtocolFixes.newerThanOrEqualsTo1_9()) { val useItem = PacketWrapper.create(29, null, Via.getManager().connectionManager.connections.iterator().next()) useItem.write(Type.VAR_INT, 1) diff --git a/src/main/java/net/aspw/client/features/module/impl/combat/TPAura.kt b/src/main/java/net/aspw/client/features/module/impl/combat/TPAura.kt index f48a9a54..b7688455 100644 --- a/src/main/java/net/aspw/client/features/module/impl/combat/TPAura.kt +++ b/src/main/java/net/aspw/client/features/module/impl/combat/TPAura.kt @@ -1,13 +1,12 @@ package net.aspw.client.features.module.impl.combat -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import net.aspw.client.event.EventTarget import net.aspw.client.event.UpdateEvent import net.aspw.client.event.WorldEvent import net.aspw.client.features.module.Module import net.aspw.client.features.module.ModuleCategory import net.aspw.client.features.module.ModuleInfo -import net.aspw.client.protocol.ProtocolBase +import net.aspw.client.protocol.api.ProtocolFixes import net.aspw.client.utils.EntityUtils import net.aspw.client.utils.PacketUtils import net.aspw.client.utils.RotationUtils @@ -134,7 +133,7 @@ class TPAura : Module() { lastTarget = it - if (ProtocolBase.getManager().targetVersion.newerThan(ProtocolVersion.v1_8)) + if (ProtocolFixes.newerThan1_8()) mc.netHandler.addToSendQueue(C02PacketUseEntity(it, C02PacketUseEntity.Action.ATTACK)) when (swingValue.get().lowercase(Locale.getDefault())) { @@ -142,7 +141,7 @@ class TPAura : Module() { "packet" -> mc.netHandler.addToSendQueue(C0APacketAnimation()) } - if (!ProtocolBase.getManager().targetVersion.newerThan(ProtocolVersion.v1_8)) + if (!ProtocolFixes.newerThan1_8()) mc.netHandler.addToSendQueue(C02PacketUseEntity(it, C02PacketUseEntity.Action.ATTACK)) path.reverse() diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLadder.java b/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLadder.java index cb017a40..94d0f0a0 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLadder.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLadder.java @@ -1,8 +1,6 @@ package net.aspw.client.injection.forge.mixins.block; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import net.aspw.client.protocol.ProtocolBase; -import net.aspw.client.utils.MinecraftInstance; +import net.aspw.client.protocol.api.ProtocolFixes; import net.minecraft.block.BlockLadder; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; @@ -16,7 +14,7 @@ public abstract class MixinBlockLadder extends MixinBlock { @ModifyConstant(method = "setBlockBoundsBasedOnState", constant = @Constant(floatValue = 0.125F)) private float ViaVersion_LadderBB(float constant) { - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) + if (ProtocolFixes.newerThan1_8()) return 0.1875F; return 0.125F; } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLilyPad.java b/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLilyPad.java index b320d666..f83771cf 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLilyPad.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLilyPad.java @@ -1,8 +1,6 @@ package net.aspw.client.injection.forge.mixins.block; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import net.aspw.client.protocol.ProtocolBase; -import net.aspw.client.utils.MinecraftInstance; +import net.aspw.client.protocol.api.ProtocolFixes; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLilyPad; import net.minecraft.block.state.IBlockState; @@ -24,7 +22,7 @@ public abstract class MixinBlockLilyPad extends BlockBush { */ @Overwrite public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) + if (ProtocolFixes.newerThan1_8()) return new AxisAlignedBB((double) pos.getX() + 0.0625D, (double) pos.getY() + 0.0D, (double) pos.getZ() + 0.0625D, (double) pos.getX() + 0.9375D, (double) pos.getY() + 0.09375D, (double) pos.getZ() + 0.9375D); return new AxisAlignedBB((double) pos.getX() + 0.0D, (double) pos.getY() + 0.0D, (double) pos.getZ() + 0.0D, (double) pos.getX() + 1.0D, (double) pos.getY() + 0.015625D, (double) pos.getZ() + 1.0D); } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/client/MixinMinecraft.java b/src/main/java/net/aspw/client/injection/forge/mixins/client/MixinMinecraft.java index edd9fb28..92f41ae9 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/client/MixinMinecraft.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/client/MixinMinecraft.java @@ -1,11 +1,9 @@ package net.aspw.client.injection.forge.mixins.client; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.event.*; import net.aspw.client.features.module.impl.other.FastPlace; import net.aspw.client.injection.forge.mixins.accessors.MinecraftForgeClientAccessor; -import net.aspw.client.protocol.ProtocolBase; import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.CPSCounter; import net.aspw.client.utils.MinecraftInstance; @@ -270,7 +268,7 @@ private void sendClickBlockToController(boolean leftClick) { if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { BlockPos blockPos = this.objectMouseOver.getBlockPos(); - if (this.thePlayer.isUsingItem() && ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_8)) + if (this.thePlayer.isUsingItem() && ProtocolFixes.newerThanOrEqualsTo1_8()) return; if (this.leftClickCounter == 0) diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntity.java b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntity.java index d2e84656..29f514d7 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntity.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntity.java @@ -1,11 +1,10 @@ package net.aspw.client.injection.forge.mixins.entity; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.event.StrafeEvent; import net.aspw.client.features.module.impl.combat.HitBox; import net.aspw.client.features.module.impl.movement.Flight; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.EntityUtils; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.block.Block; @@ -355,12 +354,12 @@ private void getCollisionBorderSize(final CallbackInfoReturnable callback final HitBox hitBoxes = Objects.requireNonNull(Launch.moduleManager.getModule(HitBox.class)); if (hitBoxes.getState() && EntityUtils.isSelected(((Entity) ((Object) this)), true)) { - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) { + if (ProtocolFixes.newerThan1_8()) { callbackInfoReturnable.setReturnValue(hitBoxes.getSizeValue().get()); } else { callbackInfoReturnable.setReturnValue(0.1F + hitBoxes.getSizeValue().get()); } - } else if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) { + } else if (ProtocolFixes.newerThan1_8()) { callbackInfoReturnable.setReturnValue(0.0F); } } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityLivingBase.java b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityLivingBase.java index e90a4a10..6365699a 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityLivingBase.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityLivingBase.java @@ -1,14 +1,12 @@ package net.aspw.client.injection.forge.mixins.entity; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.event.JumpEvent; import net.aspw.client.features.module.impl.movement.Jesus; import net.aspw.client.features.module.impl.movement.NoJumpDelay; import net.aspw.client.features.module.impl.visual.Animations; import net.aspw.client.features.module.impl.visual.VisualAbilities; -import net.aspw.client.protocol.ProtocolBase; -import net.aspw.client.utils.MinecraftInstance; +import net.aspw.client.protocol.api.ProtocolFixes; import net.minecraft.block.Block; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.EntityLivingBase; @@ -176,7 +174,7 @@ private void isPotionActive(Potion p_isPotionActive_1_, final CallbackInfoReturn @ModifyConstant(method = "onLivingUpdate", constant = @Constant(doubleValue = 0.005D)) private double ViaVersion_MovementThreshold(double constant) { - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) + if (ProtocolFixes.newerThan1_8()) return 0.003D; return 0.005D; } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayer.java b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayer.java index 7d4035d7..d42e6ec6 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayer.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayer.java @@ -1,7 +1,6 @@ package net.aspw.client.injection.forge.mixins.entity; import com.mojang.authlib.GameProfile; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.features.api.McUpdatesHandler; import net.aspw.client.features.api.PacketManager; @@ -10,7 +9,7 @@ import net.aspw.client.features.module.impl.movement.LongJump; import net.aspw.client.features.module.impl.movement.Speed; import net.aspw.client.features.module.impl.player.BowJump; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.CooldownHelper; import net.aspw.client.utils.MinecraftInstance; import net.aspw.client.utils.PacketUtils; @@ -145,7 +144,7 @@ public float getEyeHeight() { final Flight flight = Objects.requireNonNull(Launch.moduleManager.getModule(Flight.class)); final Speed speed = Objects.requireNonNull(Launch.moduleManager.getModule(Speed.class)); final BowJump bowJump = Objects.requireNonNull(Launch.moduleManager.getModule(BowJump.class)); - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !mc.isIntegratedServerRunning() && McUpdatesHandler.doingEyeRot) + if (ProtocolFixes.newerThanOrEqualsTo1_13() && McUpdatesHandler.doingEyeRot) return McUpdatesHandler.lastEyeHeight + (McUpdatesHandler.eyeHeight - McUpdatesHandler.lastEyeHeight) * mc.timer.renderPartialTicks; if (this.isPlayerSleeping()) return 0.2F; @@ -181,7 +180,7 @@ private void injectCooldown(final CallbackInfo callbackInfo) { @Inject(method = "dropItem", at = @At("HEAD")) private void dropItem(ItemStack p_dropItem_1_, boolean p_dropItem_2_, boolean p_dropItem_3_, CallbackInfoReturnable cir) { for (int i = 0; i < this.mainInventory.length; ++i) { - if (!MinecraftInstance.mc.isIntegratedServerRunning() && ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_16)) + if (ProtocolFixes.newerThanOrEqualsTo1_16()) PacketUtils.sendPacketNoEvent(new C0APacketAnimation()); if (this.mainInventory[i] != null) { this.mainInventory[i] = null; @@ -189,7 +188,7 @@ private void dropItem(ItemStack p_dropItem_1_, boolean p_dropItem_2_, boolean p_ } for (int j = 0; j < this.armorInventory.length; ++j) { - if (!MinecraftInstance.mc.isIntegratedServerRunning() && ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_16)) + if (ProtocolFixes.newerThanOrEqualsTo1_16()) PacketUtils.sendPacketNoEvent(new C0APacketAnimation()); if (this.armorInventory[j] != null) { this.armorInventory[j] = null; diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayerSP.java b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayerSP.java index d4966331..4f5d0798 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayerSP.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityPlayerSP.java @@ -1,6 +1,5 @@ package net.aspw.client.injection.forge.mixins.entity; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.event.*; import net.aspw.client.features.module.impl.exploit.PortalMenu; @@ -8,7 +7,7 @@ import net.aspw.client.features.module.impl.movement.SilentSneak; import net.aspw.client.features.module.impl.player.Scaffold; import net.aspw.client.features.module.impl.visual.Interface; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.CooldownHelper; import net.aspw.client.utils.MovementUtils; import net.aspw.client.utils.Rotation; @@ -217,7 +216,7 @@ public void updateEntityActionState() { @Redirect(method = "onUpdateWalkingPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/NetHandlerPlayClient;addToSendQueue(Lnet/minecraft/network/Packet;)V", ordinal = 7)) public void emulateIdlePacket(final NetHandlerPlayClient instance, final Packet p_addToSendQueue_1_) { - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8)) { + if (ProtocolFixes.newerThan1_8()) { if (this.viaForge$prevOnGround == this.onGround) { return; } diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/item/MixinItemBlock.java b/src/main/java/net/aspw/client/injection/forge/mixins/item/MixinItemBlock.java index 13a94d13..a4b4eba8 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/item/MixinItemBlock.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/item/MixinItemBlock.java @@ -1,7 +1,6 @@ package net.aspw.client.injection.forge.mixins.item; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -53,7 +52,7 @@ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); } - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) { + if (ProtocolFixes.newerThan1_8()) { MinecraftInstance.mc.theWorld.playSoundAtPos(pos.add(0.5, 0.5, 0.5), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F, false); } else { worldIn.playSoundEffect((float) pos.getX() + 0.5F, (float) pos.getY() + 0.5F, (float) pos.getZ() + 0.5F, this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinLayerArmorBase.java b/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinLayerArmorBase.java index 53a05496..e3e87fcb 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinLayerArmorBase.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinLayerArmorBase.java @@ -1,10 +1,9 @@ package net.aspw.client.injection.forge.mixins.render; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.features.api.McUpdatesHandler; import net.aspw.client.features.module.impl.visual.CustomModel; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.client.renderer.entity.layers.LayerArmorBase; import net.minecraft.entity.EntityLivingBase; @@ -37,7 +36,7 @@ public class MixinLayerArmorBase { public void doRenderLayer(final EntityLivingBase entitylivingbaseIn, final float limbSwing, final float limbSwingAmount, final float partialTicks, final float ageInTicks, final float netHeadYaw, final float headPitch, final float scale, final CallbackInfo ci) { final CustomModel customModel = Objects.requireNonNull(Launch.moduleManager.getModule(CustomModel.class)); - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !MinecraftInstance.mc.isIntegratedServerRunning() && McUpdatesHandler.shouldAnimation() && entitylivingbaseIn == MinecraftInstance.mc.thePlayer) + if (ProtocolFixes.newerThanOrEqualsTo1_13() && McUpdatesHandler.shouldAnimation() && entitylivingbaseIn == MinecraftInstance.mc.thePlayer) ci.cancel(); if (customModel.getState() && customModel.getOnlySelf().get() && entitylivingbaseIn == MinecraftInstance.mc.thePlayer) { diff --git a/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinModelBiped.java b/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinModelBiped.java index 8def0b31..13cd9b35 100644 --- a/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinModelBiped.java +++ b/src/main/java/net/aspw/client/injection/forge/mixins/render/MixinModelBiped.java @@ -1,6 +1,5 @@ package net.aspw.client.injection.forge.mixins.render; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.aspw.client.Launch; import net.aspw.client.features.api.McUpdatesHandler; import net.aspw.client.features.api.PacketManager; @@ -9,7 +8,7 @@ import net.aspw.client.features.module.impl.combat.TPAura; import net.aspw.client.features.module.impl.movement.SilentSneak; import net.aspw.client.features.module.impl.visual.Animations; -import net.aspw.client.protocol.ProtocolBase; +import net.aspw.client.protocol.api.ProtocolFixes; import net.aspw.client.utils.MinecraftInstance; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; @@ -56,7 +55,7 @@ private void revertSwordAnimation(float p_setRotationAngles1, float p_setRotatio final KillAuraRecode killAuraRecode = Objects.requireNonNull(Launch.moduleManager.getModule(KillAuraRecode.class)); final SilentSneak silentSneak = Objects.requireNonNull(Launch.moduleManager.getModule(SilentSneak.class)); - if (ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !MinecraftInstance.mc.isIntegratedServerRunning() && McUpdatesHandler.shouldAnimation() && p_setRotationAngles7 instanceof EntityPlayer && p_setRotationAngles7.equals(MinecraftInstance.mc.thePlayer)) { + if (ProtocolFixes.newerThanOrEqualsTo1_13() && McUpdatesHandler.shouldAnimation() && p_setRotationAngles7 instanceof EntityPlayer && p_setRotationAngles7.equals(MinecraftInstance.mc.thePlayer)) { GlStateManager.rotate(45.0F, 1F, 0.0F, 0.0F); GlStateManager.translate(0.0F, 0.0F, -0.7F); 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 fb40afe1..6a509f28 100644 --- a/src/main/java/net/aspw/client/protocol/api/ProtocolFixes.java +++ b/src/main/java/net/aspw/client/protocol/api/ProtocolFixes.java @@ -18,7 +18,7 @@ public static void sendConditionalSwing(final MovingObjectPosition mop) { } public static void sendFixedAttack(final EntityPlayer entityIn, final Entity target) { - if (ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8)) { + if (newerThan1_8()) { mc.playerController.attackEntity(entityIn, target); mc.thePlayer.swingItem(); } else { @@ -26,4 +26,36 @@ public static void sendFixedAttack(final EntityPlayer entityIn, final Entity tar mc.playerController.attackEntity(entityIn, target); } } + + public static boolean newerThan1_8() { + return ProtocolBase.getManager().getTargetVersion().newerThan(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean newerThanOrEqualsTo1_8() { + return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_8) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean newerThanOrEqualsTo1_9() { + return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_9) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean newerThanOrEqualsTo1_10() { + return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_10) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean newerThanOrEqualsTo1_13() { + return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_13) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean olderThanOrEqualsTo1_13_2() { + return ProtocolBase.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean newerThanOrEqualsTo1_14() { + return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } + + public static boolean newerThanOrEqualsTo1_16() { + return ProtocolBase.getManager().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14) && !MinecraftInstance.mc.isIntegratedServerRunning(); + } } \ No newline at end of file