Fixed the Soul Network and made sure the majority of the items worked on it.
This commit is contained in:
parent
241c0b8dda
commit
6fb409f20f
19 changed files with 99 additions and 80 deletions
|
@ -4,12 +4,15 @@ import WayofTime.bloodmagic.BloodMagic;
|
|||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.network.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -35,6 +38,15 @@ public class ItemBindable extends Item implements IBindable
|
|||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Syphons from the owner's network if possible - if not enough LP is found,
|
||||
* it will instead take the LP from the holder of the item.
|
||||
*
|
||||
* @param stack
|
||||
* @param player
|
||||
* @param lpUsed
|
||||
* @return
|
||||
*/
|
||||
public static boolean syphonNetwork(ItemStack stack, EntityPlayer player, int lpUsed)
|
||||
{
|
||||
if (player == null)
|
||||
|
@ -42,7 +54,14 @@ public class ItemBindable extends Item implements IBindable
|
|||
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
return NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player, player.worldObj), lpUsed);
|
||||
if (stack != null && stack.getItem() instanceof ItemBindable)
|
||||
{
|
||||
ItemBindable itemBindable = (ItemBindable) stack.getItem();
|
||||
String owner = itemBindable.getBindableOwner(stack);
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(owner);
|
||||
return NetworkHelper.syphonAndDamage(network, player, lpUsed);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
double posX = player.posX;
|
||||
|
@ -50,17 +69,26 @@ public class ItemBindable extends Item implements IBindable
|
|||
double posZ = player.posZ;
|
||||
|
||||
// SpellHelper.sendIndexedParticleToAllAround(player.worldObj, posX,posY, posZ, 20, player.worldObj.provider.getDimensionId(), 4, posX, posY, posZ);
|
||||
player.worldObj.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.8F);
|
||||
player.worldObj.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to be used for when you want to drain from a network
|
||||
* without an online player. This will not take health from the owner if it
|
||||
* fails to find sufficient LP.
|
||||
*
|
||||
* @param itemStack
|
||||
* @param lpUsed
|
||||
* @return
|
||||
*/
|
||||
public static boolean syphonNetwork(ItemStack itemStack, int lpUsed)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBindable)
|
||||
{
|
||||
ItemBindable itemBindable = (ItemBindable) itemStack.getItem();
|
||||
return !Strings.isNullOrEmpty(itemBindable.getBindableOwner(itemStack)) && syphonNetwork(itemStack, PlayerHelper.getPlayerFromUUID(itemBindable.getBindableOwner(itemStack)), lpUsed);
|
||||
return !Strings.isNullOrEmpty(itemBindable.getBindableOwner(itemStack)) && NetworkHelper.syphonFromContainer(itemStack, lpUsed);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -67,9 +67,9 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable
|
|||
return stack;
|
||||
|
||||
if (stack.getTagCompound().getString(Constants.NBT.OWNER_UUID).equals(PlayerHelper.getUsernameFromPlayer(player)))
|
||||
NetworkHelper.setMaxOrb(NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID), world), getOrbLevel(stack.getItemDamage()));
|
||||
NetworkHelper.setMaxOrb(NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)), getOrbLevel(stack.getItemDamage()));
|
||||
|
||||
NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID), world).addLifeEssence(200, getMaxEssence(stack.getItemDamage()));
|
||||
NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)).addLifeEssence(200, getMaxEssence(stack.getItemDamage()));
|
||||
hurtPlayer(player, 200);
|
||||
return stack;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemLavaCrystal extends ItemBindable implements IFuelHandler
|
||||
{
|
||||
|
@ -15,7 +13,7 @@ public class ItemLavaCrystal extends ItemBindable implements IFuelHandler
|
|||
{
|
||||
super();
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".lavaCrystal");
|
||||
setLPUsed(1);
|
||||
setLPUsed(25);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,20 +44,16 @@ public class ItemLavaCrystal extends ItemBindable implements IFuelHandler
|
|||
|
||||
if (fuelItem instanceof ItemLavaCrystal)
|
||||
{
|
||||
if (syphonNetwork(fuel, getLPUsed()))
|
||||
if (syphonNetwork(fuel, getLPUsed())) //TODO: change to canSyphonNetwork
|
||||
{
|
||||
return 1;
|
||||
return 200;
|
||||
} else
|
||||
{
|
||||
NBTTagCompound tag = fuel.getTagCompound();
|
||||
|
||||
if (tag == null || MinecraftServer.getServer() == null || MinecraftServer.getServer().getConfigurationManager() == null)
|
||||
return 0;
|
||||
|
||||
if (Strings.isNullOrEmpty(((ItemLavaCrystal) fuelItem).getBindableOwner(fuel)))
|
||||
return 0;
|
||||
else
|
||||
hurtPlayer(PlayerHelper.getPlayerFromUUID(getBindableOwner(fuel)), getLPUsed());
|
||||
EntityPlayer player = PlayerHelper.getPlayerFromUUID(getBindableOwner(fuel));
|
||||
if (player != null)
|
||||
{
|
||||
//TODO: Add nausea to the player.
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
|
||||
if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0)
|
||||
{
|
||||
NetworkHelper.getSoulNetwork(player, world).hurtPlayer(1.0F);
|
||||
NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 1.0F);
|
||||
addLP(stack, CONVERSION);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
|||
if (!world.isRemote)
|
||||
{
|
||||
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack), world).getCurrentEssence();
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack)).getCurrentEssence();
|
||||
|
||||
if (position == null)
|
||||
{
|
||||
|
|
|
@ -62,9 +62,6 @@ public class ItemSigilLava extends ItemSigilBase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.setUnusable(stack, !syphonNetwork(stack, player, getLPUsed()));
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
|
|||
if (!world.isRemote)
|
||||
{
|
||||
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack), world).getCurrentEssence();
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack)).getCurrentEssence();
|
||||
|
||||
if (position == null)
|
||||
{
|
||||
|
|
|
@ -62,9 +62,6 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.setUnusable(stack, !syphonNetwork(stack, player, getLPUsed()));
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue