Search in sources :

Example 11 with VoxelShape

use of net.minecraft.server.v1_14_R1.VoxelShape in project Citizens2 by CitizensDev.

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
    return shape.isEmpty() ? new BoundingBox(0, 0, 0, 0, 0, 0) : NMSBoundingBox.wrap(shape.getBoundingBox());
}
Also used : VoxelShape(net.minecraft.server.v1_14_R1.VoxelShape) BoundingBox(net.citizensnpcs.api.util.BoundingBox) WorldServer(net.minecraft.server.v1_14_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld)

Example 12 with VoxelShape

use of net.minecraft.server.v1_14_R1.VoxelShape in project Citizens2 by CitizensDev.

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
    return shape.isEmpty() ? BoundingBox.EMPTY : NMSBoundingBox.wrap(shape.getBoundingBox());
}
Also used : VoxelShape(net.minecraft.server.v1_13_R2.VoxelShape) WorldServer(net.minecraft.server.v1_13_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld)

Example 13 with VoxelShape

use of net.minecraft.server.v1_14_R1.VoxelShape in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method aa.

public static double aa(IBlockAccess var0, BlockPosition var1) {
    BlockPosition var2 = var1.down();
    VoxelShape var3 = var0.getType(var2).getCollisionShape(var0, var2);
    return var2.getY() + (var3.isEmpty() ? 0.0D : var3.c(EnumDirection.EnumAxis.Y));
}
Also used : VoxelShape(net.minecraft.server.v1_16_R3.VoxelShape) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition)

Example 14 with VoxelShape

use of net.minecraft.server.v1_14_R1.VoxelShape 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 15 with VoxelShape

use of net.minecraft.server.v1_14_R1.VoxelShape in project InteractionVisualizer by LOOHP.

the class V1_13 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_13_R1.BlockPosition blockpos = new net.minecraft.server.v1_13_R1.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.getType(blockpos).g(world, blockpos);
    return shape.d().stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
}
Also used : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) CraftChunk(org.bukkit.craftbukkit.v1_13_R1.CraftChunk) Block(org.bukkit.block.Block) CraftWorld(org.bukkit.craftbukkit.v1_13_R1.CraftWorld) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) VoxelShape(net.minecraft.server.v1_13_R1.VoxelShape) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) WorldServer(net.minecraft.server.v1_13_R1.WorldServer) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) CraftMagicNumbers(org.bukkit.craftbukkit.v1_13_R1.util.CraftMagicNumbers) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) PacketType(com.comphenix.protocol.PacketType) EntityItem(net.minecraft.server.v1_13_R1.EntityItem) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) CraftItem(org.bukkit.craftbukkit.v1_13_R1.entity.CraftItem) VoxelShape(net.minecraft.server.v1_13_R1.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_13_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_13_R1.CraftWorld)

Aggregations

PacketContainer (com.comphenix.protocol.events.PacketContainer)7 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)7 BoundingBox (com.loohp.interactionvisualizer.objectholders.BoundingBox)7 ChunkPosition (com.loohp.interactionvisualizer.objectholders.ChunkPosition)7 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)7 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)7 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)7 ValuePairs (com.loohp.interactionvisualizer.objectholders.ValuePairs)7 WrappedIterable (com.loohp.interactionvisualizer.objectholders.WrappedIterable)7 List (java.util.List)7 Collectors (java.util.stream.Collectors)7 Material (org.bukkit.Material)7 World (org.bukkit.World)7 Block (org.bukkit.block.Block)7 Entity (org.bukkit.entity.Entity)7 Item (org.bukkit.entity.Item)7 EquipmentSlot (org.bukkit.inventory.EquipmentSlot)7 ItemStack (org.bukkit.inventory.ItemStack)7 PacketType (com.comphenix.protocol.PacketType)4 ItemSlot (com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot)4