Class AdvancementBuilder

java.lang.Object
net.minheur.techno_lib.advancement.AdvancementBuilder

public class AdvancementBuilder extends Object
Custom builder for advancements
  • Field Details

    • id

      private final String id
      The id of your advancement (ex. smelt_iron)
    • group

      private final String group
      The group of your advancement (ex. story)
    • isRoot

      private final boolean isRoot
      Set if the advancement is a root or not
    • json

      private final com.google.gson.JsonObject json
      The json of your advancement. The properties are added to it progressively.
    • modid

      private final String modid
      The ID of the mod using this class. Used in ids
  • Constructor Details

    • AdvancementBuilder

      public AdvancementBuilder(String id, String group, boolean isRoot, String modid)
  • 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 page
      background - the background of the advancement page (only for root advancements, set to null if non-root)
      frameType - the type of advancement you want
      showToast - set if a toast should appear when you get the advancement
      announce - set if a chat message should be sent when you get the advancement
      hidden - set if the advancement should be hidden until you get it
      Returns:
      the building advancement
    • parent

      public AdvancementBuilder parent(net.minecraft.resources.ResourceLocation parentId)
      Add a parent to your advancement. Should not be set if it's a root advancement.
      Parameters:
      parentId - the of the parent
      Returns:
      the building advancement
    • criterion

      public AdvancementBuilder criterion(String name, com.google.gson.JsonObject trigger)
      Adds a criterion for your advancement
      Parameters:
      name - the name of your criterion. Should be set in requirements(java.lang.String[][]) strategy.
      trigger - the trigger of your criterion as a JsonObject. Consider using CriterionBuilder for easier criterion.
      Returns:
      the building advancement
    • requirements

      public AdvancementBuilder requirements(String[][] reqs)
      You need to add you requirement. reqs is 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

      public AdvancementBuilder rewards(net.minecraft.advancements.AdvancementRewards rewards)
      Add a reward to your advancement. You can use AdvancementRewards.Builder for 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

      public String getFullId()
      Get the full id, usable in parent(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

      public String getId()
      Returns:
      your advancement's id
    • getGroup

      public String 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