Record Class NotAdvancedIngredient<STACK>
java.lang.Object
java.lang.Record
com.petrolpark.core.recipe.ingredient.advanced.NotAdvancedIngredient<STACK>
- All Implemented Interfaces:
IForcingItemAdvancedIngredient,ITypelessAdvancedIngredient<STACK>,Predicate<STACK>
public record NotAdvancedIngredient<STACK>(IAdvancedIngredient<? super STACK> ingredient)
extends Record
implements ITypelessAdvancedIngredient<STACK>, IForcingItemAdvancedIngredient
-
Constructor Summary
ConstructorsConstructorDescriptionNotAdvancedIngredient(IAdvancedIngredient<? super STACK> ingredient) Creates an instance of aNotAdvancedIngredientrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCounterDescription(Lang.IndentedTooltipBuilder description) voidaddToDescription(Lang.IndentedTooltipBuilder description) static final <STACK> com.mojang.serialization.MapCodec<NotAdvancedIngredient<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.IAdvancedIngredient<? super STACK> Returns the value of theingredientrecord component.modifyCounterExamples(Stream<STACK> counterExampleStacks) Modify an example stack so it does notfulfillthisIAdvancedIngredient.modifyExamples(Stream<STACK> exampleStacks) Modify an example stack so itfulfillthisIAdvancedIngredient.static final IAdvancedIngredient<net.minecraft.world.item.ItemStack> of(IAdvancedIngredient<? super net.minecraft.world.item.ItemStack> ingredient) 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<? super net.minecraft.network.RegistryFriendlyByteBuf, NotAdvancedIngredient<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.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
-
NotAdvancedIngredient
Creates an instance of aNotAdvancedIngredientrecord class.- Parameters:
ingredient- the value for theingredientrecord component
-
-
Method Details
-
codec
public static final <STACK> com.mojang.serialization.MapCodec<NotAdvancedIngredient<STACK>> codec(com.mojang.serialization.Codec<IAdvancedIngredient<? super STACK>> typeCodec) -
streamCodec
public static final <STACK> net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,NotAdvancedIngredient<STACK>> streamCodec(net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, IAdvancedIngredient<? super STACK>> typeStreamCodec) -
of
public static final IAdvancedIngredient<net.minecraft.world.item.ItemStack> of(IAdvancedIngredient<? super net.minecraft.world.item.ItemStack> ingredient) -
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
-
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
-
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.
-
addToDescription
- Specified by:
addToDescriptionin interfaceITypelessAdvancedIngredient<STACK>
-
addToCounterDescription
- Specified by:
addToCounterDescriptionin interfaceITypelessAdvancedIngredient<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 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). -
ingredient
Returns the value of theingredientrecord component.- Returns:
- the value of the
ingredientrecord component
-