Sigils should draw LP from the bound network, not the user

This commit is contained in:
Nicholas Ignoffo 2016-12-19 17:32:03 -08:00
parent ae2ff03547
commit 082d2b8f4d
16 changed files with 14 additions and 24 deletions

View file

@ -64,7 +64,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
@Override @Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{ {
return (NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && onSigilUse(stack, player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; return (NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && onSigilUse(stack, player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
} }
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
@ -79,7 +79,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
{ {
if (entityIn.ticksExisted % 100 == 0) if (entityIn.ticksExisted % 100 == 0)
{ {
if (!NetworkHelper.getSoulNetwork((EntityPlayerMP) entityIn).syphonAndDamage((EntityPlayer) entityIn, getLpUsed())) if (!NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed()))
{ {
setActivatedState(stack, false); setActivatedState(stack, false);
} }

View file

@ -110,7 +110,9 @@ public class NetworkHelper
* - Amount of LP to syphon * - Amount of LP to syphon
* *
* @return - Whether the action should be performed. * @return - Whether the action should be performed.
* @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage(EntityPlayer, int)}
*/ */
@Deprecated
public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon)
{ {

View file

@ -86,7 +86,7 @@ public class SubCommandNetwork extends SubCommandBase
if (Utils.isInteger(args[2])) if (Utils.isInteger(args[2]))
{ {
int amount = Integer.parseInt(args[2]); int amount = Integer.parseInt(args[2]);
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, amount); NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, amount);
displaySuccessString(sender, "commands.network.syphon.success", amount, player.getDisplayName().getFormattedText()); displaySuccessString(sender, "commands.network.syphon.success", amount, player.getDisplayName().getFormattedText());
} else } else
{ {

View file

@ -53,7 +53,7 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
if (!world.isRemote) if (!world.isRemote)
{ {
if (!player.capabilities.isCreativeMode) if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())); this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()));
if (!unusable) if (!unusable)
player.fallDistance = 0; player.fallDistance = 0;

View file

@ -6,7 +6,6 @@ import java.util.List;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.impl.ItemSigil; import WayofTime.bloodmagic.api.impl.ItemSigil;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import lombok.Getter; import lombok.Getter;

View file

@ -49,7 +49,7 @@ public class ItemSigilBloodLight extends ItemSigilBase
{ {
world.setBlockState(blockPos, ModBlocks.BLOOD_LIGHT.getDefaultState()); world.setBlockState(blockPos, ModBlocks.BLOOD_LIGHT.getDefaultState());
if (!world.isRemote) if (!world.isRemote)
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLpUsed()); NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
resetCooldown(stack); resetCooldown(stack);
player.swingArm(hand); player.swingArm(hand);
return super.onItemRightClick(stack, world, player, hand); return super.onItemRightClick(stack, world, player, hand);
@ -59,7 +59,7 @@ public class ItemSigilBloodLight extends ItemSigilBase
if (!world.isRemote) if (!world.isRemote)
{ {
world.spawnEntityInWorld(new EntityBloodLight(world, player)); world.spawnEntityInWorld(new EntityBloodLight(world, player));
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLpUsed()); NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
} }
resetCooldown(stack); resetCooldown(stack);
} }

View file

@ -1,6 +1,5 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.compress.CompressionRegistry; import WayofTime.bloodmagic.api.compress.CompressionRegistry;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;

View file

@ -9,7 +9,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModPotions; import WayofTime.bloodmagic.registry.ModPotions;
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase public class ItemSigilEnderSeverance extends ItemSigilToggleableBase

View file

@ -6,8 +6,6 @@ import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;

View file

@ -1,6 +1,5 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.registry.ModPotions; import WayofTime.bloodmagic.registry.ModPotions;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View file

@ -18,7 +18,6 @@ import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import WayofTime.bloodmagic.api.Constants;
public class ItemSigilLava extends ItemSigilBase public class ItemSigilLava extends ItemSigilBase
{ {
@ -64,7 +63,7 @@ public class ItemSigilLava extends ItemSigilBase
return super.onItemRightClick(stack, world, player, hand); return super.onItemRightClick(stack, world, player, hand);
} }
if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1)) if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1))
{ {
return super.onItemRightClick(stack, world, player, hand); return super.onItemRightClick(stack, world, player, hand);
} }
@ -93,7 +92,7 @@ public class ItemSigilLava extends ItemSigilBase
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000); FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
int amount = ((IFluidHandler) tile).fill(side, fluid, false); int amount = ((IFluidHandler) tile).fill(side, fluid, false);
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
{ {
((IFluidHandler) tile).fill(side, fluid, true); ((IFluidHandler) tile).fill(side, fluid, true);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;

View file

@ -15,7 +15,6 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.IBloodAltar; import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.iface.IAltarReader; import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.NetworkHelper;

View file

@ -105,7 +105,7 @@ public class ItemSigilTransposition extends ItemSigilBase
stack.getTagCompound().setByte(Constants.NBT.CONTAINED_BLOCK_META, metadata); stack.getTagCompound().setByte(Constants.NBT.CONTAINED_BLOCK_META, metadata);
stack.getTagCompound().setTag(Constants.NBT.CONTAINED_TILE_ENTITY, tileNBTTag); stack.getTagCompound().setTag(Constants.NBT.CONTAINED_TILE_ENTITY, tileNBTTag);
NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, cost); NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, cost);
world.removeTileEntity(blockPos); world.removeTileEntity(blockPos);
world.setBlockToAir(blockPos); world.setBlockToAir(blockPos);

View file

@ -16,7 +16,6 @@ import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import WayofTime.bloodmagic.api.Constants;
public class ItemSigilVoid extends ItemSigilBase public class ItemSigilVoid extends ItemSigilBase
{ {
@ -99,7 +98,7 @@ public class ItemSigilVoid extends ItemSigilBase
{ {
FluidStack amount = ((IFluidHandler) tile).drain(side, 1000, false); FluidStack amount = ((IFluidHandler) tile).drain(side, 1000, false);
if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
{ {
((IFluidHandler) tile).drain(side, 1000, true); ((IFluidHandler) tile).drain(side, 1000, true);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
@ -115,7 +114,7 @@ public class ItemSigilVoid extends ItemSigilBase
return EnumActionResult.FAIL; return EnumActionResult.FAIL;
} }
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
{ {
world.setBlockToAir(newPos); world.setBlockToAir(newPos);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;

View file

@ -61,7 +61,7 @@ public class ItemSigilWater extends ItemSigilBase
if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack))
return super.onItemRightClick(stack, world, player, hand); return super.onItemRightClick(stack, world, player, hand);
if (this.canPlaceWater(world, blockpos1) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && this.tryPlaceWater(world, blockpos1)) if (this.canPlaceWater(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceWater(world, blockpos1))
return super.onItemRightClick(stack, world, player, hand); return super.onItemRightClick(stack, world, player, hand);
} }
} }

View file

@ -1,13 +1,10 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.registry.ModPotions; import WayofTime.bloodmagic.registry.ModPotions;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemSigilWhirlwind extends ItemSigilToggleableBase public class ItemSigilWhirlwind extends ItemSigilToggleableBase