Record Class TypeAttachedAdvancedIngredient<STACK,INGREDIENT extends ITypelessAdvancedIngredient<? super STACK>>
java.lang.Object
java.lang.Record
com.petrolpark.core.recipe.ingredient.advanced.TypeAttachedAdvancedIngredient<STACK,INGREDIENT>
- All Implemented Interfaces:
IAdvancedIngredient<STACK>,IForcingItemAdvancedIngredient,ITypelessAdvancedIngredient<STACK>,Predicate<STACK>
public record TypeAttachedAdvancedIngredient<STACK,INGREDIENT extends ITypelessAdvancedIngredient<? super STACK>> (INGREDIENT extends ITypelessAdvancedIngredient<? super STACK> untypedIngredient, IAdvancedIngredientType<STACK> type)
extends Record
implements IAdvancedIngredient<STACK>, IForcingItemAdvancedIngredient
-
Constructor Summary
ConstructorsConstructorDescriptionTypeAttachedAdvancedIngredient(INGREDIENT untypedIngredient, IAdvancedIngredientType<STACK> type) Creates an instance of aTypeAttachedAdvancedIngredientrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCounterDescription(Lang.IndentedTooltipBuilder description) voidaddToDescription(Lang.IndentedTooltipBuilder description) 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.IAdvancedIngredientType<? super STACK> getType()final inthashCode()Returns a hash code value for this object.modifyCounterExamples(Stream<STACK> counterExampleStacks) Modify an example stack so it does notfulfillthisIAdvancedIngredient.modifyExamples(Stream<STACK> exampleStacks) Modify an example stack so itfulfillthisIAdvancedIngredient.IAdvancedIngredient<? super STACK> simplify()TheIAdvancedIngredient(not necessarily of the sametype) which is the exact samepredicateas this, but which has the smallest possible overhead.booleanfinal StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.Returns the value of theuntypedIngredientrecord component.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, streamCounterExamples, streamExamples
-
Constructor Details
-
TypeAttachedAdvancedIngredient
public TypeAttachedAdvancedIngredient(INGREDIENT untypedIngredient, IAdvancedIngredientType<STACK> type) Creates an instance of aTypeAttachedAdvancedIngredientrecord class.- Parameters:
untypedIngredient- the value for theuntypedIngredientrecord componenttype- the value for thetyperecord component
-
-
Method Details
-
test
-
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
-
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
-
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.
-
getType
- Specified by:
getTypein interfaceIAdvancedIngredient<STACK>
-
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 interfaceIAdvancedIngredient<STACK>- Specified by:
simplifyin interfaceITypelessAdvancedIngredient<STACK>
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
untypedIngredient
Returns the value of theuntypedIngredientrecord component.- Returns:
- the value of the
untypedIngredientrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-