2016-01-07 11:01:38 -05:00
|
|
|
package WayofTime.bloodmagic.item.soul;
|
|
|
|
|
2018-02-05 17:04:38 -08:00
|
|
|
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.soul.IDemonWill;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.util.helper.NBTHelper;
|
2018-02-13 23:32:15 -08:00
|
|
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
|
|
|
import WayofTime.bloodmagic.item.ItemEnum;
|
|
|
|
import WayofTime.bloodmagic.item.types.ISubItem;
|
2016-03-17 13:00:44 -07:00
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2017-08-15 20:21:54 -07:00
|
|
|
import net.minecraft.client.util.ITooltipFlag;
|
2016-01-07 11:01:38 -05:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2017-08-15 20:21:54 -07:00
|
|
|
import net.minecraft.world.World;
|
2016-01-07 11:01:38 -05:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
2018-02-13 23:32:15 -08:00
|
|
|
import javax.annotation.Nonnull;
|
2016-03-17 13:00:44 -07:00
|
|
|
import java.util.List;
|
2018-02-13 23:32:15 -08:00
|
|
|
import java.util.Locale;
|
2016-03-17 13:00:44 -07:00
|
|
|
|
2018-02-13 23:32:15 -08:00
|
|
|
public class ItemMonsterSoul extends ItemEnum.Variant<ItemMonsterSoul.WillType> implements IDemonWill {
|
2016-01-07 11:01:38 -05:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public ItemMonsterSoul() {
|
2018-02-13 23:32:15 -08:00
|
|
|
super(WillType.class, "monster_soul");
|
2016-01-07 11:01:38 -05:00
|
|
|
|
|
|
|
setMaxStackSize(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-15 21:30:48 -07:00
|
|
|
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
2016-09-06 18:55:32 -07:00
|
|
|
if (!stack.hasTagCompound())
|
|
|
|
return;
|
2017-01-02 01:18:29 -08:00
|
|
|
tooltip.add(TextHelper.localize("tooltip.bloodmagic.will", getWill(getType(stack), stack)));
|
2016-01-07 11:01:38 -05:00
|
|
|
|
2017-08-15 20:21:54 -07:00
|
|
|
super.addInformation(stack, world, tooltip, flag);
|
2016-01-07 11:01:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public EnumDemonWillType getType(ItemStack stack) {
|
2016-11-02 12:16:24 -04:00
|
|
|
return EnumDemonWillType.values()[stack.getItemDamage() % 5];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public double getWill(EnumDemonWillType type, ItemStack soulStack) {
|
|
|
|
if (type != this.getType(soulStack)) {
|
2016-11-02 12:16:24 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-07 11:01:38 -05:00
|
|
|
NBTHelper.checkNBT(soulStack);
|
|
|
|
|
|
|
|
NBTTagCompound tag = soulStack.getTagCompound();
|
|
|
|
|
|
|
|
return tag.getDouble(Constants.NBT.SOULS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls) {
|
2016-01-07 11:01:38 -05:00
|
|
|
NBTHelper.checkNBT(soulStack);
|
|
|
|
|
|
|
|
NBTTagCompound tag = soulStack.getTagCompound();
|
|
|
|
|
2016-11-02 12:16:24 -04:00
|
|
|
soulStack.setItemDamage(type.ordinal());
|
|
|
|
|
2016-01-07 11:01:38 -05:00
|
|
|
tag.setDouble(Constants.NBT.SOULS, souls);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount) {
|
2016-11-02 12:16:24 -04:00
|
|
|
double souls = getWill(type, soulStack);
|
2016-01-07 11:01:38 -05:00
|
|
|
|
|
|
|
double soulsDrained = Math.min(drainAmount, souls);
|
2016-11-02 12:16:24 -04:00
|
|
|
setWill(type, soulStack, souls - soulsDrained);
|
2016-01-07 11:01:38 -05:00
|
|
|
|
|
|
|
return soulsDrained;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public ItemStack createWill(int meta, double number) {
|
2016-11-02 12:16:24 -04:00
|
|
|
ItemStack soulStack = new ItemStack(this, 1, meta % 5);
|
|
|
|
setWill(getType(soulStack), soulStack, number);
|
2016-01-07 11:01:38 -05:00
|
|
|
return soulStack;
|
|
|
|
}
|
2016-03-16 01:10:33 -07:00
|
|
|
|
2016-12-07 08:14:05 -05:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public double getWill(ItemStack willStack) {
|
2016-12-07 08:14:05 -05:00
|
|
|
return this.getWill(EnumDemonWillType.DEFAULT, willStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void setWill(ItemStack willStack, double will) {
|
2016-12-07 08:14:05 -05:00
|
|
|
this.setWill(EnumDemonWillType.DEFAULT, willStack, will);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public double drainWill(ItemStack willStack, double drainAmount) {
|
2016-12-07 08:14:05 -05:00
|
|
|
return this.drainWill(EnumDemonWillType.DEFAULT, willStack, drainAmount);
|
|
|
|
}
|
2018-02-13 23:32:15 -08:00
|
|
|
|
|
|
|
public enum WillType implements ISubItem {
|
|
|
|
|
|
|
|
RAW,
|
|
|
|
CORROSIVE,
|
|
|
|
DESTRUCTIVE,
|
|
|
|
VENGEFUL,
|
2018-02-14 23:38:57 -08:00
|
|
|
STEADFAST,;
|
2018-02-13 23:32:15 -08:00
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public String getInternalName() {
|
|
|
|
return name().toLowerCase(Locale.ROOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public ItemStack getStack(int count) {
|
|
|
|
return new ItemStack(RegistrarBloodMagicItems.MONSTER_SOUL, count, ordinal());
|
|
|
|
}
|
|
|
|
}
|
2016-01-07 11:01:38 -05:00
|
|
|
}
|