2015-12-28 00:38:12 +00:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
2016-01-19 06:34:12 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2015-12-28 00:38:12 +00:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
|
|
|
|
import WayofTime.bloodmagic.item.ItemBindable;
|
|
|
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-01-31 19:31:16 +00:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2015-12-28 00:38:12 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class ItemSigilBloodLight extends ItemSigilBase
|
|
|
|
{
|
|
|
|
public ItemSigilBloodLight()
|
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
super("bloodLight", 10);
|
2016-01-19 06:34:12 +00:00
|
|
|
setRegistryName(Constants.BloodMagicItem.SIGIL_BLOOD_LIGHT.getRegName());
|
2015-12-28 00:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 20:34:40 +00:00
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
|
|
|
{
|
2015-12-30 22:24:40 +00:00
|
|
|
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonNetwork(stack, player, getLPUsed() * 5) && !world.isRemote)
|
2016-01-31 19:31:16 +00:00
|
|
|
{
|
|
|
|
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
|
|
|
|
|
|
|
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
|
|
|
{
|
|
|
|
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
|
|
|
|
|
|
|
|
if (world.isAirBlock(blockPos))
|
|
|
|
{
|
|
|
|
world.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
world.spawnEntityInWorld(new EntityBloodLight(world, player));
|
|
|
|
}
|
|
|
|
}
|
2015-12-28 00:38:12 +00:00
|
|
|
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-10 01:30:10 +00:00
|
|
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2016-01-10 01:30:10 +00:00
|
|
|
super.onItemUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
|
|
|
|
2015-12-31 18:50:38 +00:00
|
|
|
if (world.isRemote)
|
|
|
|
return false;
|
2015-12-28 00:38:12 +00:00
|
|
|
|
2015-12-30 22:24:40 +00:00
|
|
|
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonNetwork(stack, player, getLPUsed()))
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
BlockPos newPos = blockPos.offset(side);
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (world.isAirBlock(newPos))
|
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
world.setBlockState(newPos, ModBlocks.bloodLight.getDefaultState());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|