Search in sources :

Example 21 with Int3

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);
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 22 with Int3

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;
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 23 with Int3

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITilePortalNode(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.ITilePortalNode) Int3(WayofTime.alchemicalWizardry.api.Int3) Block(net.minecraft.block.Block) IBlockPortalNode(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.IBlockPortalNode)

Example 24 with Int3

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);
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3)

Example 25 with Int3

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);
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) Block(net.minecraft.block.Block)

Aggregations

Int3 (WayofTime.alchemicalWizardry.api.Int3)34 TileEntity (net.minecraft.tileentity.TileEntity)10 LinkedList (java.util.LinkedList)7 Block (net.minecraft.block.Block)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 World (net.minecraft.world.World)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 IInventory (net.minecraft.inventory.IInventory)4 ItemStack (net.minecraft.item.ItemStack)4 GridSpace (WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)3 DemonBuilding (WayofTime.alchemicalWizardry.common.demonVillage.DemonBuilding)2 DemonVillagePath (WayofTime.alchemicalWizardry.common.demonVillage.DemonVillagePath)2 Int3AndBool (WayofTime.alchemicalWizardry.common.demonVillage.DemonVillagePath.Int3AndBool)2 GridSpaceHolder (WayofTime.alchemicalWizardry.common.demonVillage.GridSpaceHolder)2 TEDemonPortal (WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)2