mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-02 22:07:49 +01:00
Change PlayerMovementMapper to a handler and fix the mappings so it works.
This commit is contained in:
parent
7984f6400c
commit
6bb473ea8d
@ -2,23 +2,17 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8;
|
|||||||
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||||
|
|
||||||
public class PlayerMovementMapper extends PacketRemapper {
|
public class PlayerMovementMapper extends PacketHandler {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
handler(new PacketHandler() {
|
MovementTracker tracker = wrapper.user().get(MovementTracker.class);
|
||||||
@Override
|
tracker.incrementIdlePacket();
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
// If packet has the ground data
|
||||||
MovementTracker tracker = wrapper.user().get(MovementTracker.class);
|
if (wrapper.is(Type.BOOLEAN, 0)) {
|
||||||
tracker.incrementIdlePacket();
|
tracker.setGround(wrapper.get(Type.BOOLEAN, 0));
|
||||||
// If packet has the ground data
|
}
|
||||||
if (wrapper.is(Type.BOOLEAN, 0)) {
|
|
||||||
tracker.setGround(wrapper.get(Type.BOOLEAN, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,6 +443,52 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Player Position Packet
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x04, 0x0C, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.DOUBLE); // 0 - X
|
||||||
|
map(Type.DOUBLE); // 1 - Y
|
||||||
|
map(Type.DOUBLE); // 2 - Z
|
||||||
|
map(Type.BOOLEAN); // 3 - Ground
|
||||||
|
handler(new PlayerMovementMapper());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player Move & Look Packet
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x06, 0x0D, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.DOUBLE); // 0 - X
|
||||||
|
map(Type.DOUBLE); // 1 - Y
|
||||||
|
map(Type.DOUBLE); // 2 - Z
|
||||||
|
map(Type.FLOAT); // 3 - Yaw
|
||||||
|
map(Type.FLOAT); // 4 - Pitch
|
||||||
|
map(Type.BOOLEAN); // 5 - Ground
|
||||||
|
handler(new PlayerMovementMapper());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player Look Packet
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x05, 0x0E, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.FLOAT); // 0 - Yaw
|
||||||
|
map(Type.FLOAT); // 1 - Pitch
|
||||||
|
map(Type.BOOLEAN); // 2 - Ground
|
||||||
|
handler(new PlayerMovementMapper());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player Packet
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x03, 0x0F, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.BOOLEAN); // 0 - Ground
|
||||||
|
handler(new PlayerMovementMapper());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/* Packets which do not have any field remapping or handlers */
|
/* Packets which do not have any field remapping or handlers */
|
||||||
|
|
||||||
protocol.registerIncoming(State.PLAY, 0x01, 0x02); // Chat Message Packet
|
protocol.registerIncoming(State.PLAY, 0x01, 0x02); // Chat Message Packet
|
||||||
@ -451,9 +497,6 @@ public class PlayerPackets {
|
|||||||
|
|
||||||
protocol.registerIncoming(State.PLAY, 0x00, 0x0B); // Keep Alive Request Packet
|
protocol.registerIncoming(State.PLAY, 0x00, 0x0B); // Keep Alive Request Packet
|
||||||
|
|
||||||
protocol.registerIncoming(State.PLAY, 0x04, 0x0C, new PlayerMovementMapper()); // Player Position Packet
|
|
||||||
protocol.registerIncoming(State.PLAY, 0x06, 0x0D, new PlayerMovementMapper()); // Player Move & Look Packet
|
|
||||||
protocol.registerIncoming(State.PLAY, 0x05, 0x0E, new PlayerMovementMapper()); // Player Look Packet
|
|
||||||
protocol.registerIncoming(State.PLAY, 0x03, 0x0F, new PlayerMovementMapper()); // Player Packet
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user