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