2013-05-07 01:02:25 +00:00
|
|
|
package biomesoplenty.items;
|
|
|
|
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import biomesoplenty.BiomesOPlenty;
|
2013-05-08 12:13:51 +00:00
|
|
|
import biomesoplenty.api.Items;
|
2013-05-07 01:02:25 +00:00
|
|
|
import biomesoplenty.items.projectiles.EntityDart;
|
2013-05-16 13:50:12 +00:00
|
|
|
import biomesoplenty.items.projectiles.EntityDart.DartType;
|
2013-05-07 01:02:25 +00:00
|
|
|
|
|
|
|
public class ItemDartBlower extends Item
|
|
|
|
{
|
|
|
|
public ItemDartBlower(int par1)
|
|
|
|
{
|
|
|
|
super(par1);
|
|
|
|
this.maxStackSize = 1;
|
2013-05-08 12:39:12 +00:00
|
|
|
this.setMaxDamage(63);
|
2013-05-07 01:02:25 +00:00
|
|
|
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
|
|
|
setUnlocalizedName("dartblower");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void registerIcons(IconRegister iconRegister)
|
|
|
|
{
|
|
|
|
itemIcon = iconRegister.registerIcon("BiomesOPlenty:dartblower");
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack onItemRightClick(ItemStack itemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
|
|
{
|
2013-05-08 12:13:51 +00:00
|
|
|
boolean flag = par3EntityPlayer.capabilities.isCreativeMode;
|
2013-05-07 01:02:25 +00:00
|
|
|
|
2013-05-16 13:50:12 +00:00
|
|
|
if (flag || par3EntityPlayer.inventory.hasItem(Items.dart.get().itemID))
|
2013-05-08 12:13:51 +00:00
|
|
|
{
|
2013-05-11 12:51:16 +00:00
|
|
|
//EntityArrow entitydart = new EntityArrow(par2World, par3EntityPlayer, 2.0F);
|
2013-05-16 13:50:12 +00:00
|
|
|
EntityDart entityDart = new EntityDart(par2World, par3EntityPlayer, 1.25F);
|
2013-05-08 12:13:51 +00:00
|
|
|
|
|
|
|
itemStack.damageItem(1, par3EntityPlayer);
|
|
|
|
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 2.0F / (1.0F * 0.4F + 1.2F) + 1.0F * 0.5F);
|
2013-05-07 01:02:25 +00:00
|
|
|
|
2013-05-16 13:50:12 +00:00
|
|
|
int slot = -1;
|
|
|
|
if (par3EntityPlayer.inventory.hasItemStack(new ItemStack(Items.dart.get().itemID, 1, 1)))
|
|
|
|
{
|
|
|
|
entityDart.setDartType(DartType.POISON);
|
|
|
|
|
|
|
|
for (int k = 0; k < par3EntityPlayer.inventory.mainInventory.length; ++k)
|
|
|
|
if (par3EntityPlayer.inventory.mainInventory[k] != null && par3EntityPlayer.inventory.mainInventory[k].itemID == Items.dart.get().itemID && par3EntityPlayer.inventory.mainInventory[k].getItemDamage() == 1)
|
|
|
|
{
|
|
|
|
slot = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (par3EntityPlayer.inventory.hasItemStack(new ItemStack(Items.dart.get().itemID, 1, 0)))
|
|
|
|
{
|
|
|
|
entityDart.setDartType(DartType.NORMAL);
|
|
|
|
|
|
|
|
for (int k = 0; k < par3EntityPlayer.inventory.mainInventory.length; ++k)
|
|
|
|
if (par3EntityPlayer.inventory.mainInventory[k] != null && par3EntityPlayer.inventory.mainInventory[k].itemID == Items.dart.get().itemID && par3EntityPlayer.inventory.mainInventory[k].getItemDamage() == 0)
|
|
|
|
{
|
|
|
|
slot = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!par2World.isRemote)
|
|
|
|
par2World.spawnEntityInWorld(entityDart);
|
|
|
|
|
|
|
|
if (!flag && slot >= 0)
|
|
|
|
par3EntityPlayer.inventory.decrStackSize(slot, 1);
|
2013-05-08 12:13:51 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 01:02:25 +00:00
|
|
|
return itemStack;
|
|
|
|
}
|
|
|
|
}
|