net.minecraft.world.gen.structure.StructureBoundingBox Java Examples

The following examples show how to use net.minecraft.world.gen.structure.StructureBoundingBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StructureLoader.java    From YUNoMakeGoodMap with Apache License 2.0 6 votes vote down vote up
@Override
public void generate(World world, BlockPos pos)
{
    PlacementSettings settings = new PlacementSettings();
    Template temp = null;
    String suffix = world.provider.getDimensionType().getSuffix();
    String opts = world.getWorldInfo().getGeneratorOptions() + suffix;

    if (!Strings.isNullOrEmpty(opts))
        temp = StructureUtil.loadTemplate(new ResourceLocation(opts), (WorldServer)world, true);
    if (temp == null)
        temp = StructureUtil.loadTemplate(new ResourceLocation("/config/", this.fileName + suffix), (WorldServer)world, !Strings.isNullOrEmpty(suffix));
    if (temp == null)
        return; //If we're not in the overworld, and we don't have a template...

    BlockPos spawn = StructureUtil.findSpawn(temp, settings);
    if (spawn != null)
    {
        pos = pos.subtract(spawn);
        world.setSpawnPoint(pos);
    }

    temp.addBlocksToWorld(world, pos, settings, 0); //Push to world, with no neighbor notifications!
    world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!
}
 
Example #2
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
private void placeSupport(World p_189921_1_, StructureBoundingBox p_189921_2_, int p_189921_3_, int p_189921_4_, int p_189921_5_, int p_189921_6_, int p_189921_7_, Random p_189921_8_) {
    if (this.isSupportingBox(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_7_, p_189921_6_, p_189921_5_)) {
        IBlockState iblockstate = this.getPlanksBlock();
        IBlockState iblockstate1 = this.getFenceBlock();
        IBlockState iblockstate2 = Blocks.AIR.getDefaultState();
        this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_4_, p_189921_5_, p_189921_3_, p_189921_6_ - 1, p_189921_5_, iblockstate1, iblockstate2, false);
        this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_7_, p_189921_4_, p_189921_5_, p_189921_7_, p_189921_6_ - 1, p_189921_5_, iblockstate1, iblockstate2, false);

        if (p_189921_8_.nextInt(4) == 0) {
            this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_6_, p_189921_5_, p_189921_3_, p_189921_6_, p_189921_5_, iblockstate, iblockstate2, false);
            this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_7_, p_189921_6_, p_189921_5_, p_189921_7_, p_189921_6_, p_189921_5_, iblockstate, iblockstate2, false);
        } else {
            this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_6_, p_189921_5_, p_189921_7_, p_189921_6_, p_189921_5_, iblockstate, iblockstate2, false);
            this.randomlyPlaceBlock(p_189921_1_, p_189921_2_, p_189921_8_, 0.05F, p_189921_3_ + 1, p_189921_6_, p_189921_5_ - 1, BlockLoader.TOFUISHI_TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH));
            this.randomlyPlaceBlock(p_189921_1_, p_189921_2_, p_189921_8_, 0.05F, p_189921_3_ + 1, p_189921_6_, p_189921_5_ + 1, BlockLoader.TOFUISHI_TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH));
        }
    }
}
 
Example #3
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
 * Discover the y coordinate that will serve as the ground level of the supplied BoundingBox. (A median of
 * all the levels in the BB's horizontal rectangle).
 */
protected int getAverageGroundLevel(World worldIn, StructureBoundingBox structurebb) {
    int i = 0;
    int j = 0;
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int k = this.boundingBox.minZ; k <= this.boundingBox.maxZ; ++k) {
        for (int l = this.boundingBox.minX; l <= this.boundingBox.maxX; ++l) {
            blockpos$mutableblockpos.setPos(l, 64, k);

            if (structurebb.isVecInside(blockpos$mutableblockpos)) {
                i += Math.max(worldIn.getTopSolidOrLiquidBlock(blockpos$mutableblockpos).getY(), worldIn.provider.getAverageGroundLevel() - 1);
                ++j;
            }
        }
    }

    if (j == 0) {
        return -1;
    } else {
        return i / j;
    }
}
 
Example #4
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
private static StructureTofuMineshaftPieces.Peice createRandomShaftPiece(List<StructureComponent> p_189940_0_, Random p_189940_1_, int p_189940_2_, int p_189940_3_, int p_189940_4_, @Nullable EnumFacing p_189940_5_, int p_189940_6_, MapGenTofuMineshaft.Type p_189940_7_) {
    int i = p_189940_1_.nextInt(100);

    if (i >= 80) {
        StructureBoundingBox structureboundingbox = StructureTofuMineshaftPieces.Cross.findCrossing(p_189940_0_, p_189940_1_, p_189940_2_, p_189940_3_, p_189940_4_, p_189940_5_);

        if (structureboundingbox != null) {
            return new StructureTofuMineshaftPieces.Cross(p_189940_6_, p_189940_1_, structureboundingbox, p_189940_5_, p_189940_7_);
        }
    } else if (i >= 70) {
        StructureBoundingBox structureboundingbox1 = StructureTofuMineshaftPieces.Stairs.findStairs(p_189940_0_, p_189940_1_, p_189940_2_, p_189940_3_, p_189940_4_, p_189940_5_);

        if (structureboundingbox1 != null) {
            return new StructureTofuMineshaftPieces.Stairs(p_189940_6_, p_189940_1_, structureboundingbox1, p_189940_5_, p_189940_7_);
        }
    } else {
        StructureBoundingBox structureboundingbox2 = StructureTofuMineshaftPieces.Corridor.findCorridorSize(p_189940_0_, p_189940_1_, p_189940_2_, p_189940_3_, p_189940_4_, p_189940_5_);

        if (structureboundingbox2 != null) {
            return new StructureTofuMineshaftPieces.Corridor(p_189940_6_, p_189940_1_, structureboundingbox2, p_189940_5_, p_189940_7_);
        }
    }

    return null;
}
 
Example #5
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 4 - 1, 0);
    }

    IBlockState iblockstate = this.getBiomeSpecificBlockState(Blocks.OAK_FENCE.getDefaultState());
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 2, 3, 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
    this.setBlockState(worldIn, iblockstate, 1, 0, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 1, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 1, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.WOOL.getStateFromMeta(EnumDyeColor.WHITE.getDyeDamage()), 1, 3, 0, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.EAST, 2, 3, 0, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.NORTH, 1, 3, 1, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.WEST, 0, 3, 0, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 1, 3, -1, structureBoundingBoxIn);
    return true;
}
 
Example #6
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn)) {
        return false;
    } else {
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.minY, this.boundingBox.maxZ, BlockLoader.zundatofuTerrain.getDefaultState(), Blocks.AIR.getDefaultState(), true);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY + 1, this.boundingBox.minZ, this.boundingBox.maxX, Math.min(this.boundingBox.minY + 3, this.boundingBox.maxY), this.boundingBox.maxZ, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);

        for (StructureBoundingBox structureboundingbox : this.connectedRooms) {
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, structureboundingbox.minX, structureboundingbox.maxY - 2, structureboundingbox.minZ, structureboundingbox.maxX, structureboundingbox.maxY, structureboundingbox.maxZ, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        }

        this.randomlyRareFillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY + 4, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.AIR.getDefaultState(), false);
        return true;
    }
}
 
Example #7
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 5, 0);
    }

    IBlockState iblockstate = this.getBiomeSpecificBlockState(Blocks.SPRUCE_FENCE.getDefaultState());
    this.setBlockState(worldIn, iblockstate, 1, 0, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 1, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 1, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.WOOL.getStateFromMeta(EnumDyeColor.BLACK.getDyeDamage()), 1, 3, 0, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.EAST, 2, 3, 0, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.NORTH, 1, 3, 1, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.WEST, 0, 3, 0, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 1, 3, -1, structureBoundingBoxIn);
    return true;
}
 
Example #8
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
public static StructureBoundingBox findStairs(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing) {
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y - 5, z, x, y + 2, z);

    switch (facing) {
        case NORTH:
        default:
            structureboundingbox.maxX = x + 2;
            structureboundingbox.minZ = z - 8;
            break;
        case SOUTH:
            structureboundingbox.maxX = x + 2;
            structureboundingbox.maxZ = z + 8;
            break;
        case WEST:
            structureboundingbox.minX = x - 8;
            structureboundingbox.maxZ = z + 2;
            break;
        case EAST:
            structureboundingbox.maxX = x + 8;
            structureboundingbox.maxZ = z + 2;
    }

    return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
}
 
Example #9
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static StructureBoundingBox findPieceBox(Start start, List<StructureComponent> p_175848_1_, Random rand, int p_175848_3_, int p_175848_4_, int p_175848_5_, EnumFacing facing) {
    for (int i = 7 * MathHelper.getInt(rand, 3, 5); i >= 7; i -= 7) {
        StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p_175848_3_, p_175848_4_, p_175848_5_, 0, 0, 0, 3, 3, i, facing);

        if (StructureComponent.findIntersecting(p_175848_1_, structureboundingbox) == null) {
            return structureboundingbox;
        }
    }

    return null;
}
 
Example #10
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 6 - 1, 0);
    }

    IBlockState iblockstate = this.getBiomeSpecificBlockState(BlockLoader.tofuTerrain.getDefaultState());
    IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
    IBlockState iblockstate4 = BlockLoader.TOFUFARMLAND.getDefaultState();
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 0, 6, 5, 6, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 6, 0, 6, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 1, 5, 0, 5, iblockstate4, iblockstate4, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 3, 5, 0, 3, BlockLoader.SOYMILK.getDefaultState(), BlockLoader.SOYMILK.getDefaultState(), false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 5, 1, 1, BlockLoader.SOYBEAN.getDefaultState(), BlockLoader.SOYBEAN.getDefaultState(), false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 2, 5, 1, 2, BlockLoader.SOYBEAN.getDefaultState(), BlockLoader.SOYBEAN.getDefaultState(), false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 4, 5, 1, 4, BlockLoader.SOYBEAN.getDefaultState(), BlockLoader.SOYBEAN.getDefaultState(), false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 5, 5, 1, 5, BlockLoader.SOYBEAN.getDefaultState(), BlockLoader.SOYBEAN.getDefaultState(), false);


    for (int i = 0; i < 7; ++i) {
        for (int j = 0; j < 7; ++j) {
            this.clearCurrentPositionBlocksUpwards(worldIn, j, 6, i, structureBoundingBoxIn);
            this.replaceAirAndLiquidDownwards(worldIn, iblockstate, j, -1, i, structureBoundingBoxIn);
        }
    }

    return true;
}
 
Example #11
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public WoodHut(Start start, int type, Random rand, StructureBoundingBox structurebb, EnumFacing facing) {
    super(start, type);
    this.setCoordBaseMode(facing);
    this.boundingBox = structurebb;
    this.isTallHouse = rand.nextBoolean();
    this.tablePosition = rand.nextInt(3);
}
 
Example #12
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public Well(Start start, int type, Random rand, int x, int z) {
    super(start, type);
    this.setCoordBaseMode(EnumFacing.Plane.HORIZONTAL.random(rand));

    if (this.getCoordBaseMode().getAxis() == EnumFacing.Axis.Z) {
        this.boundingBox = new StructureBoundingBox(x, 64, z, x + 6 - 1, 78, z + 6 - 1);
    } else {
        this.boundingBox = new StructureBoundingBox(x, 64, z, x + 6 - 1, 78, z + 6 - 1);
    }
}
 
Example #13
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
         * Mineshafts at the end, it adds Fences...
         */
        public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
            if (this.averageGroundLvl < 0) {
                this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

                if (this.averageGroundLvl < 0) {
                    return true;
                }

                this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 3, 0);
            }

            IBlockState iblockstate = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
//            IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUMOMEN_TORCH.getDefaultState());
            IBlockState soymilk = this.getBiomeSpecificBlockState(BlockLoader.SOYMILK.getDefaultState());
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 1, 4, 12, 4, iblockstate, BlockLoader.SOYMILK.getDefaultState(), false);
            this.setBlockState(worldIn, soymilk, 2, 12, 2, structureBoundingBoxIn);
            this.setBlockState(worldIn, soymilk, 3, 12, 2, structureBoundingBoxIn);
            this.setBlockState(worldIn, soymilk, 2, 12, 3, structureBoundingBoxIn);
            this.setBlockState(worldIn, soymilk, 3, 12, 3, structureBoundingBoxIn);

            this.fillWithBlocks(worldIn, structureBoundingBoxIn,1, 12, 1,1,15,1,iblockstate,iblockstate,false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn,4, 12, 1,4,15,1,iblockstate,iblockstate,false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn,1, 12, 4,1,15,4,iblockstate,iblockstate,false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn,4, 12, 4,4,15,4,iblockstate,iblockstate,false);

            this.fillWithBlocks(worldIn, structureBoundingBoxIn,1, 15, 1,4,15,4,iblockstate,iblockstate,false);

            return true;
        }
 
Example #14
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
private static StructureComponent generateAndAddRoadPiece(Start start, List<StructureComponent> p_176069_1_, Random rand, int p_176069_3_, int p_176069_4_, int p_176069_5_, EnumFacing facing, int p_176069_7_) {
    if (p_176069_7_ > 3 + start.terrainType) {
        return null;
    } else if (Math.abs(p_176069_3_ - start.getBoundingBox().minX) <= 112 && Math.abs(p_176069_5_ - start.getBoundingBox().minZ) <= 112) {
        StructureBoundingBox structureboundingbox = Path.findPieceBox(start, p_176069_1_, rand, p_176069_3_, p_176069_4_, p_176069_5_, facing);

        if (structureboundingbox != null && structureboundingbox.minY > 10) {
            StructureComponent structurecomponent = new Path(start, p_176069_7_, rand, structureboundingbox, facing);
            p_176069_1_.add(structurecomponent);
            start.pendingRoads.add(structurecomponent);
            return structurecomponent;
        } else {
            return null;
        }
    } else {
        return null;
    }
}
 
Example #15
Source File: NewSpawnPlatformCommand.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length != 2)
        throw new WrongUsageException(getUsage(sender));

    EntityPlayer player = getPlayer(server, sender, args[1]);

    if (player != null)
    {
        PlacementSettings settings = new PlacementSettings();
        WorldServer world = (WorldServer) sender.getEntityWorld();

        int platformNumber = SpawnPlatformSavedData.get(world).addAndGetPlatformNumber();
        BlockPos pos = getPositionOfPlatform(world, platformNumber);

        Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[0]), world, true);
        BlockPos spawn = StructureUtil.findSpawn(temp, settings);
        spawn = spawn == null ? pos : spawn.add(pos);

        sender.sendMessage(new TextComponentString("Building \"" + args[0] + "\" at " + pos.toString()));
        temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications!
        world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!

        if (player instanceof EntityPlayerMP) {
            ((EntityPlayerMP) player).setPositionAndUpdate(spawn.getX() + 0.5, spawn.getY() + 1.6, spawn.getZ() + 0.5);
        }

        player.setSpawnChunk(spawn, true, world.provider.getDimension());
    }
    else
    {
        throw new WrongUsageException(getUsage(sender));
    }
}
 
Example #16
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public Corridor(int p_i47140_1_, Random p_i47140_2_, StructureBoundingBox p_i47140_3_, EnumFacing p_i47140_4_, MapGenTofuMineshaft.Type p_i47140_5_) {
    super(p_i47140_1_, p_i47140_5_);
    this.setCoordBaseMode(p_i47140_4_);
    this.boundingBox = p_i47140_3_;
    this.hasRails = p_i47140_2_.nextInt(3) == 0;
    this.hasSpiders = !this.hasRails && p_i47140_2_.nextInt(23) == 0;

    if (this.getCoordBaseMode().getAxis() == EnumFacing.Axis.Z) {
        this.sectionCount = p_i47140_3_.getZSize() / 5;
    } else {
        this.sectionCount = p_i47140_3_.getXSize() / 5;
    }
}
 
Example #17
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static StructureBoundingBox findCorridorSize(List<StructureComponent> p_175814_0_, Random rand, int x, int y, int z, EnumFacing facing) {
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);
    int i;

    for (i = rand.nextInt(3) + 2; i > 0; --i) {
        int j = i * 5;

        switch (facing) {
            case NORTH:
            default:
                structureboundingbox.maxX = x + 2;
                structureboundingbox.minZ = z - (j - 1);
                break;
            case SOUTH:
                structureboundingbox.maxX = x + 2;
                structureboundingbox.maxZ = z + (j - 1);
                break;
            case WEST:
                structureboundingbox.minX = x - (j - 1);
                structureboundingbox.maxZ = z + 2;
                break;
            case EAST:
                structureboundingbox.maxX = x + (j - 1);
                structureboundingbox.maxZ = z + 2;
        }

        if (StructureComponent.findIntersecting(p_175814_0_, structureboundingbox) == null) {
            break;
        }
    }

    return i > 0 ? structureboundingbox : null;
}
 
Example #18
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Spawns a number of villagers in this component. Parameters: world, component bounding box, x offset, y
 * offset, z offset, number of villagers
 */
protected void spawnVillagers(World worldIn, StructureBoundingBox structurebb, int x, int y, int z, int count) {
    if (this.villagersSpawned < count) {
        for (int i = this.villagersSpawned; i < count; ++i) {
            int j = this.getXWithOffset(x + i, z);
            int k = this.getYWithOffset(y);
            int l = this.getZWithOffset(x + i, z);

            if (!structurebb.isVecInside(new BlockPos(j, k, l))) {
                break;
            }

            ++this.villagersSpawned;

            if (this.field_189929_i) {
                EntityZombieVillager entityzombie = new EntityZombieVillager(worldIn);
                entityzombie.setLocationAndAngles((double) j + 0.5D, (double) k, (double) l + 0.5D, 0.0F, 0.0F);
                entityzombie.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData) null);
                entityzombie.enablePersistence();
                worldIn.spawnEntity(entityzombie);
            } else {
                EntityTofunian entityvillager = new EntityTofunian(worldIn);
                entityvillager.setLocationAndAngles((double) j + 0.5D, (double) k, (double) l + 0.5D, 0.0F, 0.0F);
                entityvillager.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData) null);
                worldIn.spawnEntity(entityvillager);
            }
        }
    }
}
 
Example #19
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Adds chest to the structure and sets its contents
 */
protected boolean generateChest(World worldIn, StructureBoundingBox structurebb, Random randomIn, int x, int y, int z, ResourceLocation loot) {
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));

    if (structurebb.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && worldIn.getBlockState(blockpos.down()).getMaterial() != Material.AIR) {
        IBlockState iblockstate = Blocks.RAIL.getDefaultState().withProperty(BlockRail.SHAPE, randomIn.nextBoolean() ? BlockRailBase.EnumRailDirection.NORTH_SOUTH : BlockRailBase.EnumRailDirection.EAST_WEST);
        this.setBlockState(worldIn, iblockstate, x, y, z, structurebb);
        EntityMinecartChest entityminecartchest = new EntityMinecartChest(worldIn, (double) ((float) blockpos.getX() + 0.5F), (double) ((float) blockpos.getY() + 0.5F), (double) ((float) blockpos.getZ() + 0.5F));
        entityminecartchest.setLootTable(loot, randomIn.nextLong());
        worldIn.spawnEntity(entityminecartchest);
        return true;
    } else {
        return false;
    }
}
 
Example #20
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static StructureBoundingBox findCrossing(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing) {
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);

    if (rand.nextInt(4) == 0) {
        structureboundingbox.maxY += 4;
    }

    switch (facing) {
        case NORTH:
        default:
            structureboundingbox.minX = x - 1;
            structureboundingbox.maxX = x + 3;
            structureboundingbox.minZ = z - 4;
            break;
        case SOUTH:
            structureboundingbox.minX = x - 1;
            structureboundingbox.maxX = x + 3;
            structureboundingbox.maxZ = z + 3 + 1;
            break;
        case WEST:
            structureboundingbox.minX = x - 4;
            structureboundingbox.minZ = z - 1;
            structureboundingbox.maxZ = z + 3;
            break;
        case EAST:
            structureboundingbox.maxX = x + 3 + 1;
            structureboundingbox.minZ = z - 1;
            structureboundingbox.maxZ = z + 3;
    }

    return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
}
 
Example #21
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn)) {
        return false;
    } else {
        IBlockState iblockstate = this.getPlanksBlock();

        if (this.isMultipleFloors) {
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ - 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.maxY - 2, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.maxY - 2, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY + 3, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.minY + 3, this.boundingBox.maxZ - 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        } else {
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        }

        this.placeSupportPillar(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxY);
        this.placeSupportPillar(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.maxY);
        this.placeSupportPillar(worldIn, structureBoundingBoxIn, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxY);
        this.placeSupportPillar(worldIn, structureBoundingBoxIn, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.maxY);

        for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i) {
            for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j) {
                if (this.getBlockStateFromPos(worldIn, i, this.boundingBox.minY - 1, j, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getSkyBrightness(worldIn, i, this.boundingBox.minY - 1, j, structureBoundingBoxIn) < 8) {
                    this.setBlockState(worldIn, iblockstate, i, this.boundingBox.minY - 1, j, structureBoundingBoxIn);
                }
            }
        }

        return true;
    }
}
 
Example #22
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
protected boolean isSupportingBox(World p_189918_1_, StructureBoundingBox p_189918_2_, int p_189918_3_, int p_189918_4_, int p_189918_5_, int p_189918_6_) {
    for (int i = p_189918_3_; i <= p_189918_4_; ++i) {
        if (this.getBlockStateFromPos(p_189918_1_, i, p_189918_5_ + 1, p_189918_6_, p_189918_2_).getMaterial() == Material.AIR) {
            return false;
        }
    }

    return true;
}
 
Example #23
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public void offset(int x, int y, int z) {
    super.offset(x, y, z);

    for (StructureBoundingBox structureboundingbox : this.connectedRooms) {
        structureboundingbox.offset(x, y, z);
    }
}
 
Example #24
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * (abstract) Helper method to write subclass data to NBT
 */
protected void writeStructureToNBT(NBTTagCompound tagCompound) {
    super.writeStructureToNBT(tagCompound);
    NBTTagList nbttaglist = new NBTTagList();

    for (StructureBoundingBox structureboundingbox : this.connectedRooms) {
        nbttaglist.appendTag(structureboundingbox.toNBTTagIntArray());
    }

    tagCompound.setTag("Entrances", nbttaglist);
}
 
Example #25
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * (abstract) Helper method to read subclass data from NBT
 */
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) {
    super.readStructureFromNBT(tagCompound, p_143011_2_);
    NBTTagList nbttaglist = tagCompound.getTagList("Entrances", 11);

    for (int i = 0; i < nbttaglist.tagCount(); ++i) {
        this.connectedRooms.add(new StructureBoundingBox(nbttaglist.getIntArrayAt(i)));
    }
}
 
Example #26
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn)) {
        return false;
    } else {
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 2, 7, 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 7, 2, 2, 8, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);

        for (int i = 0; i < 5; ++i) {
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5 - i - (i < 4 ? 1 : 0), 2 + i, 2, 7 - i, 2 + i, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        }

        return true;
    }
}
 
Example #27
Source File: MapGenTofuCastle.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Keeps iterating Structure Pieces and spawning them until the checks tell it to stop
 */
public void generateStructure(World worldIn, Random rand, StructureBoundingBox structurebb) {
    super.generateStructure(worldIn, rand, structurebb);
    int i = this.boundingBox.minY;

    for (int j = structurebb.minX; j <= structurebb.maxX; ++j) {
        for (int k = structurebb.minZ; k <= structurebb.maxZ; ++k) {
            BlockPos blockpos = new BlockPos(j, i, k);

            if (!worldIn.isAirBlock(blockpos) && this.boundingBox.isVecInside(blockpos)) {
                boolean flag = false;

                for (StructureComponent structurecomponent : this.components) {
                    if (structurecomponent.getBoundingBox().isVecInside(blockpos)) {
                        flag = true;
                        break;
                    }
                }

                if (flag) {
                    for (int l = i - 1; l > 1; --l) {
                        BlockPos blockpos1 = new BlockPos(j, l, k);

                        if (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getMaterial().isLiquid()) {
                            break;
                        }

                        worldIn.setBlockState(blockpos1, BlockLoader.tofuTerrain.getDefaultState(), 2);
                    }
                }
            }
        }
    }
}
 
Example #28
Source File: WAVillagerHouse.java    From Sakura_mod with MIT License 5 votes vote down vote up
public static WAVillagerHouse createPiece(StructureVillagePieces.Start start,
		List<StructureComponent> list, Random rand, int minX, int minY, int minZ, EnumFacing facing, int type) {
	StructureBoundingBox box = StructureBoundingBox
			.getComponentToAddBoundingBox(minX, minY, minZ, 0, 0, 0, 9, 9, 6, facing);
	return StructureComponent.findIntersecting(list, box) != null ? null : new WAVillagerHouse(start,
			type, rand, box, facing);
}
 
Example #29
Source File: VillageHandlerGuardTower2.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public static VillagePieceGuardTower2 createPiece(StructureVillagePieces.Start start, List<StructureComponent> structures, Random rand, int x,
		int y, int z, EnumFacing facing, int p_175850_7_) {
	BlockPos size = new BlockMapMeasurer(NAME).measure();
	StructureBoundingBox bounds = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, size.getX(), size.getY(), size.getZ(),
			facing);
	return canVillageGoDeeper(bounds) && StructureComponent.findIntersecting(structures, bounds) == null
			? new VillagePieceGuardTower2(start, p_175850_7_, rand, bounds, facing) : null;
}
 
Example #30
Source File: VillageHandlerKeep.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public static VillagePieceKeep createPiece(StructureVillagePieces.Start start, List<StructureComponent> structures, Random rand, int x, int y,
		int z, EnumFacing facing, int p_175850_7_) {
	BlockPos size = new BlockMapMeasurer(NAME).measure();
	StructureBoundingBox bounds = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, size.getX(), size.getY(), size.getZ(),
			facing);
	return canVillageGoDeeper(bounds) && StructureComponent.findIntersecting(structures, bounds) == null
			? new VillagePieceKeep(start, p_175850_7_, rand, bounds, facing) : null;
}