use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.
the class TEDemonPortal method createPortalBuilding.
/**
* The Stage is at what point the portal is in reacting to the creation of the Demon Portal.
* Stage == 0 means just the saving
* Stage == 1 means to telepose the portal
* Stage == 2 means the teleposition is complete and that the building may be constructed
*/
public void createPortalBuilding(int stage, String name, int tier) {
for (DemonBuilding build : TEDemonPortal.buildingList) {
if (build.buildingType != DemonBuilding.BUILDING_PORTAL || build.buildingTier != tier) {
continue;
}
if (build.getName().equals(this.nextDemonPortalName)) {
int x = 0;
int z = 0;
GridSpace home = this.getGridSpace(x, z);
int yLevel = home.getYLevel();
GridSpaceHolder grid = this.createGSH();
ForgeDirection chosenDirection = this.nextDemonPortalDirection;
Int3 portalSpace = build.getDoorSpace(chosenDirection);
int yOffset = portalSpace.yCoord;
switch(stage) {
case 0:
break;
case 1:
int yDestination = yLevel + yOffset;
if (yCoord != yDestination) {
BlockTeleposer.swapBlocks(this, worldObj, worldObj, xCoord, yCoord, zCoord, xCoord, yDestination, zCoord);
} else {
// Nuthin - just as a reminder that we can now increment properly
}
break;
case 2:
build.destroyAllInField(worldObj, xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection.getOpposite(), true);
build.setAllGridSpaces(x, z, yLevel, chosenDirection.getOpposite(), GridSpace.MAIN_PORTAL, grid);
this.loadGSH(grid);
break;
}
return;
}
}
}
use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.
the class TEDemonPortal method expandAreaInNegZ.
public void expandAreaInNegZ() {
GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 2];
if (printDebug)
AlchemicalWizardry.logger.info("x " + newGrid.length + "z " + newGrid[0].length);
for (int i = 0; i <= negXRadius + posXRadius; i++) {
newGrid[i][0] = new GridSpace();
}
for (int i = 0; i <= negXRadius + posXRadius; i++) {
for (int j = 0; j <= negZRadius + posZRadius; j++) {
newGrid[i][j + 1] = area[i][j];
}
}
area = newGrid;
negZRadius += 1;
}
use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.
the class TEDemonPortal method createGriddedRoad.
public // Total grid length
int createGriddedRoad(// Total grid length
int gridXi, // Total grid length
int yi, // Total grid length
int gridZi, // Total grid length
ForgeDirection dir, // Total grid length
int gridLength, // Total grid length
boolean convertStarter) {
if (gridLength == 0 || gridLength == 1) {
return 0;
}
int initGridX = gridXi;
int initGridZ = gridZi;
int initY = yi;
if (convertStarter) {
this.setGridSpace(initGridX, initGridZ, new GridSpace(GridSpace.CROSSROAD, initY));
DemonCrosspath crosspath = new DemonCrosspath(xCoord + initGridX * 5, initY, zCoord + initGridZ * 5);
crosspath.createCrosspath(worldObj);
}
for (int index = 0; index < gridLength - 1; index++) {
DemonVillagePath path = new DemonVillagePath(xCoord + initGridX * 5, initY, zCoord + initGridZ * 5, dir, 6);
Int3AndBool temp = path.constructFullPath(this, worldObj, this.getRoadStepClearance());
Int3 next = temp.coords;
if (next != null) {
initY = next.yCoord;
if (printDebug)
AlchemicalWizardry.logger.info("" + initY);
}
if (!temp.bool) {
return index;
}
initGridX += dir.offsetX;
initGridZ += dir.offsetZ;
if (!this.getGridSpace(initGridX, initGridZ).isRoadSegment()) {
this.setGridSpace(initGridX, initGridZ, new GridSpace(GridSpace.ROAD, initY));
}
}
return gridLength - 1;
}
use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.
the class TEDemonPortal method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("negXRadius", negXRadius);
par1NBTTagCompound.setInteger("negZRadius", negZRadius);
par1NBTTagCompound.setInteger("posXRadius", posXRadius);
par1NBTTagCompound.setInteger("posZRadius", posZRadius);
par1NBTTagCompound.setInteger("houseCooldown", houseCooldown);
par1NBTTagCompound.setInteger("roadCooldown", roadCooldown);
par1NBTTagCompound.setInteger("demonHoardCooldown", demonHoardCooldown);
NBTTagList gridList = new NBTTagList();
for (int i = 0; i <= negXRadius + posXRadius; i++) {
for (int j = 0; j <= negZRadius + posZRadius; j++) {
GridSpace space = area[i][j];
NBTTagCompound nextTag;
if (space == null) {
nextTag = new GridSpace().getTag();
} else {
nextTag = space.getTag();
}
gridList.appendTag(nextTag);
}
}
par1NBTTagCompound.setTag("Grid", gridList);
par1NBTTagCompound.setBoolean("init", this.isInitialized);
par1NBTTagCompound.setInteger("tier", this.tier);
par1NBTTagCompound.setInteger("demonHouseCooldown", this.demonHouseCooldown);
par1NBTTagCompound.setString("nextDemonPortalName", nextDemonPortalName);
par1NBTTagCompound.setInteger("buildingStage", buildingStage);
par1NBTTagCompound.setInteger("nextDemonPortalDirection", this.nextDemonPortalDirection.ordinal());
par1NBTTagCompound.setFloat("pointPool", pointPool);
par1NBTTagCompound.setInteger("lockdownTimer", this.lockdownTimer);
par1NBTTagCompound.setInteger("delayBeforeParty", delayBeforeParty);
par1NBTTagCompound.setString("demonType", this.type.toString());
}
use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.
the class TEDemonPortal method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readFromNBT(par1NBTTagCompound);
this.negXRadius = par1NBTTagCompound.getInteger("negXRadius");
this.negZRadius = par1NBTTagCompound.getInteger("negZRadius");
this.posXRadius = par1NBTTagCompound.getInteger("posXRadius");
this.posZRadius = par1NBTTagCompound.getInteger("posZRadius");
this.houseCooldown = par1NBTTagCompound.getInteger("houseCooldown");
this.roadCooldown = par1NBTTagCompound.getInteger("roadCooldown");
this.demonHoardCooldown = par1NBTTagCompound.getInteger("demonHoardCooldown");
area = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 1];
NBTTagList tagList = par1NBTTagCompound.getTagList("Grid", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++) {
int length = (negZRadius + posZRadius + 1);
int x = i / length;
int z = i % length;
NBTTagCompound tag = tagList.getCompoundTagAt(i);
GridSpace space = GridSpace.getGridFromTag(tag);
area[x][z] = space;
}
this.isInitialized = par1NBTTagCompound.getBoolean("init");
this.tier = par1NBTTagCompound.getInteger("tier");
this.demonHouseCooldown = par1NBTTagCompound.getInteger("demonHouseCooldown");
this.nextDemonPortalName = par1NBTTagCompound.getString("nextDemonPortalName");
this.buildingStage = par1NBTTagCompound.getInteger("buildingStage");
this.nextDemonPortalDirection = ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("nextDemonPortalDirection"));
this.pointPool = par1NBTTagCompound.getFloat("pointPool");
this.lockdownTimer = par1NBTTagCompound.getInteger("lockdownTimer");
this.delayBeforeParty = par1NBTTagCompound.getInteger("delayBeforeParty");
this.type = DemonType.valueOf(par1NBTTagCompound.getString("demonType"));
}
Aggregations