/** * Called when the entity picks up an item. */ public void onItemPickup(Entity entityIn, int quantity) { if (!entityIn.isDead && !this.worldObj.isRemote) { EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker(); if (entityIn instanceof EntityItem) { entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId())); } if (entityIn instanceof EntityArrow) { entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId())); } if (entityIn instanceof EntityXPOrb) { entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId())); } } }
/** * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize */ public void onItemPickup(Entity p_71001_1_, int p_71001_2_) { if (!p_71001_1_.isDead && !this.worldObj.isRemote) { EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker(); if (p_71001_1_ instanceof EntityItem) { entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId())); } if (p_71001_1_ instanceof EntityArrow) { entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId())); } if (p_71001_1_ instanceof EntityXPOrb) { entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId())); } } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else { Entity entity = source.getEntity(); this.aiSit.setSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { amount = (amount + 1.0F) / 2.0F; } return super.attackEntityFrom(source, amount); } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)cause.getEntity(); double d0 = entityplayer.posX - this.posX; double d1 = entityplayer.posZ - this.posZ; if (d0 * d0 + d1 * d1 >= 2500.0D) { entityplayer.triggerAchievement(AchievementList.snipeSkeleton); } } else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled()) { ((EntityCreeper)cause.getEntity()).func_175493_co(); this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F); } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { Entity entity = source.getSourceOfDamage(); if (entity instanceof EntityArrow) { EntityArrow entityarrow = (EntityArrow)entity; if (entityarrow.isBurning()) { this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ); } } return super.attackEntityFrom(source, amount); }
/** * Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4)); int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F)); if (i > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D); } if (j > 0) { entityarrow.setKnockbackStrength(j); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1) { entityarrow.setFire(100); } this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entityarrow); }
@SubscribeEvent public static void onLivingDropsEvent(LivingDropsEvent event) { if (ConfigHandler.dropMoney && !(event.getEntityLiving() instanceof EntityPlayer) && event.getEntityLiving() instanceof IMob && event.getEntityLiving().getEntityWorld().isRemote == false) { if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getSource().getTrueSource() instanceof FakePlayer)) { CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ); return; } if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityArrow) { EntityArrow arrow = (EntityArrow) event.getSource().getTrueSource(); if (arrow.shootingEntity instanceof EntityPlayer && !(arrow.shootingEntity instanceof FakePlayer)) { CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ); return; } } } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)cause.getEntity(); double d0 = entityplayer.posX - this.posX; double d1 = entityplayer.posZ - this.posZ; if (d0 * d0 + d1 * d1 >= 2500.0D) { entityplayer.addStat(AchievementList.SNIPE_SKELETON); } } else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled()) { ((EntityCreeper)cause.getEntity()).incrementDroppedSkulls(); this.entityDropItem(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == SkeletonType.WITHER ? 1 : 0), 0.0F); } }
@Override public void onCollideWithPlayer(EntityPlayer player) { boolean inGround = false; try { inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i"); } catch (Exception e) { } if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) { boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode; ItemStack stack = new ItemStack(ModItems.tipped_arrow); TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration()); if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack)) flag = false; if (flag) { playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); player.onItemPickup(this, 1); setDead(); } } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else { Entity entity = source.getEntity(); if (this.aiSit != null) { this.aiSit.setSitting(false); } if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { amount = (amount + 1.0F) / 2.0F; } return super.attackEntityFrom(source, amount); } }
protected EntityArrow func_190726_a(float p_190726_1_) { ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); if (itemstack.getItem() == Items.SPECTRAL_ARROW) { EntitySpectralArrow entityspectralarrow = new EntitySpectralArrow(this.world, this); entityspectralarrow.func_190547_a(this, p_190726_1_); return entityspectralarrow; } else { EntityArrow entityarrow = super.func_190726_a(p_190726_1_); if (itemstack.getItem() == Items.TIPPED_ARROW && entityarrow instanceof EntityTippedArrow) { ((EntityTippedArrow)entityarrow).setPotionEffect(itemstack); } return entityarrow; } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)cause.getEntity(); double d0 = entityplayer.posX - this.posX; double d1 = entityplayer.posZ - this.posZ; if (d0 * d0 + d1 * d1 >= 2500.0D) { entityplayer.addStat(AchievementList.SNIPE_SKELETON); } } }
public PlasmaArrow(World worldIn, EntityLivingBase shooter) { this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ); this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.pickupStatus = EntityArrow.PickupStatus.ALLOWED; } }
/** * Destroys skeleton arrows in the protected area * Checks whether the arrow was shot by a class deriving from IRangedAttackMob * Sets the arrow on fire for visual effect by default * An arrow already on fire is killed * The effect of this is that the arrow, for one tick, is engulfed in flame, as it looks strange to have the arrow disappear for no reason * @param chunkBounds AxisAlignedBB in which block should act */ private void killArrows(AxisAlignedBB chunkBounds) { List<EntityArrow> list = world.getEntitiesWithinAABB(EntityArrow.class, chunkBounds); for (EntityArrow arrow : list) { if (arrow.shootingEntity instanceof IRangedAttackMob) { if (arrow.isBurning()) { arrow.setDead(); } else { arrow.setFire(1); arrow.addVelocity(-arrow.motionX, 0, -arrow.motionZ); } } } }
/** * Destroys skeleton arrows in the protected area * Checks whether the arrow was shot by a class deriving from IRangedAttackMob * Sets the arrow on fire for visual effect by default * An arrow already on fire is killed * The effect of this is that the arrow, for one tick, is engulfed in flame, as it looks strange to have the arrow disappear for no reason * @param areaBounds AxisAlignedBB in which block should act */ private void killArrows(AxisAlignedBB areaBounds) { List<EntityArrow> list = world.getEntitiesWithinAABB(EntityArrow.class, areaBounds); for (EntityArrow arrow : list) { if (arrow.shootingEntity instanceof IRangedAttackMob) { if (arrow.isBurning()) { arrow.setDead(); } else { arrow.setFire(1); arrow.addVelocity(-arrow.motionX, 0, -arrow.motionZ); } } } }
private boolean isInGround(EntityArrow a) { try { return (boolean) inground.get(a); } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); return false; } }
/** * Called When an Entity Collided with the Block */ public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (!worldIn.isRemote && entityIn instanceof EntityArrow) { EntityArrow entityarrow = (EntityArrow)entityIn; if (entityarrow.isBurning()) { this.explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)), entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null); worldIn.setBlockToAir(pos); } } }
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state) { this.updateBlockBounds(state); List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ)); boolean flag = !list.isEmpty(); boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue(); if (flag && !flag1) { worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true))); this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING)); worldIn.markBlockRangeForRenderUpdate(pos, pos); worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F); } if (!flag && flag1) { worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false))); this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING)); worldIn.markBlockRangeForRenderUpdate(pos, pos); worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F); } if (flag) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isClosed()) { Entity entity = source.getSourceOfDamage(); if (entity instanceof EntityArrow) { return false; } } if (super.attackEntityFrom(source, amount)) { if ((double)this.getHealth() < (double)this.getMaxHealth() * 0.5D && this.rand.nextInt(4) == 0) { this.tryTeleportToNewPosition(); } return true; } else { return false; } }
private void checkPressed(IBlockState p_185616_1_, World p_185616_2_, BlockPos p_185616_3_) { List <? extends Entity > list = p_185616_2_.<Entity>getEntitiesWithinAABB(EntityArrow.class, p_185616_1_.getBoundingBox(p_185616_2_, p_185616_3_).offset(p_185616_3_)); boolean flag = !list.isEmpty(); boolean flag1 = ((Boolean)p_185616_1_.getValue(POWERED)).booleanValue(); if (flag && !flag1) { p_185616_2_.setBlockState(p_185616_3_, p_185616_1_.withProperty(POWERED, Boolean.valueOf(true))); this.notifyNeighbors(p_185616_2_, p_185616_3_, (EnumFacing)p_185616_1_.getValue(FACING)); p_185616_2_.markBlockRangeForRenderUpdate(p_185616_3_, p_185616_3_); this.playClickSound((EntityPlayer)null, p_185616_2_, p_185616_3_); } if (!flag && flag1) { p_185616_2_.setBlockState(p_185616_3_, p_185616_1_.withProperty(POWERED, Boolean.valueOf(false))); this.notifyNeighbors(p_185616_2_, p_185616_3_, (EnumFacing)p_185616_1_.getValue(FACING)); p_185616_2_.markBlockRangeForRenderUpdate(p_185616_3_, p_185616_3_); this.playReleaseSound(p_185616_2_, p_185616_3_); } if (flag) { p_185616_2_.scheduleUpdate(new BlockPos(p_185616_3_), this, this.tickRate(p_185616_2_)); } }