Search in sources :

Example 1 with IWizardryCapability

use of com.teamwizardry.wizardry.api.capability.IWizardryCapability in project Wizardry by TeamWizardry.

the class TileManaInteracter method drainMana.

public double drainMana(double mana) {
    if (!world.isBlockLoaded(pos))
        return -1;
    IWizardryCapability cap = getWizardryCap();
    if (cap == null)
        return -1;
    double amount = MathHelper.clamp(cap.getMana(), 0, mana);
    CapManager manager = new CapManager(cap);
    manager.removeMana(amount);
    return amount;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) IWizardryCapability(com.teamwizardry.wizardry.api.capability.IWizardryCapability)

Example 2 with IWizardryCapability

use of com.teamwizardry.wizardry.api.capability.IWizardryCapability in project Wizardry by TeamWizardry.

the class BloodRenderLayer method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull AbstractClientPlayer entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    IWizardryCapability cap = WizardryCapabilityProvider.getCap(entity);
    if (cap != null) {
        EnumBloodType type = cap.getBloodType();
        if (type != null && type != EnumBloodType.NONE) {
            render.bindTexture(EnumBloodType.getResourceLocation(type));
            ClientUtilMethods.glColor(type.color);
            setModelVisibilities(entity);
            GlStateManager.enableBlendProfile(Profile.PLAYER_SKIN);
            GlStateManager.disableLighting();
            ShaderHelper.INSTANCE.useShader(Shaders.rawColor);
            render.getMainModel().render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
            GlStateManager.enableLighting();
            ShaderHelper.INSTANCE.releaseShader();
            GlStateManager.disableBlendProfile(Profile.PLAYER_SKIN);
            GlStateManager.color(1.0F, 1.0F, 1.0F);
        }
    }
}
Also used : EnumBloodType(com.teamwizardry.wizardry.api.capability.EnumBloodType) IWizardryCapability(com.teamwizardry.wizardry.api.capability.IWizardryCapability)

Example 3 with IWizardryCapability

use of com.teamwizardry.wizardry.api.capability.IWizardryCapability in project Wizardry by TeamWizardry.

the class TilePearlHolder method update.

@Override
public void update() {
    super.update();
    if (containsNacrePearl()) {
        if (world.isRemote)
            return;
        updateCooldown(getItemStack());
        IWizardryCapability pearlCap = WizardryCapabilityProvider.getCap(getItemStack());
        if (pearlCap == null || pearlCap.getMana() > pearlCap.getMaxMana() || isPartOfStructure || structurePos != null)
            return;
        if (world.isBlockPowered(getPos()))
            return;
        if (isCoolingDown(getItemStack()))
            return;
        if (pearlCap.getMana() == 0)
            return;
        BlockPos closestMagnet = null;
        for (int i = -10; i < 10; i++) for (int j = -10; j < 10; j++) for (int k = -10; k < 10; k++) {
            BlockPos pos = new BlockPos(getPos().getX() + i, getPos().getY() + j, getPos().getZ() + k);
            if (world.getBlockState(pos).getBlock() != ModBlocks.MANA_MAGNET)
                continue;
            if (closestMagnet == null)
                closestMagnet = pos;
            else if (pos.distanceSq(getPos()) < getPos().distanceSq(closestMagnet))
                closestMagnet = pos;
        }
        if (closestMagnet == null)
            return;
        {
            Vec3d direction = new Vec3d(closestMagnet).subtract(new Vec3d(getPos())).normalize();
            SpellData spell = new SpellData(getWorld());
            spell.addData(LOOK, direction);
            spell.addData(ORIGIN, new Vec3d(getPos()).addVector(0.5, 1.5, 0.5));
            spell.addData(CAPABILITY, pearlCap);
            SpellUtils.runSpell(getItemStack(), spell);
            setCooldown(world, null, null, getItemStack(), spell);
        }
    }
}
Also used : SpellData(com.teamwizardry.wizardry.api.spell.SpellData) BlockPos(net.minecraft.util.math.BlockPos) IWizardryCapability(com.teamwizardry.wizardry.api.capability.IWizardryCapability) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with IWizardryCapability

use of com.teamwizardry.wizardry.api.capability.IWizardryCapability in project Wizardry by TeamWizardry.

the class PacketUpdateCaps method handle.

@Override
public void handle(@Nonnull MessageContext ctx) {
    EntityPlayer player = LibrarianLib.PROXY.getClientPlayer();
    IWizardryCapability cap = WizardryCapabilityProvider.getCap(player);
    if (cap != null) {
        cap.deserializeNBT(tags);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) IWizardryCapability(com.teamwizardry.wizardry.api.capability.IWizardryCapability)

Aggregations

IWizardryCapability (com.teamwizardry.wizardry.api.capability.IWizardryCapability)4 CapManager (com.teamwizardry.wizardry.api.capability.CapManager)1 EnumBloodType (com.teamwizardry.wizardry.api.capability.EnumBloodType)1 SpellData (com.teamwizardry.wizardry.api.spell.SpellData)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3d (net.minecraft.util.math.Vec3d)1