Search in sources :

Example 1 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class EntityMinorDemonGrunt method isSamePortal.

@Override
public boolean isSamePortal(IHoardDemon demon) {
    Int3 position = demon.getPortalLocation();
    TileEntity portal = worldObj.getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord);
    return portal instanceof TEDemonPortal ? portal == worldObj.getTileEntity(position.xCoord, position.yCoord, position.zCoord) : false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Int3(WayofTime.alchemicalWizardry.api.Int3) TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)

Example 2 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class RitualEffectDemonPortal method performEffect.

@Override
public void performEffect(IMasterRitualStone ritualStone) {
    String owner = ritualStone.getOwner();
    int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
    World world = ritualStone.getWorld();
    int x = ritualStone.getXCoord();
    int y = ritualStone.getYCoord();
    int z = ritualStone.getZCoord();
    if (currentEssence < this.getCostPerRefresh()) {
        SoulNetworkHandler.causeNauseaToPlayer(owner);
    } else {
        NBTTagCompound tag = ritualStone.getCustomRitualTag();
        boolean reagentsFulfilled = true;
        for (Reagent reagent : reagents) {
            int reagentAmount = tag.getInteger(ReagentRegistry.getKeyForReagent(reagent));
            if (reagentAmount < neededAmount) {
                reagentsFulfilled = false;
                // System.out.println("Reagents not fulfilled. Missing: " + ReagentRegistry.getKeyForReagent(reagent));
                int drainAmount = Math.min(drainRate, neededAmount - reagentAmount);
                if (drainAmount <= 0) {
                    continue;
                }
                if (this.canDrainReagent(ritualStone, reagent, drainAmount, true)) {
                    if (rand.nextInt(10) == 0) {
                        this.createRandomLightning(world, x, y, z);
                    }
                    reagentAmount += drainAmount;
                    tag.setInteger(ReagentRegistry.getKeyForReagent(reagent), reagentAmount);
                    break;
                }
            }
        }
        ritualStone.setCustomRitualTag(tag);
        if (reagentsFulfilled && checkCreatePortal(ritualStone)) {
            world.setBlock(x, y + 1, z, ModBlocks.blockDemonPortal);
            TEDemonPortal portal = (TEDemonPortal) world.getTileEntity(x, y + 1, z);
            portal.start();
            ritualStone.setActive(false);
        }
        SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
    }
}
Also used : TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) World(net.minecraft.world.World) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 3 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class EntityDemonAIHurtByTarget method startExecuting.

@Override
public void startExecuting() {
    Int3 portalPosition = ((IHoardDemon) this.taskOwner).getPortalLocation();
    if (portalPosition == null) {
        super.startExecuting();
        return;
    }
    TileEntity portal = this.taskOwner.worldObj.getTileEntity(portalPosition.xCoord, portalPosition.yCoord, portalPosition.zCoord);
    if ((this.taskOwner.getAITarget() instanceof IHoardDemon && portalPosition.equals(((IHoardDemon) this.taskOwner.getAITarget()).getPortalLocation()))) {
        return;
    }
    this.taskOwner.setAttackTarget(this.taskOwner.getAITarget());
    if (this.entityCallsForHelp && this.taskOwner instanceof IHoardDemon) {
        if (portal instanceof TEDemonPortal) {
            ((TEDemonPortal) portal).notifyDemons(taskOwner, this.taskOwner.getAITarget(), 25);
        }
    // double d0 = this.getTargetDistance();
    // List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getBoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));
    // Iterator iterator = list.iterator();
    // 
    // while (iterator.hasNext())
    // {
    // EntityCreature entitycreature = (EntityCreature)iterator.next();
    // 
    // if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))
    // {
    // entitycreature.setAttackTarget(this.taskOwner.getAITarget());
    // }
    // }
    }
    super.startExecuting();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Int3(WayofTime.alchemicalWizardry.api.Int3) TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal) IHoardDemon(WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon)

Example 4 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class EntityMinorDemonGrunt method onUpdate.

/**
 * Called to update the entity's position/logic.
 */
@Override
public void onUpdate() {
    if (!this.enthralled) {
        TileEntity tile = this.worldObj.getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord);
        if (tile instanceof TEDemonPortal) {
            ((TEDemonPortal) tile).enthrallDemon(this);
            this.enthralled = true;
        } else if (tile instanceof IMasterRitualStone) {
            IMasterRitualStone stone = (IMasterRitualStone) tile;
            LocalRitualStorage stor = stone.getLocalStorage();
            if (stor instanceof LocalStorageAlphaPact) {
                LocalStorageAlphaPact storage = (LocalStorageAlphaPact) stor;
                storage.thrallDemon(this);
            }
        }
    }
    super.onUpdate();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LocalRitualStorage(WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage) TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal) IMasterRitualStone(WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone) LocalStorageAlphaPact(WayofTime.alchemicalWizardry.common.rituals.LocalStorageAlphaPact)

Example 5 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class BlockDemonPortal method onBlockHarvested.

@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof TEDemonPortal) {
        ((TEDemonPortal) tile).notifyPortalOfBreak();
    }
    super.onBlockHarvested(world, x, y, z, meta, player);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)

Aggregations

TEDemonPortal (WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)7 TileEntity (net.minecraft.tileentity.TileEntity)5 Int3 (WayofTime.alchemicalWizardry.api.Int3)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)1 TeleposeEvent (WayofTime.alchemicalWizardry.api.event.TeleposeEvent)1 IMasterRitualStone (WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone)1 LocalRitualStorage (WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage)1 IHoardDemon (WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon)1 LocalStorageAlphaPact (WayofTime.alchemicalWizardry.common.rituals.LocalStorageAlphaPact)1 Block (net.minecraft.block.Block)1 BlockMobSpawner (net.minecraft.block.BlockMobSpawner)1 BlockPortal (net.minecraft.block.BlockPortal)1 World (net.minecraft.world.World)1