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 CraftEntityEquipment(CraftLivingEntity entity) { this.entity = entity; }
public boolean damageEntity(DamageSource damagesource, float f) { if (!super.damageEntity(damagesource, f)) { return false; } else { EntityLiving entityliving = this.getGoalTarget(); if (entityliving == null && this.bT() instanceof EntityLiving) { entityliving = (EntityLiving) this.bT(); } if (entityliving == null && damagesource.getEntity() instanceof EntityLiving) { entityliving = (EntityLiving) damagesource.getEntity(); } if (entityliving != null && this.world.difficulty == EnumDifficulty.HARD && (double) this.random.nextFloat() < this.getAttributeInstance(bp).getValue()) { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.locY); int k = MathHelper.floor(this.locZ); EntityZombie entityzombie = new EntityZombie(this.world); for (int l = 0; l < 50; ++l) { int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); if (World.a((IBlockAccess) this.world, i1, j1 - 1, k1) && this.world.getLightLevel(i1, j1, k1) < 10) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); if (this.world.b(entityzombie.boundingBox) && this.world.getCubes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.world.containsLiquid(entityzombie.boundingBox)) { this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit // CraftBukkit start - call EntityTargetEvent org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entityzombie, entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); if (!event.isCancelled()) { if (event.getTarget() == null) { entityzombie.setGoalTarget(null); } else { entityzombie.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); } } // CraftBukkit end entityzombie.prepare((GroupDataEntity) null); this.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); entityzombie.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); break; } } } } return true; } }
public static EntityPotionEffectChangeEvent callEntityPotionEffectChangeEvent(EntityLiving living, MobEffect mobEffect, EntityPotionEffectChangeEvent.Cause cause, World world, double locX, double locY, double locZ){ PotionEffect effect = new PotionEffect(PotionEffectType.getById(mobEffect.getEffectId()), mobEffect.getDuration(), mobEffect.getAmplifier()); CraftLivingEntity entity = (CraftLivingEntity) living.getBukkitEntity(); Location location = new Location(world.getWorld(), locX, locY, locZ); return callEntityPotionEffectChangeEvent(entity, effect, cause, location); }
public static EntityPotionEffectChangeEvent callEntityPotionEffectChangeEvent(CraftLivingEntity entity, PotionEffect effect, EntityPotionEffectChangeEvent.Cause cause, Location location){ EntityPotionEffectChangeEvent event = new EntityPotionEffectChangeEvent(entity, effect, cause, effect.isAmbient(), location); entity.getServer().getPluginManager().callEvent(event); return event; }