Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed stronghold locate not working (and any module that handles Entity S2C packets) by adding bundle packet support #3840

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -21,8 +21,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 @@ -33,12 +35,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