Class AmadronRecipe

java.lang.Object
me.desht.pneumaticcraft.api.crafting.recipe.PneumaticCraftRecipe
me.desht.pneumaticcraft.api.crafting.recipe.AmadronRecipe
All Implemented Interfaces:
net.minecraft.world.item.crafting.Recipe<PneumaticCraftRecipe.DummyIInventory>
Direct Known Subclasses:
AmadronOffer

public abstract class AmadronRecipe extends PneumaticCraftRecipe
An Amadron trade offer, loaded from datapack. Note that any trades discovered from villager trades, or added by players, do not come from datapacks and are not added to the vanilla recipe system (and thus will not appear in JEI), but are still represented by instances of this class and displayed in the Amadron tablet.
  • Nested Class Summary

    Nested classes/interfaces inherited from class me.desht.pneumaticcraft.api.crafting.recipe.PneumaticCraftRecipe

    PneumaticCraftRecipe.DummyIInventory
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AmadronRecipe(net.minecraft.resources.ResourceLocation id)
    Construct a new offer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAvailabilityData(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.
    Get the offer's input, i.e.
    abstract int
    Get the maximum (initial) stock level for this offer.
    Get the offer's output, i.e.
    abstract int
    Get the number of trades Amadron currently has in stock for this offer.
    abstract int
    The rarity for villager and periodic trades, in the range of 1 (common) to 5 (very rare)
    abstract net.minecraft.network.chat.Component
    Get the offer's vendor name, for display purposes.
    boolean
     
    boolean
    isRemovableBy(net.minecraft.world.entity.player.Player player)
    Can this offer be removed by the given player?
    abstract boolean
    Is this a static offer, always displayed on the Amadron tablet? Or periodic, shuffled in at random once per Minecraft day (by default) ?
    abstract boolean
    isUsableByPlayer(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.
    final boolean
    Does this offer match the given query string? The input resource, output resource and vendor names are all tested (case-insensitive) for the query.
    abstract void
    setStock(int stock)
    Update the number of trades Amadron currently has in stock for this offer.

    Methods inherited from class me.desht.pneumaticcraft.api.crafting.recipe.PneumaticCraftRecipe

    assemble, canCraftInDimensions, getId, getResultItem, isSpecial, matches, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.world.item.crafting.Recipe

    getGroup, getIngredients, getRemainingItems, getSerializer, getToastSymbol, getType, isIncomplete
  • Constructor Details

    • AmadronRecipe

      protected AmadronRecipe(net.minecraft.resources.ResourceLocation id)
      Construct a new offer. The ID must be unique; for offers loaded from datapack, it is derived from the mod and JSON filename; for offers added by players, it is "pneumaticcraft:{playername}_{timestamp}"; for villager trades, it is "{modname}:{profession}_{level}_{index}"
      Parameters:
      id - the unique recipe ID
  • Method Details

    • getInput

      @Nonnull public abstract AmadronTradeResource getInput()
      Get the offer's input, i.e. what the Amadrone will collect from the player's Amadron inventory.
      Returns:
      the input
    • getOutput

      @Nonnull public abstract AmadronTradeResource getOutput()
      Get the offer's output, i.e. what the player will receive in return from the Amadrone
      Returns:
      the output
    • getVendorName

      public abstract net.minecraft.network.chat.Component getVendorName()
      Get 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.
      Returns:
      the vendor name
    • isStaticOffer

      public abstract boolean isStaticOffer()
      Is this a static offer, always displayed on the Amadron tablet? Or periodic, shuffled in at random once per Minecraft day (by default) ?
      Returns:
      true if this is a static offer, false otherwise
    • getTradeLevel

      public abstract int getTradeLevel()
      The rarity for villager and periodic trades, in the range of 1 (common) to 5 (very rare)
      Returns:
      the rarity, or 0 if this is a static (always shown) offer
    • getStock

      public abstract int getStock()
      Get 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)
      Returns:
      the number of trades in stock, or any negative number for unlimited stock
    • setStock

      public abstract void setStock(int stock)
      Update 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 by getMaxStock() (provided that the max stock level is > 0).
      Parameters:
      stock - the new stock level
    • getMaxStock

      public abstract int getMaxStock()
      Get the maximum (initial) stock level for this offer.
      Returns:
      the max stock level; any quantity ≤ 0 indicates no maximum in force
    • isRemovableBy

      public boolean isRemovableBy(net.minecraft.world.entity.player.Player player)
      Can this offer be removed by the given player?
      Parameters:
      player - the player
      Returns:
      true if this player can remove this offer from the system, false otherwise
    • isUsableByPlayer

      public abstract boolean isUsableByPlayer(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. 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 via IMiscHelpers.registerPlayerMatcher(ResourceLocation, IPlayerMatcher.MatcherFactory).
      Parameters:
      player - the player to check
      Returns:
      true if the offer is available to the player at the time of use, false otherwise
    • passesQuery

      public final boolean passesQuery(String query)
      Does this offer match the given query string? The input resource, output resource and vendor names are all tested (case-insensitive) for the query.
      Parameters:
      query - the query string
      Returns:
      true if the recipe matches, false otherwise
    • addAvailabilityData

      public void addAvailabilityData(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.
      Parameters:
      curTip - tooltip to add information to
    • isLocationLimited

      public boolean isLocationLimited()