Skip to content

Commit

Permalink
TEMP: 1.19 test server compat
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Aug 6, 2023
1 parent a0475aa commit ca43a6a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
49 changes: 25 additions & 24 deletions src/main/java/com/zenith/feature/pathing/Pathing.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,34 @@ public Position calculateNextMove(final BlockPos goal) {
final Position goalPosition = new Position(goal.getX() + 0.5, goal.getY(), goal.getZ() + 0.5);
final double xDelta = goalPosition.getX() - currentPlayerPos.getX();
final double zDelta = goalPosition.getZ() - currentPlayerPos.getZ();
if (Math.abs(xDelta) > Math.abs(zDelta)) {
if (xDelta != 0) {
final Position xMovePos = currentPlayerPos.addX(getNextMoveDelta(xDelta));
if (isNextWalkSafe(xMovePos)) {
return xMovePos;
}
}
if (zDelta != 0) {
final Position zMovePos = currentPlayerPos.addZ(getNextMoveDelta(zDelta));
if (isNextWalkSafe(zMovePos)) {
return zMovePos;
}
}
} else {
if (zDelta != 0) {
final Position zMovePos = currentPlayerPos.addZ(getNextMoveDelta(zDelta));
if (isNextWalkSafe(zMovePos)) {
return zMovePos;
}
if (xDelta != 0) {
final Position xMovePos = currentPlayerPos.addX(getNextMoveDelta(xDelta));
if (isNextWalkSafe(xMovePos)) {
return xMovePos;
}
if (xDelta != 0) {
final Position xMovePos = currentPlayerPos.addX(getNextMoveDelta(xDelta));
if (isNextWalkSafe(xMovePos)) {
return xMovePos;
}
}
if (zDelta != 0) {
final Position zMovePos = currentPlayerPos.addZ(getNextMoveDelta(zDelta));
if (isNextWalkSafe(zMovePos)) {
return zMovePos;
}
}
// if (Math.abs(xDelta) > Math.abs(zDelta)) {
//
// } else {
// if (zDelta != 0) {
// final Position zMovePos = currentPlayerPos.addZ(getNextMoveDelta(zDelta));
// if (isNextWalkSafe(zMovePos)) {
// return zMovePos;
// }
// }
// if (xDelta != 0) {
// final Position xMovePos = currentPlayerPos.addX(getNextMoveDelta(xDelta));
// if (isNextWalkSafe(xMovePos)) {
// return xMovePos;
// }
// }
// }

// CLIENT_LOG.info("Pathing: No safe movement towards goal found");
return currentPlayerPos;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/zenith/feature/pathing/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public static int floor(double value) {
}

public ClientPlayerPositionPacket toPlayerPositionPacket() {
return new ClientPlayerPositionPacket(false, x, y, z);
return toPlayerPositionPacket(false);
}

public ClientPlayerPositionPacket toPlayerPositionPacket(boolean onGround) {
return new ClientPlayerPositionPacket(onGround, x, y, z);
}

public BlockPos toBlockPos() {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/zenith/module/impl/AntiAFK.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import com.collarmc.pounce.Subscribe;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
Expand Down Expand Up @@ -90,7 +88,7 @@ && isNull(Proxy.getInstance().getCurrentPlayer().get())
gravityTick();
}
if (CONFIG.client.extra.antiafk.actions.walk && (!CONFIG.client.extra.antiafk.actions.gravity || gravityT <= 0)) {
sendClientPacketAsync(new ClientPlayerStatePacket(CACHE.getPlayerCache().getEntityId(), PlayerState.STOP_SPRINTING));
// sendClientPacketAsync(new ClientPlayerStatePacket(CACHE.getPlayerCache().getEntityId(), PlayerState.STOP_SPRINTING));
walkTick();
// check distance delta every 9 mins. Stuck kick should happen at 20 mins
if (distanceDeltaCheckTimer.tick(10800L, true) && CONFIG.client.server.address.toLowerCase().contains("2b2t.org") && CONFIG.client.extra.antiafk.actions.stuckWarning) {
Expand Down Expand Up @@ -203,7 +201,7 @@ private void walkTick() {
if (nextMovePos.equals(PATHING.getCurrentPlayerPos())) {
shouldWalk = false;
}
sendClientPacketAsync(nextMovePos.toPlayerPositionPacket());
sendClientPacketAsync(nextMovePos.toPlayerPositionPacket());
this.positionCache.put(nextMovePos, nextMovePos);
}
}
Expand Down Expand Up @@ -237,7 +235,7 @@ private boolean antiStuckTick() {
}
antiStuckStartY = PATHING.getCurrentPlayerPos().getY();
// increases hunger loss by 4x if we're sprinting
sendClientPacketAsync(new ClientPlayerStatePacket(CACHE.getPlayerCache().getEntityId(), PlayerState.START_SPRINTING));
// sendClientPacketAsync(new ClientPlayerStatePacket(CACHE.getPlayerCache().getEntityId(), PlayerState.START_SPRINTING));
}
final Position nextAntiStuckMove = PATHING.calculateNextJumpMove(antiStuckStartY, antiStuckT);
antiStuckT++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void packetSent(Session session, Packet packet) {
@Override
public void packetError(PacketErrorEvent event) {
CLIENT_LOG.error("", event.getCause());
event.setSuppress(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket;
import com.zenith.Proxy;
import com.zenith.network.client.ClientSession;
import com.zenith.network.registry.AsyncIncomingHandler;
import com.zenith.util.Wait;
import lombok.NonNull;


Expand All @@ -15,6 +17,11 @@ public boolean applyAsync(@NonNull ServerConfirmTransactionPacket packet, @NonNu
if (packet.getWindowId() == 0 && packet.getActionId() == -1337 && !packet.getAccepted()) {
session.send(new ClientConfirmTransactionPacket(packet.getWindowId(), packet.getActionId(), true));
}
// Via Ping packet compat
if (Proxy.getInstance().getCurrentPlayer().get() == null) {
Wait.waitALittleMs(300);
session.send(new ClientConfirmTransactionPacket(packet.getWindowId(), packet.getActionId(), true));
}
return true;
}

Expand Down

0 comments on commit ca43a6a

Please sign in to comment.