Search in sources :

Example 16 with ComplexCollisionBox

use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.

the class BlockBox1_10_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_10_R1.World world = ((org.bukkit.craftbukkit.v1_10_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    final AxisAlignedBB collide = BlockBoxManager.cbox.copy().offset(x, y, z).toAxisAlignedBB();
    List<AxisAlignedBB> boxes = new ArrayList<>();
    net.minecraft.server.v1_10_R1.Block vblock = CraftMagicNumbers.getBlock(block);
    BlockPosition blockPos = new BlockPosition(x, y, z);
    vblock.a(vblock.getBlockData(), world, blockPos, collide, boxes, null);
    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.server.v1_10_R1.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) ArrayList(java.util.ArrayList) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox)

Example 17 with ComplexCollisionBox

use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.

the class BlockBox1_13_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_13_R1.World world = ((org.bukkit.craftbukkit.v1_13_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_13_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_13_R1.Block vblock = iblockData.getBlock();
    BlockPosition blockPos = new BlockPosition(x, y, z);
    VoxelShape shape = vblock.a(iblockData, (IBlockAccess) world, blockPos);
    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 : ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_13_R1(net.minecraft.server.v1_13_R1)

Example 18 with ComplexCollisionBox

use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox 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 19 with ComplexCollisionBox

use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.

the class BlockBox1_18_R2 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final World world = ((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) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) IBlockData(net.minecraft.world.level.block.state.IBlockData) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BlockPosition(net.minecraft.core.BlockPosition) CraftBlock(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) Block(net.minecraft.world.level.block.Block) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Example 20 with ComplexCollisionBox

use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.

the class DynamicFence method fetch.

@Override
public CollisionBox fetch(ProtocolVersion version, Block b) {
    ComplexCollisionBox box = new ComplexCollisionBox(new SimpleCollisionBox(min, 0, min, max, 1.5, max));
    boolean east = fenceConnects(version, b, BlockFace.EAST);
    boolean north = fenceConnects(version, b, BlockFace.NORTH);
    boolean south = fenceConnects(version, b, BlockFace.SOUTH);
    boolean west = fenceConnects(version, b, BlockFace.WEST);
    if (east)
        box.add(new SimpleCollisionBox(max, 0, min, 1, 1.5, max));
    if (west)
        box.add(new SimpleCollisionBox(0, 0, min, max, 1.5, max));
    if (north)
        box.add(new SimpleCollisionBox(min, 0, 0, max, 1.5, min));
    if (south)
        box.add(new SimpleCollisionBox(min, 0, max, max, 1.5, 1));
    return box;
}
Also used : SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox)

Aggregations

ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)21 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)21 ArrayList (java.util.ArrayList)9 BlockPosition (net.minecraft.core.BlockPosition)3 World (net.minecraft.world.level.World)3 Block (net.minecraft.world.level.block.Block)3 IBlockData (net.minecraft.world.level.block.state.IBlockData)3 AxisAlignedBB (net.minecraft.world.phys.AxisAlignedBB)3 VoxelShape (net.minecraft.world.phys.shapes.VoxelShape)3 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1 AxisAlignedBB (net.minecraft.server.v1_11_R1.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)1 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)1 net.minecraft.server.v1_13_R1 (net.minecraft.server.v1_13_R1)1 AxisAlignedBB (net.minecraft.server.v1_13_R2.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)1 VoxelShape (net.minecraft.server.v1_13_R2.VoxelShape)1 net.minecraft.server.v1_14_R1 (net.minecraft.server.v1_14_R1)1