Search in sources :

Example 31 with SimpleCollisionBox

use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox 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)

Example 32 with SimpleCollisionBox

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

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

the class BlockBox1_14_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_14_R1.World world = ((org.bukkit.craftbukkit.v1_14_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_14_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_14_R1.Block vblock = iblockData.getBlock();
    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.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
        }
        return complexBox;
    }
}
Also used : ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_14_R1(net.minecraft.server.v1_14_R1)

Example 34 with SimpleCollisionBox

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

the class BlockBox1_16_R3 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final net.minecraft.server.v1_16_R3.World world = ((org.bukkit.craftbukkit.v1_16_R3.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_16_R3.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_16_R3.Block vblock = iblockData.getBlock();
    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.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
        }
        return complexBox;
    }
}
Also used : World(net.minecraft.server.v1_16_R3.World) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_16_R3(net.minecraft.server.v1_16_R3) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 35 with SimpleCollisionBox

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

the class BlockBox1_7_R4 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_7_R4.World world = ((org.bukkit.craftbukkit.v1_7_R4.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_7_R4.Block vblock = CraftMagicNumbers.getBlock(block);
    vblock.a(world, x, y, z, collide, boxes, null);
    if (boxes.size() == 0) {
        AxisAlignedBB box = vblock.a(world, x, y, z);
        return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
    } 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_7_R4.AxisAlignedBB) ArrayList(java.util.ArrayList) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox)

Aggregations

SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)39 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)20 ArrayList (java.util.ArrayList)11 KLocation (cc.funkemunky.api.utils.KLocation)8 CollisionBox (cc.funkemunky.api.utils.world.CollisionBox)7 Block (org.bukkit.block.Block)7 Packet (dev.brighten.anticheat.check.api.Packet)6 Location (org.bukkit.Location)6 Vector (org.bukkit.util.Vector)6 WrappedInFlyingPacket (cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket)5 WrappedInUseEntityPacket (cc.funkemunky.api.tinyprotocol.packet.in.WrappedInUseEntityPacket)4 RayCollision (cc.funkemunky.api.utils.world.types.RayCollision)4 AxisAlignedBB (dev.brighten.anticheat.utils.AxisAlignedBB)3 Vec3D (dev.brighten.anticheat.utils.Vec3D)3 lombok.val (lombok.val)3 Material (org.bukkit.Material)3 Entity (org.bukkit.entity.Entity)3 ProtocolVersion (cc.funkemunky.api.tinyprotocol.api.ProtocolVersion)2 WrappedInBlockPlacePacket (cc.funkemunky.api.tinyprotocol.packet.in.WrappedInBlockPlacePacket)2 BlockData (cc.funkemunky.api.utils.world.BlockData)2