Added a lot of soul stuff.
This commit is contained in:
parent
45870812d4
commit
72ed003da1
13 changed files with 278 additions and 9 deletions
|
@ -9,6 +9,12 @@ Version 2.0.0-4
|
||||||
- Added Rituals:
|
- Added Rituals:
|
||||||
- Animal Growth ritual
|
- Animal Growth ritual
|
||||||
|
|
||||||
|
- Added parts for the new Soul System
|
||||||
|
- Added the Monster Soul
|
||||||
|
- Added the Soul Sword, which will be powered by consuming souls
|
||||||
|
- Added a Lesser Soul Gem in order to hold onto more souls
|
||||||
|
- SSSSSSSSoooooooouuuuuuulllllllllsssssss
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Version 2.0.0-3
|
Version 2.0.0-3
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package WayofTime.bloodmagic.api.iface;
|
package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package WayofTime.bloodmagic.api.iface;
|
package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
@ -25,4 +25,6 @@ public interface ISoulGem
|
||||||
public double getSouls(ItemStack soulGemStack);
|
public double getSouls(ItemStack soulGemStack);
|
||||||
|
|
||||||
public int getMaxSouls(ItemStack soulGemStack);
|
public int getMaxSouls(ItemStack soulGemStack);
|
||||||
|
|
||||||
|
public double drainSouls(ItemStack stack, double drainAmount);
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package WayofTime.bloodmagic.api.iface;
|
package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides several helper methods in order to handle soul
|
||||||
|
* consumption and use for a player. This refers to the Soul System, meaning
|
||||||
|
* Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found
|
||||||
|
* in WayofTime.bloodmagic.api.network
|
||||||
|
*
|
||||||
|
* @author WayofTime
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PlayerSoulHandler
|
||||||
|
{
|
||||||
|
public static double getTotalSouls(EntityPlayer player)
|
||||||
|
{
|
||||||
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
|
double souls = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < inventory.length; i++)
|
||||||
|
{
|
||||||
|
ItemStack stack = inventory[i];
|
||||||
|
if (stack != null)
|
||||||
|
{
|
||||||
|
if (stack.getItem() instanceof ISoul)
|
||||||
|
{
|
||||||
|
souls += ((ISoul) stack.getItem()).getSouls(stack);
|
||||||
|
} else if (stack.getItem() instanceof ISoulGem)
|
||||||
|
{
|
||||||
|
souls += ((ISoulGem) stack.getItem()).getSouls(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return souls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param amount
|
||||||
|
* @return - amount consumed
|
||||||
|
*/
|
||||||
|
public static double consumeSouls(EntityPlayer player, double amount)
|
||||||
|
{
|
||||||
|
double consumed = 0;
|
||||||
|
|
||||||
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
|
for (int i = 0; i < inventory.length; i++)
|
||||||
|
{
|
||||||
|
if (consumed >= amount)
|
||||||
|
{
|
||||||
|
return consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack stack = inventory[i];
|
||||||
|
if (stack != null)
|
||||||
|
{
|
||||||
|
if (stack.getItem() instanceof ISoul)
|
||||||
|
{
|
||||||
|
consumed += ((ISoul) stack.getItem()).drainSouls(stack, amount - consumed);
|
||||||
|
if (((ISoul) stack.getItem()).getSouls(stack) <= 0)
|
||||||
|
{
|
||||||
|
inventory[i] = null;
|
||||||
|
}
|
||||||
|
} else if (stack.getItem() instanceof ISoulGem)
|
||||||
|
{
|
||||||
|
consumed += ((ISoulGem) stack.getItem()).drainSouls(stack, amount - consumed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an ISoul contained in an ItemStack to one of the Soul Gems in the
|
||||||
|
* player's inventory.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param soulStack
|
||||||
|
* - ItemStack that contains an ISoul to be added
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ItemStack addSouls(EntityPlayer player, ItemStack soulStack)
|
||||||
|
{
|
||||||
|
if (soulStack == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
|
for (int i = 0; i < inventory.length; i++)
|
||||||
|
{
|
||||||
|
ItemStack stack = inventory[i];
|
||||||
|
if (stack != null)
|
||||||
|
{
|
||||||
|
if (stack.getItem() instanceof ISoulGem)
|
||||||
|
{
|
||||||
|
ItemStack newStack = ((ISoulGem) stack.getItem()).fillSoulGem(stack, soulStack);
|
||||||
|
if (newStack == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return soulStack;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.iface.ISoul;
|
import WayofTime.bloodmagic.api.soul.ISoul;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||||
|
|
||||||
|
|
116
src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java
Normal file
116
src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
package WayofTime.bloodmagic.item.soul;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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.soul.ISoul;
|
||||||
|
import WayofTime.bloodmagic.api.soul.ISoulGem;
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||||
|
|
||||||
|
public class ItemSoulGem extends Item implements ISoulGem
|
||||||
|
{
|
||||||
|
public static String[] names = { "lesser" };
|
||||||
|
|
||||||
|
public ItemSoulGem()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
setUnlocalizedName(Constants.Mod.MODID + ".soulGem.");
|
||||||
|
setHasSubtypes(true);
|
||||||
|
setMaxStackSize(1);
|
||||||
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack stack)
|
||||||
|
{
|
||||||
|
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void getSubItems(Item id, CreativeTabs creativeTab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < names.length; i++)
|
||||||
|
list.add(new ItemStack(id, 1, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||||
|
{
|
||||||
|
tooltip.add(TextHelper.localize("tooltip.BloodMagic.soulGem." + names[stack.getItemDamage()]));
|
||||||
|
tooltip.add(TextHelper.localize("tooltip.BloodMagic.souls", getSouls(stack)));
|
||||||
|
|
||||||
|
super.addInformation(stack, player, tooltip, advanced);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack fillSoulGem(ItemStack soulGemStack, ItemStack soulStack)
|
||||||
|
{
|
||||||
|
if (soulStack != null && soulStack.getItem() instanceof ISoul)
|
||||||
|
{
|
||||||
|
ISoul soul = (ISoul) soulStack.getItem();
|
||||||
|
double soulsLeft = getSouls(soulGemStack);
|
||||||
|
|
||||||
|
if (soulsLeft < getMaxSouls(soulGemStack))
|
||||||
|
{
|
||||||
|
double newSoulsLeft = Math.min(soulsLeft + soul.getSouls(soulStack), getMaxSouls(soulGemStack));
|
||||||
|
soul.drainSouls(soulStack, newSoulsLeft - soulsLeft);
|
||||||
|
|
||||||
|
setSouls(soulGemStack, newSoulsLeft);
|
||||||
|
if (soul.getSouls(soulStack) <= 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return soulStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getSouls(ItemStack soulGemStack)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(soulGemStack);
|
||||||
|
|
||||||
|
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||||
|
|
||||||
|
return tag.getDouble(Constants.NBT.SOULS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSouls(ItemStack soulGemStack, double souls)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(soulGemStack);
|
||||||
|
|
||||||
|
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||||
|
|
||||||
|
tag.setDouble(Constants.NBT.SOULS, souls);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double drainSouls(ItemStack soulGemStack, double drainAmount)
|
||||||
|
{
|
||||||
|
double souls = getSouls(soulGemStack);
|
||||||
|
|
||||||
|
double soulsDrained = Math.min(drainAmount, souls);
|
||||||
|
setSouls(soulGemStack, souls - soulsDrained);
|
||||||
|
|
||||||
|
return soulsDrained;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxSouls(ItemStack soulGemStack)
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,8 +17,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.iface.ISoul;
|
import WayofTime.bloodmagic.api.soul.ISoul;
|
||||||
import WayofTime.bloodmagic.api.iface.ISoulWeapon;
|
import WayofTime.bloodmagic.api.soul.ISoulWeapon;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
import WayofTime.bloodmagic.registry.ModItems;
|
import WayofTime.bloodmagic.registry.ModItems;
|
||||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import WayofTime.bloodmagic.item.sigil.ItemSigilVoid;
|
||||||
import WayofTime.bloodmagic.item.sigil.ItemSigilWater;
|
import WayofTime.bloodmagic.item.sigil.ItemSigilWater;
|
||||||
import WayofTime.bloodmagic.item.sigil.ItemSigilWhirlwind;
|
import WayofTime.bloodmagic.item.sigil.ItemSigilWhirlwind;
|
||||||
import WayofTime.bloodmagic.item.soul.ItemMonsterSoul;
|
import WayofTime.bloodmagic.item.soul.ItemMonsterSoul;
|
||||||
|
import WayofTime.bloodmagic.item.soul.ItemSoulGem;
|
||||||
import WayofTime.bloodmagic.item.soul.ItemSoulSword;
|
import WayofTime.bloodmagic.item.soul.ItemSoulSword;
|
||||||
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
|
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
|
||||||
|
|
||||||
|
@ -111,6 +112,7 @@ public class ModItems
|
||||||
|
|
||||||
public static Item arcaneAshes;
|
public static Item arcaneAshes;
|
||||||
public static Item monsterSoul;
|
public static Item monsterSoul;
|
||||||
|
public static Item soulGem;
|
||||||
|
|
||||||
public static Item soulSword;
|
public static Item soulSword;
|
||||||
|
|
||||||
|
@ -186,6 +188,7 @@ public class ModItems
|
||||||
|
|
||||||
arcaneAshes = registerItem(new ItemArcaneAshes());
|
arcaneAshes = registerItem(new ItemArcaneAshes());
|
||||||
monsterSoul = registerItem(new ItemMonsterSoul());
|
monsterSoul = registerItem(new ItemMonsterSoul());
|
||||||
|
soulGem = registerItem(new ItemSoulGem());
|
||||||
|
|
||||||
soulSword = registerItem(new ItemSoulSword());
|
soulSword = registerItem(new ItemSoulSword());
|
||||||
}
|
}
|
||||||
|
@ -287,6 +290,7 @@ public class ModItems
|
||||||
|
|
||||||
renderHelper.itemRender(arcaneAshes);
|
renderHelper.itemRender(arcaneAshes);
|
||||||
renderHelper.itemRender(monsterSoul, 0);
|
renderHelper.itemRender(monsterSoul, 0);
|
||||||
|
renderHelper.itemRender(soulGem, 0);
|
||||||
|
|
||||||
renderHelper.itemRender(soulSword, 0);
|
renderHelper.itemRender(soulSword, 0);
|
||||||
renderHelper.itemRender(soulSword, 1);
|
renderHelper.itemRender(soulSword, 1);
|
||||||
|
|
|
@ -28,13 +28,16 @@ import net.minecraftforge.event.world.BlockEvent;
|
||||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||||
import WayofTime.bloodmagic.ConfigHandler;
|
import WayofTime.bloodmagic.ConfigHandler;
|
||||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||||
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
||||||
import WayofTime.bloodmagic.api.iface.ISoulWeapon;
|
|
||||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||||
|
import WayofTime.bloodmagic.api.soul.ISoul;
|
||||||
|
import WayofTime.bloodmagic.api.soul.ISoulWeapon;
|
||||||
|
import WayofTime.bloodmagic.api.soul.PlayerSoulHandler;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import WayofTime.bloodmagic.block.BlockAltar;
|
import WayofTime.bloodmagic.block.BlockAltar;
|
||||||
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
||||||
|
@ -413,7 +416,18 @@ public class EventHandler
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onItemPickup(EntityItemPickupEvent event)
|
public void onItemPickup(EntityItemPickupEvent event)
|
||||||
{
|
{
|
||||||
//TODO:
|
ItemStack stack = event.item.getEntityItem();
|
||||||
|
if (stack != null && stack.getItem() instanceof ISoul)
|
||||||
|
{
|
||||||
EntityPlayer player = event.entityPlayer;
|
EntityPlayer player = event.entityPlayer;
|
||||||
|
|
||||||
|
ItemStack remainder = PlayerSoulHandler.addSouls(player, stack);
|
||||||
|
|
||||||
|
if (remainder == null)
|
||||||
|
{
|
||||||
|
stack.stackSize = 0;
|
||||||
|
event.setResult(Result.ALLOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@ item.BloodMagic.ritualDivinerdawn.name=Ritual Diviner [Dawn]
|
||||||
item.BloodMagic.arcaneAshes.name=Arcane Ashes
|
item.BloodMagic.arcaneAshes.name=Arcane Ashes
|
||||||
|
|
||||||
item.BloodMagic.soul.sword.name=Soul Sword
|
item.BloodMagic.soul.sword.name=Soul Sword
|
||||||
|
item.BloodMagic.soulGem.lesser.name=Lesser Soul Gem
|
||||||
|
|
||||||
# Blocks
|
# Blocks
|
||||||
tile.BloodMagic.fluid.lifeEssence.name=Life Essence
|
tile.BloodMagic.fluid.lifeEssence.name=Life Essence
|
||||||
|
@ -235,6 +236,7 @@ tooltip.BloodMagic.livingArmour.upgrade.level=(Level %d)
|
||||||
|
|
||||||
tooltip.BloodMagic.souls=Soul Quality: %1$,.3f
|
tooltip.BloodMagic.souls=Soul Quality: %1$,.3f
|
||||||
tooltip.BloodMagic.soul.sword.desc=Uses souls to unleash its full potential.
|
tooltip.BloodMagic.soul.sword.desc=Uses souls to unleash its full potential.
|
||||||
|
tooltip.BloodMagic.soulGem.lesser=A gem used to contain many souls
|
||||||
|
|
||||||
# Ritual
|
# Ritual
|
||||||
ritual.BloodMagic.testRitual=Test Ritual
|
ritual.BloodMagic.testRitual=Test Ritual
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"parent":"bloodmagic:item/ItemModelBase",
|
||||||
|
"textures": {
|
||||||
|
"layer0":"bloodmagic:items/SoulGemLesser"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 221 B |
Loading…
Add table
Add a link
Reference in a new issue