Merge pull request #709 from Arcaratus/1.9
Improved the API and internal workings
This commit is contained in:
commit
81e9452a21
28 changed files with 389 additions and 340 deletions
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.impl.ItemBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
|
@ -29,7 +28,7 @@ public class ItemBindableBase extends ItemBindable
|
|||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
if (!Strings.isNullOrEmpty(getOwnerUUID(stack)))
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentOwner", PlayerHelper.getUsernameFromStack(stack)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,16 +65,16 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab
|
|||
return super.onItemRightClick(stack, world, player, hand);
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
if (Strings.isNullOrEmpty(getOwnerUUID(stack)))
|
||||
return super.onItemRightClick(stack, world, player, hand);
|
||||
|
||||
if (world.isRemote)
|
||||
return super.onItemRightClick(stack, world, player, hand);
|
||||
|
||||
if (stack.getTagCompound().getString(Constants.NBT.OWNER_UUID).equals(PlayerHelper.getUsernameFromPlayer(player)))
|
||||
NetworkHelper.setMaxOrb(NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)), getOrbLevel(stack.getItemDamage()));
|
||||
if (getOwnerUUID(stack).equals(PlayerHelper.getUsernameFromPlayer(player)))
|
||||
NetworkHelper.setMaxOrb(NetworkHelper.getSoulNetwork(getOwnerUUID(stack)), getOrbLevel(stack.getItemDamage()));
|
||||
|
||||
NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)).addLifeEssence(200, getMaxEssence(stack.getItemDamage()));
|
||||
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).addLifeEssence(200, getMaxEssence(stack.getItemDamage()));
|
||||
NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 200);
|
||||
return super.onItemRightClick(stack, world, player, hand);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
|
|
|
@ -26,7 +26,6 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
|
@ -84,7 +83,7 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
boolean silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, stack) > 0;
|
||||
int fortuneLvl = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, stack);
|
||||
int range = (int) (charge / 6); //Charge is a max of 30 - want 5 to be the max
|
||||
int range = (charge / 6); //Charge is a max of 30 - want 5 to be the max
|
||||
|
||||
HashMultiset<ItemStackWrapper> drops = HashMultiset.create();
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
|
|
|
@ -97,7 +97,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
|
||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic." + (getActivated(stack) ? "activated" : "deactivated")));
|
||||
|
||||
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
if (!Strings.isNullOrEmpty(getOwnerUUID(stack)))
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentOwner", PlayerHelper.getUsernameFromStack(stack)));
|
||||
}
|
||||
|
||||
|
@ -113,20 +113,6 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
return stack.getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
|
@ -169,4 +155,24 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
{
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
}
|
||||
|
||||
// IActivatable
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
if (!Strings.isNullOrEmpty(getOwnerUUID(stack)))
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentOwner", PlayerHelper.getUsernameFromStack(stack)));
|
||||
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
|
@ -258,13 +258,18 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
if (stack != null)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -21,9 +17,8 @@ import WayofTime.bloodmagic.BloodMagic;
|
|||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.DamageSourceBloodMagic;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
||||
|
||||
public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
||||
{
|
||||
|
@ -57,11 +52,11 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
|||
if (BloodMagicAPI.getEntitySacrificeValues().containsKey(entityName))
|
||||
lifeEssence = BloodMagicAPI.getEntitySacrificeValues().get(entityName);
|
||||
|
||||
if (findAndFillAltar(attacker.worldObj, target, lifeEssence))
|
||||
if (PlayerSacrificeHelper.findAndFillAltar(attacker.worldObj, target, lifeEssence))
|
||||
{
|
||||
target.worldObj.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.block_fire_extinguish, SoundCategory.BLOCKS, 0.5F, 2.6F + (target.worldObj.rand.nextFloat() - target.worldObj.rand.nextFloat()) * 0.8F);
|
||||
target.setHealth(-1);
|
||||
target.onDeath(new DamageSourceBloodMagic());
|
||||
target.onDeath(BloodMagicAPI.getDamageSource());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -74,39 +69,4 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
|||
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean findAndFillAltar(World world, EntityLivingBase sacrifice, int amount)
|
||||
{
|
||||
IBloodAltar bloodAltar = findBloodAltar(world, sacrifice.getPosition());
|
||||
|
||||
if (bloodAltar != null)
|
||||
{
|
||||
bloodAltar.sacrificialDaggerCall(amount, true);
|
||||
bloodAltar.startCycle();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IBloodAltar findBloodAltar(World world, BlockPos blockPos)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
tileEntity = world.getTileEntity(blockPos.add(i, k, j));
|
||||
|
||||
if ((tileEntity instanceof IBloodAltar))
|
||||
return (IBloodAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,7 @@ import net.minecraft.item.EnumAction;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -31,7 +26,6 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
|
@ -154,7 +148,7 @@ public class ItemSacrificialDagger extends Item implements IVariantProvider
|
|||
return super.onItemRightClick(stack, world, player, hand);
|
||||
|
||||
// TODO - Check if SoulFray is active
|
||||
findAndFillAltar(world, player, lpAdded);
|
||||
PlayerSacrificeHelper.findAndFillAltar(world, player, lpAdded);
|
||||
|
||||
return super.onItemRightClick(stack, world, player, hand);
|
||||
}
|
||||
|
@ -168,42 +162,6 @@ public class ItemSacrificialDagger extends Item implements IVariantProvider
|
|||
return ret;
|
||||
}
|
||||
|
||||
protected void findAndFillAltar(World world, EntityPlayer player, int amount)
|
||||
{
|
||||
BlockPos pos = player.getPosition();
|
||||
IBloodAltar altarEntity = getAltar(world, pos);
|
||||
|
||||
if (altarEntity == null)
|
||||
return;
|
||||
|
||||
altarEntity.sacrificialDaggerCall(amount, false);
|
||||
altarEntity.startCycle();
|
||||
}
|
||||
|
||||
public IBloodAltar getAltar(World world, BlockPos pos)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
BlockPos newPos = pos.add(i, j, k);
|
||||
tileEntity = world.getTileEntity(newPos);
|
||||
|
||||
if (tileEntity instanceof IBloodAltar)
|
||||
{
|
||||
return (IBloodAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.api.util.helper.ItemHelper.LivingUpgrades;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
|
@ -14,13 +14,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
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;
|
||||
|
||||
|
@ -47,7 +45,8 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
{
|
||||
return super.onItemRightClick(stack, world, player, hand);
|
||||
}
|
||||
LivingArmourUpgrade upgrade = ItemUpgradeTome.getUpgrade(stack);
|
||||
|
||||
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
|
||||
if (upgrade == null)
|
||||
{
|
||||
return super.onItemRightClick(stack, world, player, hand);
|
||||
|
@ -83,8 +82,8 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
for (int i = 0; i < maxLevel; i++)
|
||||
{
|
||||
ItemStack stack = new ItemStack(this);
|
||||
setKey(stack, key);
|
||||
setLevel(stack, i);
|
||||
LivingUpgrades.setKey(stack, key);
|
||||
LivingUpgrades.setLevel(stack, i);
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
@ -98,52 +97,12 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade getUpgrade(ItemStack stack)
|
||||
{
|
||||
String key = getKey(stack);
|
||||
int level = getLevel(stack);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public static void setLevel(ItemStack stack, int level)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setInteger("level", level);
|
||||
}
|
||||
|
||||
public static 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 = ItemUpgradeTome.getUpgrade(stack);
|
||||
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
|
||||
if (upgrade != null)
|
||||
{
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));
|
||||
|
|
|
@ -5,14 +5,13 @@ 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.api.util.helper.ItemHelper.LivingUpgrades;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
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 org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
@ -43,41 +42,17 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
{
|
||||
String key = entry.getKey();
|
||||
ItemStack stack = new ItemStack(this);
|
||||
setKey(stack, key);
|
||||
LivingUpgrades.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<String> tooltip, boolean advanced)
|
||||
{
|
||||
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour"))));
|
||||
LivingArmourUpgrade upgrade = ItemUpgradeTrainer.getUpgrade(stack);
|
||||
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
|
||||
if (upgrade != null)
|
||||
{
|
||||
tooltip.add(TextHelper.localize(upgrade.getUnlocalizedName()));
|
||||
|
@ -88,7 +63,7 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
public List<String> getTrainedUpgrades(ItemStack stack)
|
||||
{
|
||||
List<String> keyList = new ArrayList<String>();
|
||||
String key = getKey(stack);
|
||||
String key = LivingUpgrades.getKey(stack);
|
||||
|
||||
if (!key.isEmpty())
|
||||
{
|
||||
|
@ -106,7 +81,7 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
return false;
|
||||
}
|
||||
|
||||
setKey(stack, keys.get(0));
|
||||
LivingUpgrades.setKey(stack, keys.get(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,11 @@ package WayofTime.bloodmagic.item.gear;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IItemLPContainer;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LPContainer;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
|
@ -23,7 +25,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, IVariantProvider
|
||||
public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider
|
||||
{
|
||||
public final int CAPACITY = 10000; // Max LP storage
|
||||
|
||||
|
@ -52,23 +54,10 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I
|
|||
{
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (!(tile instanceof TileAltar))
|
||||
if (!(tile instanceof IBloodAltar))
|
||||
return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND);
|
||||
|
||||
TileAltar altar = (TileAltar) tile;
|
||||
|
||||
if (!altar.isActive())
|
||||
{
|
||||
int amount = this.getStoredLP(stack);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
setStoredLP(stack, amount);
|
||||
world.notifyBlockUpdate(position.getBlockPos(), world.getBlockState(position.getBlockPos()), world.getBlockState(position.getBlockPos()), 3);
|
||||
}
|
||||
}
|
||||
LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, position.getBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,28 +87,26 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I
|
|||
return ret;
|
||||
}
|
||||
|
||||
public void addLP(ItemStack stack, int toAdd)
|
||||
// IFillable
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (toAdd < 0)
|
||||
toAdd = 0;
|
||||
|
||||
if (toAdd > CAPACITY)
|
||||
toAdd = CAPACITY;
|
||||
|
||||
setStoredLP(stack, Math.min(getStoredLP(stack) + toAdd, CAPACITY));
|
||||
}
|
||||
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
return this.CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLP(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP);
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,12 @@ package WayofTime.bloodmagic.item.gear;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IItemLPContainer;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LPContainer;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
|
@ -24,15 +26,23 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IVariantProvider
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider
|
||||
{
|
||||
/** How much LP per half heart */
|
||||
/**
|
||||
* How much LP per half heart
|
||||
*/
|
||||
public final int CONVERSION = 100;
|
||||
/** Max LP storage */
|
||||
/**
|
||||
* Max LP storage
|
||||
*/
|
||||
public final int CAPACITY = 10000;
|
||||
/** How often the pack syphons */
|
||||
/**
|
||||
* How often the pack syphons
|
||||
*/
|
||||
public final int INTERVAL = 20;
|
||||
/** How much health is required for the pack to syphon (0 - 1) */
|
||||
/**
|
||||
* How much health is required for the pack to syphon (0 - 1)
|
||||
*/
|
||||
public final float HEALTHREQ = 0.5f;
|
||||
|
||||
public ItemPackSelfSacrifice()
|
||||
|
@ -54,29 +64,17 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
if (position == null)
|
||||
{
|
||||
return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (position.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (!(tile instanceof TileAltar))
|
||||
if (!(tile instanceof IBloodAltar))
|
||||
return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND);
|
||||
|
||||
TileAltar altar = (TileAltar) tile;
|
||||
|
||||
if (!altar.isActive())
|
||||
{
|
||||
int amount = this.getStoredLP(stack);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
setStoredLP(stack, amount);
|
||||
world.notifyBlockUpdate(position.getBlockPos(), world.getBlockState(position.getBlockPos()), world.getBlockState(position.getBlockPos()), 3);
|
||||
}
|
||||
}
|
||||
LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, position.getBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +92,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0)
|
||||
{
|
||||
NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 1.0F);
|
||||
addLP(stack, CONVERSION);
|
||||
LPContainer.addLPToItem(stack, CONVERSION, CAPACITY);
|
||||
}
|
||||
|
||||
if (getStoredLP(stack) > CAPACITY)
|
||||
|
@ -117,28 +115,26 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
return ret;
|
||||
}
|
||||
|
||||
public void addLP(ItemStack stack, int toAdd)
|
||||
// IFillable
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (toAdd < 0)
|
||||
toAdd = 0;
|
||||
|
||||
if (toAdd > CAPACITY)
|
||||
toAdd = CAPACITY;
|
||||
|
||||
setStoredLP(stack, Math.min(getStoredLP(stack) + toAdd, CAPACITY));
|
||||
}
|
||||
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
return this.CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLP(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP);
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider
|
|||
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
if (!Strings.isNullOrEmpty(getOwnerName(stack)))
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentOwner", PlayerHelper.getUsernameFromStack(stack)));
|
||||
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
|
|
|
@ -8,19 +8,22 @@ import WayofTime.bloodmagic.api.Constants;
|
|||
import WayofTime.bloodmagic.api.impl.ItemSigilToggleable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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 org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IVariantProvider
|
||||
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider
|
||||
{
|
||||
protected final String tooltipBase;
|
||||
private final String name;
|
||||
|
@ -28,7 +31,6 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IVar
|
|||
public ItemSigilToggleableBase(String name, int lpUsed)
|
||||
{
|
||||
super(lpUsed);
|
||||
setToggleable();
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".sigil." + name);
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
|
@ -45,16 +47,31 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IVar
|
|||
super.addInformation(stack, player, tooltip, advanced);
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic." + (getActivated(stack) ? "activated" : "deactivated")));
|
||||
|
||||
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
if (!Strings.isNullOrEmpty(getOwnerName(stack)))
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentOwner", PlayerHelper.getUsernameFromStack(stack)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "active=false"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "active=true"));
|
||||
return new CustomMeshDefinitionActivatable("ItemSigil" + WordUtils.capitalize(name));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("active=false");
|
||||
ret.add("active=true");
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue