Search in sources :

Example 6 with Rotation

use of net.minecraft.util.Rotation in project NetherEx by LogicTechCorp.

the class WorldGenGroundStructure method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed());
    Mirror[] mirrors = Mirror.values();
    Rotation[] rotations = Rotation.values();
    Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
    Rotation rotation = rotations[rand.nextInt(rotations.length)];
    MinecraftServer server = world.getMinecraftServer();
    TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
    Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants));
    PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setRandom(rand);
    BlockPos structureSize = Template.transformedBlockPos(placementSettings, template.getSize());
    BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX() / 2, 96, pos.getZ() - structureSize.getZ() / 2);
    BlockPos spawnPos = WorldGenUtil.getSuitableGroundPos(world, newPos, allowedBlocks, structureSize, 0.8F);
    if (!spawnPos.equals(BlockPos.ORIGIN)) {
        WorldGenUtil.generateStructure(world, spawnPos, rand, template, placementSettings, lootTables, spawnerMobs);
        return true;
    }
    return false;
}
Also used : TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Mirror(net.minecraft.util.Mirror) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template)

Aggregations

Rotation (net.minecraft.util.Rotation)6 BlockPos (net.minecraft.util.math.BlockPos)6 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)6 Template (net.minecraft.world.gen.structure.template.Template)6 MinecraftServer (net.minecraft.server.MinecraftServer)5 Mirror (net.minecraft.util.Mirror)5 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)5 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1