use of net.minecraft.world.level.World in project Atlas by funkemunky.
the class BlockBox1_18_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
final World world = ((org.bukkit.craftbukkit.v1_18_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
IBlockData iblockData = ((CraftBlock) block).getNMS();
Block vblock = iblockData.b();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
List<AxisAlignedBB> boxes = shape.d();
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.world.level.World in project Crazy-Crates by Crazy-Crew.
the class NMS_Support method openChest.
@Override
public void openChest(Block block, boolean open) {
Material type = block.getType();
if (type == Material.CHEST || type == Material.TRAPPED_CHEST || type == Material.ENDER_CHEST) {
World world = ((CraftWorld) block.getWorld()).getHandle();
BlockPosition position = new BlockPosition(block.getX(), block.getY(), block.getZ());
if (block.getType() == Material.ENDER_CHEST) {
TileEntityEnderChest tileChest = (TileEntityEnderChest) world.getBlockEntity(position, false);
world.a(position, tileChest.q(), 1, open ? 1 : 0);
} else {
TileEntityChest tileChest = (TileEntityChest) world.getBlockEntity(position, false);
world.a(position, tileChest.q(), 1, open ? 1 : 0);
}
}
}
use of net.minecraft.world.level.World in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_17_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) world.getTileEntity(blockPosition);
if (tileChest != null)
world.playBlockAction(blockPosition, tileChest.getBlock().getBlock(), 1, open ? 1 : 0);
}
use of net.minecraft.world.level.World in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_17_R1 method updateTileEntity.
@Override
public void updateTileEntity(Chest chest) {
Location loc = chest.getLocation();
World world = ((CraftWorld) loc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
TileEntity tileEntity = world.getTileEntity(blockPosition);
TileEntityWildChest tileEntityWildChest;
if (tileEntity instanceof TileEntityWildChest) {
tileEntityWildChest = (TileEntityWildChest) tileEntity;
((WChest) chest).setTileEntityContainer(tileEntityWildChest);
} else {
tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
world.removeTileEntity(blockPosition);
world.setTileEntity(tileEntityWildChest);
Chunk chunk = world.getChunkAtWorldCoords(blockPosition);
world.a(CREATE_TICKING_BLOCK.invoke(chunk, tileEntityWildChest, tileEntityWildChest));
}
}
use of net.minecraft.world.level.World in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_17_R1 method removeTileEntity.
@Override
public void removeTileEntity(Chest chest) {
Location loc = chest.getLocation();
World world = ((CraftWorld) loc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
TileEntity currentTileEntity = world.getTileEntity(blockPosition);
if (currentTileEntity instanceof TileEntityWildChest)
world.removeTileEntity(blockPosition);
}
Aggregations