|
22 | 22 | import com.viaversion.viabackwards.protocol.v1_17to1_16_4.Protocol1_17To1_16_4; |
23 | 23 | import com.viaversion.viaversion.api.minecraft.Particle; |
24 | 24 | import com.viaversion.viaversion.api.minecraft.entities.EntityType; |
| 25 | +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2; |
25 | 26 | import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17; |
26 | 27 | import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType; |
27 | 28 | import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; |
@@ -50,6 +51,29 @@ protected void registerPackets() { |
50 | 51 | registerTracker(ClientboundPackets1_17.ADD_PLAYER, EntityTypes1_17.PLAYER); |
51 | 52 | registerSetEntityData(ClientboundPackets1_17.SET_ENTITY_DATA, Types1_17.ENTITY_DATA_LIST, Types1_16.ENTITY_DATA_LIST); |
52 | 53 |
|
| 54 | + protocol.appendClientbound(ClientboundPackets1_17.ADD_ENTITY, wrapper -> { |
| 55 | + final int entityType = wrapper.get(Types.VAR_INT, 1); |
| 56 | + if (entityType != EntityTypes1_16_2.ITEM_FRAME.getId()) { |
| 57 | + return; |
| 58 | + } |
| 59 | + |
| 60 | + // Older clients will ignore the data field and the server sets the item frame rotation by the yaw/pitch field inside the packet, |
| 61 | + // newer clients do the opposite and ignore yaw/pitch and use the data field from the packet. |
| 62 | + final int data = wrapper.get(Types.INT, 0); |
| 63 | + |
| 64 | + float pitch = 0F; |
| 65 | + float yaw = 0F; |
| 66 | + switch (Math.abs(data % 6)) { |
| 67 | + case 0 /* down */ -> pitch = 90F; |
| 68 | + case 1 /* up */ -> pitch = -90F; |
| 69 | + case 2 /* north */ -> yaw = 180F; |
| 70 | + case 4 /* west */ -> yaw = 90F; |
| 71 | + case 5 /* east */ -> yaw = 270; |
| 72 | + } |
| 73 | + wrapper.set(Types.BYTE, 0, (byte) (pitch * 256F / 360F)); |
| 74 | + wrapper.set(Types.BYTE, 1, (byte) (yaw * 256F / 360F)); |
| 75 | + }); |
| 76 | + |
53 | 77 | protocol.registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_16_2.REMOVE_ENTITIES, wrapper -> { |
54 | 78 | int entityId = wrapper.read(Types.VAR_INT); |
55 | 79 | tracker(wrapper.user()).removeEntity(entityId); |
|
0 commit comments