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;
}
Aggregations