Record Class UpgradeDataProvider.Upgrade<R extends UpgradeSerialiser<?>>

java.lang.Object
java.lang.Record
dan200.computercraft.api.upgrades.UpgradeDataProvider.Upgrade<R>
Type Parameters:
R - The type of upgrade serialiser.
Record Components:
id - The ID for this upgrade.
serialiser - The serialiser which reads and writes this upgrade.
serialise - Augment the generated JSON with additional fields.
Enclosing class:
UpgradeDataProvider<T extends UpgradeBase,R extends UpgradeSerialiser<? extends T>>

public static record UpgradeDataProvider.Upgrade<R extends UpgradeSerialiser<?>>(net.minecraft.resources.ResourceLocation id, R extends UpgradeSerialiser<?> serialiser, Consumer<com.google.gson.JsonObject> serialise) extends Record
A constructed upgrade instance, produced UpgradeDataProvider.addUpgrades(Consumer).
  • Constructor Details

    • Upgrade

      public Upgrade(net.minecraft.resources.ResourceLocation id, R serialiser, Consumer<com.google.gson.JsonObject> serialise)
      Creates an instance of a Upgrade record class.
      Parameters:
      id - the value for the id record component
      serialiser - the value for the serialiser record component
      serialise - the value for the serialise record component
  • Method Details

    • add

      public void add(Consumer<UpgradeDataProvider.Upgrade<R>> add)
      Convenience method for registering an upgrade.
      Parameters:
      add - The callback given to UpgradeDataProvider.addUpgrades(Consumer)
    • requireMod

      public UpgradeDataProvider.Upgrade<R> requireMod(String modId)
      Return a new UpgradeDataProvider.Upgrade which requires the given mod to be present.

      This uses mod-loader-specific hooks (Forge's crafting conditions and Fabric's resource conditions). If using this in a multi-loader setup, you must generate resources separately for the two loaders.

      Parameters:
      modId - The id of the mod.
      Returns:
      A new upgrade instance.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public net.minecraft.resources.ResourceLocation id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • serialiser

      public R serialiser()
      Returns the value of the serialiser record component.
      Returns:
      the value of the serialiser record component
    • serialise

      public Consumer<com.google.gson.JsonObject> serialise()
      Returns the value of the serialise record component.
      Returns:
      the value of the serialise record component