BloodMagic/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java
Nicholas Ignoffo ddaadfbe52 Swap the API packages
The new one is now built for the api jar and the old one is now internal.
It will slowly be moved around to sane places within the internal code. Most
of the features provided in the old "api" are addon specific features which
will generally rely on the main jar anyways. The new API will be specific
to compatibility features, such as blacklists, recipes, and value modification.
2018-02-05 17:04:46 -08:00

91 lines
3.1 KiB
Java

package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.apibutnotreally.iface.IUpgradeTrainer;
import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourHandler;
import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.apibutnotreally.util.helper.ItemHelper.LivingUpgrades;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
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 java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVariantProvider {
public ItemUpgradeTrainer() {
super();
setCreativeTab(BloodMagic.TAB_TOMES);
setUnlocalizedName(BloodMagic.MODID + ".upgradeTrainer");
setHasSubtypes(true);
setMaxStackSize(1);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
if (!isInCreativeTab(creativeTab))
return;
list.add(new ItemStack(this));
for (Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) {
String key = entry.getKey();
ItemStack stack = new ItemStack(this);
LivingUpgrades.setKey(stack, key);
list.add(stack);
}
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour"))));
if (!stack.hasTagCompound())
return;
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
if (upgrade != null) {
tooltip.add(TextHelper.localize(upgrade.getUnlocalizedName()));
}
}
@Override
public List<String> getTrainedUpgrades(ItemStack stack) {
List<String> keyList = new ArrayList<String>();
String key = LivingUpgrades.getKey(stack);
if (!key.isEmpty()) {
keyList.add(key);
}
return keyList;
}
@Override
public boolean setTrainedUpgrades(ItemStack stack, List<String> keys) {
if (keys.isEmpty()) {
return false;
}
LivingUpgrades.setKey(stack, keys.get(0));
return true;
}
@Override
public List<Pair<Integer, String>> getVariants() {
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
ret.add(new ImmutablePair<Integer, String>(0, "type=upgradetrainer"));
return ret;
}
}