Search in sources :

Example 1 with SoulNetwork

use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.

the class ItemBloodOrb method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    BloodOrb orb = getOrb(stack);
    if (orb == null)
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    if (world == null)
        return super.onItemRightClick(world, player, hand);
    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
    if (PlayerHelper.isFakePlayer(player))
        return super.onItemRightClick(world, player, hand);
    if (!stack.hasTagCompound())
        return super.onItemRightClick(world, player, hand);
    Binding binding = getBinding(stack);
    if (binding == null)
        return super.onItemRightClick(world, player, hand);
    if (world.isRemote)
        return super.onItemRightClick(world, player, hand);
    SoulNetwork ownerNetwork = NetworkHelper.getSoulNetwork(binding);
    if (binding.getOwnerId().equals(player.getGameProfile().getId()))
        ownerNetwork.setOrbTier(orb.getTier());
    // Add LP to owner's network
    ownerNetwork.add(200, orb.getCapacity());
    // Hurt whoever is using it
    ownerNetwork.hurtPlayer(player, 200);
    return super.onItemRightClick(world, player, hand);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) BloodOrb(WayofTime.bloodmagic.orb.BloodOrb) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) ItemStack(net.minecraft.item.ItemStack)

Example 2 with SoulNetwork

use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.

the class ItemSigilVoid method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (PlayerHelper.isFakePlayer(player))
        return EnumActionResult.FAIL;
    if (world.isRemote || player.isSneaking() || isUnusable(stack)) {
        return EnumActionResult.FAIL;
    }
    if (!world.canMineBlockBody(player, blockPos)) {
        return EnumActionResult.FAIL;
    }
    SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
    TileEntity tile = world.getTileEntity(blockPos);
    if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
        IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
        FluidStack amount = handler.drain(1000, false);
        if (amount != null && amount.amount > 0 && network.syphonAndDamage(player, getLpUsed())) {
            handler.drain(1000, true);
            return EnumActionResult.SUCCESS;
        }
        return EnumActionResult.FAIL;
    }
    BlockPos newPos = blockPos.offset(side);
    if (!player.canPlayerEdit(newPos, side, stack)) {
        return EnumActionResult.FAIL;
    }
    if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && network.syphonAndDamage(player, getLpUsed())) {
        world.setBlockToAir(newPos);
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.FAIL;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 3 with SoulNetwork

use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.

the class ItemSigilBloodLight method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() instanceof ISigil.Holding)
        stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
    if (PlayerHelper.isFakePlayer(player))
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    RayTraceResult mop = this.rayTrace(world, player, false);
    if (getCooldownRemainder(stack) > 0)
        return super.onItemRightClick(world, player, hand);
    if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
        if (world.isAirBlock(blockPos)) {
            world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
            if (!world.isRemote) {
                SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
                network.syphonAndDamage(player, getLpUsed());
            }
            resetCooldown(stack);
            player.swingArm(hand);
            return super.onItemRightClick(world, player, hand);
        }
    } else {
        if (!world.isRemote) {
            SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
            world.spawnEntity(new EntityBloodLight(world, player));
            network.syphonAndDamage(player, getLpUsed());
        }
        resetCooldown(stack);
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) EntityBloodLight(WayofTime.bloodmagic.entity.projectile.EntityBloodLight) ItemStack(net.minecraft.item.ItemStack)

Example 4 with SoulNetwork

use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.

the class TileAlchemyTable method getContainedLp.

public int getContainedLp() {
    ItemStack orbStack = getStackInSlot(orbSlot);
    if (!orbStack.isEmpty()) {
        if (orbStack.getItem() instanceof IBloodOrb) {
            NBTTagCompound itemTag = orbStack.getTagCompound();
            if (itemTag == null) {
                return 0;
            }
            String ownerUUID = itemTag.getString(Constants.NBT.OWNER_UUID);
            if (Strings.isNullOrEmpty(ownerUUID)) {
                return 0;
            }
            SoulNetwork network = NetworkHelper.getSoulNetwork(ownerUUID);
            return network.getCurrentEssence();
        }
    }
    return 0;
}
Also used : SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) ItemStack(net.minecraft.item.ItemStack)

Example 5 with SoulNetwork

use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.

the class ItemLivingArmour method damageArmor.

@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
    if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        int preDamage = stack.getItemDamage();
        if (source.isUnblockable()) {
            return;
        }
        if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) {
            // TODO: Syphon a load of LP.
            if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) entity;
                SoulNetwork network = NetworkHelper.getSoulNetwork(player);
                network.syphonAndDamage(player, damage * 100);
            }
            return;
        }
        stack.damageItem(damage, entity);
        int receivedDamage = stack.getItemDamage() - preDamage;
        if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            if (LivingArmour.hasFullSet(player)) {
                LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
                if (armour != null) {
                    StatTrackerRepairing.incrementCounter(armour, receivedDamage);
                }
            }
        }
    } else {
        stack.damageItem(damage, entity);
    }
    // TODO Armour shouldn't get damaged... for now
    return;
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)11 Binding (WayofTime.bloodmagic.core.data.Binding)6 ItemStack (net.minecraft.item.ItemStack)6 IBindable (WayofTime.bloodmagic.iface.IBindable)5 IBloodOrb (WayofTime.bloodmagic.orb.IBloodOrb)4 BloodOrb (WayofTime.bloodmagic.orb.BloodOrb)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 EntityBloodLight (WayofTime.bloodmagic.entity.projectile.EntityBloodLight)1 ItemBindEvent (WayofTime.bloodmagic.event.ItemBindEvent)1 RitualEvent (WayofTime.bloodmagic.event.RitualEvent)1 SoulNetworkEvent (WayofTime.bloodmagic.event.SoulNetworkEvent)1 ItemActivationCrystal (WayofTime.bloodmagic.item.ItemActivationCrystal)1 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)1 TileAltar (WayofTime.bloodmagic.tile.TileAltar)1 PlayerNotFoundException (net.minecraft.command.PlayerNotFoundException)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 TextComponentString (net.minecraft.util.text.TextComponentString)1