Java Code Examples for net.minecraft.init.Items.TIPPED_ARROW

The following are Jave code examples for showing how to use TIPPED_ARROW of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Backmemed   File: EntitySkeleton.java   View Source Code Vote up 6 votes
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;
    }
}
 
Example 2
Project: Backmemed   File: RecipeTippedArrow.java   View Source Code Vote up 6 votes
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = inv.getStackInRowAndColumn(1, 1);

    if (itemstack.getItem() != Items.LINGERING_POTION)
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        ItemStack itemstack1 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(itemstack1, PotionUtils.getPotionFromItem(itemstack));
        PotionUtils.appendEffects(itemstack1, PotionUtils.getFullEffectsFromItem(itemstack));
        return itemstack1;
    }
}
 
Example 3
Project: CombinedPotions   File: RecipeCombinedPotions2.java   View Source Code Vote up 6 votes
private boolean canCombineItems(ItemStack stackA, ItemStack stackB)
{
	if (ItemStack.areItemsEqual(stackA, stackB)) return true;

	if (stackA.getItem() == Items.POTIONITEM && stackB.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackB.getMetadata() == 0) return true;
	if (stackA.getItem() == Items.SPLASH_POTION && stackB.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackB.getMetadata() == 1) return true;
	if (stackA.getItem() == Items.LINGERING_POTION && stackB.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackB.getMetadata() == 2) return true;

	if (stackB.getItem() == Items.POTIONITEM && stackA.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackA.getMetadata() == 0) return true;
	if (stackB.getItem() == Items.SPLASH_POTION && stackA.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackA.getMetadata() == 1) return true;
	if (stackB.getItem() == Items.LINGERING_POTION && stackA.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackA.getMetadata() == 2) return true;

	if (stackA.getItem() == Items.TIPPED_ARROW && stackB.getItem() == Item.getByNameOrId("potioncore:custom_arrow")) return true;
	if (stackB.getItem() == Items.TIPPED_ARROW && stackA.getItem() == Item.getByNameOrId("potioncore:custom_arrow")) return true;

	return false;
}
 
Example 4
Project: CombinedPotions   File: RecipeCombinedPotions2.java   View Source Code Vote up 6 votes
private ItemStack getOutputStack(ItemStack inputStack)
{
	Item item = inputStack.getItem();

	if (item == Items.POTIONITEM || (item == Item.getByNameOrId("potioncore:custom_potion") && inputStack.getMetadata() == 0))
	{
		return new ItemStack(Items.POTIONITEM, 1, 0);
	}
	else if (item == Items.SPLASH_POTION || (item == Item.getByNameOrId("potioncore:custom_potion") && inputStack.getMetadata() == 1))
	{
		return new ItemStack(Items.SPLASH_POTION, 1, 0);
	}
	else if (item == Items.LINGERING_POTION || (item == Item.getByNameOrId("potioncore:custom_potion") && inputStack.getMetadata() == 2))
	{
		return new ItemStack(Items.LINGERING_POTION, 1, 0);
	}
	else if (item == Items.TIPPED_ARROW || item == Item.getByNameOrId("potioncore:custom_arrow"))
	{
		return new ItemStack(Items.TIPPED_ARROW, 1, 0);
	}

	else return ItemStack.EMPTY;
}
 
Example 5
Project: CustomWorldGen   File: EntityTippedArrow.java   View Source Code Vote up 6 votes
public void setPotionEffect(ItemStack stack)
{
    if (stack.getItem() == Items.TIPPED_ARROW)
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(stack.getTagCompound());
        Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack);

        if (!collection.isEmpty())
        {
            for (PotionEffect potioneffect : collection)
            {
                this.customPotionEffects.add(new PotionEffect(potioneffect));
            }
        }

        this.dataManager.set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, collection))));
    }
    else if (stack.getItem() == Items.ARROW)
    {
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(0));
    }
}
 
Example 6
Project: CustomWorldGen   File: RecipeTippedArrow.java   View Source Code Vote up 6 votes
/**
 * Returns an Item that is the result of this recipe
 */
@Nullable
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = inv.getStackInRowAndColumn(1, 1);

    if (itemstack != null && itemstack.getItem() == Items.LINGERING_POTION)
    {
        ItemStack itemstack1 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(itemstack1, PotionUtils.getPotionFromItem(itemstack));
        PotionUtils.appendEffects(itemstack1, PotionUtils.getFullEffectsFromItem(itemstack));
        return itemstack1;
    }
    else
    {
        return null;
    }
}
 
Example 7
Project: Backmemed   File: EntityTippedArrow.java   View Source Code Vote up 5 votes
public void setPotionEffect(ItemStack stack)
{
    if (stack.getItem() == Items.TIPPED_ARROW)
    {
        this.potion = PotionUtils.getPotionFromItem(stack);
        Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack);

        if (!collection.isEmpty())
        {
            for (PotionEffect potioneffect : collection)
            {
                this.customPotionEffects.add(new PotionEffect(potioneffect));
            }
        }

        int i = func_191508_b(stack);

        if (i == -1)
        {
            this.func_190548_o();
        }
        else
        {
            this.func_191507_d(i);
        }
    }
    else if (stack.getItem() == Items.ARROW)
    {
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(-1));
    }
}
 
Example 8
Project: CombinedPotions   File: RecipeCombinedPotions.java   View Source Code Vote up 5 votes
@Override
public boolean matches(InventoryCrafting inv, World worldIn)
{
	ItemStack tempStack = ItemStack.EMPTY;

	int potionEffects = 0;
	for (int i = 0; i < inv.getSizeInventory(); i++)
	{
		ItemStack stack = inv.getStackInSlot(i);
		if (!stack.isEmpty())
		{

			Item item = stack.getItem();
			if (item != Items.TIPPED_ARROW && item != Items.POTIONITEM && item != Items.SPLASH_POTION && item != Items.LINGERING_POTION) return false;

			if (tempStack.isEmpty())
			{
				tempStack = stack.copy();
			}
			else
			{
				if (!ItemStack.areItemsEqual(tempStack, stack)) return false;
			}

			if (ModConfiguration.maxPotionEffects >= 0)
			{
				potionEffects += PotionUtils.getEffectsFromStack(stack).size();
				if (potionEffects > ModConfiguration.maxPotionEffects) return false;
			}
		}
	}

	return true;
}
 
Example 9
Project: CustomWorldGen   File: EntityTippedArrow.java   View Source Code Vote up 5 votes
protected ItemStack getArrowStack()
{
    if (this.customPotionEffects.isEmpty() && this.potion == PotionTypes.EMPTY)
    {
        return new ItemStack(Items.ARROW);
    }
    else
    {
        ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW);
        PotionUtils.addPotionToItemStack(itemstack, this.potion);
        PotionUtils.appendEffects(itemstack, this.customPotionEffects);
        return itemstack;
    }
}
 
Example 10
Project: CustomWorldGen   File: EntitySkeleton.java   View Source Code Vote up 4 votes
/**
 * 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)
{
    EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this);
    double d0 = target.posX - this.posX;
    double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entitytippedarrow.posY;
    double d2 = target.posZ - this.posZ;
    double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
    entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
    int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
    int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
    DifficultyInstance difficultyinstance = this.worldObj.getDifficultyForLocation(new BlockPos(this));
    entitytippedarrow.setDamage((double)(distanceFactor * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));

    if (i > 0)
    {
        entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double)i * 0.5D + 0.5D);
    }

    if (j > 0)
    {
        entitytippedarrow.setKnockbackStrength(j);
    }

    boolean flag = this.isBurning() && difficultyinstance.isHard() && this.rand.nextBoolean() || this.getSkeletonType() == SkeletonType.WITHER;
    flag = flag || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;

    if (flag)
    {
        entitytippedarrow.setFire(100);
    }

    ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND);

    if (itemstack != null && itemstack.getItem() == Items.TIPPED_ARROW)
    {
        entitytippedarrow.setPotionEffect(itemstack);
    }
    else if (this.getSkeletonType() == SkeletonType.STRAY)
    {
        entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
    }

    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitytippedarrow);
}