/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(new EntitySnowball(worldIn, playerIn)); } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return itemStackIn; }
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn) { ItemStack itemstack = worldIn.getHeldItem(playerIn); if (!worldIn.capabilities.isCreativeMode) { itemstack.func_190918_g(1); } itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!itemStackIn.isRemote) { EntitySnowball entitysnowball = new EntitySnowball(itemStackIn, worldIn); entitysnowball.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F); itemStackIn.spawnEntityInWorld(entitysnowball); } worldIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); }
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn); entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntityInWorld(entitysnowball); } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); }
@Override public void execute(EntityLivingBase target, @Nullable AbstractMorph morph) { if (!target.worldObj.isRemote) { EntitySnowball snowball = new EntitySnowball(target.worldObj, target); Vec3d vec3d = target.getLook(1.0F); double d1 = 4.0D; double d2 = vec3d.xCoord * d1; double d3 = vec3d.yCoord * d1; double d4 = vec3d.zCoord * d1; snowball.setPosition(target.posX, target.posY + target.height * 0.9F, target.posZ); snowball.motionX = d2; snowball.motionY = d3; snowball.motionZ = d4; target.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (target.getRNG().nextFloat() * 0.4F + 0.8F)); target.worldObj.spawnEntityInWorld(snowball); } }
public boolean snowballFight(DamageSource damagesource) { if (damagesource instanceof EntityDamageSourceIndirect) { EntityDamageSourceIndirect snowdamage = (EntityDamageSourceIndirect) damagesource; if (snowdamage.getSourceOfDamage() != null && snowdamage .getSourceOfDamage() instanceof EntitySnowball) { snowballin += 1; if (attackTime < 10) { attackTime = 10; } } } return snowballin <= 0; }
private void tossSnowball(EntityLivingBase attackTarget) { EntitySnowball entitysnowball = new EntitySnowball(worldObj, this); double d = attackTarget.posX - this.posX; double d1 = ( attackTarget.posY + (double) attackTarget.getEyeHeight() ) - 1.1000000238418579D - entitysnowball.posY; double d2 = attackTarget.posZ - this.posZ; float f = MathHelper.sqrt_double(d * d + d2 * d2) * 0.2F; entitysnowball.setThrowableHeading(d, d1 + (double) f, d2, 1.6F, 12F); worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / ( this.getRNG().nextFloat() * 0.4F + 0.8F )); worldObj.spawnEntityInWorld(entitysnowball); attackTime = 30; armSwing(!didSwing); faceEntity(attackTarget, 180F, 180F); snowballin -= 1; if (snowballin < 0) { snowballin = 0; } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isClient) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } return par1ItemStack; }
@Override public void update() { super.update(); List<Entity> entityList = worldObj.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX() - .5, pos.getY() - .5, pos.getZ() - .5, pos.getX() + 1.5, pos.getY() + 1.5, pos.getZ() + 1.5)); for (Entity entity : entityList) { if (entity instanceof EntitySnowball || entity instanceof EntityEgg) { //Fun fact: Eggs and snowballs use the same particle code for (int i = 0; i < 8; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.SNOWBALL, entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D); } entity.setDead(); if (!worldObj.isRemote) { onEntityCollidedWithBlock(entity); } } else if (entity instanceof EntityArrow) { entity.setDead(); if (!worldObj.isRemote) { onEntityCollidedWithBlock(entity); } } } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { // if (!par3EntityPlayer.capabilities.isCreativeMode) // { // --par1ItemStack.stackSize; // } par3EntityPlayer.swingItem();//Make the item swing on right click par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } return par1ItemStack; }
@SubscribeEvent public void replaceSnowballWithArrow(EntityJoinWorldEvent event) { Entity entity = event.entity; World world = entity.worldObj; if (!(entity instanceof EntitySnowball)) { return; } if (!world.isRemote) { EntityArrow arrow = new EntityArrow(world); arrow.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, 0, 0); arrow.motionX = entity.motionX; arrow.motionY = entity.motionY; arrow.motionZ = entity.motionZ; arrow.posX += arrow.motionX; arrow.posY += arrow.motionY; arrow.posZ += arrow.motionZ; world.spawnEntityInWorld(arrow); entity.setDead(); } }
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { if (!p_77659_3_.capabilities.isCreativeMode) { --p_77659_1_.stackSize; } p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!p_77659_2_.isRemote) { p_77659_2_.spawnEntityInWorld(new EntitySnowball(p_77659_2_, p_77659_3_)); } return p_77659_1_; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } return par1ItemStack; }
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { /* * if(lastUse == 0) par2World.getWorldTime(); */ par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote/* && lastUse + 4 < par2World.getWorldTime() */) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); // lastUse = par2World.getWorldTime(); } par1ItemStack.damageItem(1, par3EntityPlayer); return par1ItemStack; }
/** * Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D; double d1 = p_82196_1_.posX - this.posX; double d2 = d0 - entitysnowball.posY; double d3 = p_82196_1_.posZ - this.posZ; float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F; entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entitysnowball); }
/** * Attack the specified entity using a ranged attack. * * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0 */ public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { EntitySnowball entitysnowball = new EntitySnowball(this.world, this); double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d1 = target.posX - this.posX; double d2 = d0 - entitysnowball.posY; double d3 = target.posZ - this.posZ; float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F; entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntityInWorld(entitysnowball); }
/** * Attack the specified entity using a ranged attack. * * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0 */ public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d1 = target.posX - this.posX; double d2 = d0 - entitysnowball.posY; double d3 = target.posZ - this.posZ; float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F; entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entitysnowball); }
/** * Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase entity, float damage) { if (System.currentTimeMillis() % 5000 < 2000) { EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); double d0 = entity.posX - this.posX; double d1 = entity.posY + (double)entity.getEyeHeight() - 1.100000023841858D - entitysnowball.posY; double d2 = entity.posZ - this.posZ; float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F; entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F); this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entitysnowball); } }
/** * Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { EntitySnowball var3 = new EntitySnowball(this.worldObj, this); double var4 = par1EntityLivingBase.posX - this.posX; double var6 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - var3.posY; double var8 = par1EntityLivingBase.posZ - this.posZ; float var10 = MathHelper.sqrt_double(var4 * var4 + var8 * var8) * 0.2F; var3.setThrowableHeading(var4, var6 + (double)var10, var8, 1.6F, 12.0F); this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(var3); }
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { EntitySnowball entitysnowball = new EntitySnowball(this.world, this); EntityArrow entityarrow = new EntityTippedArrow(this.world, this); double d0 = par1EntityLivingBase.posX - this.posX; double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitysnowball.posY; double d2 = par1EntityLivingBase.posZ - this.posZ; float f1 = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F; entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F); entityarrow.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entityarrow); this.world.spawnEntity(entitysnowball); }
public void onEntityCollidedWithBlock(Entity entity) { if (entity instanceof EntityArrow) { addFuel(Config.pumpArrowDuration, Config.pumpArrowSpeed); } if (entity instanceof EntityEgg) { addFuel(Config.pumpEggDuration, Config.pumpEggSpeed); } if (entity instanceof EntitySnowball) { addFuel(Config.pumpSnowballDuration, Config.pumpSnowballSpeed); } }
/** * Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_) { EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d1 = target.posX - this.posX; double d2 = d0 - entitysnowball.posY; double d3 = target.posZ - this.posZ; float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F; entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entitysnowball); }
@SubscribeEvent public void replaceSnowballWithArrow(EntityJoinWorldEvent event) { Entity snowball = event.getEntity(); World world = snowball.worldObj; if (!(snowball instanceof EntitySnowball)) { return; } if (!world.isRemote) { EntityTippedArrow arrow = new EntityTippedArrow(world); arrow.setLocationAndAngles(snowball.posX, snowball.posY, snowball.posZ, 0, 0); arrow.motionX = snowball.motionX; arrow.motionY = snowball.motionY; arrow.motionZ = snowball.motionZ; // gets arrow out of player's head // gets the angle of arrow right, in the direction of motion arrow.posX += arrow.motionX; arrow.posY += arrow.motionY; arrow.posZ += arrow.motionZ; world.spawnEntityInWorld(arrow); snowball.setDead(); } }
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); double d0 = p_82196_1_.posX - this.posX; double d1 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D - entitysnowball.posY; double d2 = p_82196_1_.posZ - this.posZ; float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F; entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F); this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entitysnowball); }
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.consumeInventoryItem(Items.snowball)) { par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1F, 0.9F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } } return par1ItemStack; }
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } return par1ItemStack; }
public void func_82196_d(EntityLivingBase p_82196_1_, float p_82196_2_) { EntitySnowball var3 = new EntitySnowball(this.field_70170_p, this); double var4 = p_82196_1_.field_70165_t - this.field_70165_t; double var6 = p_82196_1_.field_70163_u + (double)p_82196_1_.func_70047_e() - 1.100000023841858D - var3.field_70163_u; double var8 = p_82196_1_.field_70161_v - this.field_70161_v; float var10 = MathHelper.func_76133_a(var4 * var4 + var8 * var8) * 0.2F; var3.func_70186_c(var4, var6 + (double)var10, var8, 1.6F, 12.0F); this.func_85030_a("random.bow", 1.0F, 1.0F / (this.func_70681_au().nextFloat() * 0.4F + 0.8F)); this.field_70170_p.func_72838_d(var3); }
public ItemStack func_77659_a(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { if(!p_77659_3_.field_71075_bZ.field_75098_d) { --p_77659_1_.field_77994_a; } p_77659_2_.func_72956_a(p_77659_3_, "random.bow", 0.5F, 0.4F / (field_77697_d.nextFloat() * 0.4F + 0.8F)); if(!p_77659_2_.field_72995_K) { p_77659_2_.func_72838_d(new EntitySnowball(p_77659_2_, p_77659_3_)); } return p_77659_1_; }
/** * Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); double d0 = par1EntityLivingBase.posX - this.posX; double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitysnowball.posY; double d2 = par1EntityLivingBase.posZ - this.posZ; float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F; entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F); this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(entitysnowball); }
@Override public boolean execute(EntityPlayerMP target) { final World world = target.world; for (int i = 0; i < 200; i++) { EntitySnowball snowball = new EntitySnowball(world, target.posX, target.posY + 4, target.posZ); snowball.motionX = RANDOM.nextGaussian() * 0.05; snowball.motionY = 1; snowball.motionZ = RANDOM.nextGaussian() * 0.05; world.spawnEntity(snowball); } return true; }