Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-14 12:00:10 +01:00
Fix display rotation change
Dieser Commit ist enthalten in:
Ursprung
359cdb13eb
Commit
8f51ab2f6a
@ -20,8 +20,10 @@ package com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20;
|
||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||
@ -45,10 +47,97 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerTrackerWithData1_19(ClientboundPackets1_19_4.SPAWN_ENTITY, Entity1_19_4Types.FALLING_BLOCK);
|
||||
registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_20.METADATA_LIST, Types1_19_4.METADATA_LIST);
|
||||
registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.UUID); // Entity UUID
|
||||
map(Type.VAR_INT); // Entity type
|
||||
map(Type.DOUBLE); // X
|
||||
map(Type.DOUBLE); // Y
|
||||
map(Type.DOUBLE); // Z
|
||||
map(Type.BYTE); // Pitch
|
||||
map(Type.BYTE); // Yaw
|
||||
map(Type.BYTE); // Head yaw
|
||||
map(Type.VAR_INT); // Data
|
||||
handler(getSpawnTrackerWithDataHandler1_19(Entity1_19_4Types.FALLING_BLOCK));
|
||||
handler(wrapper -> {
|
||||
final int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
final EntityType entityType = tracker(wrapper.user()).entityType(entityId);
|
||||
if (entityType == Entity1_19_4Types.ITEM_DISPLAY) {
|
||||
// Turn it upside down
|
||||
wrapper.set(Type.BYTE, 0, (byte) -wrapper.get(Type.BYTE, 0));
|
||||
wrapper.set(Type.BYTE, 1, (byte) (wrapper.get(Type.BYTE, 1) - 128));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
final PacketHandler displayYawPitchHandler = wrapper -> {
|
||||
final TrackedEntity trackedEntity = tracker(wrapper.user()).entity(wrapper.get(Type.VAR_INT, 0));
|
||||
if (trackedEntity == null || trackedEntity.entityType() != Entity1_19_4Types.ITEM_DISPLAY) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Turn it upside down
|
||||
wrapper.set(Type.BYTE, 0, (byte) (wrapper.get(Type.BYTE, 0) - 128));
|
||||
wrapper.set(Type.BYTE, 1, (byte) -wrapper.get(Type.BYTE, 1));
|
||||
};
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.ENTITY_POSITION_AND_ROTATION, new PacketHandlers() {
|
||||
@Override
|
||||
protected void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.SHORT); // Delta X
|
||||
map(Type.SHORT); // Delta Y
|
||||
map(Type.SHORT); // Delta Z
|
||||
map(Type.BYTE); // Yaw
|
||||
map(Type.BYTE); // Pitch
|
||||
handler(displayYawPitchHandler);
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.ENTITY_ROTATION, new PacketHandlers() {
|
||||
@Override
|
||||
protected void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.BYTE); // Yaw
|
||||
map(Type.BYTE); // Pitch
|
||||
handler(displayYawPitchHandler);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.ENTITY_HEAD_LOOK, wrapper -> {
|
||||
final TrackedEntity trackedEntity = tracker(wrapper.user()).entity(wrapper.passthrough(Type.VAR_INT));
|
||||
if (trackedEntity == null || trackedEntity.entityType() != Entity1_19_4Types.ITEM_DISPLAY) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) (wrapper.read(Type.BYTE) - 128));
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.ENTITY_TELEPORT, new PacketHandlers() {
|
||||
@Override
|
||||
protected void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.DOUBLE); // X
|
||||
map(Type.DOUBLE); // Y
|
||||
map(Type.DOUBLE); // Z
|
||||
map(Type.BYTE); // Yaw
|
||||
map(Type.BYTE); // Pitch
|
||||
handler(wrapper -> {
|
||||
final TrackedEntity trackedEntity = tracker(wrapper.user()).entity(wrapper.get(Type.VAR_INT, 0));
|
||||
if (trackedEntity == null || trackedEntity.entityType() != Entity1_19_4Types.ITEM_DISPLAY) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.set(Type.BYTE, 0, (byte) (wrapper.get(Type.BYTE, 0) - 128));
|
||||
wrapper.set(Type.BYTE, 1, (byte) -wrapper.get(Type.BYTE, 1));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren