use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEDemonPortal method createRandomDemonHoard.
public int createRandomDemonHoard(TEDemonPortal teDemonPortal, int tier, DemonType type, boolean spawnGuardian) {
int next = rand.nextInt(4);
ForgeDirection dir;
switch(next) {
case 0:
dir = ForgeDirection.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
break;
default:
dir = ForgeDirection.NORTH;
}
Int3 road = findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
if (road == null) {
return 0;
}
if (TEDemonPortal.printDebug)
System.out.println("Spawning Demons");
return DemonPacketRegistry.spawnDemons(teDemonPortal, worldObj, xCoord + road.xCoord * 5, road.yCoord + 1, zCoord + road.zCoord * 5, type, tier, spawnGuardian);
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEDemonPortal method createRandomRoad.
public // Return the number of road spaces
int createRandomRoad() {
int next = rand.nextInt(4);
ForgeDirection dir;
switch(next) {
case 0:
dir = ForgeDirection.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
break;
default:
dir = ForgeDirection.NORTH;
}
Int3 road = findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
int x = road.xCoord;
int yLevel = road.yCoord;
int z = road.zCoord;
if (printDebug)
AlchemicalWizardry.logger.info("X: " + x + " Z: " + z + " Direction: " + dir.toString());
List<ForgeDirection> directions = this.findValidExtentionDirection(x, z);
if (directions.size() <= 0) {
return 0;
}
int maxDistance = 5;
int distance = 0;
ForgeDirection dominantDirection = null;
for (ForgeDirection direction : directions) {
int amt = this.getLength(direction, maxDistance, x, z);
if (amt > distance) {
distance = amt;
dominantDirection = direction;
} else if (amt == distance && rand.nextBoolean()) {
dominantDirection = direction;
}
}
if (dominantDirection == null) {
return 0;
}
if (printDebug)
AlchemicalWizardry.logger.info("I got here!");
if (printDebug)
AlchemicalWizardry.logger.info("Distance: " + distance + " Direction: " + dominantDirection.toString() + " yLevel: " + yLevel);
this.createGriddedRoad(x, yLevel, z, dominantDirection, distance + 1, true);
return distance;
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class BlockSet method buildAtIndex.
public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, int index, boolean populateInventories, int tier) {
Block block = this.getBlock();
if (index >= positions.size() || block == null) {
return;
}
Int3 position = positions.get(index);
int xOff = position.xCoord;
int yOff = position.yCoord;
int zOff = position.zCoord;
int meta = this.getMetaForDirection(dir);
switch(dir) {
case NORTH:
break;
case SOUTH:
xOff *= -1;
zOff *= -1;
break;
case WEST:
int temp = zOff;
zOff = xOff * -1;
xOff = temp;
break;
case EAST:
int temp2 = zOff * -1;
zOff = xOff;
xOff = temp2;
break;
default:
}
world.setBlock(xCoord + xOff, yCoord + yOff, zCoord + zOff, block, meta, 3);
if (populateInventories) {
this.populateIfIInventory(world, xCoord + xOff, yCoord + yOff, zCoord + zOff, tier);
}
if (block instanceof IBlockPortalNode) {
TileEntity tile = world.getTileEntity(xCoord + xOff, yCoord + yOff, zCoord + zOff);
if (tile instanceof ITilePortalNode) {
((ITilePortalNode) tile).setPortalLocation(teDemonPortal);
}
}
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class DemonBuilding method getGridOffsetFromRoad.
public Int3 getGridOffsetFromRoad(ForgeDirection sideOfRoad, int yLevel) {
Int3 doorSpace = this.getDoorSpace(sideOfRoad);
int x = doorSpace.xCoord;
int z = doorSpace.zCoord;
switch(sideOfRoad) {
case SOUTH:
z++;
break;
case EAST:
x++;
break;
case WEST:
x--;
break;
default:
z--;
break;
}
return new Int3(x, yLevel, z);
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class DemonVillagePath method getFinalLocation.
public Int3 getFinalLocation(World world, int clearance) {
int xi = xPos;
int yi = yPos;
int zi = zPos;
for (int i = 0; i < length; i++) {
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
for (int yOffset = 0; yOffset <= clearance; yOffset++) {
int sign = 1;
Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
if ((this.forceReplaceBlock(block1)) || (!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block1)) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset))) {
yi += sign * yOffset;
break;
} else {
sign = -1;
Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
if ((this.forceReplaceBlock(block2)) || (!block2.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block2)) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset))) {
yi += sign * yOffset;
break;
}
}
}
}
return new Int3(xi, yi, zi);
}
Aggregations