2016-06-12 15:20:48 -04:00
|
|
|
package WayofTime.bloodmagic.item.alchemy;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
2017-08-15 20:21:54 -07:00
|
|
|
import net.minecraft.client.util.ITooltipFlag;
|
2016-06-12 15:20:48 -04:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.MobEffects;
|
|
|
|
import net.minecraft.item.EnumAction;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
import net.minecraft.util.ActionResult;
|
|
|
|
import net.minecraft.util.EnumActionResult;
|
|
|
|
import net.minecraft.util.EnumHand;
|
2017-01-01 22:26:42 -08:00
|
|
|
import net.minecraft.util.NonNullList;
|
2016-06-12 15:20:48 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
|
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
|
|
|
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
2017-08-15 18:14:28 -07:00
|
|
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
2016-06-12 15:20:48 -04:00
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
|
|
|
|
2016-06-26 09:38:13 -04:00
|
|
|
import com.google.common.collect.Iterables;
|
|
|
|
|
2016-06-12 15:20:48 -04:00
|
|
|
public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvider
|
|
|
|
{
|
|
|
|
private static ArrayList<String> names = new ArrayList<String>();
|
|
|
|
|
|
|
|
public static final String DRAFT_ANGELUS = "draftAngelus";
|
|
|
|
|
|
|
|
public ItemLivingArmourPointsUpgrade()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2017-08-14 20:53:42 -07:00
|
|
|
setUnlocalizedName(BloodMagic.MODID + ".livingPointUpgrade.");
|
2016-06-12 15:20:48 -04:00
|
|
|
setHasSubtypes(true);
|
2017-08-14 20:53:42 -07:00
|
|
|
setCreativeTab(BloodMagic.TAB_BM);
|
2016-06-12 15:20:48 -04:00
|
|
|
|
|
|
|
buildItemList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-15 20:21:54 -07:00
|
|
|
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
2016-06-12 15:20:48 -04:00
|
|
|
{
|
2016-09-06 18:55:32 -07:00
|
|
|
if (!stack.hasTagCompound())
|
|
|
|
return;
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2017-01-02 01:18:29 -08:00
|
|
|
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmourPointsUpgrade.desc", 200))));
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
|
|
|
|
{
|
|
|
|
EntityPlayer player = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null;
|
|
|
|
|
|
|
|
if (player == null || !player.capabilities.isCreativeMode)
|
|
|
|
{
|
2017-01-01 22:26:42 -08:00
|
|
|
stack.shrink(1);
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!worldIn.isRemote)
|
|
|
|
{
|
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5));
|
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5));
|
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
|
|
|
|
|
|
|
|
if (LivingArmour.hasFullSet(player))
|
|
|
|
{
|
|
|
|
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
|
2016-06-26 09:38:13 -04:00
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
2016-06-12 15:20:48 -04:00
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
if (armour.maxUpgradePoints < 200)
|
|
|
|
{
|
|
|
|
armour.maxUpgradePoints = 200;
|
|
|
|
((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
|
2016-06-26 09:38:13 -04:00
|
|
|
ItemLivingArmour.setLivingArmour(chestStack, armour);
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMaxItemUseDuration(ItemStack stack)
|
|
|
|
{
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumAction getItemUseAction(ItemStack stack)
|
|
|
|
{
|
|
|
|
return EnumAction.DRINK;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-01-01 22:26:42 -08:00
|
|
|
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
|
2016-06-12 15:20:48 -04:00
|
|
|
{
|
|
|
|
playerIn.setActiveHand(hand);
|
2017-01-01 22:26:42 -08:00
|
|
|
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void buildItemList()
|
|
|
|
{
|
|
|
|
names.add(0, DRAFT_ANGELUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getUnlocalizedName(ItemStack stack)
|
|
|
|
{
|
|
|
|
return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-15 20:21:54 -07:00
|
|
|
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
2016-06-12 15:20:48 -04:00
|
|
|
{
|
2017-08-15 20:21:54 -07:00
|
|
|
if (!isInCreativeTab(creativeTab))
|
|
|
|
return;
|
|
|
|
|
2016-06-12 15:20:48 -04:00
|
|
|
for (int i = 0; i < names.size(); i++)
|
2017-08-15 20:21:54 -07:00
|
|
|
list.add(new ItemStack(this, 1, i));
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public static ItemStack getStack(String name)
|
|
|
|
{
|
2017-08-15 21:24:59 -07:00
|
|
|
return new ItemStack(RegistrarBloodMagicItems.POINTS_UPGRADE, 1, names.indexOf(name));
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Pair<Integer, String>> getVariants()
|
|
|
|
{
|
|
|
|
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
|
|
|
for (String name : names)
|
|
|
|
ret.add(new ImmutablePair<Integer, String>(names.indexOf(name), "type=" + name));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ItemStack getStack(String key, int stackSize)
|
|
|
|
{
|
|
|
|
ItemStack stack = getStack(key);
|
2017-01-01 22:26:42 -08:00
|
|
|
stack.setCount(stackSize);
|
2016-06-12 15:20:48 -04:00
|
|
|
|
|
|
|
return stack;
|
|
|
|
}
|
2017-08-15 20:21:54 -07:00
|
|
|
|
|
|
|
public static ArrayList<String> getNames() {
|
|
|
|
return names;
|
|
|
|
}
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|