3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Handle ENTITY_TELEPORT's targeting the client player (#3296)

Dieser Commit ist enthalten in:
RK_01 2023-04-14 16:38:39 +02:00 committet von GitHub
Ursprung 20d86374b5
Commit 394be165fd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -106,6 +106,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
}); });
} }
}); });
protocol.registerClientbound(ClientboundPackets1_19_3.SET_PASSENGERS, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_19_3.SET_PASSENGERS, new PacketHandlers() {
@Override @Override
protected void register() { protected void register() {
@ -131,6 +132,30 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
} }
}); });
protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_TELEPORT, new PacketHandlers() {
@Override
protected void register() {
handler(wrapper -> {
final int entityId = wrapper.read(Type.VAR_INT); // entity id
final int clientEntityId = wrapper.user().getEntityTracker(Protocol1_19_4To1_19_3.class).clientEntityId();
if (entityId != clientEntityId) {
wrapper.write(Type.VAR_INT, entityId); // entity id
return;
}
wrapper.setPacketType(ClientboundPackets1_19_4.PLAYER_POSITION);
wrapper.passthrough(Type.DOUBLE); // x
wrapper.passthrough(Type.DOUBLE); // y
wrapper.passthrough(Type.DOUBLE); // z
wrapper.write(Type.FLOAT, wrapper.read(Type.BYTE) * 360F / 256F); // yaw
wrapper.write(Type.FLOAT, wrapper.read(Type.BYTE) * 360F / 256F); // pitch
wrapper.read(Type.BOOLEAN); // on ground
wrapper.write(Type.BYTE, (byte) 0); // flags
wrapper.write(Type.VAR_INT, -1); // teleport id
});
}
});
protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_ANIMATION, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_ANIMATION, new PacketHandlers() {
@Override @Override
public void register() { public void register() {