blob: 30390ee6dcdf0d9d31dc88851cc1250a7ba8e2c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package com.arslaancodes.arslaansmagichax.mixin;
import com.arslaancodes.arslaansmagichax.events.SendPacketEventBus;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.network.protocol.Packet;
import com.arslaancodes.arslaansmagichax.events.PacketEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientCommonPacketListenerImpl.class)
public class ClientCommonNetworkHandlerMixin {
@Inject(method = "send", at = @At("HEAD"), cancellable = true)
private void onSendPacket(Packet<?> packet, CallbackInfo ci) {
PacketEvent.Send ev = new PacketEvent.Send(packet);
SendPacketEventBus.post(ev);
if (ev.isCancelled()) {
ci.cancel();
}
}
}
|