Search in sources :

Example 11 with CraftBlock

use of org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock in project Atlas by funkemunky.

the class BlockBox1_13_R2 method getCollisionBox.

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

Example 12 with CraftBlock

use of org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock in project Atlas by funkemunky.

the class BlockBox1_15_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final net.minecraft.server.v1_15_R1.World world = ((org.bukkit.craftbukkit.v1_15_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_15_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_15_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_15_R1.block.CraftBlock) World(net.minecraft.server.v1_15_R1.World) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 13 with CraftBlock

use of org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock in project Atlas by funkemunky.

the class BlockBox1_16_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_16_R1.World world = ((org.bukkit.craftbukkit.v1_16_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_16_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_16_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_16_R1.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_16_R1(net.minecraft.server.v1_16_R1) CraftWorld(org.bukkit.craftbukkit.v1_16_R1.CraftWorld)

Example 14 with CraftBlock

use of org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock in project Atlas by funkemunky.

the class BlockBox1_16_R2 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final net.minecraft.server.v1_16_R2.World world = ((org.bukkit.craftbukkit.v1_16_R2.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_16_R2.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_16_R2.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_16_R2.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_16_R2(net.minecraft.server.v1_16_R2) World(net.minecraft.server.v1_16_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 15 with CraftBlock

use of org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock 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;
    }
}
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_17_R1.block.CraftBlock) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_17_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_17_R1.block.CraftBlock) Block(net.minecraft.world.level.block.Block) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Aggregations

BlockPos (net.minecraft.core.BlockPos)13 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)10 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)10 ServerLevel (net.minecraft.server.level.ServerLevel)10 CraftBlock (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)6 CraftBlock (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)6 Direction (net.minecraft.core.Direction)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 BlockPlaceContext (net.minecraft.world.item.context.BlockPlaceContext)5 BlockHitResult (net.minecraft.world.phys.BlockHitResult)5 Vec3 (net.minecraft.world.phys.Vec3)5 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)5 CraftBlock (org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock)5 ItemStack (org.bukkit.inventory.ItemStack)5 HitBox (me.deecaad.weaponmechanics.weapon.projectile.HitBox)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 Block (org.bukkit.block.Block)4 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)4 ShortArraySet (it.unimi.dsi.fastutil.shorts.ShortArraySet)3