Skip to content

Commit

Permalink
Added bundle packet support
Browse files Browse the repository at this point in the history
Regenerated PacketUtil
  • Loading branch information
hexadecimal233 authored and Wide-Cat committed Aug 12, 2023
1 parent 4a5b958 commit 96ba7da
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ private void lastPosition(double x, double y, double z) {
}

private void findStronghold() {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop");
if (this.firstStart == null || this.firstEnd == null || this.secondStart == null || this.secondEnd == null) {
error("Missing position data");
cancel();
Expand All @@ -284,7 +285,6 @@ private void findStronghold() {
cancel();
return;
}
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop");
MeteorClient.EVENT_BUS.unsubscribe(this);
Vec3d coords = new Vec3d(intersection[0], 0, intersection[1]);
MutableText text = Text.literal("Stronghold roughly located at ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.PacketEncoderException;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BundleS2CPacket;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand All @@ -34,12 +36,17 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.net.InetSocketAddress;
import java.util.Iterator;

@Mixin(ClientConnection.class)
public class ClientConnectionMixin {
@Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
private static <T extends PacketListener> void onHandlePacket(Packet<T> packet, PacketListener listener, CallbackInfo info) {
if (MeteorClient.EVENT_BUS.post(PacketEvent.Receive.get(packet)).isCancelled()) info.cancel();
if (packet instanceof BundleS2CPacket bundle) {
for (Iterator<Packet<ClientPlayPacketListener>> it = bundle.getPackets().iterator(); it.hasNext(); ) {
if (MeteorClient.EVENT_BUS.post(PacketEvent.Receive.get(it.next())).isCancelled()) it.remove();
}
} else if (MeteorClient.EVENT_BUS.post(PacketEvent.Receive.get(packet)).isCancelled()) info.cancel();
}

@Inject(method = "disconnect", at = @At("HEAD"))
Expand Down
Loading

0 comments on commit 96ba7da

Please sign in to comment.