Search in sources :

Example 11 with GridSpace

use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.

the class TEDemonPortal method expandAreaInNegX.

public void expandAreaInNegX() {
    GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 2][negZRadius + posZRadius + 1];
    for (int i = 0; i <= negZRadius + posZRadius; i++) {
        newGrid[0][i] = new GridSpace();
    }
    for (int i = 0; i <= negXRadius + posXRadius; i++) {
        for (int j = 0; j <= negZRadius + posZRadius; j++) {
            newGrid[i + 1][j] = area[i][j];
        }
    }
    area = newGrid;
    negXRadius += 1;
}
Also used : GridSpace(WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)

Example 12 with GridSpace

use of WayofTime.alchemicalWizardry.common.demonVillage.GridSpace in project BloodMagic by WayofTime.

the class TEDemonPortal method findEmptySpaceNearRoad.

public Int3 findEmptySpaceNearRoad(ForgeDirection dir, int amount, int closeness) {
    int index = 0;
    if (dir == ForgeDirection.NORTH) {
        if (printDebug)
            System.out.print("NORTH!");
        for (int i = 0; i <= negZRadius + posZRadius; i++) {
            for (int j = 0; j <= negXRadius + posXRadius; j++) {
                GridSpace space = area[j][i];
                if (space.isEmpty()) {
                    int yLevel = this.findNearestRoadYLevel(j - negXRadius, i - negZRadius, closeness);
                    if (yLevel == -1) {
                        continue;
                    }
                    index++;
                    if (index >= amount) {
                        return new Int3(j - negXRadius, yLevel, i - negZRadius);
                    }
                }
            }
        }
    } else if (dir == ForgeDirection.SOUTH) {
        for (int i = negZRadius + posZRadius; i >= 0; i--) {
            for (int j = 0; j <= negXRadius + posXRadius; j++) {
                GridSpace space = area[j][i];
                int yLevel = this.findNearestRoadYLevel(j - negXRadius, i - negZRadius, closeness);
                if (yLevel == -1) {
                    continue;
                }
                if (space.isEmpty()) {
                    index++;
                    if (index >= amount) {
                        return new Int3(j - negXRadius, yLevel, i - negZRadius);
                    }
                }
            }
        }
    } else if (dir == ForgeDirection.EAST) {
        for (int i = negXRadius + posXRadius; i >= 0; i--) {
            for (int j = 0; j <= negZRadius + posZRadius; j++) {
                GridSpace space = area[i][j];
                int yLevel = this.findNearestRoadYLevel(i - negXRadius, j - negZRadius, closeness);
                if (yLevel == -1) {
                    continue;
                }
                if (space.isEmpty()) {
                    index++;
                    if (index >= amount) {
                        return new Int3(i - negXRadius, yLevel, j - negZRadius);
                    }
                }
            }
        }
    } else if (dir == ForgeDirection.WEST) {
        for (int i = 0; i <= negXRadius + posXRadius; i++) {
            for (int j = 0; j <= negZRadius + posZRadius; j++) {
                GridSpace space = area[i][j];
                int yLevel = this.findNearestRoadYLevel(i - negXRadius, j - negZRadius, closeness);
                if (yLevel == -1) {
                    continue;
                }
                if (space.isEmpty()) {
                    index++;
                    if (index >= amount) {
                        return new Int3(i - negXRadius, yLevel, j - negZRadius);
                    }
                }
            }
        }
    }
    return new Int3(0, 0, 0);
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) GridSpace(WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)

Aggregations

GridSpace (WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)12 Int3 (WayofTime.alchemicalWizardry.api.Int3)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 DemonBuilding (WayofTime.alchemicalWizardry.common.demonVillage.DemonBuilding)1 DemonCrosspath (WayofTime.alchemicalWizardry.common.demonVillage.DemonCrosspath)1 DemonVillagePath (WayofTime.alchemicalWizardry.common.demonVillage.DemonVillagePath)1 Int3AndBool (WayofTime.alchemicalWizardry.common.demonVillage.DemonVillagePath.Int3AndBool)1 GridSpaceHolder (WayofTime.alchemicalWizardry.common.demonVillage.GridSpaceHolder)1 DemonType (WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.DemonType)1 LinkedList (java.util.LinkedList)1