Skip to content

Commit bc06d9e

Browse files
Handle experience orb spawn via add entity packet in 1.14->1.13.2 (#849)
1 parent a0d063d commit bc06d9e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/EntityPacketRewriter1_14.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@ public void register() {
153153
};
154154
if (data != 0)
155155
wrapper.set(Types.INT, 0, data);
156+
} else if (entityType.is(EntityTypes1_13.EntityType.EXPERIENCE_ORB)) {
157+
// Newer clients can spawn experience orbs via add entity, map to add experience orb and override values via multiple packets
158+
wrapper.cancel();
159+
final int entityId = wrapper.get(Types.VAR_INT, 0);
160+
161+
// Shrug about uuid or rotations
162+
final PacketWrapper addExperienceOrb = PacketWrapper.create(ClientboundPackets1_13.ADD_EXPERIENCE_ORB, wrapper.user());
163+
addExperienceOrb.write(Types.VAR_INT, entityId); // Entity id
164+
addExperienceOrb.write(Types.DOUBLE, wrapper.get(Types.DOUBLE, 0)); // X
165+
addExperienceOrb.write(Types.DOUBLE, wrapper.get(Types.DOUBLE, 1)); // Y
166+
addExperienceOrb.write(Types.DOUBLE, wrapper.get(Types.DOUBLE, 2)); // Z
167+
addExperienceOrb.write(Types.SHORT, (short) 0); // Experience count
168+
addExperienceOrb.send(Protocol1_14To1_13_2.class);
169+
170+
final PacketWrapper setEntityMotion = PacketWrapper.create(ClientboundPackets1_13.SET_ENTITY_MOTION, wrapper.user());
171+
setEntityMotion.write(Types.VAR_INT, entityId); // Entity id
172+
setEntityMotion.write(Types.SHORT, wrapper.get(Types.SHORT, 0));
173+
setEntityMotion.write(Types.SHORT, wrapper.get(Types.SHORT, 1));
174+
setEntityMotion.write(Types.SHORT, wrapper.get(Types.SHORT, 2));
175+
setEntityMotion.send(Protocol1_14To1_13_2.class);
176+
return;
156177
} else {
157178
for (final EntityTypes1_13.ObjectType type : EntityTypes1_13.ObjectType.values()) {
158179
if (type.getType() == entityType) {

0 commit comments

Comments
 (0)