Search in sources :

Example 1 with BlockPosition

use of net.minecraft.core.BlockPosition in project Crazy-Crates by Crazy-Crew.

the class StructureService method createSingleStructure.

/**
 * Creates a single structure of maximum 32x32x32 blocks. If you need a larger area, use {@link #createStructuresArray(Location[], String)}
 * @param corners - The edges of the area (order doesn't matter)
 * @param author - The listed author of the structure
 * @return DefinedStructure - The new structure instance
 */
public static DefinedStructure createSingleStructure(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);
    if (dimensions[0] > 32 || dimensions[1] > 32 || dimensions[2] > 32)
        throw new IllegalArgumentException("A single structure can only be 32x32x32! If you need more, use #createStructuresArea.");
    DefinedStructure structure = new DefinedStructure();
    structure.a(world, new BlockPosition(normalized[0].getBlockX(), normalized[0].getBlockY(), normalized[0].getBlockZ()), new BlockPosition(dimensions[0], dimensions[1], dimensions[2]), true, Blocks.jb);
    structure.a(author);
    return structure;
}
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 2 with BlockPosition

use of net.minecraft.core.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_18_R1 method playChestAction.

@Override
public void playChestAction(Location location, boolean open) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityChest tileChest = (TileEntityChest) getTileEntity(world, blockPosition);
    if (tileChest != null)
        playBlockAction(world, blockPosition, getBlock(getBlock(tileChest)), 1, open ? 1 : 0);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 3 with BlockPosition

use of net.minecraft.core.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_18_R2 method playChestAction.

@Override
public void playChestAction(Location location, boolean open) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityChest tileChest = (TileEntityChest) getBlockEntity(world, blockPosition);
    if (tileChest != null)
        blockEvent(world, blockPosition, getBlock(NMSMappings_v1_18_R2.getBlockState(tileChest)), 1, open ? 1 : 0);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Example 4 with BlockPosition

use of net.minecraft.core.BlockPosition in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_17_R1 method setChestName.

@Override
public void setChestName(Location chest, String name) {
    assert chest.getWorld() != null;
    World world = ((CraftWorld) chest.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(chest.getBlockX(), chest.getBlockY(), chest.getBlockZ());
    TileEntityChest tileEntityChest = (TileEntityChest) world.getTileEntity(blockPosition);
    assert tileEntityChest != null;
    tileEntityChest.setCustomName(CraftChatMessage.fromString(name)[0]);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 5 with BlockPosition

use of net.minecraft.core.BlockPosition in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_17_R1 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.getItemInMainHand();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.world.level.block.state.IBlockData) BlockPosition(net.minecraft.core.BlockPosition) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) WorldServer(net.minecraft.server.level.WorldServer) ItemStack(net.minecraft.world.item.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Aggregations

BlockPosition (net.minecraft.core.BlockPosition)18 World (net.minecraft.world.level.World)10 WorldServer (net.minecraft.server.level.WorldServer)8 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)7 TileEntityChest (net.minecraft.world.level.block.entity.TileEntityChest)6 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)6 IBlockData (net.minecraft.world.level.block.state.IBlockData)5 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)5 Location (org.bukkit.Location)4 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)2 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)2 StringReader (com.mojang.brigadier.StringReader)2 Random (java.util.Random)2 ArgumentBlock (net.minecraft.commands.arguments.blocks.ArgumentBlock)2 ArgumentTileLocation (net.minecraft.commands.arguments.blocks.ArgumentTileLocation)2 EntityPlayer (net.minecraft.server.level.EntityPlayer)2 ItemStack (net.minecraft.world.item.ItemStack)2 Block (net.minecraft.world.level.block.Block)2 TileEntity (net.minecraft.world.level.block.entity.TileEntity)2 DefinedStructure (net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructure)2