Search in sources :

Example 1 with IDemon

use of WayofTime.alchemicalWizardry.common.IDemon 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 IDemon

use of WayofTime.alchemicalWizardry.common.IDemon in project BloodMagic by WayofTime.

the class DaggerOfSacrifice method hitEntity.

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) {
    if (par3EntityLivingBase == null || par2EntityLivingBase == null || par3EntityLivingBase.worldObj.isRemote || (par3EntityLivingBase instanceof EntityPlayer && SpellHelper.isFakePlayer(par3EntityLivingBase.worldObj, (EntityPlayer) par3EntityLivingBase))) {
        return false;
    }
    if (par2EntityLivingBase instanceof IHoardDemon) {
        return false;
    }
    if (par2EntityLivingBase.isChild() || par2EntityLivingBase instanceof EntityPlayer || par2EntityLivingBase instanceof IBossDisplayData) {
        return false;
    }
    World world = par2EntityLivingBase.worldObj;
    if (par2EntityLivingBase.isDead || par2EntityLivingBase.getHealth() < 0.5f) {
        return false;
    }
    if (par2EntityLivingBase instanceof IDemon) {
        ((IDemon) par2EntityLivingBase).setDropCrystal(false);
        this.findAndNotifyAltarOfDemon(world, par2EntityLivingBase);
    }
    int lifeEssence = 500;
    if (par2EntityLivingBase instanceof EntityVillager)
        lifeEssence = 2000;
    else if (par2EntityLivingBase instanceof EntitySlime)
        lifeEssence = 150;
    else if (par2EntityLivingBase instanceof EntityEnderman)
        lifeEssence = 200;
    else if (par2EntityLivingBase instanceof EntityAnimal)
        lifeEssence = 250;
    if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, lifeEssence)) {
        double posX = par2EntityLivingBase.posX;
        double posY = par2EntityLivingBase.posY;
        double posZ = par2EntityLivingBase.posZ;
        for (int i = 0; i < 8; i++) {
            SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
        }
        par2EntityLivingBase.setHealth(-1);
        par2EntityLivingBase.onDeath(DamageSource.generic);
    }
    return false;
}
Also used : EntityVillager(net.minecraft.entity.passive.EntityVillager) EntitySlime(net.minecraft.entity.monster.EntitySlime) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) IHoardDemon(WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon) IDemon(WayofTime.alchemicalWizardry.common.IDemon) EntityEnderman(net.minecraft.entity.monster.EntityEnderman)

Aggregations

IDemon (WayofTime.alchemicalWizardry.common.IDemon)2 SummoningRegistryComponent (WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistryComponent)1 IHoardDemon (WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon)1 EnergyBattery (WayofTime.alchemicalWizardry.common.items.EnergyBattery)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 World (net.minecraft.world.World)1