Class GlobalResearch

java.lang.Object
com.minecolonies.core.research.GlobalResearch
All Implemented Interfaces:
IGlobalResearch

public class GlobalResearch extends Object implements IGlobalResearch
The implementation of the IGlobalResearch interface which represents the research on the global level.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GlobalResearch(net.minecraft.resources.ResourceLocation id, @Nullable net.minecraft.resources.ResourceLocation parent, net.minecraft.resources.ResourceLocation branch, net.minecraft.network.chat.contents.TranslatableContents name, net.minecraft.network.chat.contents.TranslatableContents subtitle, int depth, int sortOrder, boolean onlyChild, boolean hidden, boolean autostart, boolean instant, boolean immutable)
    Create the new research with multiple effects
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a child to a research.
    void
    addChild(net.minecraft.resources.ResourceLocation child)
    Add a child to a research, without setting parentage.
    void
    Add an individual cost.
    void
    Add an individual effect.
    void
    Add an individual requirement
    boolean
    canDisplay(int uni_level)
    Check if this research can be displayed in the GUI.
    boolean
    canResearch(@NotNull IBuilding building, @NotNull ILocalResearchTree localTree)
    Check if this research can be executed at this moment.
    net.minecraft.resources.ResourceLocation
    Get the id of the branch.
    List<net.minecraft.resources.ResourceLocation>
    Get the list of children of the research.
    Get the cost list from the research.
    int
    Get the depth in the research tree.
    Get the effect of the research.
    @NotNull net.minecraft.resources.ResourceLocation
    Getter of the id of the research.
    net.minecraft.network.chat.contents.TranslatableContents
    Human-readable description of research, in human-readable text or as a translation key.
    @Nullable net.minecraft.resources.ResourceLocation
    Get the id of the parent IResearch.
    Getter for the research requirement.
    int
    Get the sort order for relative display position.
    net.minecraft.network.chat.contents.TranslatableContents
    Subtitle description of research, in human-readable text or as a translation key.
    boolean
    hasEnoughResources(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.core.BlockPos universityPos)
    Checks if there are enough resources between the player inventory and the university's inventory to start this research.
    boolean
    Check if this research is an only child research.
    boolean
    Check if this research has other children and if one of these children has been research already.
    boolean
    Check if this research should automatically start when requirements are complete.
    boolean
    Check if this research is a hidden research.
    boolean
    Check if this research is an immutable research.
    boolean
    Check if this research is an instant research.
    void
    startResearch(@NotNull ILocalResearchTree localResearchTree)
    Start the research.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GlobalResearch

      public GlobalResearch(net.minecraft.resources.ResourceLocation id, @Nullable @Nullable net.minecraft.resources.ResourceLocation parent, net.minecraft.resources.ResourceLocation branch, net.minecraft.network.chat.contents.TranslatableContents name, net.minecraft.network.chat.contents.TranslatableContents subtitle, int depth, int sortOrder, boolean onlyChild, boolean hidden, boolean autostart, boolean instant, boolean immutable)
      Create the new research with multiple effects
      Parameters:
      id - its id.
      parent - the research's parent, if one is present, or null if not.
      branch - the branch it is on.
      name - the optional name of the research. If empty, a key generated from the id will be used instead.
      subtitle - the optional short description of the research, in plaintext or as a translation key.
      depth - the depth in the tree.
      sortOrder - the relative vertical order of the research's display, in relation to its siblings.
      onlyChild - if the research allows only one child research to be completed.
      hidden - if the research is only visible when eligible to be researched.
      autostart - if the research should begin automatically, or notify the player, when it is eligible.
      instant - if the research should be completed instantly (ish) from when begun.
      immutable - if the research can not be reset once unlocked.
  • Method Details

    • canResearch

      public boolean canResearch(@NotNull @NotNull IBuilding building, @NotNull @NotNull ILocalResearchTree localTree)
      Description copied from interface: IGlobalResearch
      Check if this research can be executed at this moment.
      Specified by:
      canResearch in interface IGlobalResearch
      Parameters:
      building - the university building trying to do the research.
      localTree - the local tree of the colony.
      Returns:
      true if so.
    • canDisplay

      public boolean canDisplay(int uni_level)
      Description copied from interface: IGlobalResearch
      Check if this research can be displayed in the GUI.
      Specified by:
      canDisplay in interface IGlobalResearch
      Parameters:
      uni_level - the level of the university.
      Returns:
      true if so.
    • hasEnoughResources

      public boolean hasEnoughResources(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.core.BlockPos universityPos)
      Checks if there are enough resources between the player inventory and the university's inventory to start this research.
      Specified by:
      hasEnoughResources in interface IGlobalResearch
      Parameters:
      player - the player to check.
      universityPos - the position of the university to check.
      Returns:
      true if the player has enough resources.
    • getCostList

      public List<IResearchCost> getCostList()
      Description copied from interface: IGlobalResearch
      Get the cost list from the research.
      Specified by:
      getCostList in interface IGlobalResearch
      Returns:
      the list.
    • startResearch

      public void startResearch(@NotNull @NotNull ILocalResearchTree localResearchTree)
      Description copied from interface: IGlobalResearch
      Start the research.
      Specified by:
      startResearch in interface IGlobalResearch
      Parameters:
      localResearchTree - the local research tree to store in the colony.
    • getId

      @NotNull public @NotNull net.minecraft.resources.ResourceLocation getId()
      Description copied from interface: IGlobalResearch
      Getter of the id of the research.
      Specified by:
      getId in interface IGlobalResearch
      Returns:
      the research id, as a ResourceLocation
    • getName

      public net.minecraft.network.chat.contents.TranslatableContents getName()
      Description copied from interface: IGlobalResearch
      Human-readable description of research, in human-readable text or as a translation key.
      Specified by:
      getName in interface IGlobalResearch
      Returns:
      the description.
    • getSubtitle

      public net.minecraft.network.chat.contents.TranslatableContents getSubtitle()
      Description copied from interface: IGlobalResearch
      Subtitle description of research, in human-readable text or as a translation key.
      Specified by:
      getSubtitle in interface IGlobalResearch
      Returns:
      the optional subtitle name.
    • getParent

      @Nullable public @Nullable net.minecraft.resources.ResourceLocation getParent()
      Description copied from interface: IGlobalResearch
      Get the id of the parent IResearch.
      Specified by:
      getParent in interface IGlobalResearch
      Returns:
      the parent id, as a ResourceLocation
    • getBranch

      public net.minecraft.resources.ResourceLocation getBranch()
      Description copied from interface: IGlobalResearch
      Get the id of the branch.
      Specified by:
      getBranch in interface IGlobalResearch
      Returns:
      the branch id, as a ResourceLocation
    • getDepth

      public int getDepth()
      Description copied from interface: IGlobalResearch
      Get the depth in the research tree.
      Specified by:
      getDepth in interface IGlobalResearch
      Returns:
      the depth.
    • getSortOrder

      public int getSortOrder()
      Description copied from interface: IGlobalResearch
      Get the sort order for relative display position.
      Specified by:
      getSortOrder in interface IGlobalResearch
      Returns:
      the depth.
    • isInstant

      public boolean isInstant()
      Description copied from interface: IGlobalResearch
      Check if this research is an instant research. If so, it will attempt to start when its requirements are complete, and prompt the player.
      Specified by:
      isInstant in interface IGlobalResearch
      Returns:
      true if so.
    • isHidden

      public boolean isHidden()
      Description copied from interface: IGlobalResearch
      Check if this research is a hidden research. If so, it (and its children) should only be visible if all requirements are met.
      Specified by:
      isHidden in interface IGlobalResearch
      Returns:
      true if so.
    • isAutostart

      public boolean isAutostart()
      Description copied from interface: IGlobalResearch
      Check if this research should automatically start when requirements are complete. This can temporarily exceed normal limits of the max number of concurrent researches.
      Specified by:
      isAutostart in interface IGlobalResearch
      Returns:
      true if so.
    • isImmutable

      public boolean isImmutable()
      Description copied from interface: IGlobalResearch
      Check if this research is an immutable research. If so, it (and ancestor research unlocking it) can not be reset once completed.
      Specified by:
      isImmutable in interface IGlobalResearch
      Returns:
      true if so.
    • hasOnlyChild

      public boolean hasOnlyChild()
      Description copied from interface: IGlobalResearch
      Check if this research is an only child research. This means, after researching one child no other children can be researched.
      Specified by:
      hasOnlyChild in interface IGlobalResearch
      Returns:
      true if so.
    • hasResearchedChild

      public boolean hasResearchedChild(@NotNull @NotNull ILocalResearchTree localTree)
      Description copied from interface: IGlobalResearch
      Check if this research has other children and if one of these children has been research already.
      Specified by:
      hasResearchedChild in interface IGlobalResearch
      Parameters:
      localTree - the local tree of the colony.
      Returns:
      true if so.
    • addChild

      public void addChild(IGlobalResearch child)
      Description copied from interface: IGlobalResearch
      Add a child to a research.
      Specified by:
      addChild in interface IGlobalResearch
      Parameters:
      child - the child to add.
    • addChild

      public void addChild(net.minecraft.resources.ResourceLocation child)
      Description copied from interface: IGlobalResearch
      Add a child to a research, without setting parentage.
      Specified by:
      addChild in interface IGlobalResearch
      Parameters:
      child - the child to add
    • addCost

      public void addCost(IResearchCost cost)
      Description copied from interface: IGlobalResearch
      Add an individual cost.
      Specified by:
      addCost in interface IGlobalResearch
      Parameters:
      cost - the individual item to add to the cost list, as a reseach cost instance.
    • addEffect

      public void addEffect(IResearchEffect effect)
      Description copied from interface: IGlobalResearch
      Add an individual effect.
      Specified by:
      addEffect in interface IGlobalResearch
      Parameters:
      effect - the individual effect to add to the research, as a IResearchEffect.
    • addRequirement

      public void addRequirement(IResearchRequirement requirement)
      Description copied from interface: IGlobalResearch
      Add an individual requirement
      Specified by:
      addRequirement in interface IGlobalResearch
      Parameters:
      requirement - the individual requirement to add to the research, as an IResearchRequirement.
    • getResearchRequirements

      public List<IResearchRequirement> getResearchRequirements()
      Description copied from interface: IGlobalResearch
      Getter for the research requirement.
      Specified by:
      getResearchRequirements in interface IGlobalResearch
      Returns:
      the requirement.
    • getChildren

      public List<net.minecraft.resources.ResourceLocation> getChildren()
      Description copied from interface: IGlobalResearch
      Get the list of children of the research.
      Specified by:
      getChildren in interface IGlobalResearch
      Returns:
      a copy of the list of child identifiers.
    • getEffects

      public List<IResearchEffect> getEffects()
      Description copied from interface: IGlobalResearch
      Get the effect of the research.
      Specified by:
      getEffects in interface IGlobalResearch
      Returns:
      the effect.