Skip to content

Commit

Permalink
Handle experience orb spawn via add entity packet in 1.14->1.13.2 (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Aug 3, 2024
1 parent a0d063d commit bc06d9e
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ public void register() {
};
if (data != 0)
wrapper.set(Types.INT, 0, data);
} else if (entityType.is(EntityTypes1_13.EntityType.EXPERIENCE_ORB)) {
// Newer clients can spawn experience orbs via add entity, map to add experience orb and override values via multiple packets
wrapper.cancel();
final int entityId = wrapper.get(Types.VAR_INT, 0);

// Shrug about uuid or rotations
final PacketWrapper addExperienceOrb = PacketWrapper.create(ClientboundPackets1_13.ADD_EXPERIENCE_ORB, wrapper.user());
addExperienceOrb.write(Types.VAR_INT, entityId); // Entity id
addExperienceOrb.write(Types.DOUBLE, wrapper.get(Types.DOUBLE, 0)); // X
addExperienceOrb.write(Types.DOUBLE, wrapper.get(Types.DOUBLE, 1)); // Y
addExperienceOrb.write(Types.DOUBLE, wrapper.get(Types.DOUBLE, 2)); // Z
addExperienceOrb.write(Types.SHORT, (short) 0); // Experience count
addExperienceOrb.send(Protocol1_14To1_13_2.class);

final PacketWrapper setEntityMotion = PacketWrapper.create(ClientboundPackets1_13.SET_ENTITY_MOTION, wrapper.user());
setEntityMotion.write(Types.VAR_INT, entityId); // Entity id
setEntityMotion.write(Types.SHORT, wrapper.get(Types.SHORT, 0));
setEntityMotion.write(Types.SHORT, wrapper.get(Types.SHORT, 1));
setEntityMotion.write(Types.SHORT, wrapper.get(Types.SHORT, 2));
setEntityMotion.send(Protocol1_14To1_13_2.class);
return;
} else {
for (final EntityTypes1_13.ObjectType type : EntityTypes1_13.ObjectType.values()) {
if (type.getType() == entityType) {
Expand Down

0 comments on commit bc06d9e

Please sign in to comment.