Package com.minecolonies.core.research
Class GlobalResearch
java.lang.Object
com.minecolonies.core.research.GlobalResearch
- All Implemented Interfaces:
IGlobalResearch
The implementation of the IGlobalResearch interface which represents the research on the global level.
-
Constructor Summary
ConstructorsConstructorDescriptionGlobalResearch(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 TypeMethodDescriptionvoidaddChild(IGlobalResearch child) Add a child to a research.voidaddChild(net.minecraft.resources.ResourceLocation child) Add a child to a research, without setting parentage.voidaddCost(net.neoforged.neoforge.common.crafting.SizedIngredient cost) Add item costs.voidaddEffect(IResearchEffect effect) Add an individual effect.voidaddRequirement(IResearchRequirement requirement) Add an individual requirementbooleancanDisplay(int uni_level) Check if this research can be displayed in the GUI.booleancanResearch(@NotNull IBuilding building, @NotNull ILocalResearchTree localTree) Check if this research can be executed at this moment.net.minecraft.resources.ResourceLocationGet the id of the branch.List<net.minecraft.resources.ResourceLocation> Get the list of children of the research.List<net.neoforged.neoforge.common.crafting.SizedIngredient> Get the cost list from the research.intgetDepth()Get the depth in the research tree.Get the effect of the research.@NotNull net.minecraft.resources.ResourceLocationgetId()Getter of the id of the research.net.minecraft.network.chat.contents.TranslatableContentsgetName()Human-readable description of research, in human-readable text or as a translation key.@Nullable net.minecraft.resources.ResourceLocationGet the id of the parent IResearch.Getter for the research requirement.intGet the sort order for relative display position.net.minecraft.network.chat.contents.TranslatableContentsSubtitle description of research, in human-readable text or as a translation key.booleanhasEnoughResources(@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.booleanCheck if this research is an only child research.booleanhasResearchedChild(@NotNull ILocalResearchTree localTree) Check if this research has other children and if one of these children has been research already.booleanCheck if this research should automatically start when requirements are complete.booleanisHidden()Check if this research is a hidden research.booleanCheck if this research is an immutable research.booleanCheck if this research is an instant research.voidstartResearch(@NotNull ILocalResearchTree localResearchTree) Start the research.
-
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:IGlobalResearchCheck if this research can be executed at this moment.- Specified by:
canResearchin interfaceIGlobalResearch- 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:IGlobalResearchCheck if this research can be displayed in the GUI.- Specified by:
canDisplayin interfaceIGlobalResearch- 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:
hasEnoughResourcesin interfaceIGlobalResearch- Parameters:
player- the player to check.universityPos- the position of the university to check.- Returns:
- true if the player has enough resources.
-
getCostList
Description copied from interface:IGlobalResearchGet the cost list from the research.- Specified by:
getCostListin interfaceIGlobalResearch- Returns:
- the list.
-
startResearch
Description copied from interface:IGlobalResearchStart the research.- Specified by:
startResearchin interfaceIGlobalResearch- Parameters:
localResearchTree- the local research tree to store in the colony.
-
getId
@NotNull public @NotNull net.minecraft.resources.ResourceLocation getId()Description copied from interface:IGlobalResearchGetter of the id of the research.- Specified by:
getIdin interfaceIGlobalResearch- Returns:
- the research id, as a ResourceLocation
-
getName
public net.minecraft.network.chat.contents.TranslatableContents getName()Description copied from interface:IGlobalResearchHuman-readable description of research, in human-readable text or as a translation key.- Specified by:
getNamein interfaceIGlobalResearch- Returns:
- the description.
-
getSubtitle
public net.minecraft.network.chat.contents.TranslatableContents getSubtitle()Description copied from interface:IGlobalResearchSubtitle description of research, in human-readable text or as a translation key.- Specified by:
getSubtitlein interfaceIGlobalResearch- Returns:
- the optional subtitle name.
-
getParent
@Nullable public @Nullable net.minecraft.resources.ResourceLocation getParent()Description copied from interface:IGlobalResearchGet the id of the parent IResearch.- Specified by:
getParentin interfaceIGlobalResearch- Returns:
- the parent id, as a ResourceLocation
-
getBranch
public net.minecraft.resources.ResourceLocation getBranch()Description copied from interface:IGlobalResearchGet the id of the branch.- Specified by:
getBranchin interfaceIGlobalResearch- Returns:
- the branch id, as a ResourceLocation
-
getDepth
public int getDepth()Description copied from interface:IGlobalResearchGet the depth in the research tree.- Specified by:
getDepthin interfaceIGlobalResearch- Returns:
- the depth.
-
getSortOrder
public int getSortOrder()Description copied from interface:IGlobalResearchGet the sort order for relative display position.- Specified by:
getSortOrderin interfaceIGlobalResearch- Returns:
- the depth.
-
isInstant
public boolean isInstant()Description copied from interface:IGlobalResearchCheck 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:
isInstantin interfaceIGlobalResearch- Returns:
- true if so.
-
isHidden
public boolean isHidden()Description copied from interface:IGlobalResearchCheck if this research is a hidden research. If so, it (and its children) should only be visible if all requirements are met.- Specified by:
isHiddenin interfaceIGlobalResearch- Returns:
- true if so.
-
isAutostart
public boolean isAutostart()Description copied from interface:IGlobalResearchCheck 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:
isAutostartin interfaceIGlobalResearch- Returns:
- true if so.
-
isImmutable
public boolean isImmutable()Description copied from interface:IGlobalResearchCheck if this research is an immutable research. If so, it (and ancestor research unlocking it) can not be reset once completed.- Specified by:
isImmutablein interfaceIGlobalResearch- Returns:
- true if so.
-
hasOnlyChild
public boolean hasOnlyChild()Description copied from interface:IGlobalResearchCheck if this research is an only child research. This means, after researching one child no other children can be researched.- Specified by:
hasOnlyChildin interfaceIGlobalResearch- Returns:
- true if so.
-
hasResearchedChild
Description copied from interface:IGlobalResearchCheck if this research has other children and if one of these children has been research already.- Specified by:
hasResearchedChildin interfaceIGlobalResearch- Parameters:
localTree- the local tree of the colony.- Returns:
- true if so.
-
addChild
Description copied from interface:IGlobalResearchAdd a child to a research.- Specified by:
addChildin interfaceIGlobalResearch- Parameters:
child- the child to add.
-
addChild
public void addChild(net.minecraft.resources.ResourceLocation child) Description copied from interface:IGlobalResearchAdd a child to a research, without setting parentage.- Specified by:
addChildin interfaceIGlobalResearch- Parameters:
child- the child to add
-
addCost
public void addCost(net.neoforged.neoforge.common.crafting.SizedIngredient cost) Description copied from interface:IGlobalResearchAdd item costs.- Specified by:
addCostin interfaceIGlobalResearch- Parameters:
cost- the items to add to the cost list.
-
addEffect
Description copied from interface:IGlobalResearchAdd an individual effect.- Specified by:
addEffectin interfaceIGlobalResearch- Parameters:
effect- the individual effect to add to the research, as a IResearchEffect.
-
addRequirement
Description copied from interface:IGlobalResearchAdd an individual requirement- Specified by:
addRequirementin interfaceIGlobalResearch- Parameters:
requirement- the individual requirement to add to the research, as an IResearchRequirement.
-
getResearchRequirements
Description copied from interface:IGlobalResearchGetter for the research requirement.- Specified by:
getResearchRequirementsin interfaceIGlobalResearch- Returns:
- the requirement.
-
getChildren
Description copied from interface:IGlobalResearchGet the list of children of the research.- Specified by:
getChildrenin interfaceIGlobalResearch- Returns:
- a copy of the list of child identifiers.
-
getEffects
Description copied from interface:IGlobalResearchGet the effect of the research.- Specified by:
getEffectsin interfaceIGlobalResearch- Returns:
- the effect.
-