2014-06-27 19:43:09 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.items;
|
|
|
|
|
2015-07-30 08:44:01 -04:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2015-07-30 08:44:01 -04:00
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.StatCollector;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.DimensionManager;
|
2015-07-30 08:44:01 -04:00
|
|
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
|
|
|
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellParadigmBlock;
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
public class ItemComplexSpellCrystal extends EnergyItems
|
|
|
|
{
|
|
|
|
public ItemComplexSpellCrystal()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.setMaxStackSize(1);
|
|
|
|
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
|
|
|
{
|
2015-01-22 20:13:57 +03:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.complexspellcrystal.desc"));
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-01-16 10:00:50 -05:00
|
|
|
if (!(par1ItemStack.getTagCompound() == null))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-01-16 10:00:50 -05:00
|
|
|
NBTTagCompound itemTag = par1ItemStack.getTagCompound();
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-01-16 10:00:50 -05:00
|
|
|
if (!par1ItemStack.getTagCompound().getString("ownerName").equals(""))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-01-22 20:13:57 +03:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + par1ItemStack.getTagCompound().getString("ownerName"));
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
2015-01-22 20:13:57 +03:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack));
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
|
|
{
|
2015-01-31 23:37:17 +00:00
|
|
|
if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking())
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
return par1ItemStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!par2World.isRemote)
|
|
|
|
{
|
|
|
|
World world = DimensionManager.getWorld(getDimensionID(par1ItemStack));
|
|
|
|
|
|
|
|
if (world != null)
|
|
|
|
{
|
2015-01-16 10:00:50 -05:00
|
|
|
NBTTagCompound itemTag = par1ItemStack.getTagCompound();
|
2015-07-30 08:44:01 -04:00
|
|
|
TileEntity tileEntity = world.getTileEntity(new BlockPos(itemTag.getInteger("xCoord"), itemTag.getInteger("yCoord"), itemTag.getInteger("zCoord")));
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
if (tileEntity instanceof TESpellParadigmBlock)
|
|
|
|
{
|
|
|
|
TESpellParadigmBlock tileParad = (TESpellParadigmBlock) tileEntity;
|
|
|
|
|
|
|
|
tileParad.castSpell(par2World, par3EntityPlayer, par1ItemStack);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return par1ItemStack;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return par1ItemStack;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return par1ItemStack;
|
|
|
|
}
|
|
|
|
par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
|
|
|
return par1ItemStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDimensionID(ItemStack itemStack)
|
|
|
|
{
|
2015-01-16 10:00:50 -05:00
|
|
|
if (itemStack.getTagCompound() == null)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
itemStack.setTagCompound(new NBTTagCompound());
|
|
|
|
}
|
|
|
|
|
2015-01-16 10:00:50 -05:00
|
|
|
return itemStack.getTagCompound().getInteger("dimensionId");
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
}
|