Search in sources :

Example 16 with VoxelShape

use of net.minecraft.server.v1_13_R2.VoxelShape in project MechanicsMain by WeaponMechanics.

the class v1_13_R2 method getHitBox.

@Override
public HitBox getHitBox(Block block) {
    if (block.isEmpty() || block.isLiquid() || block.isPassable())
        return null;
    BoundingBox boundingBox = block.getBoundingBox();
    HitBox hitBox = new HitBox(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
    hitBox.setBlockHitBox(block);
    if (WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        CraftBlock craftBlock = (CraftBlock) block;
        List<AxisAlignedBB> voxelShape = craftBlock.getNMS().getCollisionShape(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition()).d();
        if (voxelShape.size() > 1) {
            int x = block.getX();
            int y = block.getY();
            int z = block.getZ();
            for (AxisAlignedBB boxPart : voxelShape) {
                hitBox.addVoxelShapePart(new HitBox(x + boxPart.minX, y + boxPart.minY, z + boxPart.minZ, x + boxPart.maxX, y + boxPart.maxY, z + boxPart.maxZ));
            }
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_13_R2.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BoundingBox(org.bukkit.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock)

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