Added upgrade tomes to a separate creative tab.

This commit is contained in:
WayofTime 2016-01-09 22:20:59 -05:00
parent cf4a02bf89
commit ebdf85182c
7 changed files with 161 additions and 0 deletions

View file

@ -44,6 +44,15 @@ public class BloodMagic
}
};
public static CreativeTabs tabUpgradeTome = new CreativeTabs(Constants.Mod.MODID + ".creativeTabTome")
{
@Override
public Item getTabIconItem()
{
return ModItems.upgradeTome;
}
};
private LogHelper logger = new LogHelper(Constants.Mod.MODID);
private File configDir;

View file

@ -12,6 +12,7 @@ public class LivingArmourHandler
public static List<Class<? extends StatTracker>> trackers = new ArrayList<Class<? extends StatTracker>>();
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap<String, Class<? extends LivingArmourUpgrade>>();
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap<String, Constructor<? extends LivingArmourUpgrade>>();
public static HashMap<String, Integer> upgradeMaxLevelMap = new HashMap<String, Integer>();
public static void registerStatTracker(Class<? extends StatTracker> tracker)
{
@ -28,6 +29,7 @@ public class LivingArmourHandler
{
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
upgradeMaxLevelMap.put(upgrade.getUniqueIdentifier(), upgrade.getMaxTier());
try
{
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);

View file

@ -0,0 +1,136 @@
package WayofTime.bloodmagic.item;
import java.util.List;
import java.util.Map.Entry;
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.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ItemUpgradeTome extends Item
{
public ItemUpgradeTome()
{
super();
setCreativeTab(BloodMagic.tabUpgradeTome);
setUnlocalizedName(Constants.Mod.MODID + ".upgradeTome");
setHasSubtypes(true);
setMaxStackSize(1);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (world.isRemote)
{
return stack;
}
LivingArmourUpgrade upgrade = this.getUpgrade(stack);
if (upgrade == null)
{
return stack;
}
ItemStack chestStack = player.getCurrentArmor(2);
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
{
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour == null)
{
return stack;
}
if (armour.upgradeArmour(player, upgrade))
{
ItemLivingArmour.armourMap.put(chestStack, armour);
// ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(stack, armour, false);
stack.stackSize--;
}
}
return stack;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item id, CreativeTabs creativeTab, List<ItemStack> list)
{
for (Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet())
{
String key = entry.getKey();
int maxLevel = entry.getValue();
for (int i = 0; i < maxLevel; i++)
{
ItemStack stack = new ItemStack(this);
setKey(stack, key);
setLevel(stack, i);
list.add(stack);
}
}
}
public LivingArmourUpgrade getUpgrade(ItemStack stack)
{
String key = getKey(stack);
int level = getLevel(stack);
return LivingArmourHandler.generateUpgradeFromKey(key, level);
}
public void setKey(ItemStack stack, String key)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
tag.setString("key", key);
}
public String getKey(ItemStack stack)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
return tag.getString("key");
}
public void setLevel(ItemStack stack, int level)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
tag.setInteger("level", level);
}
public int getLevel(ItemStack stack)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
return tag.getInteger("level");
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour"))));
LivingArmourUpgrade upgrade = this.getUpgrade(stack);
if (upgrade != null)
{
tooltip.add(TextHelper.localize(upgrade.getUnlocalizedName()) + " " + TextHelper.localize("tooltip.BloodMagic.livingArmour.upgrade.level", (upgrade.getUpgradeLevel() + 1)));
}
}
}

View file

@ -26,6 +26,7 @@ import WayofTime.bloodmagic.item.ItemRitualDiviner;
import WayofTime.bloodmagic.item.ItemSacrificialDagger;
import WayofTime.bloodmagic.item.ItemSlate;
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
import WayofTime.bloodmagic.item.ItemUpgradeTome;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
@ -118,6 +119,7 @@ public class ModItems
public static Item sentientArmourBoots;
public static Item altarMaker;
public static Item upgradeTome;
public static Item arcaneAshes;
public static Item monsterSoul;
@ -202,6 +204,7 @@ public class ModItems
sentientArmourBoots = registerItem(new ItemSentientArmour(3), "ItemSentientArmourBoots");
altarMaker = registerItem(new ItemAltarMaker());
upgradeTome = registerItem(new ItemUpgradeTome());
arcaneAshes = registerItem(new ItemArcaneAshes());
monsterSoul = registerItem(new ItemMonsterSoul());
@ -312,6 +315,7 @@ public class ModItems
renderHelper.itemRender(sentientArmourBoots, "ItemSentientArmour3");
renderHelper.itemRender(altarMaker);
renderHelper.itemRender(upgradeTome);
renderHelper.itemRender(arcaneAshes);
renderHelper.itemRender(monsterSoul, 0);

View file

@ -1,5 +1,6 @@
#Creative Tab
itemGroup.BloodMagic.creativeTab=Blood Magic
itemGroup.BloodMagic.creativeTabTome=Blood Magic Upgrade Tomes
#Items
item.BloodMagic.activationCrystal.weak.name=Weak Activation Crystal
@ -108,6 +109,7 @@ item.BloodMagic.ritualDivinerdusk.name=Ritual Diviner [Dusk]
item.BloodMagic.ritualDivinerdawn.name=Ritual Diviner [Dawn]
item.BloodMagic.arcaneAshes.name=Arcane Ashes
item.BloodMagic.upgradeTome.name=Living Armour Upgrade Tome
item.BloodMagic.sentientSword.name=Sentient Sword
item.BloodMagic.soulGem.petty.name=Petty Tartaric Gem
@ -281,6 +283,7 @@ chat.BloodMagic.ritual.activate=A rush of energy flows through the ritual!
chat.BloodMagic.ritual.notValid=You feel that these runes are not configured correctly...
chat.BloodMagic.livingArmour.upgrade.poisonRemove=You are starting to feel better already!
chat.BloodMagic.livingArmour.newUpgrade=Upgrade acquired!
# JustEnoughItems
jei.BloodMagic.recipe.altar=Blood Altar

View file

@ -0,0 +1,7 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/UpgradeTome"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B