Search in sources :

Example 6 with World

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;
    }
}
Also used : AxisAlignedBB(net.minecraft.world.phys.AxisAlignedBB) BlockPosition(net.minecraft.core.BlockPosition) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) IBlockData(net.minecraft.world.level.block.state.IBlockData) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) CraftBlock(org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock) Block(net.minecraft.world.level.block.Block) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 7 with World

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);
        }
    }
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) Material(org.bukkit.Material) TileEntityEnderChest(net.minecraft.world.level.block.entity.TileEntityEnderChest) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Example 8 with World

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);
}
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 9 with World

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));
    }
}
Also used : TileEntity(net.minecraft.world.level.block.entity.TileEntity) BlockPosition(net.minecraft.core.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) World(net.minecraft.world.level.World) WChest(com.bgsoftware.wildchests.objects.chests.WChest) Chunk(net.minecraft.world.level.chunk.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Location(org.bukkit.Location)

Example 10 with World

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);
}
Also used : TileEntity(net.minecraft.world.level.block.entity.TileEntity) BlockPosition(net.minecraft.core.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Location(org.bukkit.Location)

Aggregations

BlockPosition (net.minecraft.core.BlockPosition)10 World (net.minecraft.world.level.World)10 TileEntityChest (net.minecraft.world.level.block.entity.TileEntityChest)6 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)3 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)2 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)2 Block (net.minecraft.world.level.block.Block)2 TileEntity (net.minecraft.world.level.block.entity.TileEntity)2 IBlockData (net.minecraft.world.level.block.state.IBlockData)2 AxisAlignedBB (net.minecraft.world.phys.AxisAlignedBB)2 VoxelShape (net.minecraft.world.phys.shapes.VoxelShape)2 Location (org.bukkit.Location)2 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)2 WChest (com.bgsoftware.wildchests.objects.chests.WChest)1 TileEntityEnderChest (net.minecraft.world.level.block.entity.TileEntityEnderChest)1 Chunk (net.minecraft.world.level.chunk.Chunk)1 Material (org.bukkit.Material)1 CraftBlock (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)1 CraftBlock (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)1