public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) { CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward()); CraftWorld world = (CraftWorld) entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); victim.expToDrop = event.getDroppedExp(); for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; world.dropItemNaturally(entity.getLocation(), stack); } return event; }
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) { CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward()); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); victim.expToDrop = event.getDroppedExp(); for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { if (stack == null || stack.getType() == Material.AIR) continue; world.dropItemNaturally(entity.getLocation(), stack); } return event; }
public static void playDeathAnimation(Player player) { EntityPlayer handle = ((CraftPlayer) player).getHandle(); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(handle.getId(), handle.getDataWatcher(), false); // Add/replace health to zero boolean replaced = false; DataWatcher.Item<Float> zeroHealth = new DataWatcher.Item<>(EntityPlayer.class, EntityLiving.HEALTH, 0f); if(packet.b != null) { for(int i = 0; i < packet.b.size(); i++) { DataWatcher.Item<?> item = packet.b.get(i); if(EntityLiving.HEALTH.equals(item.a())) { packet.b.set(i, zeroHealth); replaced = true; } } } if(!replaced) { if(packet.b == null) { packet.b = Collections.singletonList(zeroHealth); } else { packet.b.add(zeroHealth); } } sendPacketToViewers(player, packet); }
public void setShooter(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; if (shooter instanceof CraftHumanEntity) { getHandle().shooterName = ((CraftHumanEntity) shooter).getName(); } } else { getHandle().shooter = null; getHandle().shooterName = null; } getHandle().projectileSource = shooter; }
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); if (entity instanceof EntityInsentient) { equipment = new CraftEntityEquipment(this); } }
public Entity getSource() { EntityLiving source = getHandle().getSource(); if (source != null) { Entity bukkitEntity = source.getBukkitEntity(); if (bukkitEntity.isValid()) { return bukkitEntity; } } return null; }
/** * EntityShootBowEvent */ public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, EntityArrow entityArrow, float force) { LivingEntity shooter = (LivingEntity) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack); Arrow arrow = (Arrow) entityArrow.getBukkitEntity(); if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) { itemInHand = null; } EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, arrow, force); Bukkit.getPluginManager().callEvent(event); return event; }
/** * CreatureSpawnEvent */ public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving, SpawnReason spawnReason) { LivingEntity entity = (LivingEntity) entityliving.getBukkitEntity(); CraftServer craftServer = (CraftServer) entity.getServer(); CreatureSpawnEvent event = new CreatureSpawnEvent(entity, spawnReason); craftServer.getPluginManager().callEvent(event); return event; }
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); if (entity instanceof EntityInsentient || entity instanceof EntityArmorStand) { equipment = new CraftEntityEquipment(this); } }
public void setShooter(LivingEntity shooter) { if (shooter instanceof CraftLivingEntity) { getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; if (shooter instanceof CraftHumanEntity) { getHandle().shooterName = ((CraftHumanEntity) shooter).getName(); } } }
public void setSource(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { getHandle().setSource((EntityLiving) ((CraftLivingEntity) shooter).getHandle()); } else { getHandle().setSource((EntityLiving) null); } getHandle().projectileSource = shooter; }
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); if (!(this instanceof HumanEntity)) { equipment = new CraftEntityEquipment(this); } }
/** * EntityTameEvent */ public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityHuman tamer) { org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null); CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); entity.persistent = true; EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer); craftServer.getPluginManager().callEvent(event); return event; }
public CraftLivingEntity getTarget() { if (getHandle().target == null) return null; if (!(getHandle().target instanceof EntityLiving)) return null; return (CraftLivingEntity) getHandle().target.getBukkitEntity(); }
@Override public EntityLiving getHandle() { return (EntityLiving) entity; }
public void setHandle(final EntityLiving entity) { super.setHandle(entity); }
public CraftComplexLivingEntity(CraftServer server, EntityLiving entity) { super(server, entity); }
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim) { return callEntityDeathEvent(victim, new ArrayList<org.bukkit.inventory.ItemStack>(0)); }
public static EntityTargetLivingEntityEvent callEntityTargetLivingEvent(Entity entity, EntityLiving target, EntityTargetEvent.TargetReason reason) { EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(entity.getBukkitEntity(), (LivingEntity) target.getBukkitEntity(), reason); entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; }