Search in sources :

Example 91 with BlockHitResult

use of net.minecraft.world.phys.BlockHitResult in project AlexsMobs by Alex-the-666.

the class EntityVoidWormShot method onImpact.

/**
 * Called when this EntityFireball hits a block or entity.
 */
protected void onImpact(HitResult result) {
    HitResult.Type raytraceresult$type = result.getType();
    if (raytraceresult$type == HitResult.Type.ENTITY) {
        this.onEntityHit((EntityHitResult) result);
    } else if (raytraceresult$type == HitResult.Type.BLOCK) {
        this.onHitBlock((BlockHitResult) result);
    }
    this.playSound(SoundEvents.GLASS_BREAK, 1F, 0.5F);
    Entity entity = this.getShooter();
}
Also used : BlockHitResult(net.minecraft.world.phys.BlockHitResult) EntityHitResult(net.minecraft.world.phys.EntityHitResult) HitResult(net.minecraft.world.phys.HitResult) LivingEntity(net.minecraft.world.entity.LivingEntity) Entity(net.minecraft.world.entity.Entity) BlockHitResult(net.minecraft.world.phys.BlockHitResult)

Example 92 with BlockHitResult

use of net.minecraft.world.phys.BlockHitResult in project AlexsMobs by Alex-the-666.

the class AnimalAILeapRandomly method hasLineOfSightBlock.

private boolean hasLineOfSightBlock(Vec3 blockVec) {
    Vec3 Vector3d = new Vec3(mob.getX(), mob.getEyeY(), mob.getZ());
    BlockHitResult result = mob.level.clip(new ClipContext(Vector3d, blockVec, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mob));
    return blockVec.distanceTo(result.getLocation()) < 1.2F;
}
Also used : ClipContext(net.minecraft.world.level.ClipContext) Vec3(net.minecraft.world.phys.Vec3) BlockHitResult(net.minecraft.world.phys.BlockHitResult)

Example 93 with BlockHitResult

use of net.minecraft.world.phys.BlockHitResult in project AlexsMobs by Alex-the-666.

the class EntityMungus method hasLineOfSightMushroom.

private boolean hasLineOfSightMushroom(BlockPos destinationBlock) {
    Vec3 Vector3d = new Vec3(this.getX(), this.getEyeY(), this.getZ());
    Vec3 blockVec = net.minecraft.world.phys.Vec3.atCenterOf(destinationBlock);
    BlockHitResult result = this.level.clip(new ClipContext(Vector3d, blockVec, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
    return result.getBlockPos().equals(destinationBlock);
}
Also used : ClipContext(net.minecraft.world.level.ClipContext) Vec3(net.minecraft.world.phys.Vec3) BlockHitResult(net.minecraft.world.phys.BlockHitResult)

Example 94 with BlockHitResult

use of net.minecraft.world.phys.BlockHitResult in project AlexsMobs by Alex-the-666.

the class EntityToucan method hasLineOfSightSapling.

private boolean hasLineOfSightSapling(BlockPos destinationBlock) {
    Vec3 Vector3d = new Vec3(this.getX(), this.getEyeY(), this.getZ());
    Vec3 blockVec = net.minecraft.world.phys.Vec3.atCenterOf(destinationBlock);
    BlockHitResult result = this.level.clip(new ClipContext(Vector3d, blockVec, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
    return result.getBlockPos().equals(destinationBlock);
}
Also used : Vec3(net.minecraft.world.phys.Vec3) BlockHitResult(net.minecraft.world.phys.BlockHitResult)

Example 95 with BlockHitResult

use of net.minecraft.world.phys.BlockHitResult in project AlexsMobs by Alex-the-666.

the class MantisShrimpAIBreakBlocks method hasLineOfSightBlock.

private boolean hasLineOfSightBlock(BlockPos destinationBlock) {
    Vec3 Vector3d = new Vec3(mantisShrimp.getX(), mantisShrimp.getEyeY(), mantisShrimp.getZ());
    Vec3 blockVec = net.minecraft.world.phys.Vec3.atCenterOf(destinationBlock);
    BlockHitResult result = mantisShrimp.level.clip(new ClipContext(Vector3d, blockVec, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mantisShrimp));
    return result.getBlockPos().equals(destinationBlock);
}
Also used : ClipContext(net.minecraft.world.level.ClipContext) Vec3(net.minecraft.world.phys.Vec3) BlockHitResult(net.minecraft.world.phys.BlockHitResult)

Aggregations

BlockHitResult (net.minecraft.world.phys.BlockHitResult)181 BlockPos (net.minecraft.core.BlockPos)117 Vec3 (net.minecraft.world.phys.Vec3)79 BlockState (net.minecraft.world.level.block.state.BlockState)66 ItemStack (net.minecraft.world.item.ItemStack)63 HitResult (net.minecraft.world.phys.HitResult)51 Direction (net.minecraft.core.Direction)46 Level (net.minecraft.world.level.Level)41 ClipContext (net.minecraft.world.level.ClipContext)33 Player (net.minecraft.world.entity.player.Player)32 ServerLevel (net.minecraft.server.level.ServerLevel)23 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)20 Entity (net.minecraft.world.entity.Entity)19 InteractionHand (net.minecraft.world.InteractionHand)18 BlockPlaceContext (net.minecraft.world.item.context.BlockPlaceContext)18 ServerPlayer (net.minecraft.server.level.ServerPlayer)17 LivingEntity (net.minecraft.world.entity.LivingEntity)17 AABB (net.minecraft.world.phys.AABB)17 EntityHitResult (net.minecraft.world.phys.EntityHitResult)17 Minecraft (net.minecraft.client.Minecraft)16