Skip to content

Commit 93acaec

Browse files
Wide-CatMukjepScarlet
authored andcommitted
Send appropriate packets with correct sequence numbers
1 parent 5a908ce commit 93acaec

File tree

10 files changed

+36
-26
lines changed

10 files changed

+36
-26
lines changed

src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
import meteordevelopment.meteorclient.systems.modules.player.SpeedMine;
1616
import meteordevelopment.meteorclient.utils.world.BlockUtils;
1717
import net.minecraft.block.BlockState;
18-
import net.minecraft.client.network.ClientPlayNetworkHandler;
1918
import net.minecraft.client.network.ClientPlayerEntity;
2019
import net.minecraft.client.network.ClientPlayerInteractionManager;
20+
import net.minecraft.client.network.SequencedPacketCreator;
21+
import net.minecraft.client.world.ClientWorld;
2122
import net.minecraft.entity.Entity;
2223
import net.minecraft.entity.player.PlayerEntity;
2324
import net.minecraft.item.ItemStack;
@@ -29,7 +30,6 @@
2930
import net.minecraft.util.math.BlockPos;
3031
import net.minecraft.util.math.Direction;
3132
import org.objectweb.asm.Opcodes;
32-
import org.spongepowered.asm.mixin.Final;
3333
import org.spongepowered.asm.mixin.Mixin;
3434
import org.spongepowered.asm.mixin.Shadow;
3535
import org.spongepowered.asm.mixin.injection.At;
@@ -47,11 +47,10 @@ public abstract class ClientPlayerInteractionManagerMixin implements IClientPlay
4747
@Shadow protected abstract void syncSelectedSlot();
4848

4949
@Shadow
50-
@Final
51-
private ClientPlayNetworkHandler networkHandler;
50+
public abstract boolean breakBlock(BlockPos pos);
5251

5352
@Shadow
54-
public abstract boolean breakBlock(BlockPos pos);
53+
public abstract void sendSequencedPacket(ClientWorld world, SequencedPacketCreator packetCreator);
5554

5655
@Inject(method = "clickSlot", at = @At("HEAD"), cancellable = true)
5756
private void onClickSlot(int syncId, int slotId, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo info) {
@@ -75,8 +74,8 @@ private void onAttackBlock(BlockPos blockPos, Direction direction, CallbackInfoR
7574

7675
if (state.calcBlockBreakingDelta(mc.player, mc.world, blockPos) > 0.5f) {
7776
breakBlock(blockPos);
78-
networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, direction));
79-
networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction));
77+
sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, direction, sequence));
78+
sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction, sequence));
8079
info.setReturnValue(true);
8180
}
8281
}

src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AntiBed.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ private void place(BlockPos blockPos) {
8989
}
9090

9191
private void sendMinePackets(BlockPos blockPos) {
92-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP));
93-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP));
92+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP, sequence));
93+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP, sequence));
9494
}
9595

9696
private void sendStopPackets(BlockPos blockPos) {

src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ public void mine(boolean done) {
212212
if (rotate.get()) Rotations.rotate(Rotations.getYaw(targetPos), Rotations.getPitch(targetPos));
213213

214214
Direction direction = BlockUtils.getDirection(targetPos);
215-
if (!done) mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, targetPos, direction));
216-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, targetPos, direction));
215+
if (!done) mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, targetPos, direction, sequence));
216+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, targetPos, direction, sequence));
217217

218218
if (swingHand.get()) mc.player.swingHand(Hand.MAIN_HAND);
219219
else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));

src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ private void placeCrystal(BlockHitResult result, double damage, BlockPos support
10361036
// Place
10371037
if (supportBlock == null) {
10381038
// Place crystal
1039-
mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(hand, result, 0));
1039+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) ->new PlayerInteractBlockC2SPacket(hand, result, sequence));
10401040

10411041
if (swingMode.get().client()) mc.player.swingHand(hand);
10421042
if (swingMode.get().packet()) mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand));

src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ private void tuneBlocks() {
870870

871871
private void tuneNoteblockWithPackets(BlockPos pos) {
872872
// We don't need to raycast here. Server handles this packet fine
873-
mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(Vec3d.ofCenter(pos), Direction.DOWN, pos, false), 0));
873+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(Vec3d.ofCenter(pos), Direction.DOWN, pos, false), sequence));
874874

875875
anyNoteblockTuned = true;
876876
}
@@ -927,7 +927,7 @@ private void onTickPlay() {
927927
private void playRotate(BlockPos pos) {
928928
if (mc.interactionManager == null) return;
929929
try {
930-
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, Direction.DOWN, 0));
930+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, Direction.DOWN, sequence));
931931
} catch (NullPointerException ignored) {
932932
}
933933
}

src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstantRebreak.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ private void onTick(TickEvent.Pre event) {
117117
}
118118

119119
public void sendPacket() {
120-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction == null ? Direction.UP : direction));
120+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) ->
121+
new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction == null ? Direction.UP : direction, sequence)
122+
);
121123
}
122124

123125
public boolean shouldMine() {

src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,11 +1314,18 @@ protected void tick(HighwayBuilder b) {
13141314
return;
13151315
}
13161316

1317-
PlayerActionC2SPacket p = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, bp, BlockUtils.getDirection(bp));
13181317
rebreakTimer = b.rebreakTimer.get();
13191318

1320-
if (b.rotation.get().mine) Rotations.rotate(Rotations.getYaw(bp), Rotations.getPitch(bp), () -> b.mc.getNetworkHandler().sendPacket(p));
1321-
else b.mc.getNetworkHandler().sendPacket(p);
1319+
if (b.rotation.get().mine) {
1320+
Rotations.rotate(Rotations.getYaw(bp), Rotations.getPitch(bp), () ->
1321+
b.mc.interactionManager.sendSequencedPacket(b.mc.world, (sequence) ->
1322+
new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, bp, BlockUtils.getDirection(bp), sequence)
1323+
)
1324+
);
1325+
}
1326+
else b.mc.interactionManager.sendSequencedPacket(b.mc.world, (sequence) ->
1327+
new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, bp, BlockUtils.getDirection(bp), sequence)
1328+
);
13221329
}
13231330
else {
13241331
if (b.rotation.get().mine) Rotations.rotate(Rotations.getYaw(bp), Rotations.getPitch(bp), () -> BlockUtils.breakBlock(bp, true));
@@ -2797,13 +2804,13 @@ public DoubleMineBlock(HighwayBuilder b, BlockPos pos) {
27972804
}
27982805

27992806
public DoubleMineBlock startDestroying() {
2800-
b.mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, this.blockPos, this.direction));
2807+
b.mc.interactionManager.sendSequencedPacket(b.mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, this.blockPos, this.direction, sequence));
28012808
normalStartTime = b.mc.player.age;
28022809
return this;
28032810
}
28042811

28052812
public DoubleMineBlock stopDestroying() {
2806-
b.mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, this.blockPos, this.direction));
2813+
b.mc.interactionManager.sendSequencedPacket(b.mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, this.blockPos, this.direction, sequence));
28072814
return this;
28082815
}
28092816

src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,12 @@ private void breakBlock(BlockPos blockPos) {
501501
interacted.add(blockPos);
502502
} else if (packetMine.get()) {
503503
// Packet mine mode
504-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, BlockUtils.getDirection(blockPos)));
504+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, BlockUtils.getDirection(blockPos), sequence));
505505

506506
if (swing.get()) mc.player.swingHand(Hand.MAIN_HAND);
507507
else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
508508

509-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, BlockUtils.getDirection(blockPos)));
509+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, BlockUtils.getDirection(blockPos), sequence));
510510
} else {
511511
// Legit mine mode
512512
BlockUtils.breakBlock(blockPos, swing.get());

src/main/java/meteordevelopment/meteorclient/systems/modules/world/PacketMine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ public void mine() {
256256
private void sendMinePackets() {
257257
if (timer <= 0) {
258258
if (!mining) {
259-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, direction));
260-
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction));
259+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, direction, sequence));
260+
mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction, sequence));
261261

262262
mining = true;
263263
}

src/main/resources/meteor-client.accesswidener

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ accessible method com/mojang/blaze3d/pipeline/RenderPipeline$Builder withSnip
2323
accessible field net/minecraft/client/render/RenderPhase ITEM_ENTITY_TARGET Lnet/minecraft/client/render/RenderPhase$Target;
2424

2525
# Auto Fish
26-
accessible class net/minecraft/entity/projectile/FishingBobberEntity$State
27-
accessible field net/minecraft/entity/projectile/FishingBobberEntity state Lnet/minecraft/entity/projectile/FishingBobberEntity$State;
26+
accessible class net/minecraft/entity/projectile/FishingBobberEntity$State
27+
accessible field net/minecraft/entity/projectile/FishingBobberEntity state Lnet/minecraft/entity/projectile/FishingBobberEntity$State;
28+
29+
accessible method net/minecraft/client/network/ClientPlayerInteractionManager sendSequencedPacket (Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V

0 commit comments

Comments
 (0)