Skip to content

Commit 8043880

Browse files
committed
1.20.2-pre2
1 parent 2f373ad commit 8043880

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/EntityPacketRewriter1_20_2.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,67 @@ public EntityPacketRewriter1_20_2(final Protocol1_20To1_20_2 protocol) {
3939

4040
@Override
4141
public void registerPackets() {
42-
registerTrackerWithData1_19(ClientboundPackets1_20_2.SPAWN_ENTITY, Entity1_19_4Types.FALLING_BLOCK);
4342
registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, Types1_20_2.METADATA_LIST, Types1_20.METADATA_LIST);
4443
registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES);
4544

45+
protocol.registerClientbound(ClientboundPackets1_20_2.SPAWN_ENTITY, new PacketHandlers() {
46+
@Override
47+
protected void register() {
48+
handler(wrapper -> {
49+
final int entityId = wrapper.passthrough(Type.VAR_INT);
50+
wrapper.passthrough(Type.UUID); // UUID
51+
52+
final int entityType = wrapper.read(Type.VAR_INT);
53+
if (entityType != Entity1_19_4Types.PLAYER.getId()) {
54+
wrapper.write(Type.VAR_INT, entityType);
55+
56+
if (entityType == Entity1_19_4Types.FALLING_BLOCK.getId()) {
57+
wrapper.passthrough(Type.DOUBLE); // X
58+
wrapper.passthrough(Type.DOUBLE); // Y
59+
wrapper.passthrough(Type.DOUBLE); // Z
60+
wrapper.passthrough(Type.BYTE); // Pitch
61+
wrapper.passthrough(Type.BYTE); // Yaw
62+
wrapper.passthrough(Type.BYTE); // Head yaw
63+
final int blockState = wrapper.read(Type.VAR_INT); // Data
64+
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(blockState));
65+
}
66+
return;
67+
}
68+
69+
// Map to spawn player packet
70+
wrapper.setPacketType(ClientboundPackets1_19_4.SPAWN_PLAYER);
71+
72+
wrapper.passthrough(Type.DOUBLE); // X
73+
wrapper.passthrough(Type.DOUBLE); // Y
74+
wrapper.passthrough(Type.DOUBLE); // Z
75+
76+
final byte pitch = wrapper.read(Type.BYTE);
77+
wrapper.passthrough(Type.BYTE); // Yaw
78+
wrapper.write(Type.BYTE, pitch);
79+
wrapper.read(Type.BYTE); // Head yaw
80+
wrapper.read(Type.VAR_INT); // Data
81+
82+
final short velocityX = wrapper.read(Type.SHORT);
83+
final short velocityY = wrapper.read(Type.SHORT);
84+
final short velocityZ = wrapper.read(Type.SHORT);
85+
if (velocityX == 0 && velocityY == 0 && velocityZ == 0) {
86+
return;
87+
}
88+
89+
// Follow up with velocity packet
90+
wrapper.send(Protocol1_20To1_20_2.class);
91+
wrapper.cancel();
92+
93+
final PacketWrapper velocityPacket = wrapper.create(ClientboundPackets1_20_2.ENTITY_VELOCITY);
94+
velocityPacket.write(Type.VAR_INT, entityId);
95+
velocityPacket.write(Type.SHORT, velocityX);
96+
velocityPacket.write(Type.SHORT, velocityY);
97+
velocityPacket.write(Type.SHORT, velocityZ);
98+
velocityPacket.send(Protocol1_20To1_20_2.class);
99+
});
100+
}
101+
});
102+
46103
protocol.registerClientbound(ClientboundPackets1_20_2.JOIN_GAME, new PacketHandlers() {
47104
@Override
48105
public void register() {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
projectVersion=4.8.0-1.20.2-pre1-SNAPSHOT
1+
projectVersion=4.8.0-1.20.2-pre2-SNAPSHOT
22

33
# Smile emoji
44
mcVersions=1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10

0 commit comments

Comments
 (0)