Search in sources :

Example 31 with CraftBlock

use of org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock in project MechanicsMain by WeaponMechanics.

the class v1_15_R1 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_15_R1.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BoundingBox(org.bukkit.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock)

Example 32 with CraftBlock

use of org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock in project Mohist by MohistMC.

the class CraftBlockStates method getBlockState.

public static BlockState getBlockState(Block block) {
    Preconditions.checkNotNull(block, "block is null");
    CraftBlock craftBlock = (CraftBlock) block;
    CraftWorld world = (CraftWorld) block.getWorld();
    BlockPos blockPosition = craftBlock.getPosition();
    net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS();
    BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
    CraftBlockState blockState = getBlockState(world, blockPosition, blockData, tileEntity);
    // Inject the block's generator access
    blockState.setWorldHandle(craftBlock.getHandle());
    return blockState;
}
Also used : BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) SculkSensorBlockEntity(net.minecraft.world.level.block.entity.SculkSensorBlockEntity) PistonMovingBlockEntity(net.minecraft.world.level.block.piston.PistonMovingBlockEntity)

Aggregations

BlockPos (net.minecraft.core.BlockPos)14 ServerLevel (net.minecraft.server.level.ServerLevel)11 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)9 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)9 Direction (net.minecraft.core.Direction)6 CraftBlock (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)6 CraftBlock (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)6 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 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 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)4 ShortArraySet (it.unimi.dsi.fastutil.shorts.ShortArraySet)3 ClientboundSectionBlocksUpdatePacket (net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket)3