Search in sources :

Example 1 with EnergyBattery

use of WayofTime.alchemicalWizardry.common.items.EnergyBattery in project BloodMagic by WayofTime.

the class TEPlinth method updateEntity.

// Logic for the actual block is under here
@Override
public void updateEntity() {
    super.updateEntity();
    if (worldObj.isRemote) {
        return;
    }
    if (!isActive()) {
        if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery) {
            int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel();
            if (SummoningRegistry.isRecipeValid(bloodOrbLevel, composeItemsForRingAndParadigm(1, true), composeItemsForRingAndParadigm(2, true), composeItemsForRingAndParadigm(3, true))) {
                SummoningRegistryComponent src = SummoningRegistry.getRegistryComponent(bloodOrbLevel, composeItemsForRingAndParadigm(1, true), composeItemsForRingAndParadigm(2, true), composeItemsForRingAndParadigm(3, true));
                isActive = true;
                paradigm = true;
                progress = 0;
                ring1Inv = src.getRingRecipeForRing(1);
                ring2Inv = src.getRingRecipeForRing(2);
                ring3Inv = src.getRingRecipeForRing(3);
            } else if (SummoningRegistry.isRecipeValid(bloodOrbLevel, composeItemsForRingAndParadigm(1, false), composeItemsForRingAndParadigm(2, false), composeItemsForRingAndParadigm(3, false))) {
                SummoningRegistryComponent src = SummoningRegistry.getRegistryComponent(bloodOrbLevel, composeItemsForRingAndParadigm(1, false), composeItemsForRingAndParadigm(2, false), composeItemsForRingAndParadigm(3, false));
                isActive = true;
                paradigm = false;
                progress = 0;
                ring1Inv = src.getRingRecipeForRing(1);
                ring2Inv = src.getRingRecipeForRing(2);
                ring3Inv = src.getRingRecipeForRing(3);
            } else {
                isActive = false;
                progress = 0;
            }
        }
    } else {
        if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery) {
            if (progress % progressInterval == 0) {
                int ring = (progress / progressInterval) / 6 + 1;
                int slot = (progress / progressInterval) % 6;
                ItemStack itemStack;
                switch(ring) {
                    case 1:
                        itemStack = this.ring1Inv[slot];
                        break;
                    case 2:
                        itemStack = this.ring2Inv[slot];
                        break;
                    case 3:
                        itemStack = this.ring3Inv[slot];
                        break;
                    default:
                        itemStack = null;
                }
                if (itemStack == null) {
                    progress += progressInterval;
                } else {
                    if (this.deleteItemStackInRing(ring, itemStack)) {
                        progress++;
                    }
                }
            } else {
                progress++;
            }
            if (progress >= progressInterval * 18) {
                int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel();
                EntityLivingBase entity = SummoningRegistry.getEntity(worldObj, bloodOrbLevel, ring1Inv, ring2Inv, ring3Inv);
                if (entity != null) {
                    entity.setPosition(xCoord + 0.5, yCoord + 1, zCoord + 0.5);
                    worldObj.spawnEntityInWorld(entity);
                    if (entity instanceof IDemon) {
                        ((IDemon) entity).setSummonedConditions();
                    }
                    worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 3, false);
                    // deleteItemsInRing(1);
                    isActive = false;
                    progress = 0;
                    if (worldObj != null) {
                        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                    }
                }
            }
        }
    }
}
Also used : EnergyBattery(WayofTime.alchemicalWizardry.common.items.EnergyBattery) SummoningRegistryComponent(WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistryComponent) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack) IDemon(WayofTime.alchemicalWizardry.common.IDemon)

Example 2 with EnergyBattery

use of WayofTime.alchemicalWizardry.common.items.EnergyBattery in project BloodMagic by WayofTime.

the class BlockAltar method getComparatorInputOverride.

@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta) {
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof TEAltar) {
        ItemStack stack = ((TEAltar) tile).getStackInSlot(0);
        if (stack != null && stack.getItem() instanceof EnergyBattery) {
            EnergyBattery bloodOrb = (EnergyBattery) stack.getItem();
            int maxEssence = bloodOrb.getMaxEssence();
            int currentEssence = bloodOrb.getCurrentEssence(stack);
            int level = currentEssence * 15 / maxEssence;
            return Math.min(15, level) % 16;
        }
    }
    return 0;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnergyBattery(WayofTime.alchemicalWizardry.common.items.EnergyBattery) TEAltar(WayofTime.alchemicalWizardry.common.tileEntity.TEAltar) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EnergyBattery

use of WayofTime.alchemicalWizardry.common.items.EnergyBattery in project BloodMagic by WayofTime.

the class SigilLava method syphonBatteries.

protected boolean syphonBatteries(ItemStack ist, EntityPlayer player, int damageToBeDone) {
    if (!player.capabilities.isCreativeMode) {
        boolean usedBattery = false;
        IInventory inventory = player.inventory;
        for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
            ItemStack stack = inventory.getStackInSlot(slot);
            if (stack == null) {
                continue;
            }
            if (stack.getItem() instanceof EnergyBattery && !usedBattery) {
                if (stack.getItemDamage() <= stack.getMaxDamage() - damageToBeDone) {
                    stack.setItemDamage(stack.getItemDamage() + damageToBeDone);
                    usedBattery = true;
                }
            }
        }
        return usedBattery;
    } else {
        return true;
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) EnergyBattery(WayofTime.alchemicalWizardry.common.items.EnergyBattery) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnergyBattery (WayofTime.alchemicalWizardry.common.items.EnergyBattery)3 ItemStack (net.minecraft.item.ItemStack)3 SummoningRegistryComponent (WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistryComponent)1 IDemon (WayofTime.alchemicalWizardry.common.IDemon)1 TEAltar (WayofTime.alchemicalWizardry.common.tileEntity.TEAltar)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IInventory (net.minecraft.inventory.IInventory)1 TileEntity (net.minecraft.tileentity.TileEntity)1