use of net.minecraft.server.level.WorldServer 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.server.level.WorldServer in project InteractionVisualizer by LOOHP.
the class V1_17 method getBoundingBoxes.
@SuppressWarnings("unchecked")
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
net.minecraft.core.BlockPosition blockpos = new net.minecraft.core.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
try {
VoxelShape shape = (VoxelShape) blockDataGetShape.invoke(worldServerGetType.invoke(blockpos), world, blockpos);
return ((List<AxisAlignedBB>) voxelShapeGetAABBList.invoke(shape)).stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
} catch (Exception e) {
List<BoundingBox> boxes = new ArrayList<>();
boxes.add(BoundingBox.of(pos.getBlock()));
return boxes;
}
}
use of net.minecraft.server.level.WorldServer in project InteractionVisualizer by LOOHP.
the class V1_18 method getBoundingBoxes.
@SuppressWarnings("unchecked")
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
net.minecraft.core.BlockPosition blockpos = new net.minecraft.core.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
VoxelShape shape = world.a_(blockpos).j(world, blockpos);
try {
return ((List<AxisAlignedBB>) voxelShapeGetAABBList.invoke(shape)).stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
} catch (Exception e) {
List<BoundingBox> boxes = new ArrayList<>();
boxes.add(BoundingBox.of(pos.getBlock()));
return boxes;
}
}
use of net.minecraft.server.level.WorldServer in project InteractionVisualizer by LOOHP.
the class V1_18_2 method getBoundingBoxes.
@SuppressWarnings("unchecked")
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
net.minecraft.core.BlockPosition blockpos = new net.minecraft.core.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
VoxelShape shape = world.a_(blockpos).j(world, blockpos);
try {
return ((List<AxisAlignedBB>) voxelShapeGetAABBList.invoke(shape)).stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
} catch (Exception e) {
List<BoundingBox> boxes = new ArrayList<>();
boxes.add(BoundingBox.of(pos.getBlock()));
return boxes;
}
}
use of net.minecraft.server.level.WorldServer 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