BiomesOPlenty/src/minecraft/biomesoplenty/items/ItemEnderporter.java

67 lines
1.9 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +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.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
2013-05-03 13:00:44 +00:00
public class ItemEnderporter extends Item
{
2013-05-31 10:34:02 +00:00
public ItemEnderporter(int par1)
{
super(par1);
maxStackSize = 1;
2013-05-03 13:00:44 +00:00
this.setMaxDamage(9);
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
2013-05-31 10:34:02 +00:00
}
@Override
2013-05-03 13:00:44 +00:00
public void registerIcons(IconRegister iconRegister)
{
2013-05-31 10:34:02 +00:00
itemIcon = iconRegister.registerIcon("BiomesOPlenty:enderporter");
}
2013-05-03 13:00:44 +00:00
2013-05-31 10:34:02 +00:00
@Override
public boolean hasEffect(ItemStack par1ItemStack)
{
return true;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
2013-05-03 13:00:44 +00:00
if (par3EntityPlayer.ridingEntity != null)
2013-05-31 10:34:02 +00:00
return par1ItemStack;
else
{
2013-05-03 13:00:44 +00:00
if (par3EntityPlayer.dimension == 0)
{
par1ItemStack.damageItem(1, par3EntityPlayer);
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 999));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 200, 999));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.nightVision.id, 100, 999));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 3));
par3EntityPlayer.setPosition(par2World.getSpawnPoint().posX, 256, par2World.getSpawnPoint().posZ);
par2World.playSoundAtEntity(par3EntityPlayer, "random.levelup", 1.0F, 5.0F);
}
2013-05-31 10:34:02 +00:00
else
2013-05-03 13:00:44 +00:00
{
if (!par3EntityPlayer.worldObj.isRemote)
{
par3EntityPlayer.addChatMessage("\u00a75A mystical energy is preventing you from using this in the current world.");
}
}
2013-05-31 10:34:02 +00:00
return par1ItemStack;
}
}
2013-05-03 13:00:44 +00:00
}