13
0
geforkt von Mirrors/Paper

#1140: Add a method to send multiple equipment changes

By: Parker Hawke <hawkeboyz2@hotmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2023-02-27 20:27:47 +11:00
Ursprung c9f381c842
Commit 229f3bb810

Datei anzeigen

@ -724,15 +724,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override @Override
public void sendEquipmentChange(LivingEntity entity, EquipmentSlot slot, ItemStack item) { public void sendEquipmentChange(LivingEntity entity, EquipmentSlot slot, ItemStack item) {
this.sendEquipmentChange(entity, Map.of(slot, item));
}
@Override
public void sendEquipmentChange(LivingEntity entity, Map<EquipmentSlot, ItemStack> items) {
Preconditions.checkArgument(entity != null, "entity must not be null"); Preconditions.checkArgument(entity != null, "entity must not be null");
Preconditions.checkArgument(slot != null, "slot must not be null"); Preconditions.checkArgument(items != null, "items must not be null");
Preconditions.checkArgument(item != null, "item must not be null");
if (getHandle().connection == null) return; if (getHandle().connection == null) {
return;
}
List<Pair<EnumItemSlot, net.minecraft.world.item.ItemStack>> equipment = Arrays.asList( List<Pair<EnumItemSlot, net.minecraft.world.item.ItemStack>> equipment = new ArrayList<>(items.size());
new Pair<>(CraftEquipmentSlot.getNMS(slot), CraftItemStack.asNMSCopy(item)) for (Map.Entry<EquipmentSlot, ItemStack> entry : items.entrySet()) {
); EquipmentSlot slot = entry.getKey();
Preconditions.checkArgument(slot != null, "Cannot set null EquipmentSlot");
equipment.add(new Pair<>(CraftEquipmentSlot.getNMS(slot), CraftItemStack.asNMSCopy(entry.getValue())));
}
getHandle().connection.send(new PacketPlayOutEntityEquipment(entity.getEntityId(), equipment)); getHandle().connection.send(new PacketPlayOutEntityEquipment(entity.getEntityId(), equipment));
} }