Search in sources :

Example 1 with ArmourUpgrade

use of WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade in project BloodMagic by WayofTime.

the class ArmourForge method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) {
    if (world.isRemote) {
        return false;
    }
    int armourType = getArmourType(world, x, y, z);
    if (armourType == -1) {
        return false;
    }
    int direction = getDirectionForArmourType(world, x, y, z, armourType);
    if (!isParadigmValid(armourType, direction, world, x, y, z)) {
        return false;
    }
    List<ArmourComponent> list = null;
    ItemStack armourPiece = null;
    switch(armourType) {
        case 0:
            list = plateList;
            armourPiece = new ItemStack(ModItems.boundPlate, 1, 0);
            break;
        case 1:
            list = leggingsList;
            armourPiece = new ItemStack(ModItems.boundLeggings, 1, 0);
            break;
        case 2:
            list = helmetList;
            armourPiece = new ItemStack(ModItems.boundHelmet, 1, 0);
            break;
        case 3:
            list = bootsList;
            armourPiece = new ItemStack(ModItems.boundBoots, 1, 0);
            break;
    }
    if (list == null) {
        return false;
    }
    if (armourPiece == null) {
        return false;
    }
    if (armourPiece.getTagCompound() == null) {
        armourPiece.setTagCompound(new NBTTagCompound());
    }
    for (ArmourComponent ac : list) {
        int xOff = ac.getXOff();
        int zOff = ac.getZOff();
        TileEntity tileEntity;
        switch(direction) {
            case 1:
                tileEntity = world.getTileEntity(x + xOff, y, z - zOff);
                break;
            case 2:
                tileEntity = world.getTileEntity(x + zOff, y, z + xOff);
                break;
            case 3:
                tileEntity = world.getTileEntity(x - xOff, y, z + zOff);
                break;
            case 4:
                tileEntity = world.getTileEntity(x - zOff, y, z - xOff);
                break;
            case 5:
                tileEntity = world.getTileEntity(x + xOff, y + zOff, z);
                break;
            case 6:
                tileEntity = world.getTileEntity(x, y + zOff, z + xOff);
                break;
            default:
                tileEntity = null;
        }
        if (tileEntity instanceof TESocket) {
            ItemStack itemStack = ((TESocket) tileEntity).getStackInSlot(0);
            int xCoord = tileEntity.xCoord;
            int yCoord = tileEntity.yCoord;
            int zCoord = tileEntity.zCoord;
            ((TESocket) tileEntity).setInventorySlotContents(0, null);
            world.setBlockToAir(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
            for (int i = 0; i < 8; i++) {
                SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, world.provider.dimensionId, 1, xCoord, yCoord, zCoord);
            }
            if (itemStack != null) {
                Item item = itemStack.getItem();
                if (item instanceof ArmourUpgrade) {
                    ((BoundArmour) armourPiece.getItem()).hasAddedToInventory(armourPiece, itemStack.copy());
                    ((TESocket) tileEntity).setInventorySlotContents(0, null);
                }
            }
        }
    }
    if (armourPiece != null) {
        int xOff = (world.rand.nextInt(11) - 5);
        int zOff = (int) (Math.sqrt(25 - xOff * xOff) * (world.rand.nextInt(2) - 0.5) * 2);
        world.addWeatherEffect(new EntityLightningBolt(world, x + xOff, y + 5, z + zOff));
        world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, armourPiece));
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityItem(net.minecraft.entity.item.EntityItem) Item(net.minecraft.item.Item) BoundArmour(WayofTime.alchemicalWizardry.common.items.armour.BoundArmour) ArmourComponent(WayofTime.alchemicalWizardry.common.ArmourComponent) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TESocket(WayofTime.alchemicalWizardry.common.tileEntity.TESocket) ArmourUpgrade(WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with ArmourUpgrade

use of WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade in project BloodMagic by WayofTime.

the class BlockSocket method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) {
    TESocket tileEntity = (TESocket) world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
        return false;
    }
    ItemStack playerItem = player.getCurrentEquippedItem();
    if (tileEntity.getStackInSlot(0) == null && playerItem != null) {
        if (playerItem.getItem() instanceof ArmourUpgrade) {
            ItemStack newItem = playerItem.copy();
            newItem.stackSize = 1;
            --playerItem.stackSize;
            tileEntity.setInventorySlotContents(0, newItem);
            return true;
        } else {
            return false;
        }
    } else if (tileEntity.getStackInSlot(0) != null && playerItem == null) {
        player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
        tileEntity.setInventorySlotContents(0, null);
        tileEntity.setActive();
        return true;
    }
    world.markBlockForUpdate(x, y, z);
    return false;
}
Also used : TESocket(WayofTime.alchemicalWizardry.common.tileEntity.TESocket) ArmourUpgrade(WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ArmourUpgrade

use of WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade in project BloodMagic by WayofTime.

the class BoundArmour method canSeeLPBar.

@Override
public boolean canSeeLPBar(ItemStack itemStack) {
    ItemStack[] inv = getInternalInventory(itemStack);
    if (inv == null) {
        return false;
    }
    int blood = getMaxBloodShardLevel(itemStack);
    for (ItemStack item : inv) {
        if (item == null) {
            continue;
        }
        if (item.getItem() instanceof ArmourUpgrade && blood > 0) {
            if (item.getItem() instanceof SigilDivination) {
                return true;
            }
            if (((ArmourUpgrade) item.getItem()).isUpgrade()) {
                blood--;
            }
        }
    }
    return false;
}
Also used : ArmourUpgrade(WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade) SigilDivination(WayofTime.alchemicalWizardry.common.items.sigil.SigilDivination) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ArmourUpgrade

use of WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade in project BloodMagic by WayofTime.

the class BoundArmour method getRunicCharge.

@Override
@Optional.Method(modid = "Thaumcraft")
public int getRunicCharge(ItemStack itemstack) {
    ItemStack[] inv = this.getInternalInventory(itemstack);
    int shardLevel = this.getMaxBloodShardLevel(itemstack);
    int count = 0;
    int harden = 0;
    if (inv == null) {
        return 0;
    }
    for (ItemStack stack : inv) {
        if (count >= shardLevel) {
            break;
        }
        if (stack == null || !(stack.getItem() instanceof ArmourUpgrade)) {
            continue;
        }
        if (stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).armorType != this.armorType) {
            continue;
        }
        if (stack.hasTagCompound()) {
            NBTTagCompound tag = stack.getTagCompound();
            int enchLvl = tag.getByte("RS.HARDEN");
            if (stack.getItem() instanceof IRunicArmor) {
                enchLvl += ((IRunicArmor) stack.getItem()).getRunicCharge(stack);
            }
            if (enchLvl > 0) {
                harden += enchLvl;
                if (((ArmourUpgrade) stack.getItem()).isUpgrade()) {
                    count += 1;
                }
            }
        }
    }
    return harden;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ArmourUpgrade(WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade) ItemStack(net.minecraft.item.ItemStack) IRunicArmor(thaumcraft.api.IRunicArmor)

Example 5 with ArmourUpgrade

use of WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade in project BloodMagic by WayofTime.

the class BoundArmour method hasAddedToInventory.

public boolean hasAddedToInventory(ItemStack sigilItemStack, ItemStack addedItemStack) {
    ItemStack[] inv = getInternalInventory(sigilItemStack);
    if (inv == null) {
        return false;
    }
    if (addedItemStack == null) {
        return false;
    }
    int candidateSlot = -1;
    for (int i = invSize - 1; i >= 0; i--) {
        ItemStack nextItem = inv[i];
        if (nextItem == null) {
            candidateSlot = i;
            continue;
        }
    }
    if (candidateSlot == -1) {
        return false;
    }
    if (addedItemStack.getItem() instanceof ArmourUpgrade) {
        inv[candidateSlot] = addedItemStack;
        saveInternalInventory(sigilItemStack, inv);
        return true;
    }
    return false;
}
Also used : ArmourUpgrade(WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ArmourUpgrade (WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade)6 ItemStack (net.minecraft.item.ItemStack)6 TESocket (WayofTime.alchemicalWizardry.common.tileEntity.TESocket)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ArmourComponent (WayofTime.alchemicalWizardry.common.ArmourComponent)1 BoundArmour (WayofTime.alchemicalWizardry.common.items.armour.BoundArmour)1 SigilDivination (WayofTime.alchemicalWizardry.common.items.sigil.SigilDivination)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Item (net.minecraft.item.Item)1 ItemArmor (net.minecraft.item.ItemArmor)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IGoggles (thaumcraft.api.IGoggles)1 IRunicArmor (thaumcraft.api.IRunicArmor)1