Search in sources :

Example 1 with TileEntityDungeonSpawner

use of micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner in project Galacticraft by micdoodle8.

the class RoomBossMars method addComponentParts.

@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox chunkBox) {
    for (int i = 0; i <= this.sizeX; i++) {
        for (int j = 0; j <= this.sizeY; j++) {
            for (int k = 0; k <= this.sizeZ; k++) {
                if (i == 0 || i == this.sizeX || j == 0 || k == 0 || k == this.sizeZ) {
                    boolean placeBlock = true;
                    if (getDirection().getAxis() == EnumFacing.Axis.Z) {
                        int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
                        int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
                        if (i > start && i <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.SOUTH && k == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.NORTH && k == this.sizeZ) {
                                placeBlock = false;
                            }
                        }
                    } else {
                        int start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
                        int end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
                        if (k > start && k <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.EAST && i == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.WEST && i == this.sizeX) {
                                placeBlock = false;
                            }
                        }
                    }
                    if (placeBlock) {
                        this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, chunkBox);
                    } else {
                        this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                    }
                } else if (j == this.sizeY) {
                    if ((i <= 2 || k <= 2 || i >= this.sizeX - 2 || k >= this.sizeZ - 2) && random.nextInt(4) == 0) {
                        this.setBlockState(worldIn, Blocks.glowstone.getDefaultState(), i, j, k, chunkBox);
                    } else {
                        this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, chunkBox);
                    }
                } else if (j == 1 && (i <= 2 || k <= 2 || i >= this.sizeX - 2 || k >= this.sizeZ - 2) && random.nextInt(6) == 0) {
                    this.setBlockState(worldIn, MarsBlocks.creeperEgg.getDefaultState(), i, j, k, chunkBox);
                } else {
                    this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                }
            }
        }
    }
    int spawnerX = this.sizeX / 2;
    int spawnerY = 1;
    int spawnerZ = this.sizeZ / 2;
    BlockPos blockpos = new BlockPos(this.getXWithOffset(spawnerX, spawnerZ), this.getYWithOffset(spawnerY), this.getZWithOffset(spawnerX, spawnerZ));
    // Is this position inside the chunk currently being generated?
    if (chunkBox.isVecInside(blockpos)) {
        worldIn.setBlockState(blockpos, MarsBlocks.bossSpawner.getDefaultState(), 2);
        TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) worldIn.getTileEntity(blockpos);
        if (spawner != null) {
            spawner.setRoom(new Vector3(this.boundingBox.minX + 1, this.boundingBox.minY + 1, this.boundingBox.minZ + 1), new Vector3(this.sizeX - 1, this.sizeY - 1, this.sizeZ - 1));
        }
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.BlockPos) TileEntityDungeonSpawner(micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 2 with TileEntityDungeonSpawner

use of micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner in project Galacticraft by micdoodle8.

the class RoomBoss method addComponentParts.

@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox chunkBox) {
    for (int i = 0; i <= this.sizeX; i++) {
        for (int j = 0; j <= this.sizeY; j++) {
            for (int k = 0; k <= this.sizeZ; k++) {
                if (i == 0 || i == this.sizeX || j == 0 || j == this.sizeY || k == 0 || k == this.sizeZ) {
                    boolean placeBlock = true;
                    if (getDirection().getAxis() == EnumFacing.Axis.Z) {
                        int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
                        int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
                        if (i > start && i <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.SOUTH && k == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.NORTH && k == this.sizeZ) {
                                placeBlock = false;
                            }
                        }
                    } else {
                        int start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
                        int end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
                        if (k > start && k <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.EAST && i == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.WEST && i == this.sizeX) {
                                placeBlock = false;
                            }
                        }
                    }
                    if (placeBlock) {
                        this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, chunkBox);
                    } else {
                        this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                    }
                } else if ((i == 1 && k == 1) || (i == 1 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 1)) {
                    this.setBlockState(worldIn, Blocks.flowing_lava.getDefaultState(), i, j, k, chunkBox);
                } else if (j % 3 == 0 && j >= 2 && ((i == 1 || i == this.sizeX - 1 || k == 1 || k == this.sizeZ - 1) || (i == 2 && k == 2) || (i == 2 && k == this.sizeZ - 2) || (i == this.sizeX - 2 && k == 2) || (i == this.sizeX - 2 && k == this.sizeZ - 2))) {
                    // Horizontal bars
                    this.setBlockState(worldIn, Blocks.iron_bars.getDefaultState(), i, j, k, chunkBox);
                } else if ((i == 1 && k == 2) || (i == 2 && k == 1) || (i == 1 && k == this.sizeZ - 2) || (i == 2 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 2) || (i == this.sizeX - 2 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 2) || (i == this.sizeX - 2 && k == this.sizeZ - 1)) {
                    // Vertical bars
                    this.setBlockState(worldIn, Blocks.iron_bars.getDefaultState(), i, j, k, chunkBox);
                } else {
                    this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                }
            }
        }
    }
    int spawnerX = this.sizeX / 2;
    int spawnerY = 1;
    int spawnerZ = this.sizeZ / 2;
    BlockPos blockpos = new BlockPos(this.getXWithOffset(spawnerX, spawnerZ), this.getYWithOffset(spawnerY), this.getZWithOffset(spawnerX, spawnerZ));
    // Is this position inside the chunk currently being generated?
    if (chunkBox.isVecInside(blockpos)) {
        worldIn.setBlockState(blockpos, GCBlocks.bossSpawner.getDefaultState(), 2);
        TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) worldIn.getTileEntity(blockpos);
        if (spawner != null) {
            spawner.setRoom(new Vector3(this.boundingBox.minX + 1, this.boundingBox.minY + 1, this.boundingBox.minZ + 1), new Vector3(this.sizeX - 1, this.sizeY - 1, this.sizeZ - 1));
            spawner.setChestPos(this.chestPos);
        }
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.BlockPos) TileEntityDungeonSpawner(micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 3 with TileEntityDungeonSpawner

use of micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner in project Galacticraft by micdoodle8.

the class RoomBossVenus method addComponentParts.

@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox chunkBox) {
    StructureBoundingBox box = new StructureBoundingBox(new int[] { Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE });
    for (int i = 0; i <= this.sizeX; i++) {
        for (int j = 0; j <= this.sizeY; j++) {
            for (int k = 0; k <= this.sizeZ; k++) {
                double dX = (i - this.sizeX / 2);
                double dZ = (k - this.sizeZ / 2);
                double dXZ = Math.sqrt(dX * dX + dZ * dZ);
                double f = -Math.pow((dXZ * 1.5) / (this.sizeX / 2 - 1), 6) + this.sizeY - 1;
                if (j == 0) {
                    this.setBlockState(worldIn, this.configuration.getBrickBlockFloor(), i, j, k, chunkBox);
                } else if (j < f) {
                    this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                    if (j + 1 >= f && (dXZ > 5) && random.nextInt(12) == 0) {
                        int distFromFloor = random.nextInt(5) + 2;
                        for (int j0 = j; j0 >= distFromFloor + 1; --j0) {
                            BlockTorchWeb.EnumWebType webType;
                            if (j0 == distFromFloor + 1) {
                                webType = BlockTorchWeb.EnumWebType.WEB_1;
                            } else {
                                webType = BlockTorchWeb.EnumWebType.WEB_0;
                            }
                            this.setBlockState(worldIn, VenusBlocks.torchWeb.getDefaultState().withProperty(BlockTorchWeb.WEB_TYPE, webType), i, j0, k, chunkBox);
                        }
                    }
                    if (i < box.minX) {
                        box.minX = i;
                    }
                    if (i > box.maxX) {
                        box.maxX = i;
                    }
                    if (j < box.minY) {
                        box.minY = j;
                    }
                    if (j > box.maxY) {
                        box.maxY = j;
                    }
                    if (k < box.minZ) {
                        box.minZ = k;
                    }
                    if (k > box.maxZ) {
                        box.maxZ = k;
                    }
                } else {
                    boolean placeBlock = true;
                    int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
                    int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
                    if (i > start && i <= end && j < 5 && j > 2) {
                        if ((getDirection() == EnumFacing.SOUTH || (this.exitDirection != null && this.exitDirection == EnumFacing.SOUTH)) && k < 7) {
                            placeBlock = false;
                        }
                        if ((getDirection() == EnumFacing.NORTH || (this.exitDirection != null && this.exitDirection == EnumFacing.NORTH)) && k > this.sizeZ - 7) {
                            placeBlock = false;
                        }
                    }
                    start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
                    end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
                    if (k > start && k <= end && j < 5 && j > 2) {
                        if ((getDirection() == EnumFacing.EAST || (this.exitDirection != null && this.exitDirection == EnumFacing.EAST)) && i < 7) {
                            placeBlock = false;
                        }
                        if ((getDirection() == EnumFacing.WEST || (this.exitDirection != null && this.exitDirection == EnumFacing.WEST)) && i > this.sizeX - 7) {
                            placeBlock = false;
                        }
                    }
                    if (placeBlock) {
                        this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, chunkBox);
                    } else {
                        this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                    }
                }
            }
        }
    }
    int spawnerX = this.sizeX / 2;
    int spawnerY = 1;
    int spawnerZ = this.sizeZ / 2;
    BlockPos blockpos = new BlockPos(this.getXWithOffset(spawnerX, spawnerZ), this.getYWithOffset(spawnerY), this.getZWithOffset(spawnerX, spawnerZ));
    // Is this position inside the chunk currently being generated?
    if (chunkBox.isVecInside(blockpos)) {
        worldIn.setBlockState(blockpos, VenusBlocks.bossSpawner.getDefaultState(), 2);
        TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) worldIn.getTileEntity(blockpos);
        if (spawner != null) {
            if (box.getXSize() > 10000 || box.getYSize() > 10000 || box.getZSize() > 10000) {
                GCLog.severe("Failed to set correct boss room size. This is a bug!");
            } else {
                spawner.setRoom(new Vector3(box.minX + this.boundingBox.minX, box.minY + this.boundingBox.minY, box.minZ + this.boundingBox.minZ), new Vector3(box.maxX - box.minX + 1, box.maxY - box.minY + 1, box.maxZ - box.minZ + 1));
                spawner.setChestPos(this.chestPos);
            }
        }
    }
    return true;
}
Also used : StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) BlockPos(net.minecraft.util.BlockPos) TileEntityDungeonSpawner(micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)3 TileEntityDungeonSpawner (micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner)3 BlockPos (net.minecraft.util.BlockPos)3 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)1