Search in sources :

Example 16 with WorldServer

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);
}
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 17 with WorldServer

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);
            }
        }
    }
}
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 18 with WorldServer

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;
}
Also used : DefinedStructure(net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructure) BlockPosition(net.minecraft.core.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) Location(org.bukkit.Location)

Example 19 with WorldServer

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);
}
Also used : EntityPlayer(net.minecraft.server.level.EntityPlayer) WorldServer(net.minecraft.server.level.WorldServer) PacketPlayOutRespawn(net.minecraft.network.protocol.game.PacketPlayOutRespawn)

Example 20 with WorldServer

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);
}
Also used : EntityPlayer(net.minecraft.server.level.EntityPlayer) WorldServer(net.minecraft.server.level.WorldServer) PacketPlayOutRespawn(net.minecraft.network.protocol.game.PacketPlayOutRespawn)

Aggregations

WorldServer (net.minecraft.server.level.WorldServer)27 EntityItem (net.minecraft.world.entity.item.EntityItem)9 BlockPosition (net.minecraft.core.BlockPosition)8 EntityPlayer (net.minecraft.server.level.EntityPlayer)7 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)6 Field (java.lang.reflect.Field)5 PacketPlayOutSpawnEntity (net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity)5 Entity (net.minecraft.world.entity.Entity)5 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)5 Method (java.lang.reflect.Method)4 World (org.bukkit.World)4 LivingEntity (org.bukkit.entity.LivingEntity)4 PacketType (com.comphenix.protocol.PacketType)3 PacketContainer (com.comphenix.protocol.events.PacketContainer)3 InteractionVisualizer (com.loohp.interactionvisualizer.InteractionVisualizer)3 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)3 BoundingBox (com.loohp.interactionvisualizer.objectholders.BoundingBox)3 ChunkPosition (com.loohp.interactionvisualizer.objectholders.ChunkPosition)3 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)3 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)3