Search in sources :

Example 1 with DefinedStructureInfo

use of net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureInfo in project Crazy-Crates by Crazy-Crew.

the class StructureService method insertSingleStructure.

/**
 * Pastes a single structure into the world
 * @param structure - The structure to be pasted
 * @param startEdge - The starting corner with the lowest x, y, z coordinates
 * @param rotation - You may rotate the structure by 90 degrees steps
 */
public static void insertSingleStructure(DefinedStructure structure, Location startEdge, EnumBlockRotation rotation) {
    WorldServer world = ((CraftWorld) startEdge.getWorld()).getHandle();
    DefinedStructureInfo structInfo = new DefinedStructureInfo().a(EnumBlockMirror.a).a(rotation).a(false).a().c(false).a(new Random());
    BlockPosition blockPosition = new BlockPosition(startEdge.getBlockX(), startEdge.getBlockY(), startEdge.getBlockZ());
    structure.a(world, blockPosition, blockPosition, structInfo, random, 0);
}
Also used : Random(java.util.Random) BlockPosition(net.minecraft.core.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) DefinedStructureInfo(net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureInfo)

Example 2 with DefinedStructureInfo

use of net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureInfo in project Crazy-Crates by Crazy-Crew.

the class StructureService method insertStructuresArray.

/**
 * Pastes an array of structures into the world
 * @param structures - A one dimensional array of structures, sorted by y, z, x (iterates along x, then z, then y)
 * @param dimensions - The width, height, length of the complete resulting area
 * @param startEdge - The starting edge with the lowest x, y, z coordinates
 * @param rotation - You may rotate the structure by 90 degrees steps
 */
public static void insertStructuresArray(DefinedStructure[] structures, int[] dimensions, Location startEdge, EnumBlockRotation rotation) {
    int[] areas = getAreaSections(dimensions);
    WorldServer world = ((CraftWorld) startEdge.getWorld()).getHandle();
    for (int x = 0; x < areas[0]; x++) {
        for (int y = 0; y < areas[1]; y++) {
            for (int z = 0; z < areas[2]; z++) {
                DefinedStructureInfo structInfo = new DefinedStructureInfo().a(EnumBlockMirror.a).a(rotation).a(false).a().c(false).a(new Random());
                BlockPosition pos = new BlockPosition((x * 32) + startEdge.getBlockX(), (y * 32) + startEdge.getBlockY(), (z * 32) + startEdge.getBlockZ());
                structures[getYzxIndex(x, y, z, areas[0], areas[2])].a(world, pos, pos, structInfo, random, z);
            }
        }
    }
}
Also used : Random(java.util.Random) BlockPosition(net.minecraft.core.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) DefinedStructureInfo(net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureInfo)

Aggregations

Random (java.util.Random)2 BlockPosition (net.minecraft.core.BlockPosition)2 WorldServer (net.minecraft.server.level.WorldServer)2 DefinedStructureInfo (net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureInfo)2 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)2