MixinNetHandlerPlayServer.java
3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.mumfrey.liteloader.common.mixin;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.mumfrey.liteloader.common.ducks.ITeleportHandler;
import com.mumfrey.liteloader.core.Proxy;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.client.CPacketAnimation;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.network.play.client.CPacketPlayerBlockPlacement;
import net.minecraft.network.play.client.CPacketPlayerDigging;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.WorldServer;
@Mixin(NetHandlerPlayServer.class)
public abstract class MixinNetHandlerPlayServer implements ITeleportHandler
{
@Shadow private int teleportId;
@Shadow private Vec3d field_184362_y;
@Inject(
method = "processPlayerBlockPlacement(Lnet/minecraft/network/play/client/CPacketPlayerBlockPlacement;)V",
cancellable = true,
at = @At(
value = "INVOKE",
shift = Shift.AFTER,
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue"
+ "(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"
)
)
private void onPlaceBlock(CPacketPlayerBlockPlacement packetIn, CallbackInfo ci)
{
Proxy.onPlaceBlock(ci, (NetHandlerPlayServer)(Object)this, packetIn);
}
@Inject(
method = "handleAnimation(Lnet/minecraft/network/play/client/CPacketAnimation;)V",
cancellable = true,
at = @At(
value = "INVOKE",
shift = Shift.AFTER,
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue"
+ "(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"
)
)
private void onClickedAir(CPacketAnimation packetIn, CallbackInfo ci)
{
Proxy.onClickedAir(ci, (NetHandlerPlayServer)(Object)this, packetIn);
}
@Inject(
method = "processPlayerDigging(Lnet/minecraft/network/play/client/CPacketPlayerDigging;)V",
cancellable = true,
at = @At(
value = "INVOKE",
shift = Shift.AFTER,
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue"
+ "(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"
)
)
private void onPlayerDigging(CPacketPlayerDigging packetIn, CallbackInfo ci)
{
Proxy.onPlayerDigging(ci, (NetHandlerPlayServer)(Object)this, packetIn);
}
@Inject(
method = "processPlayer(Lnet/minecraft/network/play/client/CPacketPlayer;)V",
cancellable = true,
locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/entity/player/EntityPlayerMP;posY:D",
ordinal = 3
)
)
private void onPlayerMoved(CPacketPlayer packetIn, CallbackInfo ci, WorldServer world)
{
Proxy.onPlayerMoved(ci, (NetHandlerPlayServer)(Object)this, packetIn, world);
}
@Override
public int beginTeleport(Vec3d location)
{
this.field_184362_y = location;
if (++this.teleportId == Integer.MAX_VALUE)
{
this.teleportId = 0;
}
return this.teleportId;
}
}