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;
}
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());
}
}
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();
}
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();
}
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);
}
Aggregations