Added a few of the necessary items to start the soul system.
This commit is contained in:
parent
f379351e88
commit
45870812d4
|
@ -74,6 +74,10 @@ public class Constants
|
|||
public static final String HELD_DOWN = "heldDown";
|
||||
|
||||
public static final String UPGRADE_POISON_TIMER = "poisonTimer";
|
||||
|
||||
public static final String SOULS = "souls";
|
||||
public static final String SOUL_SWORD_DAMAGE = "soulSwordDamage";
|
||||
public static final String SOUL_SWORD_ACTIVE_DRAIN = "soulSwordActiveDrain";
|
||||
}
|
||||
|
||||
public static class Mod
|
||||
|
|
30
src/main/java/WayofTime/bloodmagic/api/iface/ISoul.java
Normal file
30
src/main/java/WayofTime/bloodmagic/api/iface/ISoul.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISoul
|
||||
{
|
||||
public double getSouls(ItemStack soulStack);
|
||||
|
||||
public void setSouls(ItemStack soulStack, double souls);
|
||||
|
||||
/**
|
||||
* Drains the souls from the soulStack. If all of the souls are drained, the
|
||||
* soulStack will be removed.
|
||||
*
|
||||
* @param soulStack
|
||||
* @param drainAmount
|
||||
* @return The number of souls drained.
|
||||
*/
|
||||
public double drainSouls(ItemStack soulStack, double drainAmount);
|
||||
|
||||
/**
|
||||
* Creates a new ItemStack with the specified number of souls.
|
||||
* Implementation should respect the number requested.
|
||||
*
|
||||
* @param meta
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
public ItemStack createSoul(int meta, double number);
|
||||
}
|
28
src/main/java/WayofTime/bloodmagic/api/iface/ISoulGem.java
Normal file
28
src/main/java/WayofTime/bloodmagic/api/iface/ISoulGem.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISoulGem
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param soulGemStack
|
||||
* - The ItemStack for this soul gem.
|
||||
* @param soulStack
|
||||
* - The ItemStack for the soul. Item should extend ISoul
|
||||
* @return - The remainder soulStack after the souls have been absorbed into
|
||||
* the gem. Return null if there are no souls left in the stack.
|
||||
*/
|
||||
public ItemStack fillSoulGem(ItemStack soulGemStack, ItemStack soulStack);
|
||||
|
||||
/**
|
||||
* Returns the number of souls that are left in the soul gem. Returns a
|
||||
* double because souls can be fractionally drained.
|
||||
*
|
||||
* @param soulGemStack
|
||||
* @return
|
||||
*/
|
||||
public double getSouls(ItemStack soulGemStack);
|
||||
|
||||
public int getMaxSouls(ItemStack soulGemStack);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISoulWeapon
|
||||
{
|
||||
public List<ItemStack> getRandomSoulDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting);
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
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.iface.ISoul;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemMonsterSoul extends Item implements ISoul
|
||||
{
|
||||
public static String[] names = { "base" };
|
||||
|
||||
public ItemMonsterSoul()
|
||||
{
|
||||
super();
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".monsterSoul.");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
setHasSubtypes(true);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@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.souls", getSouls(stack)));
|
||||
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSouls(ItemStack soulStack)
|
||||
{
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
|
||||
NBTTagCompound tag = soulStack.getTagCompound();
|
||||
|
||||
return tag.getDouble(Constants.NBT.SOULS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSouls(ItemStack soulStack, double souls)
|
||||
{
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
|
||||
NBTTagCompound tag = soulStack.getTagCompound();
|
||||
|
||||
tag.setDouble(Constants.NBT.SOULS, souls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainSouls(ItemStack soulStack, double drainAmount)
|
||||
{
|
||||
double souls = getSouls(soulStack);
|
||||
|
||||
double soulsDrained = Math.min(drainAmount, souls);
|
||||
setSouls(soulStack, souls - soulsDrained);
|
||||
|
||||
return soulsDrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createSoul(int meta, double number)
|
||||
{
|
||||
ItemStack soulStack = new ItemStack(this, 1, meta);
|
||||
setSouls(soulStack, number);
|
||||
return soulStack;
|
||||
}
|
||||
}
|
138
src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSword.java
Normal file
138
src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSword.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
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.iface.ISoul;
|
||||
import WayofTime.bloodmagic.api.iface.ISoulWeapon;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public class ItemSoulSword extends ItemSword implements ISoulWeapon
|
||||
{
|
||||
public ItemSoulSword()
|
||||
{
|
||||
super(ModItems.soulToolMaterial);
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".soul.sword");
|
||||
setHasSubtypes(true);
|
||||
setNoRepair();
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (player.isSneaking()) //TODO: change its state depending on soul consumption
|
||||
setActivated(stack, !getActivated(stack));
|
||||
|
||||
if (getActivated(stack))
|
||||
{
|
||||
setDamageOfActivatedSword(stack, 7);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
return EnumAction.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.soul.sword.desc"));
|
||||
|
||||
if (getActivated(stack))
|
||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.activated"));
|
||||
else
|
||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.deactivated"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
if (getActivated(stack))
|
||||
{
|
||||
return super.onLeftClickEntity(stack, player, entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage() > 0;
|
||||
}
|
||||
|
||||
private ItemStack setActivated(ItemStack stack, boolean activated)
|
||||
{
|
||||
stack.setItemDamage(activated ? 1 : 0);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getRandomSoulDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting)
|
||||
{
|
||||
List<ItemStack> soulList = new ArrayList<ItemStack>();
|
||||
|
||||
if (getActivated(stack))
|
||||
{
|
||||
ISoul soul = ((ISoul) ModItems.monsterSoul);
|
||||
ItemStack soulStack = soul.createSoul(0, looting * 0.5 + 1);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
|
||||
return soulList;
|
||||
}
|
||||
|
||||
public double getDamageOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack)
|
||||
{
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", getActivated(stack) ? getDamageOfActivatedSword(stack) : 2, 0));
|
||||
return multimap;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package WayofTime.bloodmagic.registry;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
@ -47,6 +46,8 @@ import WayofTime.bloodmagic.item.sigil.ItemSigilSuppression;
|
|||
import WayofTime.bloodmagic.item.sigil.ItemSigilVoid;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilWater;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilWhirlwind;
|
||||
import WayofTime.bloodmagic.item.soul.ItemMonsterSoul;
|
||||
import WayofTime.bloodmagic.item.soul.ItemSoulSword;
|
||||
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
|
||||
|
||||
public class ModItems
|
||||
|
@ -109,8 +110,12 @@ public class ModItems
|
|||
public static Item altarMaker;
|
||||
|
||||
public static Item arcaneAshes;
|
||||
public static Item monsterSoul;
|
||||
|
||||
public static Item.ToolMaterial boundToolMaterial = EnumHelper.addToolMaterial("BoundToolMaterial", 4, 0, 12, 8, 50);
|
||||
public static Item soulSword;
|
||||
|
||||
public static Item.ToolMaterial boundToolMaterial = EnumHelper.addToolMaterial("BoundToolMaterial", 4, 0, 10, 8, 50);
|
||||
public static Item.ToolMaterial soulToolMaterial = EnumHelper.addToolMaterial("SoulToolMaterial", 4, 0, 7, 8, 50);
|
||||
|
||||
public static void init()
|
||||
{
|
||||
|
@ -180,6 +185,9 @@ public class ModItems
|
|||
altarMaker = registerItem(new ItemAltarMaker());
|
||||
|
||||
arcaneAshes = registerItem(new ItemArcaneAshes());
|
||||
monsterSoul = registerItem(new ItemMonsterSoul());
|
||||
|
||||
soulSword = registerItem(new ItemSoulSword());
|
||||
}
|
||||
|
||||
public static void initRenders()
|
||||
|
@ -278,6 +286,10 @@ public class ModItems
|
|||
renderHelper.itemRender(altarMaker);
|
||||
|
||||
renderHelper.itemRender(arcaneAshes);
|
||||
renderHelper.itemRender(monsterSoul, 0);
|
||||
|
||||
renderHelper.itemRender(soulSword, 0);
|
||||
renderHelper.itemRender(soulSword, 1);
|
||||
}
|
||||
|
||||
private static Item registerItem(Item item, String name)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.util.handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -7,6 +8,7 @@ import net.minecraft.enchantment.Enchantment;
|
|||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
|
@ -15,9 +17,11 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
@ -29,6 +33,7 @@ import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
||||
import WayofTime.bloodmagic.api.iface.ISoulWeapon;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.block.BlockAltar;
|
||||
|
@ -379,4 +384,36 @@ public class EventHandler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingDrops(LivingDropsEvent event)
|
||||
{
|
||||
EntityLivingBase attackedEntity = event.entityLiving;
|
||||
DamageSource source = event.source;
|
||||
Entity entity = source.getEntity();
|
||||
|
||||
if (entity != null && entity instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase attackingEntity = (EntityLivingBase) entity;
|
||||
ItemStack heldStack = attackingEntity.getHeldItem();
|
||||
if (heldStack != null && heldStack.getItem() instanceof ISoulWeapon)
|
||||
{
|
||||
List<ItemStack> droppedSouls = ((ISoulWeapon) heldStack.getItem()).getRandomSoulDrop(attackedEntity, attackingEntity, heldStack, event.lootingLevel);
|
||||
if (!droppedSouls.isEmpty())
|
||||
{
|
||||
for (ItemStack soulStack : droppedSouls)
|
||||
{
|
||||
event.drops.add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemPickup(EntityItemPickupEvent event)
|
||||
{
|
||||
//TODO:
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ item.BloodMagic.baseComponent.reagentSight.name=Sight Reagent
|
|||
item.BloodMagic.baseComponent.reagentBinding.name=Binding Reagent
|
||||
item.BloodMagic.baseComponent.reagentSuppression.name=Suppression Reagent
|
||||
|
||||
item.BloodMagic.monsterSoul.base.name=Monster Soul
|
||||
|
||||
item.BloodMagic.sigil.air.name=Air Sigil
|
||||
item.BloodMagic.sigil.bloodLight.name=Sigil of the Blood Lamp
|
||||
item.BloodMagic.sigil.compression.name=Sigil of Compression
|
||||
|
@ -107,6 +109,8 @@ item.BloodMagic.ritualDivinerdawn.name=Ritual Diviner [Dawn]
|
|||
|
||||
item.BloodMagic.arcaneAshes.name=Arcane Ashes
|
||||
|
||||
item.BloodMagic.soul.sword.name=Soul Sword
|
||||
|
||||
# Blocks
|
||||
tile.BloodMagic.fluid.lifeEssence.name=Life Essence
|
||||
|
||||
|
@ -229,6 +233,9 @@ tooltip.BloodMagic.livingArmour.upgrade.meleeDamage=Fierce Strike
|
|||
tooltip.BloodMagic.livingArmour.upgrade.arrowShot=Trick Shot
|
||||
tooltip.BloodMagic.livingArmour.upgrade.level=(Level %d)
|
||||
|
||||
tooltip.BloodMagic.souls=Soul Quality: %1$,.3f
|
||||
tooltip.BloodMagic.soul.sword.desc=Uses souls to unleash its full potential.
|
||||
|
||||
# Ritual
|
||||
ritual.BloodMagic.testRitual=Test Ritual
|
||||
ritual.BloodMagic.waterRitual=Ritual of the Full Spring
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent":"bloodmagic:item/ItemModelBase",
|
||||
"textures": {
|
||||
"layer0":"bloodmagic:items/BaseMonsterSoul"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"parent":"bloodmagic:item/ItemModelBase",
|
||||
"textures": {
|
||||
"layer0":"bloodmagic:items/SoulSword_deactivated"
|
||||
},
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [ 0, 90, -35 ],
|
||||
"translation": [ 0, 1.25, -3.5 ],
|
||||
"scale": [ 0.85, 0.85, 0.85 ]
|
||||
},
|
||||
"firstperson": {
|
||||
"rotation": [ 0, -135, 25 ],
|
||||
"translation": [ 0, 4, 2 ],
|
||||
"scale": [ 1.7, 1.7, 1.7 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"parent":"bloodmagic:item/ItemModelBase",
|
||||
"textures": {
|
||||
"layer0":"bloodmagic:items/SoulSword_activated"
|
||||
},
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [ 0, 90, -35 ],
|
||||
"translation": [ 0, 1.25, -3.5 ],
|
||||
"scale": [ 0.85, 0.85, 0.85 ]
|
||||
},
|
||||
"firstperson": {
|
||||
"rotation": [ 0, -135, 25 ],
|
||||
"translation": [ 0, 4, 2 ],
|
||||
"scale": [ 1.7, 1.7, 1.7 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 474 B |
Binary file not shown.
After Width: | Height: | Size: 634 B |
Binary file not shown.
After Width: | Height: | Size: 626 B |
Loading…
Reference in a new issue