Search in sources :

Example 1 with GridSpace

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

the class TEDemonPortal method expandAreaInPosZ.

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

Example 2 with GridSpace

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

the class TEDemonPortal method expandAreaInPosX.

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

Example 3 with GridSpace

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

the class TEDemonPortal method getLength.

public // Number of spaces forward
int getLength(// Number of spaces forward
ForgeDirection dir, // Number of spaces forward
int maxLength, // Number of spaces forward
int x, // Number of spaces forward
int z) {
    for (int i = 1; i <= maxLength; i++) {
        GridSpace space = this.getGridSpace(x + i * dir.offsetX, z + i * dir.offsetZ);
        if (space.isEmpty()) {
            for (int k = 1; k <= this.getRoadSpacer(); k++) {
                GridSpace space1 = this.getGridSpace(x + i * dir.offsetX + dir.offsetZ * k, z + i * dir.offsetZ + dir.offsetX * k);
                GridSpace space2 = this.getGridSpace(x + i * dir.offsetX - dir.offsetZ * k, z + i * dir.offsetZ - dir.offsetX * k);
                if (space1.isRoadSegment() || space2.isRoadSegment()) {
                    return i - 1;
                }
            }
            continue;
        }
        if (space.isRoadSegment()) {
            return i;
        } else {
            return i - 1;
        }
    }
    return maxLength;
}
Also used : GridSpace(WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)

Example 4 with GridSpace

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

the class TEDemonPortal method findValidExtentionDirection.

public List<ForgeDirection> findValidExtentionDirection(int x, int z) {
    List<ForgeDirection> directions = new LinkedList();
    if (this.getGridSpace(x, z) == null || !this.getGridSpace(x, z).isRoadSegment()) {
        return directions;
    }
    GridSpace nextGrid = this.getGridSpace(x + 1, z);
    if (nextGrid.isEmpty()) {
        directions.add(ForgeDirection.EAST);
    }
    nextGrid = this.getGridSpace(x - 1, z);
    if (nextGrid.isEmpty()) {
        directions.add(ForgeDirection.WEST);
    }
    nextGrid = this.getGridSpace(x, z + 1);
    if (nextGrid.isEmpty()) {
        directions.add(ForgeDirection.SOUTH);
    }
    nextGrid = this.getGridSpace(x, z - 1);
    if (nextGrid.isEmpty()) {
        directions.add(ForgeDirection.NORTH);
    }
    return directions;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) GridSpace(WayofTime.alchemicalWizardry.common.demonVillage.GridSpace) LinkedList(java.util.LinkedList)

Example 5 with GridSpace

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

the class TEDemonPortal method initialize.

public void initialize() {
    if (isInitialized) {
        return;
    }
    DemonType[] types = DemonType.values();
    this.type = types[rand.nextInt(types.length)];
    for (int xIndex = -negXRadius; xIndex <= posXRadius; xIndex++) {
        for (int zIndex = -negZRadius; zIndex <= posZRadius; zIndex++) {
            if (Math.abs(xIndex) == 1 || Math.abs(zIndex) == 1) {
                this.setGridSpace(xIndex, zIndex, new GridSpace(GridSpace.ROAD, yCoord));
            } else if (xIndex == 0 && zIndex == 0) {
                this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, yCoord));
            } else {
                this.setGridSpace(xIndex, zIndex, new GridSpace());
            }
        }
    }
    this.houseCooldown = TEDemonPortal.buildingGridDelay;
    this.roadCooldown = TEDemonPortal.roadGridDelay;
    this.demonHoardCooldown = TEDemonPortal.demonHoardDelay;
    this.createRandomRoad();
    if (this.createRandomBuilding(DemonBuilding.BUILDING_PORTAL, tier) >= 1) {
        System.out.println("Portal building successfully found!");
        this.buildingStage = 0;
    }
    isInitialized = true;
}
Also used : GridSpace(WayofTime.alchemicalWizardry.common.demonVillage.GridSpace) DemonType(WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.DemonType)

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