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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Consumer<UpgradeDataProvider.Upgrade<R>> add) Convenience method for registering an upgrade.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.net.minecraft.resources.ResourceLocationid()Returns the value of theidrecord component.requireMod(String modId) Return a newUpgradeDataProvider.Upgradewhich requires the given mod to be present.Consumer<com.google.gson.JsonObject>Returns the value of theserialiserecord component.Returns the value of theserialiserrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Upgrade
public Upgrade(net.minecraft.resources.ResourceLocation id, R serialiser, Consumer<com.google.gson.JsonObject> serialise) Creates an instance of aUpgraderecord class.- Parameters:
id- the value for theidrecord componentserialiser- the value for theserialiserrecord componentserialise- the value for theserialiserecord component
-
-
Method Details
-
add
Convenience method for registering an upgrade.- Parameters:
add- The callback given toUpgradeDataProvider.addUpgrades(Consumer)
-
requireMod
Return a newUpgradeDataProvider.Upgradewhich 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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
id
public net.minecraft.resources.ResourceLocation id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
serialiser
Returns the value of theserialiserrecord component.- Returns:
- the value of the
serialiserrecord component
-
serialise
Returns the value of theserialiserecord component.- Returns:
- the value of the
serialiserecord component
-