From 64efaf854bccc62ac566eafc3da7bc3957eb9c72 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sun, 14 Feb 2016 21:50:32 -0500 Subject: [PATCH] Implemented most of the framework required for training specific Living Armour Upgrades. --- .../WayofTime/bloodmagic/api/Constants.java | 3 +- .../bloodmagic/api/iface/IUpgradeTrainer.java | 16 +++ .../api/livingArmour/StatTracker.java | 2 + .../StatTrackerThaumRunicShielding.java | 6 + .../bloodmagic/item/ItemUpgradeTome.java | 14 +-- .../bloodmagic/item/ItemUpgradeTrainer.java | 110 ++++++++++++++++++ .../bloodmagic/livingArmour/LivingArmour.java | 37 +++++- .../tracker/StatTrackerArrowShot.java | 6 + .../tracker/StatTrackerDigging.java | 6 + .../livingArmour/tracker/StatTrackerFood.java | 6 + .../tracker/StatTrackerGrimReaperSprint.java | 6 + .../tracker/StatTrackerHealthboost.java | 6 + .../tracker/StatTrackerMeleeDamage.java | 6 + .../tracker/StatTrackerMovement.java | 6 + .../tracker/StatTrackerPhysicalProtect.java | 6 + .../tracker/StatTrackerPoison.java | 6 + .../tracker/StatTrackerSelfSacrifice.java | 6 + .../tracker/StatTrackerSolarPowered.java | 6 + .../bloodmagic/registry/ModItems.java | 8 +- .../bloodmagic/util/handler/EventHandler.java | 49 +++++++- .../blockstates/item/ItemUpgradeTrainer.json | 16 +++ .../assets/bloodmagic/lang/en_US.lang | 1 + .../models/item/ItemUpgradeTrainer.json | 7 ++ .../textures/items/UpgradeTrainer.png | Bin 0 -> 544 bytes 24 files changed, 322 insertions(+), 13 deletions(-) create mode 100644 src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java create mode 100644 src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTrainer.json create mode 100644 src/main/resources/assets/bloodmagic/models/item/ItemUpgradeTrainer.json create mode 100644 src/main/resources/assets/bloodmagic/textures/items/UpgradeTrainer.png diff --git a/src/main/java/WayofTime/bloodmagic/api/Constants.java b/src/main/java/WayofTime/bloodmagic/api/Constants.java index 8c4e1b33..87f896f8 100644 --- a/src/main/java/WayofTime/bloodmagic/api/Constants.java +++ b/src/main/java/WayofTime/bloodmagic/api/Constants.java @@ -195,7 +195,8 @@ public class Constants SIGIL_WHIRLWIND("ItemSigilWhirlwind"), SLATE("ItemSlate"), TELEPOSITION_FOCUS("ItemTelepositionFocus"), - UPGRADE_TOME("ItemUpgradeTome"); + UPGRADE_TOME("ItemUpgradeTome"), + UPGRADE_TRAINER("ItemUpgradeTrainer"); @Getter private final String regName; diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java b/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java new file mode 100644 index 00000000..db33f93b --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java @@ -0,0 +1,16 @@ +package WayofTime.bloodmagic.api.iface; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +/** + * This interface is used for items intended to train specific upgrades while + * held in the player's inventory. + */ +public interface IUpgradeTrainer +{ + public List getTrainedUpgrades(ItemStack stack); + + public boolean setTrainedUpgrades(ItemStack stack, List keys); +} diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java index 7be546e0..2524f9d0 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java @@ -53,4 +53,6 @@ public abstract class StatTracker { this.isDirty = false; } + + public abstract boolean providesUpgrade(String key); } diff --git a/src/main/java/WayofTime/bloodmagic/compat/thaumcraft/StatTrackerThaumRunicShielding.java b/src/main/java/WayofTime/bloodmagic/compat/thaumcraft/StatTrackerThaumRunicShielding.java index f470563f..ea2e1c3d 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/thaumcraft/StatTrackerThaumRunicShielding.java +++ b/src/main/java/WayofTime/bloodmagic/compat/thaumcraft/StatTrackerThaumRunicShielding.java @@ -88,4 +88,10 @@ public class StatTrackerThaumRunicShielding extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.thaumRunicShielding"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java index 27b14ba3..62a78dd5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java @@ -40,7 +40,7 @@ public class ItemUpgradeTome extends Item { return stack; } - LivingArmourUpgrade upgrade = this.getUpgrade(stack); + LivingArmourUpgrade upgrade = ItemUpgradeTome.getUpgrade(stack); if (upgrade == null) { return stack; @@ -83,7 +83,7 @@ public class ItemUpgradeTome extends Item } } - public LivingArmourUpgrade getUpgrade(ItemStack stack) + public static LivingArmourUpgrade getUpgrade(ItemStack stack) { String key = getKey(stack); int level = getLevel(stack); @@ -91,7 +91,7 @@ public class ItemUpgradeTome extends Item return LivingArmourHandler.generateUpgradeFromKey(key, level); } - public void setKey(ItemStack stack, String key) + public static void setKey(ItemStack stack, String key) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -99,7 +99,7 @@ public class ItemUpgradeTome extends Item tag.setString("key", key); } - public String getKey(ItemStack stack) + public static String getKey(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -107,7 +107,7 @@ public class ItemUpgradeTome extends Item return tag.getString("key"); } - public void setLevel(ItemStack stack, int level) + public static void setLevel(ItemStack stack, int level) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -115,7 +115,7 @@ public class ItemUpgradeTome extends Item tag.setInteger("level", level); } - public int getLevel(ItemStack stack) + public static int getLevel(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -128,7 +128,7 @@ public class ItemUpgradeTome extends Item public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { // tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour")))); - LivingArmourUpgrade upgrade = this.getUpgrade(stack); + LivingArmourUpgrade upgrade = ItemUpgradeTome.getUpgrade(stack); if (upgrade != null) { tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1)); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java new file mode 100644 index 00000000..28196b7f --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java @@ -0,0 +1,110 @@ +package WayofTime.bloodmagic.item; + +import java.util.ArrayList; +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.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.util.helper.TextHelper; + +public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer +{ + public ItemUpgradeTrainer() + { + super(); + + setCreativeTab(BloodMagic.tabUpgradeTome); + setUnlocalizedName(Constants.Mod.MODID + ".upgradeTrainer"); + setRegistryName(Constants.BloodMagicItem.UPGRADE_TRAINER.getRegName()); + setHasSubtypes(true); + setMaxStackSize(1); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { + list.add(new ItemStack(this)); + for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) + { + String key = entry.getKey(); + ItemStack stack = new ItemStack(this); + setKey(stack, key); + list.add(stack); + } + } + + public static LivingArmourUpgrade getUpgrade(ItemStack stack) + { + String key = getKey(stack); + int level = 0; + + return LivingArmourHandler.generateUpgradeFromKey(key, level); + } + + public static void setKey(ItemStack stack, String key) + { + NBTHelper.checkNBT(stack); + NBTTagCompound tag = stack.getTagCompound(); + + tag.setString("key", key); + } + + public static String getKey(ItemStack stack) + { + NBTHelper.checkNBT(stack); + NBTTagCompound tag = stack.getTagCompound(); + + return tag.getString("key"); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { +// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour")))); + LivingArmourUpgrade upgrade = ItemUpgradeTrainer.getUpgrade(stack); + if (upgrade != null) + { + tooltip.add(TextHelper.localize(upgrade.getUnlocalizedName())); + } + } + + @Override + public List getTrainedUpgrades(ItemStack stack) + { + List keyList = new ArrayList(); + String key = getKey(stack); + + if (!key.isEmpty()) + { + keyList.add(key); + } + + return keyList; + } + + @Override + public boolean setTrainedUpgrades(ItemStack stack, List keys) + { + if (keys.isEmpty()) + { + return false; + } + + setKey(stack, keys.get(0)); + return true; + } +} diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java index 6bd010e2..80b0cf47 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java @@ -1,21 +1,23 @@ package WayofTime.bloodmagic.livingArmour; import java.lang.reflect.Constructor; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; +import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; @@ -122,6 +124,19 @@ public class LivingArmour implements ILivingArmour upgrade.onTick(world, player, this); } + List allowedUpgradesList = new ArrayList(); + for (ItemStack stack : player.inventory.mainInventory) + { + if (stack != null && stack.getItem() instanceof IUpgradeTrainer) + { + List keyList = ((IUpgradeTrainer) stack.getItem()).getTrainedUpgrades(stack); + if (!keyList.isEmpty()) + { + allowedUpgradesList.addAll(keyList); + } + } + } + for (Entry entry : trackerMap.entrySet()) { StatTracker tracker = entry.getValue(); @@ -131,6 +146,25 @@ public class LivingArmour implements ILivingArmour continue; } + if (!allowedUpgradesList.isEmpty()) + { + boolean allowed = false; + + for (String key : allowedUpgradesList) + { + if (tracker.providesUpgrade(key)) + { + allowed = true; + break; + } + } + + if (!allowed) + { + continue; + } + } + if (tracker.onTick(world, player, this)) { List upgradeList = tracker.getUpgrades(); @@ -140,6 +174,7 @@ public class LivingArmour implements ILivingArmour upgradeArmour(player, upgrade); } } + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java index c7a3c4f3..3d16375e 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java @@ -85,4 +85,10 @@ public class StatTrackerArrowShot extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.arrowShot"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java index 607947b1..c4a25104 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java @@ -85,4 +85,10 @@ public class StatTrackerDigging extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.digging"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java index 3c35ba24..ee69e03e 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java @@ -87,4 +87,10 @@ public class StatTrackerFood extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.knockback"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java index e249c0f6..bec3f1ba 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java @@ -92,4 +92,10 @@ public class StatTrackerGrimReaperSprint extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.grimReaper"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java index c8d746e1..b522f7fc 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java @@ -85,4 +85,10 @@ public class StatTrackerHealthboost extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.health"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java index 7287702f..3b0cd677 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java @@ -85,4 +85,10 @@ public class StatTrackerMeleeDamage extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.meleeDamage"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java index f9009325..4c1e0670 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java @@ -98,4 +98,10 @@ public class StatTrackerMovement extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.movement"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java index 06646467..c1691724 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java @@ -85,4 +85,10 @@ public class StatTrackerPhysicalProtect extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.physicalProtect"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java index c2df5f22..e3418195 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java @@ -71,4 +71,10 @@ public class StatTrackerPoison extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.poisonResist"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java index 20ea9180..328ad5f2 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java @@ -86,4 +86,10 @@ public class StatTrackerSelfSacrifice extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.selfSacrifice"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java index be801474..3c0c5b75 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java @@ -85,4 +85,10 @@ public class StatTrackerSolarPowered extends StatTracker return upgradeList; } + + @Override + public boolean providesUpgrade(String key) + { + return key.equals(Constants.Mod.MODID + ".upgrade.solarPowered"); + } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModItems.java b/src/main/java/WayofTime/bloodmagic/registry/ModItems.java index bfdd3a2b..02267006 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModItems.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModItems.java @@ -1,7 +1,5 @@ package WayofTime.bloodmagic.registry; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.util.helper.InventoryRenderHelperV2; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.EnumHelper; @@ -11,6 +9,7 @@ import WayofTime.bloodmagic.ConfigHandler; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.orb.BloodOrb; import WayofTime.bloodmagic.api.registry.OrbRegistry; +import WayofTime.bloodmagic.api.ritual.EnumRuneType; import WayofTime.bloodmagic.item.ItemActivationCrystal; import WayofTime.bloodmagic.item.ItemAltarMaker; import WayofTime.bloodmagic.item.ItemArcaneAshes; @@ -30,6 +29,7 @@ import WayofTime.bloodmagic.item.ItemSacrificialDagger; import WayofTime.bloodmagic.item.ItemSlate; import WayofTime.bloodmagic.item.ItemTelepositionFocus; import WayofTime.bloodmagic.item.ItemUpgradeTome; +import WayofTime.bloodmagic.item.ItemUpgradeTrainer; import WayofTime.bloodmagic.item.armour.ItemLivingArmour; import WayofTime.bloodmagic.item.armour.ItemSentientArmour; import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; @@ -60,6 +60,7 @@ import WayofTime.bloodmagic.item.soul.ItemSentientSword; import WayofTime.bloodmagic.item.soul.ItemSoulGem; import WayofTime.bloodmagic.item.soul.ItemSoulSnare; import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; +import WayofTime.bloodmagic.util.helper.InventoryRenderHelperV2; public class ModItems { @@ -125,6 +126,7 @@ public class ModItems public static Item altarMaker; public static Item upgradeTome; + public static Item upgradeTrainer; public static Item arcaneAshes; public static Item monsterSoul; @@ -213,6 +215,7 @@ public class ModItems altarMaker = registerItem(new ItemAltarMaker()); upgradeTome = registerItem(new ItemUpgradeTome()); + upgradeTrainer = registerItem(new ItemUpgradeTrainer()); arcaneAshes = registerItem(new ItemArcaneAshes()); monsterSoul = registerItem(new ItemMonsterSoul()); @@ -234,6 +237,7 @@ public class ModItems renderHelperV2.registerRender(altarMaker, "altarMaker"); renderHelperV2.registerRender(upgradeTome, "upgradeTome"); + renderHelperV2.registerRender(upgradeTrainer, "upgradeTrainer"); renderHelperV2.registerRender(arcaneAshes, "arcaneAshes"); renderHelperV2.registerRender(monsterSoul, "monsterSoul"); diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java index 0c9b5a11..28e7fe19 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.util.handler; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -44,6 +45,7 @@ import WayofTime.bloodmagic.api.event.ItemBindEvent; import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent; import WayofTime.bloodmagic.api.event.TeleposeEvent; import WayofTime.bloodmagic.api.iface.IBindable; +import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.soul.IDemonWill; import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; @@ -185,11 +187,54 @@ public class EventHandler { ItemStack output = new ItemStack(ModItems.upgradeTome); output = NBTHelper.checkNBT(output); - ((ItemUpgradeTome) output.getItem()).setKey(output, Constants.Mod.MODID + ".upgrade.revealing"); - ((ItemUpgradeTome) output.getItem()).setLevel(output, 1); + ItemUpgradeTome.setKey(output, Constants.Mod.MODID + ".upgrade.revealing"); + ItemUpgradeTome.setLevel(output, 1); event.cost = 1; event.output = output; + + return; + } + } + + if (event.left.getItem() == ModItems.upgradeTome && event.right.getItem() == ModItems.upgradeTome) + { + LivingArmourUpgrade leftUpgrade = ItemUpgradeTome.getUpgrade(event.left); + if (leftUpgrade != null && ItemUpgradeTome.getKey(event.left).equals(ItemUpgradeTome.getKey(event.right))) + { + int leftLevel = ItemUpgradeTome.getLevel(event.left); + int rightLevel = ItemUpgradeTome.getLevel(event.right); + + if (leftLevel == rightLevel && leftLevel < leftUpgrade.getMaxTier() - 1) + { + ItemStack outputStack = event.left.copy(); + ItemUpgradeTome.setLevel(outputStack, leftLevel + 1); + event.cost = leftLevel + 2; + + event.output = outputStack; + + return; + } + } + } + + if (event.left.getItem() instanceof IUpgradeTrainer && event.right.getItem() == ModItems.upgradeTome) + { + LivingArmourUpgrade rightUpgrade = ItemUpgradeTome.getUpgrade(event.right); + if (rightUpgrade != null) + { + String key = ItemUpgradeTome.getKey(event.right); + ItemStack outputStack = event.left.copy(); + List keyList = new ArrayList(); + keyList.add(key); + if (((IUpgradeTrainer) event.left.getItem()).setTrainedUpgrades(outputStack, keyList)) + { + event.cost = 1; + + event.output = outputStack; + + return; + } } } } diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTrainer.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTrainer.json new file mode 100644 index 00000000..37735a28 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTrainer.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "upgradetrainer": { + "textures": { + "layer0": "bloodmagic:items/UpgradeTrainer" + } + } + } + } +} diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 74bc7616..2d6229e0 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -121,6 +121,7 @@ item.BloodMagic.ritualDivinerdawn.name=Ritual Diviner [Dawn] item.BloodMagic.arcaneAshes.name=Arcane Ashes item.BloodMagic.upgradeTome.name=Living Armour Upgrade Tome +item.BloodMagic.upgradeTrainer.name=Living Armour Training Bracelet item.BloodMagic.sentientSword.name=Sentient Sword item.BloodMagic.soulGem.petty.name=Petty Tartaric Gem diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemUpgradeTrainer.json b/src/main/resources/assets/bloodmagic/models/item/ItemUpgradeTrainer.json new file mode 100644 index 00000000..71ff2c57 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/ItemUpgradeTrainer.json @@ -0,0 +1,7 @@ +{ + "parent":"bloodmagic:item/ItemModelBase", + "textures": { + "layer0":"bloodmagic:items/UpgradeTrainer" + } +} + diff --git a/src/main/resources/assets/bloodmagic/textures/items/UpgradeTrainer.png b/src/main/resources/assets/bloodmagic/textures/items/UpgradeTrainer.png new file mode 100644 index 0000000000000000000000000000000000000000..ab4bf9642f188266180ecbd4887dca22caad02fd GIT binary patch literal 544 zcmV+*0^j|KP)WFU8GbZ8()Nlj2>E@cM*00D$aL_t(I%Z-zfUf`610wkndizTX*Y3L%kNQ$I^ z$O5y4mm8Y9)7iP$j5NhcGvEF@^RJ;HCf;fN+=^1e|Hi~SjX`73BN2^3=YjPw^UeEF z$}2X=`HK?xZpVy5AoFgqlJb^P!I6l*1Rb!c1A2>gT9SYPQBwY1b)aL4(YKUrPY%K;8&hw5Ps%) z)f|H!tgZ37+hs3G$qITBAYZ-X49sviteWTN zbY~;w?vJh2onqo;Hm$r7l7PPFu@2bK-I}fIkVY%lA+B}8st7N_BMd7T44=7LZt43z iRdSDPvkbEATmJ(-j{ZfduXz6e0000