Class AbstractRange<T extends Number>
java.lang.Object
com.portingdeadmods.portingdeadlibs.utils.ranges.AbstractRange<T>
- Direct Known Subclasses:
FloatRange,IntRange
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRange(T minInclusive, T maxInclusive) protectedAbstractRange(T minInclusive, T maxInclusive, T step) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Collection<T> Collects all possible values in the range specified.protected abstract Collection<T> collectPossibleValues(T step) Collects all possible values in the range specified.booleanChecks if a given value fits within the range defined by min and max.getMax()getMin()Returns a collection of all possible values within the range dictated by the min, max, and step values.static <T extends Number,SELF extends AbstractRange<T>>
com.mojang.serialization.MapCodec<SELF> rangeMapCodec(com.mojang.serialization.Codec<T> codec, BiFunction<T, T, SELF> constructor) static <T extends Number,SELF extends AbstractRange<T>>
net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, SELF> rangeStreamCodec(net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, T> streamCodec, BiFunction<T, T, SELF> constructor) abstract AbstractRange<T> Utility method to create a new range shifted by a specified offset.
-
Constructor Details
-
AbstractRange
-
AbstractRange
-
-
Method Details
-
getMin
-
getMax
-
getPossibleValues
Returns a collection of all possible values within the range dictated by the min, max, and step values.- Returns:
- A collection of possible values.
-
fits
Checks if a given value fits within the range defined by min and max.- Parameters:
value- The value to check.- Returns:
- true if the value is within the range, false otherwise.
-
shift
Utility method to create a new range shifted by a specified offset.- Parameters:
offset- The offset to shift the range by.- Returns:
- A new range that is shifted by the specified offset.
-
collectPossibleValues
Collects all possible values in the range specified. Default step of 1.0f is used.- Returns:
- A collection of all possible float values in the range with a step of 1.0f.
-
collectPossibleValues
Collects all possible values in the range specified.- Parameters:
step- The step value to use for collecting possible values.- Returns:
- A collection of all possible float values in the range with a step of 1.0f.
-
rangeMapCodec
public static <T extends Number,SELF extends AbstractRange<T>> com.mojang.serialization.MapCodec<SELF> rangeMapCodec(com.mojang.serialization.Codec<T> codec, BiFunction<T, T, SELF> constructor) -
rangeStreamCodec
public static <T extends Number,SELF extends AbstractRange<T>> net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,SELF> rangeStreamCodec(net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, T> streamCodec, BiFunction<T, T, SELF> constructor)
-