BloodMagic/BM_src/WayofTime/alchemicalWizardry/common/items/ItemComplexSpellCrystal.java

109 lines
3.7 KiB
Java
Raw Normal View History

2014-01-19 02:27:08 +00:00
package WayofTime.alchemicalWizardry.common.items;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellParadigmBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2014-01-19 02:27:08 +00:00
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
2014-01-19 02:27:08 +00:00
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
2014-01-19 02:27:08 +00:00
import java.util.List;
2014-01-19 02:27:08 +00:00
public class ItemComplexSpellCrystal extends EnergyItems
{
public ItemComplexSpellCrystal(int par1)
{
super(par1);
this.setMaxStackSize(1);
2014-01-19 02:27:08 +00:00
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BlankSpell");
}
@Override
2014-01-19 02:27:08 +00:00
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Crystal of infinite possibilities.");
2014-01-19 02:27:08 +00:00
if (!(par1ItemStack.stackTagCompound == null))
{
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
{
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
}
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
2014-01-19 02:27:08 +00:00
}
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
if (par3EntityPlayer.isSneaking())
{
return par1ItemStack;
}
if (!par2World.isRemote)
2014-01-19 21:15:10 +00:00
{
//World world = MinecraftServer.getServer().worldServers[getDimensionID(par1ItemStack)];
World world = DimensionManager.getWorld(getDimensionID(par1ItemStack));
if (world != null)
{
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
TileEntity tileEntity = world.getBlockTileEntity(itemTag.getInteger("xCoord"), itemTag.getInteger("yCoord"), itemTag.getInteger("zCoord"));
if (tileEntity instanceof TESpellParadigmBlock)
{
TESpellParadigmBlock tileParad = (TESpellParadigmBlock) tileEntity;
tileParad.castSpell(par2World, par3EntityPlayer, par1ItemStack);
} else
{
return par1ItemStack;
}
} else
{
return par1ItemStack;
}
} else
{
return par1ItemStack;
2014-01-19 21:15:10 +00:00
}
2014-01-19 02:27:08 +00:00
par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
// if (!par2World.isRemote)
// {
// //par2World.spawnEntityInWorld(new EnergyBlastProjectile(par2World, par3EntityPlayer, damage));
// par2World.spawnEntityInWorld(new FireProjectile(par2World, par3EntityPlayer, 10));
// }
2014-01-19 02:27:08 +00:00
return par1ItemStack;
}
public int getDimensionID(ItemStack itemStack)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
return itemStack.stackTagCompound.getInteger("dimensionId");
}
2014-01-19 02:27:08 +00:00
}