Class ItemStackBuilderPopulators
- java.lang.Object
-
- org.spongepowered.api.item.inventory.ItemStackBuilderPopulators
-
public final class ItemStackBuilderPopulators extends java.lang.ObjectA factory for generatingBiConsumers to apply to anItemStack.Builder, usually through anItemStackGenerator.Note that the
BiConsumers are expected to utilize the passed inRandomand use the builder as necessary.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>enchantment(EnchantmentType enchantmentType)Creates a newBiConsumerthat takes the providedEnchantmentTypeand applies it to the generatedItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>enchantment(VariableAmount level, EnchantmentType enchantmentType)Creates a newBiConsumerthat takes the providedEnchantmentTypeand applies it to the generatedItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>enchantments(VariableAmount amount, java.util.Collection<Tuple<EnchantmentType,VariableAmount>> enchantments)Creates a newBiConsumerthat takes the providedCollectionof coupledEnchantmentTypeandVariableAmountto apply varying enchantments of varying amounts to the generatedItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>enchantmentsWithVanillaLevelVariance(java.util.Collection<EnchantmentType> enchantmentTypes)Creates a newBiConsumerthat takes the providedCollectionofEnchantmentTypes and applies a singularEnchantmentTypewith varying levels to the generatedItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>enchantmentsWithVanillaLevelVariance(VariableAmount amount, java.util.Collection<EnchantmentType> itemEnchantmentTypes)Creates a newBiConsumerthat takes the providedCollectionofEnchantmentTypes and applies a varying amount of generated enchantments to the generatedItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>enchantmentsWithVanillaLevelVariance(VariableAmount amount, EnchantmentType enchantmentType, EnchantmentType... enchantmentTypes)Creates a newBiConsumerthat takes the providedEnchantmentTypes and applies a variable amount of enchantmentTypes with varying levels to the generatedItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>item(java.util.function.Supplier<? extends ItemType> supplier)Creates a newBiConsumerthat defines the providedItemType, provided that theSupplierdoes not return null.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>item(ItemType itemType)Creates a newBiConsumerthat defines the providedItemType.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>items(java.util.Collection<ItemType> itemTypes)Creates a newBiConsumerthat provides a randomItemTypefrom the provided collection of item types.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>items(ItemType itemType, ItemType... itemTypes)Creates a newBiConsumerthat provides a randomItemTypeof the provided item types.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>itemStack(ItemStackSnapshot snapshot)Creates a newBiConsumerto set theItemStack.Builderto use the providedItemStackSnapshotas a "default".static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>itemStacks(ItemStackSnapshot snapshot, ItemStackSnapshot... snapshots)Creates a newBiConsumerthat uses a randomized selection of the providedItemStackSnapshots.static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>keyValue(Key<? extends Value<E>> key, E value)Creates a newBiConsumerthat sets the providedKey'ed object where the value is possibly ignored or not supported.static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>keyValues(Key<? extends Value<E>> key, java.lang.Iterable<E> values)Creates a newBiConsumerthat sets a single provided value with the providedKey.static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>listValues(Key<? extends ListValue.Mutable<E>> key, java.util.List<E> elementPool)static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>listValues(Key<? extends ListValue.Mutable<E>> key, java.util.List<E> elementPool, VariableAmount amount)static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>listValues(Key<? extends ListValue.Mutable<E>> key, WeightedTable<E> weightedTable)static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>listValueSuppliers(java.util.function.Supplier<? extends Key<? extends ListValue<E>>> key, WeightedTable<java.util.function.Function<java.util.Random,E>> weightedTable)static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>listValueSuppliers(Key<? extends ListValue<E>> key, WeightedTable<java.util.function.Function<java.util.Random,E>> weightedTable)static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>quantity(java.util.function.Supplier<VariableAmount> supplier)Creates a newBiConsumerthat sets the desired quantity for creating anItemStack.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>quantity(VariableAmount amount)Creates a newBiConsumerthat sets the desired quantity for creating anItemStack.static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>setValues(Key<? extends SetValue.Mutable<E>> key, java.util.Set<E> elementPool)static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>setValues(Key<? extends SetValue.Mutable<E>> key, java.util.Set<E> elementPool, VariableAmount amount)static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>setValues(Key<? extends SetValue.Mutable<E>> key, WeightedTable<E> weightedTable)static <E,V extends Value<E>>
java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>value(V value)static <E,V extends Value<E>>
java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>values(java.lang.Iterable<V> values)Creates a newBiConsumerthat applies a random selection of the providedValues.static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>values(java.util.Collection<Value.Immutable<?>> manipulators, VariableAmount rolls)static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random>values(WeightedTable<Value.Immutable<?>> weightedTable)
-
-
-
Method Detail
-
itemStack
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> itemStack(ItemStackSnapshot snapshot)
Creates a newBiConsumerto set theItemStack.Builderto use the providedItemStackSnapshotas a "default". Note that the normal behavior of the builder is to reset according to the snapshot.- Parameters:
snapshot- The snapshot to set the builder to use- Returns:
- The new biconsumer to apply to an itemstack builder
-
itemStacks
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> itemStacks(ItemStackSnapshot snapshot, ItemStackSnapshot... snapshots)
Creates a newBiConsumerthat uses a randomized selection of the providedItemStackSnapshots. The builder, when called will only use one at random selection to default to.- Parameters:
snapshot- The first snapshotsnapshots- The additional snapshots- Returns:
- The new biconsumer to apply to an itemstack builder
-
item
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> item(ItemType itemType)
Creates a newBiConsumerthat defines the providedItemType.- Parameters:
itemType- The given item type- Returns:
- The new biconsumer to apply to an itemstack builder
-
item
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> item(java.util.function.Supplier<? extends ItemType> supplier)
Creates a newBiConsumerthat defines the providedItemType, provided that theSupplierdoes not return null.Note that the
Supplieris not queried for anItemTypeuntil the generatedBiConsumeris called.- Parameters:
supplier- The supplier of the item type- Returns:
- The new biconsumer to apply to an itemstack builder
-
items
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> items(ItemType itemType, ItemType... itemTypes)
Creates a newBiConsumerthat provides a randomItemTypeof the provided item types.Note that the desired
ItemTypegiven to the builder is only defined at the time of callingBiConsumer.accept(Object, Object).- Parameters:
itemType- The first item typeitemTypes- The additional item types- Returns:
- The new biconsumer to apply to an item stack builder
-
items
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> items(java.util.Collection<ItemType> itemTypes)
Creates a newBiConsumerthat provides a randomItemTypefrom the provided collection of item types.- Parameters:
itemTypes- The item types to use- Returns:
- The new biconsumer to apply to an itemstack builder
-
quantity
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> quantity(VariableAmount amount)
Creates a newBiConsumerthat sets the desired quantity for creating anItemStack.Note that the default behavior of the item stack builder is still expected to take place. Negative values are not allowed.
- Parameters:
amount- The variable amount- Returns:
- The new biconsumer to apply to an itemstack builder
-
quantity
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> quantity(java.util.function.Supplier<VariableAmount> supplier)
Creates a newBiConsumerthat sets the desired quantity for creating anItemStack. The supplier is not queried for aVariableAmountuntil the generated bi consumer is called on.Note that the default behavior of an item stack builder is still expected to take place. Negative values are not allowed.
- Parameters:
supplier- The supplier of the variable amount- Returns:
- The new biconsumer to apply to an itemstack builder
-
keyValue
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> keyValue(Key<? extends Value<E>> key, E value)
Creates a newBiConsumerthat sets the providedKey'ed object where the value is possibly ignored or not supported. No checks on whether the key or object is supported until called upon.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of value- Parameters:
key- The key to usevalue- The value to use- Returns:
- The new biconsumer to apply to an itemstack builder
-
keyValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> keyValues(Key<? extends Value<E>> key, java.lang.Iterable<E> values)
Creates a newBiConsumerthat sets a single provided value with the providedKey. Only a single value is chosen to provide to the itemstack builder.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of value- Parameters:
key- The key to usevalues- The pool of possible values- Returns:
- The new biconsumer to apply to an itemstack builder
-
listValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> listValues(Key<? extends ListValue.Mutable<E>> key, java.util.List<E> elementPool, VariableAmount amount)
Creates a newBiConsumerwhere theKeyis responsible for aListbasedValue.Mutable. Given that the provided elements are chosen with aRandom, it's not clear that the elements will be added in bundles or in the same iteration order.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of elements- Parameters:
key- The key to useelementPool- The pool of possible valuesamount- The variable amount of elements to add- Returns:
- The new biconsumer to apply to an itemstack builder
-
listValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> listValues(Key<? extends ListValue.Mutable<E>> key, java.util.List<E> elementPool)
Creates a newBiConsumerwhere theKeyis responsible for aListbasedValue.Mutable. Given that the provided elements are chosen with aRandom, it's not clear that the elements will be added in bundles or in the same iteration order. The default variance is provided asVariableAmount.baseWithRandomAddition(double, double)where at the least, a single element is chosen, and at most the entire collection is chosen.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of elements- Parameters:
key- The key to useelementPool- The pool of possible values- Returns:
- The new biconsumer to apply to an itemstack builder
-
listValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> listValues(Key<? extends ListValue.Mutable<E>> key, WeightedTable<E> weightedTable)
Creates a newBiConsumerwhere theKeyis responsible for aListbasedValue.Mutable. Given theWeightedTableis already generated, the values requested are only retrieved when the generated biconsumer is called upon.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of elements- Parameters:
key- The key to useweightedTable- The weighted table- Returns:
- The new biconsumer to apply to an itemstack builder
-
listValueSuppliers
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> listValueSuppliers(Key<? extends ListValue<E>> key, WeightedTable<java.util.function.Function<java.util.Random,E>> weightedTable)
Creates a newBiConsumerwhere theKeyis responsible for aListbasedValue.Mutable. Given theWeightedTableis exclusively used withFunctions, theFunctions themselves are queried with aRandomand expected to present a singular element of the defined type. It's expected that there are multiple functions to provide additional elements for a particular key'edListValue.Mutable.An example usage of this can be for generating a randomized list of
Enchantments with varying enchantment levels.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of element- Parameters:
key- The key to useweightedTable- The weighted table containing all the desired functions producing the randomized elements- Returns:
- The new biconsumer to apply to an itemstack builder
-
listValueSuppliers
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> listValueSuppliers(java.util.function.Supplier<? extends Key<? extends ListValue<E>>> key, WeightedTable<java.util.function.Function<java.util.Random,E>> weightedTable)
-
setValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> setValues(Key<? extends SetValue.Mutable<E>> key, java.util.Set<E> elementPool)
Creates a newBiConsumerwhere theKeyis responsible for aSetbasedValue.Mutable. Given theSetof element to act as a pool, the consumer will pull a random amount of the given pool and apply it as a newSet.Note that custom data is not supported through this method, use
values(Iterable)or any variant thereof for applying custom data.- Type Parameters:
E- The type of element- Parameters:
key- The key to useelementPool- The set of elements to use as a pool- Returns:
- The new biconsumer to apply to an itemstack builder
-
setValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> setValues(Key<? extends SetValue.Mutable<E>> key, java.util.Set<E> elementPool, VariableAmount amount)
Creates a newBiConsumerwhere theKeyis responsible for aSetbasedValue.Mutable. Given theSetof elements to act as a pool, the consumer will pull a variable amount based on the providedVariableAmount, and apply it as a newSet.- Type Parameters:
E- The type of element- Parameters:
key- The key to useelementPool- The set of elements to use as a poolamount- The variable amount of elements to get- Returns:
- The new biconsumer to apply to an itemstack builder
-
setValues
public static <E> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> setValues(Key<? extends SetValue.Mutable<E>> key, WeightedTable<E> weightedTable)
Creates a newBiConsumerwhere theKeyis responsible for aSetbasedValue.Mutable. Given the providedWeightedTable, the consumer will retrieve aListof values and add them as a newSet.- Type Parameters:
E- The type of element- Parameters:
key- The key to useweightedTable- The weighted table acting as an element pool- Returns:
- The new biconsumer to apply to an itemstack builder
-
value
public static <E,V extends Value<E>> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> value(V value)
- Type Parameters:
E- The type of elementV- The type of value- Parameters:
value- The value to use- Returns:
- The new biconsumer to apply to an itemstack builder
-
values
public static <E,V extends Value<E>> java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> values(java.lang.Iterable<V> values)
Creates a newBiConsumerthat applies a random selection of the providedValues.- Type Parameters:
E- The type of elementV- The type of value- Parameters:
values- The iterable collection of values to choose from- Returns:
- The new biconsumer to apply to an itemstack builder
-
values
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> values(java.util.Collection<Value.Immutable<?>> manipulators, VariableAmount rolls)
Creates a newBiConsumerthat provides aVariableAmountofValues from the provided pool. Note that no validation can be performed, however the builder will ignore unsupported data.- Parameters:
manipulators- The manipulator pool to userolls- The variable amount of manipulators to apply- Returns:
- The new biconsumer to apply to an itemstack builder
-
values
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> values(WeightedTable<Value.Immutable<?>> weightedTable)
Creates a newBiConsumerthat provides a variable amount ofValues from the providedWeightedTable. Note that no validation can be performed, however the builder will ignore unsupported data.- Parameters:
weightedTable- The weighted table containing manipulators- Returns:
- The new biconsumer to apply to an itemstack builder
-
enchantment
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> enchantment(EnchantmentType enchantmentType)
Creates a newBiConsumerthat takes the providedEnchantmentTypeand applies it to the generatedItemStack. The enchantmentType level is varied based on vanilla mechanics.- Parameters:
enchantmentType- The singular enchantmentType to add- Returns:
- The new biconsumer to apply to an itemstack builder
-
enchantment
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> enchantment(VariableAmount level, EnchantmentType enchantmentType)
Creates a newBiConsumerthat takes the providedEnchantmentTypeand applies it to the generatedItemStack. The enchantmentType level is defined by the variable amount provided.- Parameters:
level- The variance in enchantmentType levelenchantmentType- The enchantmentType to add- Returns:
- The new biconsumer to apply to an itemstack builder
-
enchantmentsWithVanillaLevelVariance
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> enchantmentsWithVanillaLevelVariance(java.util.Collection<EnchantmentType> enchantmentTypes)
Creates a newBiConsumerthat takes the providedCollectionofEnchantmentTypes and applies a singularEnchantmentTypewith varying levels to the generatedItemStack.- Parameters:
enchantmentTypes- The enchantment pool to choose from- Returns:
- The new biconsumer to apply to an itemstack builder
-
enchantmentsWithVanillaLevelVariance
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> enchantmentsWithVanillaLevelVariance(VariableAmount amount, EnchantmentType enchantmentType, EnchantmentType... enchantmentTypes)
Creates a newBiConsumerthat takes the providedEnchantmentTypes and applies a variable amount of enchantmentTypes with varying levels to the generatedItemStack.- Parameters:
amount- The variable amount of enchantmentTypes to useenchantmentType- The first enchantmentType to addenchantmentTypes- The additional enchantmentTypes to use- Returns:
- The new biconsumer to apply to an itemstack builder
-
enchantmentsWithVanillaLevelVariance
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> enchantmentsWithVanillaLevelVariance(VariableAmount amount, java.util.Collection<EnchantmentType> itemEnchantmentTypes)
Creates a newBiConsumerthat takes the providedCollectionofEnchantmentTypes and applies a varying amount of generated enchantments to the generatedItemStack.- Parameters:
amount- The varying amount of enchantments to useitemEnchantmentTypes- The enchantment pool to use- Returns:
- The new biconsumer to apply to an itemstack builder
-
enchantments
public static java.util.function.BiConsumer<ItemStack.Builder,java.util.Random> enchantments(VariableAmount amount, java.util.Collection<Tuple<EnchantmentType,VariableAmount>> enchantments)
Creates a newBiConsumerthat takes the providedCollectionof coupledEnchantmentTypeandVariableAmountto apply varying enchantments of varying amounts to the generatedItemStack.- Parameters:
amount- The varying amount of enchantmentsenchantments- The collection of enchantment tuples combining the enchantment and the variable amount of level to apply- Returns:
- The new biconsumer to apply to an itemstack builder
-
-