Skip to content

Commit

Permalink
viaのアプデへの対応を楽へ
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspw-w committed Apr 6, 2024
1 parent 22778f4 commit e37e833
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 65 deletions.
19 changes: 9 additions & 10 deletions src/main/java/net/aspw/client/features/api/McUpdatesHandler.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}

Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/net/aspw/client/features/api/PacketManager.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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())) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -134,15 +133,15 @@ 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())) {
"normal" -> mc.thePlayer.swingItem()
"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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -355,12 +354,12 @@ private void getCollisionBorderSize(final CallbackInfoReturnable<Float> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit e37e833

Please sign in to comment.