Java Code Examples for net.minecraft.entity.projectile.EntityArrow#setKnockbackStrength()
The following examples show how to use
net.minecraft.entity.projectile.EntityArrow#setKnockbackStrength() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityArcher.java From Electro-Magic-Tools with GNU General Public License v3.0 | 6 votes |
@Override public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { EntityArrow entityarrow = new EntityArrow(this.worldObj, this, par1EntityLivingBase, 1.6F, (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); entityarrow.setDamage((double) (par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.difficultySetting.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) { entityarrow.setFire(100); } this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entityarrow); }
Example 2
Source File: EntityMonolithEye.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
protected void attackWithArrow(EntityLivingBase target) { int charge = 2 + rand.nextInt(10); EntityArrow entityarrow = new EntityTippedArrow(this.world, this); double d0 = target.posX - this.posX; double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityarrow.posY; double d2 = target.posZ - this.posZ; double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().getDifficultyId() * 4)); int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this); int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); entityarrow.setDamage((double) (charge * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.world.getDifficulty().getDifficultyId() * 0.11F)); if (i > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); } if (j > 0) { entityarrow.setKnockbackStrength(j); } if (rand.nextBoolean()) { entityarrow.setFire(100); } this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entityarrow); }
Example 3
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
protected void attackWithArrow(EntityLivingBase target) { int charge = 2 + rand.nextInt(10); EntityArrow entityarrow = new EntityTippedArrow(this.world, this); double d0 = target.posX - this.posX; double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityarrow.posY; double d2 = target.posZ - this.posZ; double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().getDifficultyId() * 4)); int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this); int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); entityarrow.setDamage((double) (charge * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.world.getDifficulty().getDifficultyId() * 0.11F)); if (i > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); } if (j > 0) { entityarrow.setKnockbackStrength(j); } if (rand.nextBoolean()) { entityarrow.setFire(100); } this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entityarrow); }
Example 4
Source File: ItemZundaBow.java From TofuCraftReload with MIT License | 4 votes |
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityLiving; boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0; ItemStack itemstack = this.findAmmo(entityplayer); int i = this.getMaxItemUseDuration(stack) - timeLeft; i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, entityplayer, i, !itemstack.isEmpty() || flag); if (i < 0) return; if (!itemstack.isEmpty() || flag) { if (itemstack.isEmpty()) { itemstack = new ItemStack(Items.ARROW); } float f = getArrowVelocity(i); if ((double)f >= 0.1D) { boolean flag1 = entityplayer.capabilities.isCreativeMode || (itemstack.getItem() instanceof ItemArrow && ((ItemArrow) itemstack.getItem()).isInfinite(itemstack, stack, entityplayer)); if (!worldIn.isRemote) { ItemArrow itemarrow = (ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW); EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer); entityarrow.shoot(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.05F, 1.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); if(entityarrow instanceof EntityZundaArrow){ entityarrow.setDamage(entityarrow.getDamage() + 2.0D); } if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); if (k > 0) { entityarrow.setKnockbackStrength(k); } if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { entityarrow.setFire(100); } stack.damageItem(1, entityplayer); if (flag1 || entityplayer.capabilities.isCreativeMode && (itemstack.getItem() == Items.SPECTRAL_ARROW || itemstack.getItem() == Items.TIPPED_ARROW)) { entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } worldIn.spawnEntity(entityarrow); } worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (!flag1 && !entityplayer.capabilities.isCreativeMode) { itemstack.shrink(1); if (itemstack.isEmpty()) { entityplayer.inventory.deleteStack(itemstack); } } entityplayer.addStat(StatList.getObjectUseStats(this)); } } } }