Class AdvancementBuilder
java.lang.Object
net.minheur.techno_lib.advancement.AdvancementBuilder
Custom builder for advancements
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe group of your advancement (ex.private final StringThe id of your advancement (ex.private final booleanSet if the advancement is a root or notprivate final com.google.gson.JsonObjectThe json of your advancement.private final StringThe ID of the mod using this class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheck()Check if you've set all things correctlyAdds a criterion for your advancementdisplay(net.minecraft.world.level.ItemLike iconItem, @Nullable net.minecraft.resources.ResourceLocation background, net.minecraft.advancements.FrameType frameType, boolean showToast, boolean announce, boolean hidden) Add advancement's display parameter.Get the full id, usable inparent(ResourceLocation)of others advancement.getGroup()getId()com.google.gson.JsonObjectgetJson()get the Json of your advancement (to build it)net.minecraft.resources.ResourceLocationgetLoc()Get the full loc of the advancementparent(net.minecraft.resources.ResourceLocation parentId) Add a parent to your advancement.requirements(String[][] reqs) You need to add you requirement.rewards(net.minecraft.advancements.AdvancementRewards rewards) Add a reward to your advancement.
-
Field Details
-
id
The id of your advancement (ex.smelt_iron) -
group
The group of your advancement (ex.story) -
isRoot
private final boolean isRootSet if the advancement is a root or not -
json
private final com.google.gson.JsonObject jsonThe json of your advancement. The properties are added to it progressively. -
modid
The ID of the mod using this class. Used in ids
-
-
Constructor Details
-
AdvancementBuilder
-
-
Method Details
-
display
public AdvancementBuilder display(net.minecraft.world.level.ItemLike iconItem, @Nullable @Nullable net.minecraft.resources.ResourceLocation background, net.minecraft.advancements.FrameType frameType, boolean showToast, boolean announce, boolean hidden) Add advancement's display parameter.- Parameters:
iconItem- the icon of your advancement, displayed on advancements pagebackground- the background of the advancement page (only for root advancements, set to null if non-root)frameType- the type of advancement you wantshowToast- set if a toast should appear when you get the advancementannounce- set if a chat message should be sent when you get the advancementhidden- set if the advancement should be hidden until you get it- Returns:
- the building advancement
-
parent
Add a parent to your advancement. Should not be set if it's a root advancement.- Parameters:
parentId- theof the parent- Returns:
- the building advancement
-
criterion
Adds a criterion for your advancement- Parameters:
name- the name of your criterion. Should be set inrequirements(java.lang.String[][])strategy.trigger- the trigger of your criterion as aJsonObject. Consider usingCriterionBuilderfor easier criterion.- Returns:
- the building advancement
-
requirements
You need to add you requirement.reqsis a double array, so you need to follow this to use it :In the array, you need to accomplish one sub-array. In each sub-array, you need to complete all to get it. (ex.
[["a", "b"], ["c"]]is(a && b) || c).- Parameters:
reqs- the double array- Returns:
- the building advancement
-
rewards
Add a reward to your advancement. You can useAdvancementRewards.Builderfor easier reward. Don't set to have no rewards.- Parameters:
rewards- the reward of your advancement.- Returns:
- the building advancement
-
check
private void check()Check if you've set all things correctly -
getFullId
Get the full id, usable inparent(ResourceLocation)of others advancement.- Returns:
- the full id (with group) of your advancement.
-
getJson
public com.google.gson.JsonObject getJson()get the Json of your advancement (to build it)- Returns:
- the advancement's json
-
getId
- Returns:
- your advancement's id
-
getGroup
- Returns:
- your advancement's group
-
getLoc
public net.minecraft.resources.ResourceLocation getLoc()Get the full loc of the advancement- Returns:
- the advancement's ressource location
-