Java 类net.minecraft.world.gen.structure.template.Template 实例源码

项目:Loot-Slash-Conquer    文件:Dungeon.java   
@Override
public boolean generate(World world, Random rand, BlockPos position) 
{
    WorldServer server = (WorldServer) world;
    TemplateManager manager = server.getStructureTemplateManager();

    Template dungeonEntrance = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/test_entrance"));
    PlacementSettings settings = new PlacementSettings();

    if (LSCWorldGenerator.canSpawnHere(dungeonEntrance, world, position))
    {
        LootSlashConquer.LOGGER.info("Generating Dungeon at " + position);

        // spawn the entrance on the surface
        BlockPos entrancePos = DungeonHelper.translateToCorner(dungeonEntrance, position, Rotation.NONE);
        dungeonEntrance.addBlocksToWorld(world, entrancePos, new DungeonBlockProcessor(entrancePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2);

        // start the procedural generation
        procedurallyGenerate(manager, world, position, this.generateStaircase(manager, world, position));

        return true;
    }

    return false;
}
项目:Loot-Slash-Conquer    文件:Dungeon.java   
/**
 * Generates a stores potential room positions off of the current template. Note: this does not take into account existing rooms. Check for existing rooms when spawning each specific room position.
 * @param currentTemplate
 */
private List<DungeonRoomPosition> generatePotentialRooms(TemplateManager manager, World world, Template currentTemplate, Rotation currentTemplateRotation, BlockPos currentCenter, Rotation currentSide)
{
    List<DungeonRoomPosition> list = Lists.newArrayList();

    //Rotation side = Rotation.values()[(int) (Math.random() * 4)];
    for (Rotation side : Rotation.values())
    {
        Template nextTemplate = DungeonHelper.getRandomizedDungeonTemplate(manager, world);
        Rotation nextTemplateRotation = Rotation.values()[(int) (Math.random() * 4)];
        BlockPos centeredPosition = DungeonHelper.translateToNextRoom(currentTemplate, nextTemplate, currentCenter, side, currentTemplateRotation, nextTemplateRotation);
        StructureBoundingBox boundingBox = DungeonHelper.getStructureBoundingBox(nextTemplate, nextTemplateRotation, centeredPosition);

        if (currentSide == null || (currentSide != null && currentSide.add(Rotation.CLOCKWISE_180) != side)) // check to make sure we aren't spawning a room on the side we just spawned from.
        {
            list.add(new DungeonRoomPosition(centeredPosition, nextTemplate, nextTemplateRotation, side, boundingBox));
        }
    }

    return list;
}
项目:Loot-Slash-Conquer    文件:DungeonBlockProcessor.java   
@Nullable
public Template.BlockInfo processBlock(World world, BlockPos pos, Template.BlockInfo blockInfo)
{
    Template.BlockInfo newBlockInfo;

    //if (blockInfo.blockState.getBlock() == ModBlocks.DUNGEON_BRICK)
    //{
    //  newBlockInfo = new Template.BlockInfo(pos, Blocks.PLANKS.getDefaultState(), blockInfo.tileentityData);
    //}
    //else
    //{
        newBlockInfo = blockInfo;
    //}

    return this.chance < 1.0F && this.random.nextFloat() > this.chance ? null : newBlockInfo;
}
项目:TheOink    文件:OinkWorldGenerator.java   
private void generateOverworldStructures(World world, Random random, int posX, int posZ) {

        if(OinkConfig.piggyActive) {
            WorldServer server = (WorldServer) world;
            TemplateManager manager = server.getStructureTemplateManager();

            Template piggy = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(TheOink.MODID, "pigstructure"));

            if ((int) (Math.random() * OinkConfig.piggyStructChance) == 0) {
                int randX = posX + (int) (Math.random() * 16);
                int randZ = posZ + (int) (Math.random() * 16);
                int groundY = getGroundFromAbove(world, randX, randZ);
                BlockPos pos = new BlockPos(randX, groundY, randZ);

                if (canSpawnHere(piggy, world, pos)) {
                    TheOink.LOGGER.info("Generating Pig at " + pos);
                    piggy.addBlocksToWorld(world, pos, new PlacementSettings());
                    handleDataBlocks(piggy, world, pos, new PlacementSettings());
                }
            }
        }
    }
项目:Backmemed    文件:TileEntityStructure.java   
public boolean save(boolean p_189712_1_)
{
    if (this.mode == TileEntityStructure.Mode.SAVE && !this.world.isRemote && !StringUtils.isNullOrEmpty(this.name))
    {
        BlockPos blockpos = this.getPos().add(this.position);
        WorldServer worldserver = (WorldServer)this.world;
        MinecraftServer minecraftserver = this.world.getMinecraftServer();
        TemplateManager templatemanager = worldserver.getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
        template.takeBlocksFromWorld(this.world, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(this.author);
        return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
    }
    else
    {
        return false;
    }
}
项目:CustomWorldGen    文件:StructureEndCityPieces.java   
private void loadAndSetup(BlockPos p_186180_1_)
{
    Template template = StructureEndCityPieces.MANAGER.getTemplate((MinecraftServer)null, new ResourceLocation("endcity/" + this.pieceName));
    PlacementSettings placementsettings;

    if (this.overwrite)
    {
        placementsettings = StructureEndCityPieces.OVERWRITE.copy().setRotation(this.rotation);
    }
    else
    {
        placementsettings = StructureEndCityPieces.INSERT.copy().setRotation(this.rotation);
    }

    this.setup(template, p_186180_1_, placementsettings);
}
项目:CustomWorldGen    文件:TileEntityStructure.java   
public boolean save(boolean p_189712_1_)
{
    if (this.mode == TileEntityStructure.Mode.SAVE && !this.worldObj.isRemote && !StringUtils.isNullOrEmpty(this.name))
    {
        BlockPos blockpos = this.getPos().add(this.position);
        WorldServer worldserver = (WorldServer)this.worldObj;
        MinecraftServer minecraftserver = this.worldObj.getMinecraftServer();
        TemplateManager templatemanager = worldserver.getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
        template.takeBlocksFromWorld(this.worldObj, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(this.author);
        return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
    }
    else
    {
        return false;
    }
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
private PotentialPosition generateHallway(TemplateManager manager, World world, BlockPos roomCenter, Rotation rotation)
{           
    Template hallway = getRandomizedHallwayTemplate(manager, world); // get hallway and its center position
    BlockPos hallwayCenter = getHallwayPosition(hallway, roomCenter, rotation);

    for (BlockPos position : hallwayPositions) // check to make sure hallway can spawn. If not, exit.
    {
        if (position.equals(hallwayCenter))
            return null;
    }

    PlacementSettings settings = new PlacementSettings().setRotation(rotation);
    BlockPos hallwayCorner = translateHallwayToCorner(hallway, hallwayCenter, rotation);
    hallway.addBlocksToWorld(world, hallwayCorner, settings); // add hallway into world at translated position
    handleDataBlocks(hallway, world, hallwayCorner, settings);
    hallwayPositions.add(hallwayCenter); // add hallway to hallwayPositions list

    BlockPos potentialPosition = getRoomPosition(getRandomizedDungeonTemplate(manager, world), hallwayCenter, rotation);

    return new PotentialPosition(potentialPosition, rotation);
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
protected BlockPos getHallwayPosition(Template template, BlockPos roomCenter, Rotation rotation)
{
    int x = roomCenter.getX();
    int z = roomCenter.getZ();

    switch (rotation)
    {
        case NONE:
            x += template.getSize().getX() - 1;
            break;
        case CLOCKWISE_90:
            z += template.getSize().getX() - 1;
            break;
        case CLOCKWISE_180:
            x -= template.getSize().getX() - 1;
            break;
        case COUNTERCLOCKWISE_90:
            z -= template.getSize().getX() - 1;
            break;
    }

    return new BlockPos(x, roomCenter.getY(), z);
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
protected BlockPos getRoomPosition(Template template, BlockPos hallwayCenter, Rotation rotation)
{
    int x = hallwayCenter.getX();
    int z = hallwayCenter.getZ();

    switch (rotation)
    {
        case NONE:
            x += template.getSize().getX() - 1;
            break;
        case CLOCKWISE_90:
            z += template.getSize().getZ() - 1;
            break;
        case CLOCKWISE_180:
            x -= template.getSize().getX() - 1;
            break;
        case COUNTERCLOCKWISE_90:
            z -= template.getSize().getZ() - 1;
            break;
    }

    return new BlockPos(x, hallwayCenter.getY(), z);
}
项目:YUNoMakeGoodMap    文件:StructureUtil.java   
private static Template loadTemplate(InputStream is)
{
    if (is == null)
        return null;
    try
    {
        NBTTagCompound nbt = CompressedStreamTools.readCompressed(is);
        Template template = new Template();
        template.read(nbt);
        return template;
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    finally
    {
        if (is != null)
            IOUtils.closeQuietly(is);
    }
    return null;
}
项目:YUNoMakeGoodMap    文件:StructureLoader.java   
@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!
}
项目:Loot-Slash-Conquer    文件:LSCWorldGenerator.java   
public static boolean canSpawnHere(Template template, World world, BlockPos posAboveGround)
{
    int zwidth = template.getSize().getZ();
    int xwidth = template.getSize().getX();

    // check all the corners to see which ones are replaceable
    boolean corner1 = isCornerValid(world, posAboveGround);
    boolean corner2 = isCornerValid(world, posAboveGround.add(xwidth, 0, zwidth));

    // if Y > 20 and all corners pass the test, it's okay to spawn the structure
    return posAboveGround.getY() > 63 && corner1 && corner2;
}
项目:Loot-Slash-Conquer    文件:DungeonRoomPosition.java   
public DungeonRoomPosition(BlockPos pos, Template template, Rotation templateRotation, Rotation side, StructureBoundingBox boundingBox)
{
    this.pos = pos;
    this.template = template;
    this.templateRotation = templateRotation;
    this.side = side;
    this.boundingBox = boundingBox;
}
项目:Loot-Slash-Conquer    文件:Dungeon.java   
/** Generates the staircase underneath the entrance. */
// WORKING
private List<DungeonRoomPosition> generateStaircase(TemplateManager manager, World world, BlockPos entranceCenter)
{
    Template encasedStaircase = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/encased_staircase"));
    Template bottomStaircase = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/bottom_staircase"));
    PlacementSettings settings = new PlacementSettings();
    int depth = 4; // how many staircases are generated?

    List<DungeonRoomPosition> list = null;

    for (int i = 0; i < depth; i++)
    {
        if (i < depth - 1) // make sure we aren't at the last staircase
        {
            BlockPos encasedStaircasePos = DungeonHelper.translateToCorner(encasedStaircase, entranceCenter.add(0, -4 * (i + 1), 0), Rotation.NONE); // get the staircase position; offset by height and multiply by depth.
            encasedStaircase.addBlocksToWorld(world, encasedStaircasePos, new DungeonBlockProcessor(encasedStaircasePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2);
        }
        else // we know this is the bottom staircase, so spawn bottom staircase and store potential rooms.
        {
            BlockPos bottomStaircaseCenteredPos = entranceCenter.add(0, -4 * (depth - 1) + -5, 0);
            BlockPos bottomStaircasePos = DungeonHelper.translateToCorner(bottomStaircase, bottomStaircaseCenteredPos, Rotation.NONE);
            bottomStaircase.addBlocksToWorld(world, bottomStaircasePos, new DungeonBlockProcessor(bottomStaircasePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2);
            roomList.add(DungeonHelper.getStructureBoundingBox(bottomStaircase, Rotation.NONE, bottomStaircaseCenteredPos)); // add StructureBoundingBox to room list. Used to make sure we don't generate rooms inside of other bounding boxes.

            list = this.generatePotentialRooms(manager, world, bottomStaircase, Rotation.NONE, bottomStaircaseCenteredPos, null);
        }
    }

    return list;
}
项目:Loot-Slash-Conquer    文件:Dungeon.java   
/** Generates a room based on the DungeonRoomPosition passed in. */
@Nullable
private List<DungeonRoomPosition> generateRoom(TemplateManager manager, World world, DungeonRoomPosition drp)
{
    Template template = drp.getTemplate();
    PlacementSettings settings = new PlacementSettings().setRotation(drp.getTemplateRotation());
    BlockPos centeredPosition = drp.getPos();
    BlockPos cornerPosition = DungeonHelper.translateToCorner(template, centeredPosition, settings.getRotation());

    template.addBlocksToWorld(world, cornerPosition, new DungeonBlockProcessor(cornerPosition, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2);
    DungeonHelper.handleDataBlocks(template, world, cornerPosition, settings, 1);
    roomList.add(drp.getBoundingBox());

    return this.generatePotentialRooms(manager, world, template, settings.getRotation(), centeredPosition, drp.getSide());
}
项目:Loot-Slash-Conquer    文件:DungeonHelper.java   
public static BlockPos translateWallPos(Template template, BlockPos wallPos, Rotation wallRotation)
{
    int x = wallPos.getX();
    int z = wallPos.getZ();

    if (wallRotation == Rotation.NONE) x += template.getSize().getX() / 2;
    else if (wallRotation == Rotation.CLOCKWISE_90) z += template.getSize().getZ() / 2;
    else if (wallRotation == Rotation.CLOCKWISE_180) x -= template.getSize().getX() / 2;
    else if (wallRotation == Rotation.COUNTERCLOCKWISE_90) z -= template.getSize().getZ() / 2;

    return new BlockPos(x, wallPos.getY(), z);
}
项目:Loot-Slash-Conquer    文件:DungeonHelper.java   
/** Returns the bounding box of the specific template. Used to make sure it doesn't intersect with other rooms. */
public static StructureBoundingBox getStructureBoundingBox(Template template, Rotation rotation, BlockPos center)
{
    int minX = 0;
    int maxX = 0; 
    int minY = 0;
    int maxY = 0;
    int minZ = 0;
    int maxZ = 0;

    // we offset everything by one to get the inner room with walls, ceilings, or floors. Rooms can connect through walls so we want those checks to pass.
    if (rotation == Rotation.NONE || rotation == Rotation.CLOCKWISE_180)
    {
        minX = center.getX() - (template.getSize().getX() / 2) - 1;
        maxX = center.getX() + (template.getSize().getX() / 2) - 1;
        minY = center.getY() + 1;
        maxY = center.getY() + template.getSize().getY() - 1;
        minZ = center.getZ() - (template.getSize().getZ() / 2) - 1;
        maxZ = center.getZ() + (template.getSize().getZ() / 2) - 1;
    }
    else
    {
        minX = center.getX() - (template.getSize().getZ() / 2) - 1;
        maxX = center.getX() + (template.getSize().getZ() / 2) - 1;
        minY = center.getY() + 1;
        maxY = center.getY() + template.getSize().getY() - 1;
        minZ = center.getZ() - (template.getSize().getX() / 2) - 1;
        maxZ = center.getZ() + (template.getSize().getX() / 2) - 1;
    }

    return new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
项目:Loot-Slash-Conquer    文件:DungeonHelper.java   
public static Template getRandomizedDungeonTemplate(TemplateManager manager, World world)
{
    ArrayList<Template> templates = new ArrayList<Template>();

    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/test_room1")));
    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/test_room2")));

    return templates.get((int) (Math.random() * (templates.size())));
}
项目:Loot-Slash-Conquer    文件:DungeonHelper.java   
public static Template getStaircaseTemplate(TemplateManager manager, World world)
{
    ArrayList<Template> templates = new ArrayList<Template>();

    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "staircase1")));

    return templates.get((int) (Math.random() * (templates.size())));
}
项目:Loot-Slash-Conquer    文件:DungeonHelper.java   
/** Translates the given BlockPos to the corner of the structure for spawning. */
public static BlockPos translateToCorner(Template template, BlockPos originalPos, Rotation rotation)
{
    int x = originalPos.getX();
    int z = originalPos.getZ();

    switch (rotation)
    {
        case NONE:
            x -= template.getSize().getX() / 2;
            z -= template.getSize().getZ() / 2;
            break;
        case CLOCKWISE_90:
            x += template.getSize().getZ() / 2;
            z -= template.getSize().getX() / 2;
            break;
        case CLOCKWISE_180:
            x += template.getSize().getX() / 2;
            z += template.getSize().getZ() / 2;
            break;
        case COUNTERCLOCKWISE_90:
            x -= template.getSize().getZ() / 2;
            z += template.getSize().getX() / 2;
            break;
    }

    return new BlockPos(x, originalPos.getY(), z);
}
项目:harshencastle    文件:HarshenTemplateRenderer.java   
public void renderIntoWorld(World world, BlockPos basePos, float partialTicks)
{
    if(!world.isRemote)
        return;
    if(blocks.size() > 30000)
        return;
    for(Template.BlockInfo block : blocks){
        if(block.blockState.getBlock() != Blocks.AIR)
            HarshenClientUtils.renderGhostBlock(block.blockState, basePos.add(block.pos), false, partialTicks);
    }
}
项目:harshencastle    文件:HarshenTemplate.java   
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn)
{
    Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap();
    StructureBoundingBox structureboundingbox = placementIn.getBoundingBox();

    for (Template.BlockInfo template$blockinfo : this.blocks)
    {
        BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos);

        if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos))
        {
            IBlockState iblockstate = template$blockinfo.blockState;

            if (iblockstate.getBlock() instanceof BlockStructure && template$blockinfo.tileentityData != null)
            {
                TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode"));

                if (tileentitystructure$mode == TileEntityStructure.Mode.DATA)
                {
                    map.put(blockpos, template$blockinfo.tileentityData.getString("metadata"));
                }
            }
        }
    }

    return map;
}
项目:harshencastle    文件:HarshenTemplate.java   
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.x));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.y));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.z));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                worldIn.spawnEntity(entity);
            }
        }
    }
}
项目:Solar    文件:ObeliskDecorator.java   
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
    random.setSeed(world.getSeed());
    long good = random.nextLong();
    long succ = random.nextLong();

    good *= x >> 3;
    succ *= z >> 3;
    random.setSeed(good * succ * world.getSeed());
    //Generate
    if(GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity > 0D
            && GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity / 100D > random.nextDouble()) {
        List<AxisAlignedBB> occupied = Lists.newArrayList();
        for(int i = 0; i < GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.size; i++) {
            BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 0, z).toBlockPos());
            int below = random.nextInt(7);
            if(top.getY() > below) {
                top = top.add(0, -below, 0);
            }
            Template obelisk = obelisks.next().load(world);
            Rotation rotation = Rotation.values()[random.nextInt(4)];
            Vector3 vec = Vector3.create(obelisk.getSize()).rotate(rotation);
            AxisAlignedBB obeliskBB = new AxisAlignedBB(top, vec.add(top).toBlockPos()).grow(1);
            if(occupied.stream().noneMatch(bb -> bb.intersects(obeliskBB))) {
                PlacementSettings settings = new PlacementSettings();
                settings.setRotation(rotation);
                settings.setRandom(random);
                obelisk.addBlocksToWorld(world, top, settings);

                occupied.add(obeliskBB);
            }
        }
    }
}
项目:Solar    文件:AshenCubeStructure.java   
private void genCubes(World world, BlockPos pos) {
    //Gen Cube
    BlockPos origin = pos.add(5, 0, 5);
    Template template = Structure.ASHEN_CUBE.load(world);
    boolean loot = GEN_CONFIG.ASHEN_CUBE_STRUCTURE.loot / 100D > random.nextDouble();
    PlacementSettings integrity = new PlacementSettings();
    integrity.setIntegrity(loot ? 1F : 0.35F + 0.45F * random.nextFloat());
    template.addBlocksToWorld(world, origin, integrity);
    integrity.setIntegrity(!loot && random.nextFloat() > 0.45F ? 1F : random.nextFloat());
    Structure.ASHEN_CUBE_.generate(world, origin, integrity);
    //Add loot
    for (int i = 0; i < 6 + random.nextInt(6); i++) {
        loot = GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.loot / 100D > random.nextDouble();
        if (loot) {
            BlockPos inside = origin.add(1 + random.nextInt(4), 1, 1 + random.nextInt(4));
            IBlockState pot = ModBlocks.LARGE_POT.getDefaultState().withProperty(State.POT_VARIANT, random.nextInt(3));
            world.setBlockState(inside, pot);
        }
    }
    //Gen Cubes
    AxisAlignedBB cubeBB = new AxisAlignedBB(origin, origin.add(template.getSize()));
    for(int i = 0; i < GEN_CONFIG.ASHEN_CUBE_STRUCTURE.size; i++) {
        Template cube = nuggets.next().load(world);
        Rotation rotation = Rotation.values()[random.nextInt(4)];
        Vector3 vec = Vector3.create(cube.getSize()).rotate(rotation);
        BlockPos offset = randomVector().add(pos).toBlockPos();
        if(offset.getY() < 1  || (world.canSeeSky(offset) && GEN_CONFIG.ASHEN_CUBE_STRUCTURE.underground)) continue;
        AxisAlignedBB nuggetBB = new AxisAlignedBB(offset, vec.add(offset).toBlockPos());
        if(!nuggetBB.intersects(cubeBB)) {
            PlacementSettings settings = new PlacementSettings();
            settings.setIntegrity(random.nextFloat() > 0.85F ? 0.9F : 0.35F + 0.45F * random.nextFloat());
            settings.setRotation(rotation);
            settings.setRandom(random);
            cube.addBlocksToWorld(world, offset, settings);
        }
    }
}
项目:TheOink    文件:OinkWorldGenerator.java   
private boolean canSpawnHere(Template template, World world, BlockPos pos)
{
    int z = template.getSize().getZ();
    int x = template.getSize().getX();

    boolean corner1 = isCornerValid(world, pos);
    boolean corner2 = isCornerValid(world, pos.add(x, 0, z));

    return pos.getY() > 63 && corner1 && corner2;
}
项目:Backmemed    文件:StructureComponentTemplate.java   
protected void setup(Template p_186173_1_, BlockPos p_186173_2_, PlacementSettings p_186173_3_)
{
    this.template = p_186173_1_;
    this.setCoordBaseMode(EnumFacing.NORTH);
    this.templatePosition = p_186173_2_;
    this.placeSettings = p_186173_3_;
    this.setBoundingBoxFromTemplate();
}
项目:Backmemed    文件:WoodlandMansionPieces.java   
private void func_191129_a(List<WoodlandMansionPieces.MansionTemplate> p_191129_1_, BlockPos p_191129_2_, Rotation p_191129_3_, EnumFacing p_191129_4_, WoodlandMansionPieces.RoomCollection p_191129_5_)
{
    Rotation rotation = Rotation.NONE;
    String s = p_191129_5_.func_191104_a(this.field_191135_b);

    if (p_191129_4_ != EnumFacing.EAST)
    {
        if (p_191129_4_ == EnumFacing.NORTH)
        {
            rotation = rotation.add(Rotation.COUNTERCLOCKWISE_90);
        }
        else if (p_191129_4_ == EnumFacing.WEST)
        {
            rotation = rotation.add(Rotation.CLOCKWISE_180);
        }
        else if (p_191129_4_ == EnumFacing.SOUTH)
        {
            rotation = rotation.add(Rotation.CLOCKWISE_90);
        }
        else
        {
            s = p_191129_5_.func_191099_b(this.field_191135_b);
        }
    }

    BlockPos blockpos = Template.func_191157_a(new BlockPos(1, 0, 0), Mirror.NONE, rotation, 7, 7);
    rotation = rotation.add(p_191129_3_);
    blockpos = blockpos.func_190942_a(p_191129_3_);
    BlockPos blockpos1 = p_191129_2_.add(blockpos.getX(), 0, blockpos.getZ());
    p_191129_1_.add(new WoodlandMansionPieces.MansionTemplate(this.field_191134_a, s, blockpos1, rotation));
}
项目:Backmemed    文件:WorldGenFossils.java   
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L);
    MinecraftServer minecraftserver = worldIn.getMinecraftServer();
    Rotation[] arotation = Rotation.values();
    Rotation rotation = arotation[random.nextInt(arotation.length)];
    int i = random.nextInt(FOSSILS.length);
    TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
    Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
    Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]);
    ChunkPos chunkpos = new ChunkPos(position);
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd());
    PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random);
    BlockPos blockpos = template.transformedSize(rotation);
    int j = random.nextInt(16 - blockpos.getX());
    int k = random.nextInt(16 - blockpos.getZ());
    int l = 256;

    for (int i1 = 0; i1 < blockpos.getX(); ++i1)
    {
        for (int j1 = 0; j1 < blockpos.getX(); ++j1)
        {
            l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k));
        }
    }

    int k1 = Math.max(l - 15 - random.nextInt(10), 10);
    BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation);
    placementsettings.setIntegrity(0.9F);
    template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
    placementsettings.setIntegrity(0.1F);
    template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
    return true;
}
项目:CustomWorldGen    文件:StructureComponentTemplate.java   
protected void setup(Template p_186173_1_, BlockPos p_186173_2_, PlacementSettings p_186173_3_)
{
    this.template = p_186173_1_;
    this.setCoordBaseMode(EnumFacing.NORTH);
    this.templatePosition = p_186173_2_;
    this.placeSettings = p_186173_3_;
    this.setBoundingBoxFromTemplate();
}
项目:CustomWorldGen    文件:WorldGenFossils.java   
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L);
    MinecraftServer minecraftserver = worldIn.getMinecraftServer();
    Rotation[] arotation = Rotation.values();
    Rotation rotation = arotation[random.nextInt(arotation.length)];
    int i = random.nextInt(FOSSILS.length);
    TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
    Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
    Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]);
    ChunkPos chunkpos = new ChunkPos(position);
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd());
    PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random);
    BlockPos blockpos = template.transformedSize(rotation);
    int j = random.nextInt(16 - blockpos.getX());
    int k = random.nextInt(16 - blockpos.getZ());
    int l = 256;

    for (int i1 = 0; i1 < blockpos.getX(); ++i1)
    {
        for (int j1 = 0; j1 < blockpos.getX(); ++j1)
        {
            l = Math.min(l, worldIn.getHeightmapHeight(position.getX() + i1 + j, position.getZ() + j1 + k));
        }
    }

    int k1 = Math.max(l - 15 - random.nextInt(10), 10);
    BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation);
    placementsettings.setIntegrity(0.9F);
    template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4);
    placementsettings.setIntegrity(0.1F);
    template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4);
    return true;
}
项目:Wizardry    文件:IStructure.java   
default boolean isStructureComplete(World world, BlockPos pos) {
    for (Template.BlockInfo info : getStructure().blockInfos()) {
        if (info.blockState == null) continue;
        if (info.blockState.getMaterial() == Material.AIR || info.blockState.getBlock() == Blocks.STRUCTURE_VOID)
            continue;

        BlockPos realPos = info.pos.add(pos).subtract(offsetToCenter());
        IBlockState state = world.getBlockState(realPos);
        if (state != info.blockState) {

            if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
                continue;
            }

            if (info.blockState.getBlock() instanceof BlockStairs && state.getBlock() instanceof BlockStairs
                    && info.blockState.getBlock() == state.getBlock()
                    && info.blockState.getValue(BlockStairs.HALF) == state.getValue(BlockStairs.HALF)
                    && info.blockState.getValue(BlockStairs.SHAPE) == state.getValue(BlockStairs.SHAPE)) {
                if (info.blockState.getValue(BlockStairs.FACING) != state.getValue(BlockStairs.FACING))
                    world.setBlockState(realPos, info.blockState);
                continue;
            }
            return false;
        }
    }
    return true;
}
项目:Wizardry    文件:IStructure.java   
default HashSet<BlockPos> getErroredBlocks(World world, BlockPos pos) {
    HashSet<BlockPos> set = new HashSet<>();

    for (Template.BlockInfo info : getStructure().blockInfos()) {
        if (info.blockState == null) continue;
        if (info.blockState.getMaterial() == Material.AIR || info.blockState.getBlock() == Blocks.STRUCTURE_VOID)
            continue;

        BlockPos realPos = info.pos.add(pos).subtract(offsetToCenter());
        IBlockState state = world.getBlockState(realPos);
        if (state != info.blockState) {

            if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
                continue;
            }

            if (info.blockState.getBlock() instanceof BlockStairs && state.getBlock() instanceof BlockStairs
                    && info.blockState.getBlock() == state.getBlock()
                    && info.blockState.getValue(BlockStairs.HALF) == state.getValue(BlockStairs.HALF)
                    && info.blockState.getValue(BlockStairs.SHAPE) == state.getValue(BlockStairs.SHAPE)) {
                continue;
            }
            set.add(realPos);
        }
    }
    return set;
}
项目:Lost-Eclipse-Outdated    文件:LEWorldGenerator.java   
private boolean canSpawnHere(Template template, World world, BlockPos posAboveGround)
{
    int zwidth = template.getSize().getZ();
    int xwidth = template.getSize().getX();

    // check all the corners to see which ones are replaceable
    boolean corner1 = isCornerValid(world, posAboveGround);
    boolean corner2 = isCornerValid(world, posAboveGround.add(xwidth, 0, zwidth));

    // if Y > 20 and all corners pass the test, it's okay to spawn the structure
    return posAboveGround.getY() > 63 && corner1 && corner2;
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
private Template getRandomizedDungeonTemplate(TemplateManager manager, World world)
{
    ArrayList<Template> templates = new ArrayList<Template>();

    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "loot_room_1")));
    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "loot_room_2")));
    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "loot_room_3")));

    return templates.get((int) (Math.random() * (templates.size())));
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
private Template getRandomizedHallwayTemplate(TemplateManager manager, World world)
{
    ArrayList<Template> templates = new ArrayList<Template>();

    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "hallway_1")));
    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "hallway_2")));
    templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "hallway_3")));

    return templates.get((int) (Math.random() * (templates.size())));
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
protected BlockPos translateToCorner(Template template, BlockPos originalPos, Rotation rotation)
{
    int x = originalPos.getX();
    int z = originalPos.getZ();

    switch (rotation)
    {
        case NONE:
            x -= template.getSize().getX() / 2;
            z -= template.getSize().getZ() / 2;
            break;
        case CLOCKWISE_90:
            x += template.getSize().getX() / 2;
            z -= template.getSize().getZ() / 2;
            break;
        case CLOCKWISE_180:
            x += template.getSize().getX() / 2;
            z += template.getSize().getZ() / 2;
            break;
        case COUNTERCLOCKWISE_90:
            x -= template.getSize().getX() / 2;
            z += template.getSize().getZ() / 2;
            break;
    }

    return new BlockPos(x, originalPos.getY(), z);
}
项目:Lost-Eclipse-Outdated    文件:ProceduralDungeonBase.java   
protected BlockPos translateHallwayToCorner(Template template, BlockPos hallwayCenter, Rotation rotation)
{
    int x = hallwayCenter.getX();
    int z = hallwayCenter.getZ();

    switch (rotation)
    {
        case NONE:
            x -= template.getSize().getX() / 2;
            z -= template.getSize().getZ() / 2;
            break;
        case CLOCKWISE_90:
            x += template.getSize().getZ() / 2;
            z -= template.getSize().getX() / 2;
            break;
        case CLOCKWISE_180:
            x += template.getSize().getX() / 2;
            z += template.getSize().getZ() / 2;
            break;
        case COUNTERCLOCKWISE_90:
            x -= template.getSize().getZ() / 2;
            z += template.getSize().getX() / 2;
            break;
    }

    return new BlockPos(x, hallwayCenter.getY(), z);
}
项目:YUNoMakeGoodMap    文件:StructureUtil.java   
public static Template loadTemplate(ResourceLocation loc, WorldServer world, boolean allowNull)
{
    boolean config = "/config/".equals(loc.getResourceDomain());
    File file = new File(YUNoMakeGoodMap.instance.getStructFolder(), loc.getResourcePath() + ".nbt");

    if (config && file.exists())
    {
        try
        {
            return loadTemplate(new FileInputStream(file));
        }
        catch (FileNotFoundException e) //literally cant happen but whatever..
        {
            e.printStackTrace();
            return allowNull ? null : getDefault(world);
        }
    }
    else
    {
        ResourceLocation res = config ? new ResourceLocation(YUNoMakeGoodMap.MODID + ":" + loc.getResourcePath()) : loc;
        Template ret = loadTemplate(StructureLoader.class.getResourceAsStream("/assets/" + res.getResourceDomain() + "/structures/" + res.getResourcePath() + ".nbt")); //We're on the server we don't have Resource Packs.
        if (ret != null)
            return ret;

        //Cant find it, lets load the one shipped with this mod.
        (new FileNotFoundException(file.toString())).printStackTrace();
        return allowNull ? null : getDefault(world);
    }
}