Search in sources :

Example 11 with UnsafeList

use of org.bukkit.craftbukkit.v1_17_R1.util.UnsafeList in project MyPet by xXKeyleXx.

the class PlatformHelper method getBlockBBsInBB.

@SuppressWarnings("unchecked")
public List getBlockBBsInBB(net.minecraft.server.v1_16_R1.World world, AxisAlignedBB axisalignedbb) {
    UnsafeList unsafeList = new UnsafeList();
    int minX = MathHelper.floor(axisalignedbb.minX);
    int maxX = (int) Math.ceil(axisalignedbb.maxX);
    int minY = MathHelper.floor(axisalignedbb.minY);
    int maxY = (int) Math.ceil(axisalignedbb.maxY);
    int minZ = MathHelper.floor(axisalignedbb.minZ);
    int maxZ = (int) Math.ceil(axisalignedbb.maxZ);
    VoxelShape vec3d;
    boolean isEmpty;
    for (int x = minX; x <= maxX; x++) {
        for (int z = minZ; z <= maxZ; z++) {
            if (((ChunkProviderServer) world.getChunkProvider()).isLoaded(x >> 4, z >> 4)) {
                for (int y = minY - 1; y <= maxY; y++) {
                    BlockPosition bp = new BlockPosition(x, y, z);
                    IBlockData blockData = world.getType(bp);
                    if (blockData != null && blockData.getMaterial().isSolid()) {
                        vec3d = blockData.getCollisionShape(world, bp);
                        isEmpty = vec3d.isEmpty();
                        if (!isEmpty) {
                            for (AxisAlignedBB bb : vec3d.d()) {
                                if (bb.a(bp).c(axisalignedbb)) {
                                    unsafeList.add(bb);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return unsafeList;
}
Also used : UnsafeList(org.bukkit.craftbukkit.v1_16_R1.util.UnsafeList)

Example 12 with UnsafeList

use of org.bukkit.craftbukkit.v1_17_R1.util.UnsafeList in project MyPet by xXKeyleXx.

the class PlatformHelper method getBlockBBsInBB.

public List getBlockBBsInBB(net.minecraft.world.level.Level world, AABB axisalignedbb) {
    UnsafeList unsafeList = new UnsafeList();
    int minX = Mth.floor(axisalignedbb.minX);
    int maxX = (int) Math.ceil(axisalignedbb.maxX);
    int minY = Mth.floor(axisalignedbb.minY);
    int maxY = (int) Math.ceil(axisalignedbb.maxY);
    int minZ = Mth.floor(axisalignedbb.minZ);
    int maxZ = (int) Math.ceil(axisalignedbb.maxZ);
    VoxelShape vec3d;
    boolean isEmpty;
    for (int x = minX; x <= maxX; x++) {
        for (int z = minZ; z <= maxZ; z++) {
            if (((ServerChunkCache) world.getChunkSource()).hasChunk(x >> 4, z >> 4)) {
                for (int y = minY - 1; y <= maxY; y++) {
                    BlockPos bp = new BlockPos(x, y, z);
                    BlockState blockData = world.getBlockState(bp);
                    if (blockData != null && blockData.getMaterial().isSolid()) {
                        vec3d = blockData.getCollisionShape(world, bp);
                        isEmpty = vec3d.isEmpty();
                        if (!isEmpty) {
                            for (AABB bb : vec3d.toAabbs()) {
                                if (bb.move(bp).intersects(axisalignedbb)) {
                                    unsafeList.add(bb);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return unsafeList;
}
Also used : VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) UnsafeList(org.bukkit.craftbukkit.v1_17_R1.util.UnsafeList) ServerChunkCache(net.minecraft.server.level.ServerChunkCache) AABB(net.minecraft.world.phys.AABB)

Example 13 with UnsafeList

use of org.bukkit.craftbukkit.v1_17_R1.util.UnsafeList in project MyPet by xXKeyleXx.

the class PlatformHelper method getBlockBBsInBB.

public List getBlockBBsInBB(net.minecraft.server.v1_16_R3.World world, AxisAlignedBB axisalignedbb) {
    UnsafeList unsafeList = new UnsafeList();
    int minX = MathHelper.floor(axisalignedbb.minX);
    int maxX = (int) Math.ceil(axisalignedbb.maxX);
    int minY = MathHelper.floor(axisalignedbb.minY);
    int maxY = (int) Math.ceil(axisalignedbb.maxY);
    int minZ = MathHelper.floor(axisalignedbb.minZ);
    int maxZ = (int) Math.ceil(axisalignedbb.maxZ);
    VoxelShape vec3d;
    boolean isEmpty;
    for (int x = minX; x <= maxX; x++) {
        for (int z = minZ; z <= maxZ; z++) {
            if (((ChunkProviderServer) world.getChunkProvider()).isLoaded(x >> 4, z >> 4)) {
                for (int y = minY - 1; y <= maxY; y++) {
                    BlockPosition bp = new BlockPosition(x, y, z);
                    IBlockData blockData = world.getType(bp);
                    if (blockData != null && blockData.getMaterial().isSolid()) {
                        vec3d = blockData.getCollisionShape(world, bp);
                        isEmpty = vec3d.isEmpty();
                        if (!isEmpty) {
                            for (AxisAlignedBB bb : vec3d.d()) {
                                if (bb.a(bp).c(axisalignedbb)) {
                                    unsafeList.add(bb);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return unsafeList;
}
Also used : UnsafeList(org.bukkit.craftbukkit.v1_16_R3.util.UnsafeList)

Aggregations

BlockPos (net.minecraft.core.BlockPos)2 ServerChunkCache (net.minecraft.server.level.ServerChunkCache)2 BlockState (net.minecraft.world.level.block.state.BlockState)2 AABB (net.minecraft.world.phys.AABB)2 VoxelShape (net.minecraft.world.phys.shapes.VoxelShape)2 UnsafeList (org.bukkit.craftbukkit.v1_10_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_11_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_12_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_16_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_16_R3.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_17_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_18_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_8_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_8_R2.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_8_R3.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_9_R1.util.UnsafeList)1 UnsafeList (org.bukkit.craftbukkit.v1_9_R2.util.UnsafeList)1