use of net.minecraft.core.BlockPosition in project SSB-OneBlock by BG-Software-LLC.
the class NMSAdapter_v1_18_R1 method simulateToolBreak.
@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
ItemStack itemStack = entityPlayer.er();
WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
IBlockData blockData = worldServer.a_(blockPosition);
itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
use of net.minecraft.core.BlockPosition in project Atlas by funkemunky.
the class BlockBox1_17_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
final World world = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
IBlockData iblockData = ((CraftBlock) block).getNMS();
Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
List<AxisAlignedBB> boxes = shape.toList();
if (boxes.size() == 0) {
return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f));
}
return complexBox;
}
}
use of net.minecraft.core.BlockPosition in project SSB-OneBlock by BG-Software-LLC.
the class NMSAdapter_v1_18_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.c_(blockPosition);
assert tileEntityChest != null;
tileEntityChest.a(CraftChatMessage.fromString(name)[0]);
}
use of net.minecraft.core.BlockPosition in project SSB-OneBlock by BG-Software-LLC.
the class NMSAdapter_v1_18_R1 method setBlock.
@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
assert location.getWorld() != null;
WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
worldServer.m(blockPosition);
location.getBlock().setType(type);
if (nbt != null) {
try {
ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
IBlockData blockData = argumentBlock.b();
if (blockData != null) {
ArgumentTileLocation tileLocation = new ArgumentTileLocation(blockData, argumentBlock.a().keySet(), argumentBlock.c());
tileLocation.a(worldServer, blockPosition, 2);
worldServer.a(blockPosition, tileLocation.a().b());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
use of net.minecraft.core.BlockPosition in project SSB-OneBlock by BG-Software-LLC.
the class NMSAdapter_v1_17_R1 method setBlock.
@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
assert location.getWorld() != null;
WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
worldServer.removeTileEntity(blockPosition);
location.getBlock().setType(type);
if (nbt != null) {
try {
ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
ArgumentTileLocation tileLocation = new ArgumentTileLocation(argumentBlock.getBlockData(), argumentBlock.getStateMap().keySet(), argumentBlock.c());
tileLocation.a(worldServer, blockPosition, 2);
worldServer.update(blockPosition, tileLocation.a().getBlock());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Aggregations