use of net.minecraft.server.level.WorldServer 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);
}
use of net.minecraft.server.level.WorldServer 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);
}
}
}
}
use of net.minecraft.server.level.WorldServer in project Crazy-Crates by Crazy-Crew.
the class StructureService method createStructuresArray.
/**
* Splits up an area in 32x32x32 structures, creates those and fills an array with them
* @param corners - 2 Edges of the area (order doesn't matter)
* @param author - The listed author of the structure
* @return DefinedStructure[] - The structures in a one dimensional array, sorted by y, z, x (iterates along x, then z, then y)
*/
public static DefinedStructure[] createStructuresArray(Location[] corners, String author) {
if (corners.length != 2)
throw new IllegalArgumentException("An area needs to be set up by exactly 2 opposite edges!");
Location[] normalized = normalizeEdges(corners[0], corners[1]);
WorldServer world = ((CraftWorld) normalized[0].getWorld()).getHandle();
int[] dimensions = getDimensions(normalized);
int[] areas = getAreaSections(dimensions);
DefinedStructure[] structures = new DefinedStructure[areas[0] * areas[1] * areas[2]];
for (int x = 0; x < areas[0]; x++) {
for (int y = 0; y < areas[1]; y++) {
for (int z = 0; z < areas[2]; z++) {
DefinedStructure structure = new DefinedStructure();
int width, height, length;
if (x == areas[0] - 1 && dimensions[0] % 32 != 0)
width = dimensions[0] % 32;
else
width = 32;
if (y == areas[1] - 1 && dimensions[1] % 32 != 0)
height = dimensions[1] % 32;
else
height = 32;
if (z == areas[2] - 1 && dimensions[2] % 32 != 0)
length = dimensions[2] % 32;
else
length = 32;
structure.a(world, new BlockPosition((x * 32) + normalized[0].getBlockX(), (y * 32) + normalized[0].getBlockY(), (z * 32) + normalized[0].getBlockZ()), new BlockPosition(width, height, length), true, Blocks.jb);
structure.a(author);
structures[getYzxIndex(x, y, z, areas[0], areas[2])] = structure;
}
}
}
return structures;
}
use of net.minecraft.server.level.WorldServer in project TheAPI by TheDevTec.
the class v1_18_R2 method packetRespawn.
@Override
public Object packetRespawn(Player player) {
EntityPlayer entityPlayer = (EntityPlayer) getPlayer(player);
WorldServer worldserver = entityPlayer.x();
return new PacketPlayOutRespawn(worldserver.Z(), worldserver.aa(), BiomeManager.a(worldserver.D()), entityPlayer.d.b(), entityPlayer.d.c(), worldserver.ad(), worldserver.C(), true);
}
use of net.minecraft.server.level.WorldServer in project TheAPI by TheDevTec.
the class v1_18_R1 method packetRespawn.
@Override
public Object packetRespawn(Player player) {
EntityPlayer entityPlayer = (EntityPlayer) getPlayer(player);
WorldServer worldserver = entityPlayer.x();
return new PacketPlayOutRespawn(worldserver.q_(), worldserver.aa(), BiomeManager.a(worldserver.E()), entityPlayer.d.b(), entityPlayer.d.c(), worldserver.ad(), worldserver.D(), true);
}
Aggregations