Fixed Blood Light Sigil not using LP (#653)
Also a bandaid for accidental spamming of lights. 10 tick cooldown before being able to place another.
This commit is contained in:
parent
0f4e1ad4cb
commit
6736d2cf4b
|
@ -1,9 +1,11 @@
|
||||||
package WayofTime.bloodmagic.item.sigil;
|
package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
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.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
@ -18,38 +20,60 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
||||||
setRegistryName(Constants.BloodMagicItem.SIGIL_BLOOD_LIGHT.getRegName());
|
setRegistryName(Constants.BloodMagicItem.SIGIL_BLOOD_LIGHT.getRegName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||||
|
if (getCooldownRemainder(stack) > 0)
|
||||||
|
reduceCooldown(stack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||||
{
|
{
|
||||||
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||||
|
|
||||||
|
if (getCooldownRemainder(stack) > 0)
|
||||||
|
return stack;
|
||||||
|
|
||||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||||
{
|
{
|
||||||
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
|
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
|
||||||
|
|
||||||
if (world.isAirBlock(blockPos))
|
if (world.isAirBlock(blockPos))
|
||||||
|
{
|
||||||
world.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
|
world.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
|
||||||
|
if (!world.isRemote)
|
||||||
|
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLPUsed());
|
||||||
|
resetCooldown(stack);
|
||||||
|
player.swingItem();
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
world.spawnEntityInWorld(new EntityBloodLight(world, player));
|
if (!world.isRemote) {
|
||||||
|
world.spawnEntityInWorld(new EntityBloodLight(world, player));
|
||||||
|
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLPUsed());
|
||||||
|
}
|
||||||
|
resetCooldown(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||||
{
|
{
|
||||||
super.onItemUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
return oldStack.getItem() != newStack.getItem();
|
||||||
|
}
|
||||||
|
|
||||||
if (world.isRemote)
|
public int getCooldownRemainder(ItemStack stack) {
|
||||||
return false;
|
return NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.TICKS_REMAINING);
|
||||||
|
}
|
||||||
|
|
||||||
BlockPos newPos = blockPos.offset(side);
|
public void reduceCooldown(ItemStack stack) {
|
||||||
|
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (world.isAirBlock(newPos))
|
public void resetCooldown(ItemStack stack) {
|
||||||
world.setBlockState(newPos, ModBlocks.bloodLight.getDefaultState());
|
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, 10);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue