Record Class CompoundAdvancedIngredient<STACK>
java.lang.Object
java.lang.Record
com.petrolpark.core.recipe.ingredient.advanced.CompoundAdvancedIngredient<STACK>
- All Implemented Interfaces:
IForcingItemAdvancedIngredient,ITypelessAdvancedIngredient<STACK>,Predicate<STACK>
public record CompoundAdvancedIngredient<STACK>(List<IAdvancedIngredient<? super STACK>> ingredients, int required)
extends Record
implements ITypelessAdvancedIngredient<STACK>, IForcingItemAdvancedIngredient
-
Constructor Summary
ConstructorsConstructorDescriptionCompoundAdvancedIngredient(List<IAdvancedIngredient<? super STACK>> ingredients, int required) Creates an instance of aCompoundAdvancedIngredientrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCounterDescription(Lang.IndentedTooltipBuilder description) voidaddToDescription(Lang.IndentedTooltipBuilder description) static final IAdvancedIngredient<net.minecraft.world.item.ItemStack> and(List<IAdvancedIngredient<? super net.minecraft.world.item.ItemStack>> ingredients) protected Optional<CompoundAdvancedIngredient<? super STACK>> cast(IAdvancedIngredient<? super STACK> ingredient) static final <STACK> com.mojang.serialization.MapCodec<CompoundAdvancedIngredient<STACK>> codec(com.mojang.serialization.Codec<IAdvancedIngredient<? super STACK>> typeCodec) final booleanIndicates whether some other object is "equal to" this one.Optional<net.minecraft.world.item.ItemStack> forbidLootItemFunction(net.minecraft.world.level.storage.loot.functions.LootItemFunction function, net.minecraft.world.level.storage.loot.LootContext context, net.minecraft.world.item.ItemStack stack) Attempt to force the output of the givenLootItemFunctionso it does notconformto thisIAdvancedIngredient.Optional<net.minecraft.world.item.trading.MerchantOffer> forbidTradeListing(net.minecraft.world.entity.npc.VillagerTrades.ItemListing tradeListing, net.minecraft.world.entity.Entity trader, net.minecraft.util.RandomSource random) Attempt to force the output of the givenVillagerTrades.ItemListingto aMerchantOfferwhoseoutputdoes notconformto thisIAdvancedIngredient.Optional<net.minecraft.world.item.ItemStack> forceLootItemFunction(net.minecraft.world.level.storage.loot.functions.LootItemFunction function, net.minecraft.world.level.storage.loot.LootContext context, net.minecraft.world.item.ItemStack stack) Optional<net.minecraft.world.item.trading.MerchantOffer> forceTradeListing(net.minecraft.world.entity.npc.VillagerTrades.ItemListing tradeListing, net.minecraft.world.entity.Entity trader, net.minecraft.util.RandomSource random) Attempt to force the output of the givenVillagerTrades.ItemListingto aMerchantOfferwhoseoutputconformsto thisIAdvancedIngredient.final inthashCode()Returns a hash code value for this object.List<IAdvancedIngredient<? super STACK>> Returns the value of theingredientsrecord component.booleanisAnd()booleanbooleanisOr()modifyCounterExamples(Stream<STACK> counterExampleStacks) Modify an example stack so it does notfulfillthisIAdvancedIngredient.modifyCounterExamples(Stream<STACK> exampleStacks, IAdvancedIngredient<STACK_PARENT> ingredient) modifyExamples(Stream<STACK> exampleStacks) Modify an example stack so itfulfillthisIAdvancedIngredient.modifyExamples(Stream<STACK> exampleStacks, IAdvancedIngredient<STACK_PARENT> ingredient) static final IAdvancedIngredient<net.minecraft.world.item.ItemStack> or(List<IAdvancedIngredient<? super net.minecraft.world.item.ItemStack>> ingredients) intrequired()Returns the value of therequiredrecord component.ITypelessAdvancedIngredient<? super STACK> simplify()TheIAdvancedIngredient(not necessarily of the sametype) which is the exact samepredicateas this, but which has the smallest possible overhead.static final <STACK> net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, CompoundAdvancedIngredient<STACK>> streamCodec(net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, IAdvancedIngredient<? super STACK>> typeStreamCodec) All (or an exemplary subset) of the stacks which do notfulfillthisIAdvancedIngredient.All (or an exemplary subset) of the stacks whichfulfillthisIAdvancedIngredient.booleanfinal StringtoString()Returns a string representation of this record class.protected net.minecraft.network.chat.Componentprotected static final <STACK> CompoundAdvancedIngredient<STACK> typelessAnd(List<IAdvancedIngredient<? super STACK>> ingredients) protected static final <STACK> CompoundAdvancedIngredient<STACK> typelessOr(List<IAdvancedIngredient<? super STACK>> ingredients) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.petrolpark.core.recipe.ingredient.advanced.ITypelessAdvancedIngredient
checkedCast
-
Constructor Details
-
CompoundAdvancedIngredient
public CompoundAdvancedIngredient(List<IAdvancedIngredient<? super STACK>> ingredients, int required) Creates an instance of aCompoundAdvancedIngredientrecord class.- Parameters:
ingredients- the value for theingredientsrecord componentrequired- the value for therequiredrecord component
-
-
Method Details
-
codec
public static final <STACK> com.mojang.serialization.MapCodec<CompoundAdvancedIngredient<STACK>> codec(com.mojang.serialization.Codec<IAdvancedIngredient<? super STACK>> typeCodec) -
streamCodec
public static final <STACK> net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,CompoundAdvancedIngredient<STACK>> streamCodec(net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, IAdvancedIngredient<? super STACK>> typeStreamCodec) -
typelessAnd
protected static final <STACK> CompoundAdvancedIngredient<STACK> typelessAnd(List<IAdvancedIngredient<? super STACK>> ingredients) -
typelessOr
protected static final <STACK> CompoundAdvancedIngredient<STACK> typelessOr(List<IAdvancedIngredient<? super STACK>> ingredients) -
and
public static final IAdvancedIngredient<net.minecraft.world.item.ItemStack> and(List<IAdvancedIngredient<? super net.minecraft.world.item.ItemStack>> ingredients) -
or
public static final IAdvancedIngredient<net.minecraft.world.item.ItemStack> or(List<IAdvancedIngredient<? super net.minecraft.world.item.ItemStack>> ingredients) -
test
-
streamExamples
Description copied from interface:ITypelessAdvancedIngredientAll (or an exemplary subset) of the stacks whichfulfillthisIAdvancedIngredient. This is not guaranteed to have every possible stack, and should never be used that way.- Specified by:
streamExamplesin interfaceITypelessAdvancedIngredient<STACK>- Returns:
- Non-
null, potentially empty Stream
-
streamCounterExamples
Description copied from interface:ITypelessAdvancedIngredientAll (or an exemplary subset) of the stacks which do notfulfillthisIAdvancedIngredient. This is not guaranteed to have every possible stack (and in fact will usually be empty), and should never be used that way.- Specified by:
streamCounterExamplesin interfaceITypelessAdvancedIngredient<STACK>- Returns:
- Non-
null, potentially empty Stream
-
modifyExamples
Description copied from interface:ITypelessAdvancedIngredientModify an example stack so itfulfillthisIAdvancedIngredient.- Specified by:
modifyExamplesin interfaceITypelessAdvancedIngredient<STACK>- Parameters:
exampleStacks- May be modified- Returns:
- A stack fulfilling this Ingredient, possibly the same object reference, or
nullif that stack can never fulfill this Ingredient
-
modifyExamples
protected <STACK_PARENT> Stream<STACK> modifyExamples(Stream<STACK> exampleStacks, IAdvancedIngredient<STACK_PARENT> ingredient) -
modifyCounterExamples
Description copied from interface:ITypelessAdvancedIngredientModify an example stack so it does notfulfillthisIAdvancedIngredient.- Specified by:
modifyCounterExamplesin interfaceITypelessAdvancedIngredient<STACK>- Parameters:
counterExampleStacks- May be modified- Returns:
- A stack not fulfilling this Ingredient, possibly the same object reference, or
nullif that stack always fulfills this Ingredient
-
modifyCounterExamples
protected <STACK_PARENT> Stream<STACK> modifyCounterExamples(Stream<STACK> exampleStacks, IAdvancedIngredient<STACK_PARENT> ingredient) -
addToDescription
- Specified by:
addToDescriptionin interfaceITypelessAdvancedIngredient<STACK>
-
addToCounterDescription
- Specified by:
addToCounterDescriptionin interfaceITypelessAdvancedIngredient<STACK>
-
forceLootItemFunction
@Nonnull public Optional<net.minecraft.world.item.ItemStack> forceLootItemFunction(net.minecraft.world.level.storage.loot.functions.LootItemFunction function, net.minecraft.world.level.storage.loot.LootContext context, net.minecraft.world.item.ItemStack stack) Description copied from interface:IForcingItemAdvancedIngredientAttempt to force the output of the givenLootItemFunctiontoconformto thisIAdvancedIngredient. This should not return an ItemStack which could not have been generated by theLootItemFunctionnaturally. It is not guaranteed that the returned ItemStack (if there is one) willconform, but this method should make a best effort.- Specified by:
forceLootItemFunctionin interfaceIForcingItemAdvancedIngredient- Parameters:
function- TheLootItemFunctionbeing called. This will never be aSequenceFunction, as those are unpacked automatically. Also, if it is aLootItemConditionalFunction, then it will have already passed all conditions by the time this method is called.context-stack- The ItemStack to which theLootItemFunctionis being applied- Returns:
- Non-
nullOptional, filled if an ItemStack could be generated matching thisIAdvancedIngredient, or empty if we could not force the output of theLootItemFunctionsuccessfully and it should be called as normal.
-
forbidLootItemFunction
@Nonnull public Optional<net.minecraft.world.item.ItemStack> forbidLootItemFunction(net.minecraft.world.level.storage.loot.functions.LootItemFunction function, net.minecraft.world.level.storage.loot.LootContext context, net.minecraft.world.item.ItemStack stack) Description copied from interface:IForcingItemAdvancedIngredientAttempt to force the output of the givenLootItemFunctionso it does notconformto thisIAdvancedIngredient. This should not return an ItemStack which could not have been generated by theLootItemFunctionnaturally. It is not guaranteed that the returned ItemStack (if there is one) won'tconform, but this method should make a best effort.- Specified by:
forbidLootItemFunctionin interfaceIForcingItemAdvancedIngredient- Parameters:
function- TheLootItemFunctionbeing called. This will never be aSequenceFunction, as those are unpacked automatically. Also, if it is aLootItemConditionalFunction, then it will have already passed all conditions by the time this method is called.context-stack- The ItemStack to which theLootItemFunctionis being applied- Returns:
- Non-
nullOptional, filled if an ItemStack could be generated not matching thisIAdvancedIngredient, or empty if we could not force the output of theLootItemFunctionsuccessfully and it should be called as normal.
-
forceTradeListing
@Nullable public Optional<net.minecraft.world.item.trading.MerchantOffer> forceTradeListing(net.minecraft.world.entity.npc.VillagerTrades.ItemListing tradeListing, net.minecraft.world.entity.Entity trader, net.minecraft.util.RandomSource random) Description copied from interface:IForcingItemAdvancedIngredientAttempt to force the output of the givenVillagerTrades.ItemListingto aMerchantOfferwhoseoutputconformsto thisIAdvancedIngredient. This should not generate aMerchantOfferwhich could not have been generated by theVillagerTrades.ItemListingnaturally. It is not guaranteed that the result of the returnedMerchantOffer(if there is one) willconform, but this method should make a best effort.- Specified by:
forceTradeListingin interfaceIForcingItemAdvancedIngredient- Parameters:
tradeListing-trader-random-- Returns:
nullif thisIAdvancedIngredientcould not generate aMerchantOfferwith a matching result, an empty Optional if theVillagerTrades.ItemListingshould generate noMerchantOfferat all (i.e.returnnull), or a filled Optional containing aMerchantOfferwith a matching result.
-
forbidTradeListing
@Nullable public Optional<net.minecraft.world.item.trading.MerchantOffer> forbidTradeListing(net.minecraft.world.entity.npc.VillagerTrades.ItemListing tradeListing, net.minecraft.world.entity.Entity trader, net.minecraft.util.RandomSource random) Description copied from interface:IForcingItemAdvancedIngredientAttempt to force the output of the givenVillagerTrades.ItemListingto aMerchantOfferwhoseoutputdoes notconformto thisIAdvancedIngredient. This should not generate aMerchantOfferwhich could not have been generated by theVillagerTrades.ItemListingnaturally. It is not guaranteed that the result of the returnedMerchantOffer(if there is one) won'tconform, but this method should make a best effort.- Specified by:
forbidTradeListingin interfaceIForcingItemAdvancedIngredient- Parameters:
tradeListing-trader-random-- Returns:
nullif thisIAdvancedIngredientcould not generate aMerchantOfferwith a non-matching result, an empty Optional if theVillagerTrades.ItemListingshould generate noMerchantOfferat all (i.e.returnnull), or a filled Optional containing aMerchantOfferwith a non-matching result.
-
simplify
Description copied from interface:ITypelessAdvancedIngredientTheIAdvancedIngredient(not necessarily of the sametype) which is the exact samepredicateas this, but which has the smallest possible overhead. It is acceptable to mutate this Ingredient while calling this method, so careful caching the unsimplified version. Usually this will just returnthis.- Specified by:
simplifyin interfaceITypelessAdvancedIngredient<STACK>
-
isImpossible
public boolean isImpossible() -
isOr
public boolean isOr() -
isAnd
public boolean isAnd() -
cast
protected Optional<CompoundAdvancedIngredient<? super STACK>> cast(IAdvancedIngredient<? super STACK> ingredient) -
translate
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
ingredients
Returns the value of theingredientsrecord component.- Returns:
- the value of the
ingredientsrecord component
-
required
public int required()Returns the value of therequiredrecord component.- Returns:
- the value of the
requiredrecord component
-