Record Class EnchantmentItemAdvancedIngredient
java.lang.Object
java.lang.Record
com.petrolpark.core.recipe.ingredient.advanced.EnchantmentItemAdvancedIngredient
- All Implemented Interfaces:
IAdvancedIngredient<net.minecraft.world.item.ItemStack>,IForcingItemAdvancedIngredient,ItemAdvancedIngredient,ITypelessAdvancedIngredient<net.minecraft.world.item.ItemStack>,Predicate<net.minecraft.world.item.ItemStack>
public record EnchantmentItemAdvancedIngredient(net.minecraft.advancements.critereon.EnchantmentPredicate enchantments)
extends Record
implements ItemAdvancedIngredient
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<EnchantmentItemAdvancedIngredient> static final net.minecraft.util.RandomSourcestatic final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, EnchantmentItemAdvancedIngredient> Fields inherited from interface com.petrolpark.core.recipe.ingredient.advanced.ItemAdvancedIngredient
TYPED_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionEnchantmentItemAdvancedIngredient(net.minecraft.advancements.critereon.EnchantmentPredicate enchantments) Creates an instance of aEnchantmentItemAdvancedIngredientrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCounterDescription(Lang.IndentedTooltipBuilder description) voidaddToDescription(Lang.IndentedTooltipBuilder description) protected voidaddToDescriptionInternal(Lang.IndentedTooltipBuilder description, String postfix) protected static final Supplier<Stream<net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>>> allEnchantments(net.minecraft.world.level.storage.loot.LootContext context) net.minecraft.advancements.critereon.EnchantmentPredicateReturns the value of theenchantmentsrecord component.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.protected static final net.minecraft.world.item.enchantment.ItemEnchantmentsgetEnchantments(net.minecraft.world.item.ItemStack stack) INamedAdvancedIngredientType<net.minecraft.world.item.ItemStack> getType()final inthashCode()Returns a hash code value for this object.Stream<net.minecraft.world.item.ItemStack> modifyCounterExamples(Stream<net.minecraft.world.item.ItemStack> counterExampleStacks) Modify an example stack so it does notfulfillthisIAdvancedIngredient.Stream<net.minecraft.world.item.ItemStack> modifyExamples(Stream<net.minecraft.world.item.ItemStack> exampleStacks) Modify an example stack so itfulfillthisIAdvancedIngredient.booleantest(net.minecraft.world.item.ItemStack stack) final 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.IAdvancedIngredient
simplifyMethods inherited from interface com.petrolpark.core.recipe.ingredient.advanced.ItemAdvancedIngredient
translate, translateInverse, translateSimpleMethods inherited from interface com.petrolpark.core.recipe.ingredient.advanced.ITypelessAdvancedIngredient
checkedCast, streamCounterExamples, streamExamples
-
Field Details
-
CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,EnchantmentItemAdvancedIngredient> STREAM_CODEC -
RANDOM
public static final net.minecraft.util.RandomSource RANDOM
-
-
Constructor Details
-
EnchantmentItemAdvancedIngredient
public EnchantmentItemAdvancedIngredient(net.minecraft.advancements.critereon.EnchantmentPredicate enchantments) Creates an instance of aEnchantmentItemAdvancedIngredientrecord class.- Parameters:
enchantments- the value for theenchantmentsrecord component
-
-
Method Details
-
test
public boolean test(net.minecraft.world.item.ItemStack stack) - Specified by:
testin interfaceItemAdvancedIngredient- Specified by:
testin interfacePredicate<net.minecraft.world.item.ItemStack>
-
modifyExamples
@Nullable public Stream<net.minecraft.world.item.ItemStack> modifyExamples(Stream<net.minecraft.world.item.ItemStack> exampleStacks) Description copied from interface:ITypelessAdvancedIngredientModify an example stack so itfulfillthisIAdvancedIngredient.- Specified by:
modifyExamplesin interfaceITypelessAdvancedIngredient<net.minecraft.world.item.ItemStack>- 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
@Nullable public Stream<net.minecraft.world.item.ItemStack> modifyCounterExamples(Stream<net.minecraft.world.item.ItemStack> counterExampleStacks) Description copied from interface:ITypelessAdvancedIngredientModify an example stack so it does notfulfillthisIAdvancedIngredient.- Specified by:
modifyCounterExamplesin interfaceITypelessAdvancedIngredient<net.minecraft.world.item.ItemStack>- 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- Specified by:
forceLootItemFunctionin interfaceItemAdvancedIngredient- 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- Specified by:
forbidLootItemFunctionin interfaceItemAdvancedIngredient- 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- Specified by:
forceTradeListingin interfaceItemAdvancedIngredient- 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- Specified by:
forbidTradeListingin interfaceItemAdvancedIngredient- 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<net.minecraft.world.item.ItemStack>
-
addToCounterDescription
- Specified by:
addToCounterDescriptionin interfaceITypelessAdvancedIngredient<net.minecraft.world.item.ItemStack>
-
addToDescriptionInternal
-
getType
- Specified by:
getTypein interfaceIAdvancedIngredient<net.minecraft.world.item.ItemStack>- Specified by:
getTypein interfaceItemAdvancedIngredient
-
allEnchantments
-
getEnchantments
protected static final net.minecraft.world.item.enchantment.ItemEnchantments getEnchantments(net.minecraft.world.item.ItemStack 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). -
enchantments
public net.minecraft.advancements.critereon.EnchantmentPredicate enchantments()Returns the value of theenchantmentsrecord component.- Returns:
- the value of the
enchantmentsrecord component
-