private void playDeathAnimation(final Player player) { Bukkit.getScheduler().scheduleSyncDelayedTask(Cardinal.getInstance(), new Runnable() { @Override public void run() { EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); List<Packet> packets = new ArrayList<>(); for (EnumItemSlot slot : EnumItemSlot.values()) { packets.add(new PacketPlayOutEntityEquipment(nmsPlayer.getId(), slot, net.minecraft.server.ItemStack.a)); // Removes armor, otherwise, a client-side glitch makes items } packets.add(PacketUtils.createMetadataPacket(nmsPlayer.getId(), Watchers.getHealth(0))); packets.add(new PacketPlayOutEntityStatus(nmsPlayer, (byte) 3)); for (Player online : Bukkit.getOnlinePlayers()) { if (!online.equals(player)){ for (Packet packet : packets) { PacketUtils.sendPacket(online, packet); } } } } }, 1L); }
public ItemStack[] getArmorContents() { ItemStack[] armor = new ItemStack[]{ getEquipment(EnumItemSlot.FEET), getEquipment(EnumItemSlot.LEGS), getEquipment(EnumItemSlot.CHEST), getEquipment(EnumItemSlot.HEAD), }; return armor; }
private void setDropChance(EnumItemSlot slot, float chance) { if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] = chance - 0.1F; } else { ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] = chance - 0.1F; } }
private float getDropChance(EnumItemSlot slot) { if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { return ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] + 0.1F; } else { return ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] + 0.1F; } }
public static Packet entityHelmetPacket(int entityId, org.bukkit.inventory.ItemStack helmet) { return new PacketPlayOutEntityEquipment(entityId, EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(helmet)); }
@Override public ItemStack getItemInMainHand() { return getEquipment(EnumItemSlot.MAINHAND); }
@Override public void setItemInMainHand(ItemStack item) { setEquipment(EnumItemSlot.MAINHAND, item); }
@Override public ItemStack getItemInOffHand() { return getEquipment(EnumItemSlot.OFFHAND); }
@Override public void setItemInOffHand(ItemStack item) { setEquipment(EnumItemSlot.OFFHAND, item); }
public ItemStack getHelmet() { return getEquipment(EnumItemSlot.HEAD); }
public void setHelmet(ItemStack helmet) { setEquipment(EnumItemSlot.HEAD, helmet); }
public ItemStack getChestplate() { return getEquipment(EnumItemSlot.CHEST); }
public void setChestplate(ItemStack chestplate) { setEquipment(EnumItemSlot.CHEST, chestplate); }
public ItemStack getLeggings() { return getEquipment(EnumItemSlot.LEGS); }
public void setLeggings(ItemStack leggings) { setEquipment(EnumItemSlot.LEGS, leggings); }
public ItemStack getBoots() { return getEquipment(EnumItemSlot.FEET); }
public void setBoots(ItemStack boots) { setEquipment(EnumItemSlot.FEET, boots); }
public void setArmorContents(ItemStack[] items) { setEquipment(EnumItemSlot.FEET, items.length >= 1 ? items[0] : null); setEquipment(EnumItemSlot.LEGS, items.length >= 2 ? items[1] : null); setEquipment(EnumItemSlot.CHEST, items.length >= 3 ? items[2] : null); setEquipment(EnumItemSlot.HEAD, items.length >= 4 ? items[3] : null); }
private ItemStack getEquipment(EnumItemSlot slot) { return CraftItemStack.asBukkitCopy(entity.getHandle().getEquipment(slot)); }
private void setEquipment(EnumItemSlot slot, ItemStack stack) { entity.getHandle().setSlot(slot, CraftItemStack.asNMSCopy(stack)); }
public void clear() { for (EnumItemSlot slot : EnumItemSlot.values()) { setEquipment(slot, null); } }
@Override public float getItemInMainHandDropChance() { return getDropChance(EnumItemSlot.MAINHAND); }
@Override public void setItemInMainHandDropChance(float chance) { setDropChance(EnumItemSlot.MAINHAND, chance); }
@Override public float getItemInOffHandDropChance() { return getDropChance(EnumItemSlot.OFFHAND); }
@Override public void setItemInOffHandDropChance(float chance) { setDropChance(EnumItemSlot.OFFHAND, chance); }
public float getHelmetDropChance() { return getDropChance(EnumItemSlot.HEAD); }
public void setHelmetDropChance(float chance) { setDropChance(EnumItemSlot.HEAD, chance); }
public float getChestplateDropChance() { return getDropChance(EnumItemSlot.CHEST); }
public void setChestplateDropChance(float chance) { setDropChance(EnumItemSlot.CHEST, chance); }
public float getLeggingsDropChance() { return getDropChance(EnumItemSlot.LEGS); }
public void setLeggingsDropChance(float chance) { setDropChance(EnumItemSlot.LEGS, chance); }
public float getBootsDropChance() { return getDropChance(EnumItemSlot.FEET); }
public void setBootsDropChance(float chance) { setDropChance(EnumItemSlot.FEET, chance); }
private static void set(EquipmentSlot type, EnumItemSlot value) { slots[type.ordinal()] = value; enums[value.ordinal()] = type; }
public static EquipmentSlot getSlot(EnumItemSlot nms) { return enums[nms.ordinal()]; }
public static EnumItemSlot getNMS(EquipmentSlot slot) { return slots[slot.ordinal()]; }