2016-06-12 15:20:48 -04:00
|
|
|
package WayofTime.bloodmagic.item.alchemy;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
2018-02-19 15:41:18 -08:00
|
|
|
import WayofTime.bloodmagic.item.ItemEnum;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
2018-02-19 15:41:18 -08:00
|
|
|
import WayofTime.bloodmagic.item.types.ISubItem;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
|
|
|
import com.google.common.collect.Iterables;
|
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.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.MobEffects;
|
|
|
|
import net.minecraft.item.EnumAction;
|
|
|
|
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;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
import javax.annotation.Nonnull;
|
2017-08-15 21:30:48 -07:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
2018-02-19 15:41:18 -08:00
|
|
|
import java.util.Locale;
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
public class ItemLivingArmourPointsUpgrade extends ItemEnum.Variant<ItemLivingArmourPointsUpgrade.UpgradeType> {
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public ItemLivingArmourPointsUpgrade() {
|
2018-02-19 15:41:18 -08:00
|
|
|
super(UpgradeType.class, "living_point_upgrade");
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-15 21:30:48 -07:00
|
|
|
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
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
|
|
|
}
|
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
@Override
|
|
|
|
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
|
|
|
playerIn.setActiveHand(hand);
|
|
|
|
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
|
|
|
|
}
|
|
|
|
|
2016-06-12 15:20:48 -04:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
2018-02-19 15:41:18 -08:00
|
|
|
if (!(entityLiving instanceof EntityPlayer))
|
|
|
|
return super.onItemUseFinish(stack, worldIn, entityLiving);
|
|
|
|
|
|
|
|
EntityPlayer player = (EntityPlayer) entityLiving;
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
if (!player.capabilities.isCreativeMode)
|
2017-01-01 22:26:42 -08:00
|
|
|
stack.shrink(1);
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (!worldIn.isRemote) {
|
2016-06-12 15:20:48 -04:00
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5));
|
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5));
|
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (LivingArmour.hasFullSet(player)) {
|
2016-06-12 15:20:48 -04:00
|
|
|
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
|
2016-06-26 09:38:13 -04:00
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
2017-08-15 21:30:48 -07:00
|
|
|
if (armour != null) {
|
|
|
|
if (armour.maxUpgradePoints < 200) {
|
2016-06-12 15:20:48 -04:00
|
|
|
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
|
2017-08-15 21:30:48 -07:00
|
|
|
public int getMaxItemUseDuration(ItemStack stack) {
|
2016-06-12 15:20:48 -04:00
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public EnumAction getItemUseAction(ItemStack stack) {
|
2016-06-12 15:20:48 -04:00
|
|
|
return EnumAction.DRINK;
|
|
|
|
}
|
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
public enum UpgradeType implements ISubItem {
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
DRAFT_ANGELUS,
|
|
|
|
;
|
2016-06-12 15:20:48 -04:00
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public String getInternalName() {
|
|
|
|
return name().toLowerCase(Locale.ROOT);
|
|
|
|
}
|
2017-08-15 20:21:54 -07:00
|
|
|
|
2018-02-19 15:41:18 -08:00
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public ItemStack getStack(int count) {
|
|
|
|
return new ItemStack(RegistrarBloodMagicItems.POINTS_UPGRADE, count, ordinal());
|
|
|
|
}
|
2017-08-15 20:21:54 -07:00
|
|
|
}
|
2016-06-12 15:20:48 -04:00
|
|
|
}
|