Class ChanceModifier
java.lang.Object
com.github.darksoulq.abyssallib.world.gen.placement.PlacementModifier
com.github.darksoulq.abyssallib.world.gen.placement.modifier.ChanceModifier
A placement modifier that filters positions based on a random probability.
This modifier passes the incoming vector only if a random integer bounded by the configured chance equals zero (e.g., a chance of 10 means a 1-in-10 or 10% probability of placement).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Codec<ChanceModifier> The codec used for serializing and deserializing the chance modifier.static final PlacementModifierType<ChanceModifier> The registered type definition for the chance placement modifier. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionStream<org.bukkit.util.Vector> getPositions(PlacementContext context, Stream<org.bukkit.util.Vector> positions) Randomly drops incoming vectors based on the configured chance.getType()Retrieves the specific type definition for this modifier.
-
Field Details
-
CODEC
The codec used for serializing and deserializing the chance modifier. -
TYPE
The registered type definition for the chance placement modifier.
-
-
Constructor Details
-
ChanceModifier
public ChanceModifier(int chance) Constructs a new ChanceModifier.- Parameters:
chance- The probability fraction denominator (e.g., 5 means 20% chance).
-
-
Method Details
-
getPositions
public Stream<org.bukkit.util.Vector> getPositions(PlacementContext context, Stream<org.bukkit.util.Vector> positions) Randomly drops incoming vectors based on the configured chance.- Specified by:
getPositionsin classPlacementModifier- Parameters:
context- The current placement context providing the seeded random instance.positions- The incoming stream of potential placement vectors.- Returns:
- A filtered stream containing only the positions that passed the probability check.
-
getType
Retrieves the specific type definition for this modifier.- Specified by:
getTypein classPlacementModifier- Returns:
- The placement modifier type associated with this chance modifier.
-