Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item.sigil;

import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISentientSwordEffectProvider;
import WayofTime.bloodmagic.iface.ISigil;
Expand Down Expand Up @@ -48,9 +49,10 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
}

if (!world.isRemote) {
if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess());

if (!player.capabilities.isCreativeMode) {
Binding binding = getBinding(stack);
this.setUnusable(stack, binding == null || !NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess());
}
if (!unusable)
player.fallDistance = 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item.sigil;

import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
Expand Down Expand Up @@ -49,11 +50,13 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player

if (world.isAirBlock(blockPos))
{
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
if (!world.isRemote)
{
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
Binding binding = getBinding(stack);
if(binding != null && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
{
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
}
}
resetCooldown(stack);
player.swingArm(hand);
Expand All @@ -63,9 +66,11 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
{
if (!world.isRemote)
{
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
world.spawnEntity(new EntityBloodLight(world, player));
network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
Binding binding = getBinding(stack);
if(binding != null && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
{
world.spawnEntity(new EntityBloodLight(world, player));
}
}
resetCooldown(stack);
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;

import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
Expand Down Expand Up @@ -39,19 +40,20 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
}

BlockPos blockPos = rayTrace.getBlockPos();
Binding binding = getBinding(stack);

if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, rayTrace.sideHit, stack)) {
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, rayTrace.sideHit, stack) && binding != null) {
//Case for if block at blockPos is a fluid handler like a tank
//Try to put fluid into tank
IFluidHandler destination = getFluidHandler(world, blockPos, null);
if (destination != null && tryInsertSigilFluid(destination, false) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (destination != null && tryInsertSigilFluid(destination, false) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
boolean result = tryInsertSigilFluid(destination, true);
if (result)
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
//Do the same as above, but use sidedness to interact with the fluid handler.
IFluidHandler destinationSide = getFluidHandler(world, blockPos, rayTrace.sideHit);
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
boolean result = tryInsertSigilFluid(destinationSide, true);
if (result)
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
Expand All @@ -60,7 +62,7 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
//Place fluid in world
if (destination == null && destinationSide == null) {
BlockPos targetPos = blockPos.offset(rayTrace.sideHit);
if (tryPlaceSigilFluid(player, world, targetPos) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (tryPlaceSigilFluid(player, world, targetPos) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world,
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) {
if (entityIn.ticksExisted % 100 == 0) {
if (!NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage((EntityPlayer) entityIn, SoulTicket.item(stack, worldIn, entityIn, getLpUsed())).isSuccess()) {
Binding binding = getBinding(stack);
if (binding == null || !NetworkHelper.getSoulNetwork(binding).syphonAndDamage((EntityPlayer) entityIn, SoulTicket.item(stack, worldIn, entityIn, getLpUsed())).isSuccess()) {
setActivatedState(stack, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item.sigil;

import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
Expand Down Expand Up @@ -87,11 +88,13 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blo
}
}

stack.getTagCompound().setTag("stored", stored);
NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, cost));
world.removeTileEntity(blockPos);
world.setBlockToAir(blockPos);
return EnumActionResult.SUCCESS;
Binding binding = getBinding(stack);
if(binding != null && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, cost)).isSuccess()) {
stack.getTagCompound().setTag("stored", stored);
world.removeTileEntity(blockPos);
world.setBlockToAir(blockPos);
return EnumActionResult.SUCCESS;
}
}
} else if (stack.hasTagCompound() && stack.getTagCompound().hasKey("stored")) {
IBlockState worldState = world.getBlockState(blockPos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;

import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
Expand Down Expand Up @@ -35,18 +36,19 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
}

BlockPos blockPos = rayTrace.getBlockPos();
Binding binding = getBinding(stack);

if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, rayTrace.sideHit, stack)) {
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, rayTrace.sideHit, stack) && binding != null) {
//Void is simpler than the other fluid sigils, because getFluidHandler grabs fluid blocks just fine
//So extract from fluid tanks with a null side; or drain fluid blocks.
IFluidHandler destination = getFluidHandler(world, blockPos, null);
if (destination != null && tryRemoveFluid(destination, 1000, false) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (destination != null && tryRemoveFluid(destination, 1000, false) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (tryRemoveFluid(destination, 1000, true))
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
//Do the same as above, but use sidedness to interact with the fluid handler.
IFluidHandler destinationSide = getFluidHandler(world, blockPos, rayTrace.sideHit);
if (destinationSide != null && tryRemoveFluid(destinationSide, 1000, false) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (destinationSide != null && tryRemoveFluid(destinationSide, 1000, false) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (tryRemoveFluid(destinationSide, 1000, true))
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;

import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
Expand Down Expand Up @@ -39,26 +40,27 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
}

BlockPos blockPos = rayTrace.getBlockPos();
Binding binding = getBinding(stack);

if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, rayTrace.sideHit, stack)) {
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, rayTrace.sideHit, stack) && binding != null) {
//Case for if block at blockPos is a fluid handler like a tank
//Try to put fluid into tank
IFluidHandler destination = getFluidHandler(world, blockPos, null);
if (destination != null && tryInsertSigilFluid(destination, false) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (destination != null && tryInsertSigilFluid(destination, false) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
boolean result = tryInsertSigilFluid(destination, true);
if (result)
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
//Do the same as above, but use sidedness to interact with the fluid handler.
IFluidHandler destinationSide = getFluidHandler(world, blockPos, rayTrace.sideHit);
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
boolean result = tryInsertSigilFluid(destinationSide, true);
if (result)
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}

//Special vanilla cauldron handling, yay.
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, 3));
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
Expand All @@ -67,7 +69,7 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
//Place fluid in world
if (destination == null && destinationSide == null) {
BlockPos targetPos = blockPos.offset(rayTrace.sideHit);
if (tryPlaceSigilFluid(player, world, targetPos) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
if (tryPlaceSigilFluid(player, world, targetPos) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) {
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
Expand Down