mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-23 12:25:24 +01:00
We need playerteleport for caching, not entityteleport
This commit is contained in:
parent
d7f67065be
commit
1857244eae
@ -26,6 +26,18 @@ public abstract class PlayerPositionStorage extends StoredObject {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setX(final double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(final double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setZ(final double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setCoordinates(PacketWrapper wrapper, boolean relative) throws Exception {
|
||||
setCoordinates(wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), relative);
|
||||
}
|
||||
|
@ -65,13 +65,14 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
out(State.PLAY, 0x20, 0x1E); // Change Game State
|
||||
out(State.PLAY, 0x21, 0x1F); // Keep Alive (clientbound)
|
||||
out(State.PLAY, 0x27, 0x25); // Entity
|
||||
out(State.PLAY, 0x28, 0x26); // Entity Relative Move
|
||||
out(State.PLAY, 0x29, 0x27); // Entity Look And Relative Move
|
||||
out(State.PLAY, 0x2A, 0x28); // Entity Look
|
||||
out(State.PLAY, 0x2B, 0x29); // Vehicle Move (clientbound)
|
||||
out(State.PLAY, 0x2C, 0x2A); // Open Sign Editor
|
||||
out(State.PLAY, 0x2D, 0x2B, cancel()); // Craft Recipe Response TODO MODIFIED
|
||||
out(State.PLAY, 0x2E, 0x2C); // Player Abilities (clientbound)
|
||||
out(State.PLAY, 0x2F, 0x2D); // Combat Event
|
||||
out(State.PLAY, 0x32, 0x2F); // Player Position And Look (clientbound)
|
||||
out(State.PLAY, 0x33, 0x30); // Use Bed
|
||||
out(State.PLAY, 0x34, 0x31, cancel()); // Unlock Recipes TODO MODIFIED
|
||||
out(State.PLAY, 0x36, 0x33); // Remove Entity Effect
|
||||
@ -93,6 +94,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
out(State.PLAY, 0x4B, 0x48); // Title
|
||||
out(State.PLAY, 0x4E, 0x4A); // Player List Header And Footer
|
||||
out(State.PLAY, 0x4F, 0x4B); // Collect Item
|
||||
out(State.PLAY, 0x50, 0x4C); // Entity Teleport
|
||||
out(State.PLAY, 0x51, 0x4D, cancel()); // Advancements
|
||||
out(State.PLAY, 0x52, 0x4E); // Entity Properties
|
||||
out(State.PLAY, 0x53, 0x4F); // Entity Effect
|
||||
|
@ -30,54 +30,37 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
// Entity teleport
|
||||
protocol.registerOutgoing(State.PLAY, 0x50, 0x4C, new PacketRemapper() {
|
||||
// Player Position And Look (clientbound)
|
||||
protocol.out(State.PLAY, 0x32, 0x2F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.FLOAT);
|
||||
map(Type.FLOAT);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
|
||||
PlayerPositionStorage1_13 playerStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
if (playerStorage.getEntityId() == wrapper.get(Type.VAR_INT, 0)) {
|
||||
playerStorage.setCoordinates(wrapper, false);
|
||||
}
|
||||
byte bitField = wrapper.get(Type.BYTE, 0);
|
||||
playerStorage.setX(toSet(bitField, 0, playerStorage.getX(), wrapper.get(Type.DOUBLE, 0)));
|
||||
playerStorage.setY(toSet(bitField, 1, playerStorage.getY(), wrapper.get(Type.DOUBLE, 1)));
|
||||
playerStorage.setZ(toSet(bitField, 2, playerStorage.getZ(), wrapper.get(Type.DOUBLE, 2)));
|
||||
}
|
||||
|
||||
private double toSet(int field, int bitIndex, double origin, double packetValue) {
|
||||
// If bit is set, coordinate is relative
|
||||
return (field & (1 << bitIndex)) != 0 ? origin + packetValue : packetValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Entity relative move + Entity look and relative move
|
||||
PacketRemapper relativeMoveHandler = new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.SHORT);
|
||||
map(Type.SHORT);
|
||||
map(Type.SHORT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
PlayerPositionStorage1_13 playerStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
if (playerStorage.getEntityId() == wrapper.get(Type.VAR_INT, 0)) {
|
||||
double x = wrapper.get(Type.SHORT, 0) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
|
||||
double y = wrapper.get(Type.SHORT, 1) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
|
||||
double z = wrapper.get(Type.SHORT, 2) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
|
||||
playerStorage.setCoordinates(x, y, z, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
protocol.registerOutgoing(State.PLAY, 0x28, 0x26, relativeMoveHandler);
|
||||
protocol.registerOutgoing(State.PLAY, 0x29, 0x27, relativeMoveHandler);
|
||||
|
||||
//Spawn Object
|
||||
// Spawn Object
|
||||
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -187,16 +170,6 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_13Types.EntityType.PLAYER));
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
PlayerPositionStorage1_13 positionStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
if (positionStorage.getEntityId() == wrapper.get(Type.VAR_INT, 0)) {
|
||||
positionStorage.setCoordinates(wrapper, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -229,10 +202,6 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
handler(getTrackerHandler(Entity1_13Types.EntityType.PLAYER, Type.INT));
|
||||
handler(getDimensionHandler(1));
|
||||
handler(wrapper -> {
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
wrapper.user().get(PlayerPositionStorage1_13.class).setEntityId(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -5,17 +5,7 @@ import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
||||
|
||||
private int entityId;
|
||||
|
||||
public PlayerPositionStorage1_13(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user