Class AmadronOffer
java.lang.Object
me.desht.pneumaticcraft.api.crafting.recipe.PneumaticCraftRecipe
me.desht.pneumaticcraft.api.crafting.recipe.AmadronRecipe
me.desht.pneumaticcraft.common.recipes.amadron.AmadronOffer
- All Implemented Interfaces:
net.minecraft.world.item.crafting.Recipe<PneumaticCraftRecipe.DummyIInventory>
- Direct Known Subclasses:
AmadronPlayerOffer
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class me.desht.pneumaticcraft.api.crafting.recipe.PneumaticCraftRecipe
PneumaticCraftRecipe.DummyIInventory -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PlayerFilterprotected final AmadronTradeResourceprotected intprotected final AmadronTradeResourceprotected final PlayerFilter -
Constructor Summary
ConstructorsConstructorDescriptionAmadronOffer(net.minecraft.resources.ResourceLocation id, AmadronTradeResource input, AmadronTradeResource output, boolean isStaticOffer, int tradeLevel, int maxStock) AmadronOffer(net.minecraft.resources.ResourceLocation id, AmadronTradeResource input, AmadronTradeResource output, boolean isStaticOffer, int tradeLevel, int maxStock, int inStock, PlayerFilter whitelist, PlayerFilter blacklist) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAvailabilityData(net.minecraft.world.entity.player.Player player, List<net.minecraft.network.chat.Component> curTip) Add some information about where this offer is available, in the case of offers with limited availablity.booleanbooleanequivalentTo(AmadronPlayerOffer offer) net.minecraft.network.chat.ComponentGet a player-friendly description of the offergetInput()Get the offer's input, i.e.intGet the maximum (initial) stock level for this offer.Get the offer's output, i.e.net.minecraft.world.item.crafting.RecipeSerializer<?>intgetStock()Get the number of trades Amadron currently has in stock for this offer.intThe rarity for villager and periodic trades, in the range of 1 (common) to 5 (very rare)net.minecraft.world.item.crafting.RecipeType<?>getType()net.minecraft.network.chat.ComponentGet the offer's vendor name, for display purposes.inthashCode()booleanbooleanIs this a static offer, always displayed on the Amadron tablet? Or periodic, shuffled in at random once per Minecraft day (by default) ?booleanisUsableByPlayer(net.minecraft.world.entity.player.Player player) Is this offer available to the given player? By default, all offers are available, but offers can be whitelisted/blacklisted in data packs with the "whitelist" and "blacklist" fields in the Amadron recipe JSON.static AmadronRecipeofferFromBuf(net.minecraft.resources.ResourceLocation id, net.minecraft.network.FriendlyByteBuf buf) voidvoidsetStock(int inStock) Update the number of trades Amadron currently has in stock for this offer.com.google.gson.JsonObjecttoJson(com.google.gson.JsonObject json) toString()voidwrite(net.minecraft.network.FriendlyByteBuf buf) Writes this recipe to a PacketBuffer.Methods inherited from class me.desht.pneumaticcraft.api.crafting.recipe.AmadronRecipe
isRemovableBy, passesQueryMethods inherited from class me.desht.pneumaticcraft.api.crafting.recipe.PneumaticCraftRecipe
assemble, canCraftInDimensions, getId, getResultItem, isSpecial, matchesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.item.crafting.Recipe
getGroup, getIngredients, getRemainingItems, getToastSymbol, isIncomplete
-
Field Details
-
input
-
output
-
whitelist
-
blacklist
-
inStock
protected int inStock
-
-
Constructor Details
-
AmadronOffer
public AmadronOffer(net.minecraft.resources.ResourceLocation id, @Nonnull AmadronTradeResource input, @Nonnull AmadronTradeResource output, boolean isStaticOffer, int tradeLevel, int maxStock, int inStock, PlayerFilter whitelist, PlayerFilter blacklist) -
AmadronOffer
public AmadronOffer(net.minecraft.resources.ResourceLocation id, @Nonnull AmadronTradeResource input, @Nonnull AmadronTradeResource output, boolean isStaticOffer, int tradeLevel, int maxStock)
-
-
Method Details
-
getInput
Description copied from class:AmadronRecipeGet the offer's input, i.e. what the Amadrone will collect from the player's Amadron inventory.- Specified by:
getInputin classAmadronRecipe- Returns:
- the input
-
getOutput
Description copied from class:AmadronRecipeGet the offer's output, i.e. what the player will receive in return from the Amadrone- Specified by:
getOutputin classAmadronRecipe- Returns:
- the output
-
isStaticOffer
public boolean isStaticOffer()Description copied from class:AmadronRecipeIs this a static offer, always displayed on the Amadron tablet? Or periodic, shuffled in at random once per Minecraft day (by default) ?- Specified by:
isStaticOfferin classAmadronRecipe- Returns:
- true if this is a static offer, false otherwise
-
getTradeLevel
public int getTradeLevel()Description copied from class:AmadronRecipeThe rarity for villager and periodic trades, in the range of 1 (common) to 5 (very rare)- Specified by:
getTradeLevelin classAmadronRecipe- Returns:
- the rarity, or 0 if this is a static (always shown) offer
-
setVillagerTrade
-
equivalentTo
-
getVendorName
public net.minecraft.network.chat.Component getVendorName()Description copied from class:AmadronRecipeGet the offer's vendor name, for display purposes. The default is "Amadron" for static and periodic offers loaded from datapack, "Villagers" for villager-discovered offers, and the player's display name (at the time of offer creation) for player-added offers.- Specified by:
getVendorNamein classAmadronRecipe- Returns:
- the vendor name
-
getStock
public int getStock()Description copied from class:AmadronRecipeGet the number of trades Amadron currently has in stock for this offer. Note that all (default) static offers have unlimited trades, as do all player-added offers. Offers discovered from villager trades do have limited stock (defined by the number of trades the villager would normally offer)- Specified by:
getStockin classAmadronRecipe- Returns:
- the number of trades in stock, or any negative number for unlimited stock
-
setStock
public void setStock(int inStock) Description copied from class:AmadronRecipeUpdate the number of trades Amadron currently has in stock for this offer. It is the responsbility of the implementation to ensure the stock level does not go below 0, or above the max stock level as returned byAmadronRecipe.getMaxStock()(provided that the max stock level is > 0).- Specified by:
setStockin classAmadronRecipe- Parameters:
inStock- the new stock level
-
onTrade
-
write
public void write(net.minecraft.network.FriendlyByteBuf buf) Description copied from class:PneumaticCraftRecipeWrites this recipe to a PacketBuffer.- Specified by:
writein classPneumaticCraftRecipe- Parameters:
buf- The buffer to write to.
-
offerFromBuf
public static AmadronRecipe offerFromBuf(net.minecraft.resources.ResourceLocation id, net.minecraft.network.FriendlyByteBuf buf) -
toJson
public com.google.gson.JsonObject toJson(com.google.gson.JsonObject json) -
toString
-
getDescription
public net.minecraft.network.chat.Component getDescription()Get a player-friendly description of the offer- Returns:
- a description string
-
equals
-
hashCode
public int hashCode() -
getSerializer
public net.minecraft.world.item.crafting.RecipeSerializer<?> getSerializer() -
getType
public net.minecraft.world.item.crafting.RecipeType<?> getType() -
getMaxStock
public int getMaxStock()Description copied from class:AmadronRecipeGet the maximum (initial) stock level for this offer.- Specified by:
getMaxStockin classAmadronRecipe- Returns:
- the max stock level; any quantity ≤ 0 indicates no maximum in force
-
isUsableByPlayer
public boolean isUsableByPlayer(net.minecraft.world.entity.player.Player player) Description copied from class:AmadronRecipeIs this offer available to the given player? By default, all offers are available, but offers can be whitelisted/blacklisted in data packs with the "whitelist" and "blacklist" fields in the Amadron recipe JSON. This could be used, for example, to only allow selling snow in a desert biome, or only purchasing ender pearls in the End. Default filters are "dimensions" and "biome_categories", but others can be added viaPneumaticRegistry.IPneumaticCraftInterface.registerPlayerMatcher(ResourceLocation, IPlayerMatcher.MatcherFactory)- Specified by:
isUsableByPlayerin classAmadronRecipe- Parameters:
player- the player to check- Returns:
- true if the offer is available to the player at the time of use, false otherwise
-
addAvailabilityData
public void addAvailabilityData(net.minecraft.world.entity.player.Player player, List<net.minecraft.network.chat.Component> curTip) Description copied from class:AmadronRecipeAdd some information about where this offer is available, in the case of offers with limited availablity.- Overrides:
addAvailabilityDatain classAmadronRecipecurTip- tooltip to add information to
-
isLocationLimited
public boolean isLocationLimited()- Overrides:
isLocationLimitedin classAmadronRecipe
-