Class AbstractResearchProvider.Research

java.lang.Object
com.minecolonies.api.research.AbstractResearchProvider.Research
Enclosing class:
AbstractResearchProvider

public static class AbstractResearchProvider.Research extends Object
A Builder-like class for producing Researches.
  • Field Details

    • json

      public final com.google.gson.JsonObject json
    • id

      public final net.minecraft.resources.ResourceLocation id
    • researchLevel

      public int researchLevel
      The university level of the research.
    • translatedName

      public String translatedName
      A Translated Name to add to the output language file.
    • translatedSubtitle

      public String translatedSubtitle
      A Translated Subtitle to add to the output language file.
  • Constructor Details

    • Research

      public Research(net.minecraft.resources.ResourceLocation id, net.minecraft.resources.ResourceLocation branch)
      Creates a Research for later assembly into a JSON file.
      Parameters:
      id - A unique identifier. Suggested path format is branch/name.json.
      branch - A branch unique identifier. This will determine the location of a branch JSON, if present.
  • Method Details

    • setParentResearch

      Set the Parent Research. Parent Research must be unlocked and complete before this research is available. For now, all research above level 1 must have one parent. If not set, assumes level 1.
      Parameters:
      parent - The parent research.
      Returns:
      this
    • setName

      Set the research's name. This may be a human-readable name. If using a translation key, use setTranslatedName instead.
      Parameters:
      name - The research's displayed name, as a human-readable string or translation key.
      Returns:
      this
    • setTranslatedName

      public AbstractResearchProvider.Research setTranslatedName(String translatedName)
      Set the Translated Name. This will use the auto-generation key, and add a matching translation text to the language output file.
      Parameters:
      translatedName - The research's human-readable name.
      Returns:
      this
    • setSubtitle

      public AbstractResearchProvider.Research setSubtitle(String subtitle)
      Set the subtitle, as a human-readable name. If using a translation key, use setTranslatedSubtitle.
      Parameters:
      subtitle - The research's human-readable subtitle.
      Returns:
      this
    • setTranslatedSubtitle

      public AbstractResearchProvider.Research setTranslatedSubtitle(String translatedSubtitle)
      Sets a subtitle translation key. This will use an auto-generated key, and add a matching translation text to the language output file.
      Parameters:
      translatedSubtitle - The research's human-readable subtitle.
      Returns:
      this
    • setSortOrder

      public AbstractResearchProvider.Research setSortOrder(int sortNum)
      Sets the sort order for the research. Sibling research with a greater number will be placed lower on the University Window. Only applies for research with siblings.
      Parameters:
      sortNum - The numeric value for vertical sorting priority.
      Returns:
      this
    • setOnlyChild

      public AbstractResearchProvider.Research setOnlyChild()
      Sets only child status. OnlyChild research will allow at most one descendant to be completed at a time, and makes any descendant research resettable. Only applies to research with multiple immediate descendants.
      Returns:
      this
    • setNoReset

      public AbstractResearchProvider.Research setNoReset()
      Sets NoReset status. NoReset research can not be undone once complete, even if level 6 or descending from an onlyChild research. This is most relevant for researches that may cause inconsistent or incoherent behavior if reset. Only required when a Research is level 6, or where it or an ancestor research is onlyChild.
      Returns:
      this
    • setAutostart

      public AbstractResearchProvider.Research setAutostart()
      Sets autoStart status. Once all requirements are met, autostart Research will either begin (if no item costs are set) or notify colony players of its existence (if the research has item costs).
      Returns:
      this
    • setInstant

      public AbstractResearchProvider.Research setInstant()
      Sets instant status. Once begun, this research will complete Soon(tm), regardless of branch time multipliers or research depth.
      Returns:
      this
    • setHidden

      Sets hidden status. Hidden research will not be visible in the University BOWindow until all requirements are met. Research branches where all research is hidden or a descendant of a hidden research will be locked until at least one research is available. Locked branches will notify what requirements will unlock the branch on mouseover.
      Returns:
      this
    • setIcon

      public AbstractResearchProvider.Research setIcon(net.minecraft.world.item.ItemStack item)
      Sets an Item research icon. This icon will only be displayed after research is completed.
      Parameters:
      item - The itemStack, including count, to use as an icon.
      Returns:
      this
    • setIcon

      public AbstractResearchProvider.Research setIcon(net.minecraft.world.item.Item item)
      Sets an Item research icon. This icon will only be displayed after research is completed.
      Parameters:
      item - The item to use as an icon.
      Returns:
      this
    • setIcon

      public AbstractResearchProvider.Research setIcon(net.minecraft.world.item.Item item, int count)
      Sets an Item research icon. This icon will only be displayed after research is completed.
      Parameters:
      item - The item to use as an icon.
      count - The number to mark the icon.
      Returns:
      this
    • setIcon

      public AbstractResearchProvider.Research setIcon(net.minecraft.resources.ResourceLocation texture)
      Sets a texture research icon. This icon will only be displayed after research is completed. Overrides ItemStack and Item icons.
      Parameters:
      texture - The location of the texture file to use as an icon.
      Returns:
      this
    • addBuildingRequirement

      public AbstractResearchProvider.Research addBuildingRequirement(net.minecraft.resources.ResourceLocation buildingName, int level)
      Adds a building research requirement. The colony must have at least as many levels of this building to begin the research cumulative across all buildings of that type. (ie, guardtower 8 is fulfilled by eight level-1 guard towers, four level-2 guard towers, two level-3 and a level-2 guard tower, etc) See ModBuildings for a list of supported buildings. Whenever possible, use the public static String BUILDINGNAME_ID constants from ModBuildings. Multiple different buildings can be added as different BuildingRequirements, and all must be fulfilled to begin research.
      Parameters:
      buildingName - The name of the building to require. Derived from SchematicName.
      level - The required sum of levels across the colony.
      Returns:
      this
    • addSingleBuildingRequirement

      public AbstractResearchProvider.Research addSingleBuildingRequirement(net.minecraft.resources.ResourceLocation buildingName, int level)
      Adds a single building research requirement. The colony must have one building at this specific level or greater. (ie, guardtower 3 is fulfilled by one level-3 to level-5 guard tower, but no number of lower-level guard towers.) This does not test whether the result is possible (eg, tavern-4 will not throw an exception, but can never be achieved in-game) See ModBuildings for a list of supported buildings. Whenever possible, use the public static String BUILDINGNAME_ID constants from ModBuildings. Multiple different buildings can be added as different BuildingRequirements, and all must be fulfilled to begin research.
      Parameters:
      buildingName - The name of the building to require. Derived from SchematicName.
      level - The required sum of levels across the colony.
      Returns:
      this
    • addAlternateBuildingRequirement

      public AbstractResearchProvider.Research addAlternateBuildingRequirement(List<net.minecraft.resources.ResourceLocation> buildingNames, Integer level)
      Sets an alternate building research requirement. The colony must have at least as many levels of at least one alternate building to begin the research, cumulative across all buildings of that type. Ie, AlternateBuildingRequirement of Tavern 3 / CitizenHouse 2 / University 2 would be fulfilled by any one of those buildings level 3, or by two citizen houses. See ModBuildings for a list of supported buildings. Whenever possible, use the public static String BUILDINGNAME_ID constants from ModBuildings. Only one of all added Alternate Buildings is required. AlternateBuildingRequirements do not bypass normal BuildingRequirements.
      Parameters:
      buildingNames - The list required building.
      level - The level across the colony.
      Returns:
      this
    • addResearchRequirement

      public AbstractResearchProvider.Research addResearchRequirement(net.minecraft.resources.ResourceLocation researchReq)
      The non-parent required research, which must be completed in addition to Parent research to begin this research. This uses an auto-generated language key. To override, add an additional string parameter. Multiple ResearchRequirements are supported. ResearchRequirements can apply from other branches. If the research requirement does not exist, it is fulfilled automatically.
      Parameters:
      researchReq - The required research.
      Returns:
      this
    • addItemCost

      public AbstractResearchProvider.Research addItemCost(net.minecraft.world.item.Item item, int count)
      Adds an item cost to the research. This will be consumed when beginning the research, and will not be refunded. Multiple ItemCosts are supported, but for UI reasons it's encouraged to keep to 5 or less.
      Parameters:
      item - The item to require.
      count - The number of the item to require.
      Returns:
      this.
    • addItemCost

      public AbstractResearchProvider.Research addItemCost(List<net.minecraft.world.item.Item> items, int count)
      Adds an item cost to the research. This will be consumed when beginning the research, and will not be refunded. Multiple ItemCosts are supported, but for UI reasons it's encouraged to keep to 5 or less.
      Parameters:
      items - The item to require.
      count - The number of the item to require.
      Returns:
      this.
    • addItemCost

      public AbstractResearchProvider.Research addItemCost(net.minecraft.tags.TagKey<net.minecraft.world.item.Item> tag, int count)
      Adds an item cost to the research. This will be consumed when beginning the research, and will not be refunded. Multiple ItemCosts are supported, but for UI reasons it's encouraged to keep to 5 or less.
      Parameters:
      tag - The tag to require.
      count - The number of the item to require.
      Returns:
      this.
    • addEffect

      public AbstractResearchProvider.Research addEffect(net.minecraft.resources.ResourceLocation effect, int level)
      Add an effect to the research. Research Effects are applied on completion, and remain unless the colony is destroyed or the research is undone. Multiple Effects are supported.
      Parameters:
      effect - the id of the research effect to apply on completion.
      level - the strength of the research effect to apply on completion.
      Returns:
      this
    • addEffect

      public AbstractResearchProvider.Research addEffect(AbstractColonyBlock<?> buildingBlock, int level)
      Add an unlock building effect to the research. Research Effects are applied on completion, and remain unless the colony is destroyed or the research is undone. See ModBuildings for a list of supported buildings. Whenever possible, use the public static String BUILDINGNAME_ID constants from ModBuildings Buildings with no applicable research effects loaded default to unlocked. Multiple Effects are supported.
      Parameters:
      buildingBlock - the building block to lock behind this research.
      level - the strength of the research effect to apply on completion. Automatically generated effects will unlock up to Building Tier 10 at Level 1. Manually generated effects can limited to individual tiers based on strength.
      Returns:
      this
    • setRemove

      Sets the Research to be removed, for its own ResourceLocation. Prevents load (though not data gen) of all other settings. Not compatible with other variants of setRemove.
      Returns:
      this
    • setRemove

      public AbstractResearchProvider.Research setRemove(net.minecraft.resources.ResourceLocation researchId)
      Sets the Research JSON to remove a different individual research, by ResourceLocation. Prevents load (though not data gen) of all other settings. Not compatible with other variants of setRemove.
      Parameters:
      researchId - The target research.
      Returns:
      this
    • setRemove

      public AbstractResearchProvider.Research setRemove(Collection<net.minecraft.resources.ResourceLocation> researchIds)
      Sets the Research JSON to remove multiple individual research, by ResourceLocations. Prevents load (though not data gen) of all other settings. Not compatible with other variants of setRemove.
      Parameters:
      researchIds - The target research.
      Returns:
      this
    • addToList

      Add the Research to a collection, and return the same research. essentially the same as List.add() with a useful return.
      Parameters:
      list - The list to add the Research onto.
      Returns:
      this