E
- The type of the extent for the block raypublic static class BlockRay.BlockRayBuilder<E extends Extent> extends Object implements Iterable<BlockRayHit<E>>
Iterable
, making it
useful for 'advanced for loops'. Use BlockRay.from(Location)
to get an instance.Modifier and Type | Method and Description |
---|---|
BlockRay<E> |
build()
Returns a block ray build from the settings.
|
BlockRay.BlockRayBuilder<E> |
direction(com.flowpowered.math.vector.Vector3d direction)
Sets the direction.
|
BlockRay.BlockRayBuilder<E> |
distanceLimit(double distanceLimit)
Sets the maximum distance before stopping.
|
Optional<BlockRayHit<E>> |
end()
Iterates the built block ray until the end
and returns the last hit, if any.
|
Iterator<BlockRayHit<E>> |
iterator() |
BlockRay.BlockRayBuilder<E> |
narrowPhase(boolean enable)
Sets whether or not to perform narrow phase intersections.
|
com.flowpowered.math.vector.Vector3d |
position()
Gets the starting position of the block ray.
|
BlockRay.BlockRayBuilder<E> |
select(Predicate<BlockRayHit<E>> filter)
Adds a filter to the
BlockRay that determines whether a
potential BlockRayHit is a valid result, and should
therefore be returned by the BlockRay , pausing the ray
trace. |
BlockRay.BlockRayBuilder<E> |
skipFilter(Predicate<BlockRayHit<E>>... skipFilters)
Deprecated.
|
BlockRay.BlockRayBuilder<E> |
skipFilter(Predicate<BlockRayHit<E>> skipFilter)
Deprecated.
|
BlockRay.BlockRayBuilder<E> |
stopFilter(Predicate<BlockRayHit<E>>... stopFilters)
Deprecated.
|
BlockRay.BlockRayBuilder<E> |
stopFilter(Predicate<BlockRayHit<E>> stopFilter)
Deprecated.
Confusing name. Use
whilst(Predicate)
instead. |
BlockRay.BlockRayBuilder<E> |
to(com.flowpowered.math.vector.Vector3d end)
Sets the direction and ending location.
|
BlockRay.BlockRayBuilder<E> |
whilst(Predicate<BlockRayHit<E>> filter)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
@Deprecated public BlockRay.BlockRayBuilder<E> skipFilter(Predicate<BlockRayHit<E>> skipFilter)
select(Predicate)
skipFilter
- The filter to add@SafeVarargs @Deprecated public final BlockRay.BlockRayBuilder<E> skipFilter(Predicate<BlockRayHit<E>>... skipFilters)
select(Predicate)
skipFilters
- The filters to addpublic final BlockRay.BlockRayBuilder<E> select(Predicate<BlockRayHit<E>> filter)
BlockRay
that determines whether a
potential BlockRayHit
is a valid result, and should
therefore be returned by the BlockRay
, pausing the ray
trace. A ray trace that has been paused due to a BlockRayHit
being returned by virtue of this predicate may be continued by
calling BlockRay.next()
on the associated BlockRay
.
Take care when using this in combination with
whilst(Predicate)
. For any predicate
supplied here to match a BlockRayHit
, it must also be
allowed by any predicates supplied to
whilst(Predicate)
.
Only one filter may be applied using this method. If a second filter is applied, it will overwrite the first.
This is optional. If not specified, defaults to
BlockRay.allFilter()
.
filter
- A filter which determines whether a ray has
completedwhilst(Predicate)
public final BlockRay.BlockRayBuilder<E> whilst(Predicate<BlockRayHit<E>> filter)
BlockRay
that determines the conditions
upon which a BlockRay
may continue to iterate. Such a filter
does not cause a BlockRayHit
to be returned,
instead, it defines the point in which a BlockRay
trace should
be considered to be at its end and should not attempt to trace further.
The block ray will continue while the BlockRayHit
s that are
supplied to this Predicate
return true
. It will
end when a BlockRayHit
fails the supplied
predicate - at which point the iteration will end and no further calls
to BlockRay.next()
will be possible.
For example, if you supply the following filter to this method:
input -> { BlockType type = input.getLocation().getBlockType(); return type == BlockTypes.AIR || type == BlockTypes.WATER; }
then the BlockRay
will trace through air and water,
stopping when at the boundary of any other block not matched
by the predicate.
Only one filter may be applied using this method. If a second filter is applied, it will overwrite the first.
This is optional. If not specified, defaults to
BlockRay.allFilter()
If you wish to cause the ray to return a BlockRayHit
,
supply a predicate to select(Predicate)
instead.
filter
- The filter to addselect(Predicate)
@Deprecated public BlockRay.BlockRayBuilder<E> stopFilter(Predicate<BlockRayHit<E>> stopFilter)
whilst(Predicate)
instead.stopFilter
- The filter to add@SafeVarargs @Deprecated public final BlockRay.BlockRayBuilder<E> stopFilter(Predicate<BlockRayHit<E>>... stopFilters)
stopFilters
- The filters to addpublic BlockRay.BlockRayBuilder<E> to(com.flowpowered.math.vector.Vector3d end)
end
- The ending locationpublic BlockRay.BlockRayBuilder<E> direction(com.flowpowered.math.vector.Vector3d direction)
direction
- The directionpublic BlockRay.BlockRayBuilder<E> distanceLimit(double distanceLimit)
distanceLimit
- The distance limitpublic BlockRay.BlockRayBuilder<E> narrowPhase(boolean enable)
enable
- Whether or not to enable the narrow phasepublic com.flowpowered.math.vector.Vector3d position()
public BlockRay<E> build()
public Iterator<BlockRayHit<E>> iterator()
iterator
in interface Iterable<BlockRayHit<E extends Extent>>
public Optional<BlockRayHit<E>> end()
build()
,
BlockRay.end()