Class GlobalResearchTree

java.lang.Object
com.minecolonies.core.research.GlobalResearchTree
All Implemented Interfaces:
IGlobalResearchTree

public class GlobalResearchTree extends Object implements IGlobalResearchTree
The class which contains all research.
  • Constructor Details

    • GlobalResearchTree

      public GlobalResearchTree()
  • Method Details

    • getResearch

      public IGlobalResearch getResearch(net.minecraft.resources.ResourceLocation branch, net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Get a research by id.
      Specified by:
      getResearch in interface IGlobalResearchTree
      Parameters:
      branch - the branch of the research.
      id - the id of the research.
      Returns:
      the IGlobalResearch object.
    • getResearch

      @Nullable public @Nullable IGlobalResearch getResearch(net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Get the first research with a given id, on any branch. Avoid using when branch is available.
      Specified by:
      getResearch in interface IGlobalResearchTree
      Parameters:
      id - the id of the research.
      Returns:
      the first matching IGlobalResearch object.
    • hasResearch

      public boolean hasResearch(net.minecraft.resources.ResourceLocation branch, net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Check if a research exists, by id.
      Specified by:
      hasResearch in interface IGlobalResearchTree
      Parameters:
      branch - the branch of the research.
      id - the id of the research.
      Returns:
      true if the research exists, false if it does not.
    • hasResearch

      public boolean hasResearch(net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Check if a research exists, by id.
      Specified by:
      hasResearch in interface IGlobalResearchTree
      Parameters:
      id - the id of the research.
      Returns:
      true if the research exists, false if it does not.
    • addResearch

      public void addResearch(net.minecraft.resources.ResourceLocation branch, IGlobalResearch research, boolean isReloadedWithWorld)
      Description copied from interface: IGlobalResearchTree
      Add a research to the tree.
      Specified by:
      addResearch in interface IGlobalResearchTree
      Parameters:
      branch - the branch of the research.
      research - the research to add.
      isReloadedWithWorld - true if reloaded with world events (ie data packs, onWorldLoad), false if assigned statically once.
    • addBranchData

      public void addBranchData(net.minecraft.resources.ResourceLocation branchId, IGlobalResearchBranch branchData)
      Description copied from interface: IGlobalResearchTree
      Add data for a research branch, used to contain translation texts, research speed, and other properties.
      Specified by:
      addBranchData in interface IGlobalResearchTree
      Parameters:
      branchId - the branch Id.
      branchData - the data.
    • getResearchForEffect

      public Set<IGlobalResearch> getResearchForEffect(net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Gets all research for a given research effect id, if any are present.
      Specified by:
      getResearchForEffect in interface IGlobalResearchTree
      Parameters:
      id - the effect's identifier.
      Returns:
      The set of researches for the effect, or null if no research has this effect.
    • hasResearchEffect

      public boolean hasResearchEffect(net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Checks if a specific research effect has been registered, whether or not it is unlocked.
      Specified by:
      hasResearchEffect in interface IGlobalResearchTree
      Parameters:
      id - the effect's identifier.
      Returns:
      true if present, false if not registered.
    • getBranches

      public List<net.minecraft.resources.ResourceLocation> getBranches()
      Description copied from interface: IGlobalResearchTree
      Get the list of all branch ids.
      Specified by:
      getBranches in interface IGlobalResearchTree
      Returns:
      the list of branches.
    • getBranchData

      public IGlobalResearchBranch getBranchData(net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Get the specific GlobalResearchBranch data for a specific branch id.
      Specified by:
      getBranchData in interface IGlobalResearchTree
      Parameters:
      id - the branch of the research
    • getPrimaryResearch

      public List<net.minecraft.resources.ResourceLocation> getPrimaryResearch(net.minecraft.resources.ResourceLocation branch)
      Description copied from interface: IGlobalResearchTree
      Get the primary research of a certain branch.
      Specified by:
      getPrimaryResearch in interface IGlobalResearchTree
      Parameters:
      branch - the branch it belongs to.
      Returns:
      the list of research without parent.
    • reset

      public void reset()
      Description copied from interface: IGlobalResearchTree
      Resets all dynamically assigned research.
      Specified by:
      reset in interface IGlobalResearchTree
    • isResearchRequirementsFulfilled

      public boolean isResearchRequirementsFulfilled(List<IResearchRequirement> requirements, IColony colony)
      Description copied from interface: IGlobalResearchTree
      Checks if the research requirements are completed, for a given colony.
      Specified by:
      isResearchRequirementsFulfilled in interface IGlobalResearchTree
      Parameters:
      requirements - the research requirements.
      colony - the colony to test against.
      Returns:
      true if complete.
    • sendGlobalResearchTreePackets

      public void sendGlobalResearchTreePackets(net.minecraft.server.level.ServerPlayer player)
      Description copied from interface: IGlobalResearchTree
      Sends messages to the client from the server describing the Global Research Tree. Only used for dedicated servers.
      Specified by:
      sendGlobalResearchTreePackets in interface IGlobalResearchTree
      Parameters:
      player - the player to send the message all players should be updated on a data pack reload.
    • serializeNetworkData

      public void serializeNetworkData(net.minecraft.network.FriendlyByteBuf buf)
    • handleGlobalResearchTreeMessage

      public IMessage handleGlobalResearchTreeMessage(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: IGlobalResearchTree
      Handle messages in the client from the server describing the Global Research Tree. Only used for remote clients.
      Specified by:
      handleGlobalResearchTreeMessage in interface IGlobalResearchTree
      Parameters:
      buf - the buffer of received network data.
    • getEffectsForResearch

      public List<IResearchEffect> getEffectsForResearch(@NotNull @NotNull net.minecraft.resources.ResourceLocation id)
      Description copied from interface: IGlobalResearchTree
      Get an effect id for a particular research
      Specified by:
      getEffectsForResearch in interface IGlobalResearchTree
      Parameters:
      id - the id of the research.
      Returns:
      the effect id
    • getAutostartResearches

      public Set<IGlobalResearch> getAutostartResearches()
      Description copied from interface: IGlobalResearchTree
      Get the list of researches that are intended to start automatically once their requirements are met.
      Specified by:
      getAutostartResearches in interface IGlobalResearchTree
      Returns:
      the list of research.
    • getResearchResetCosts

      public List<ItemStorage> getResearchResetCosts()
      Description copied from interface: IGlobalResearchTree
      Validates and gets the list of research reset costs, if any are set, from their configuration values.
      Specified by:
      getResearchResetCosts in interface IGlobalResearchTree
      Returns:
      the list of items in ItemStorage format.