2016-01-07 11:01:38 -05:00
|
|
|
package WayofTime.bloodmagic.item.soul;
|
|
|
|
|
2016-03-17 13:00:44 -07:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
2016-03-16 01:10:33 -07:00
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
2016-03-17 13:00:44 -07:00
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2016-01-07 11:01:38 -05:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2016-03-16 01:10:33 -07:00
|
|
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
2016-01-07 11:01:38 -05:00
|
|
|
|
2016-03-17 13:00:44 -07:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2016-03-16 01:10:33 -07:00
|
|
|
public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
|
|
|
public static String[] names = { "base" };
|
|
|
|
|
|
|
|
public ItemMonsterSoul()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
|
|
|
setUnlocalizedName(Constants.Mod.MODID + ".monsterSoul.");
|
|
|
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
|
|
|
setHasSubtypes(true);
|
|
|
|
setMaxStackSize(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getUnlocalizedName(ItemStack stack)
|
|
|
|
{
|
|
|
|
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubItems(Item id, CreativeTabs creativeTab, List<ItemStack> list)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < names.length; i++)
|
|
|
|
list.add(new ItemStack(id, 1, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
|
|
|
{
|
2016-09-06 18:55:32 -07:00
|
|
|
if (!stack.hasTagCompound())
|
|
|
|
return;
|
2016-01-09 10:47:36 -05:00
|
|
|
tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(stack)));
|
2016-01-07 11:01:38 -05:00
|
|
|
|
|
|
|
super.addInformation(stack, player, tooltip, advanced);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-09 10:47:36 -05:00
|
|
|
public double getWill(ItemStack soulStack)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
|
|
|
NBTHelper.checkNBT(soulStack);
|
|
|
|
|
|
|
|
NBTTagCompound tag = soulStack.getTagCompound();
|
|
|
|
|
|
|
|
return tag.getDouble(Constants.NBT.SOULS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-09 10:47:36 -05:00
|
|
|
public void setWill(ItemStack soulStack, double souls)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
|
|
|
NBTHelper.checkNBT(soulStack);
|
|
|
|
|
|
|
|
NBTTagCompound tag = soulStack.getTagCompound();
|
|
|
|
|
|
|
|
tag.setDouble(Constants.NBT.SOULS, souls);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-09 10:47:36 -05:00
|
|
|
public double drainWill(ItemStack soulStack, double drainAmount)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
2016-01-09 10:47:36 -05:00
|
|
|
double souls = getWill(soulStack);
|
2016-01-07 11:01:38 -05:00
|
|
|
|
|
|
|
double soulsDrained = Math.min(drainAmount, souls);
|
2016-01-09 10:47:36 -05:00
|
|
|
setWill(soulStack, souls - soulsDrained);
|
2016-01-07 11:01:38 -05:00
|
|
|
|
|
|
|
return soulsDrained;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-09 10:47:36 -05:00
|
|
|
public ItemStack createWill(int meta, double number)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
|
|
|
ItemStack soulStack = new ItemStack(this, 1, meta);
|
2016-01-09 10:47:36 -05:00
|
|
|
setWill(soulStack, number);
|
2016-01-07 11:01:38 -05:00
|
|
|
return soulStack;
|
|
|
|
}
|
2016-03-16 01:10:33 -07:00
|
|
|
|
|
|
|
@Override
|
2016-03-16 18:41:06 -04:00
|
|
|
public List<Pair<Integer, String>> getVariants()
|
|
|
|
{
|
2016-03-16 01:10:33 -07:00
|
|
|
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
|
|
|
ret.add(new ImmutablePair<Integer, String>(0, "type=monstersoul"));
|
|
|
|
return ret;
|
|
|
|
}
|
2016-01-07 11:01:38 -05:00
|
|
|
}
|