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 TypeMethodDescriptionvoid
add
(Consumer<UpgradeDataProvider.Upgrade<R>> add) Convenience method for registering an upgrade.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.net.minecraft.resources.ResourceLocation
id()
Returns the value of theid
record component.requireMod
(String modId) Return a newUpgradeDataProvider.Upgrade
which requires the given mod to be present.Consumer<com.google.gson.JsonObject>
Returns the value of theserialise
record component.Returns the value of theserialiser
record component.final String
toString()
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 aUpgrade
record class.- Parameters:
id
- the value for theid
record componentserialiser
- the value for theserialiser
record componentserialise
- the value for theserialise
record component
-
-
Method Details
-
add
Convenience method for registering an upgrade.- Parameters:
add
- The callback given toUpgradeDataProvider.addUpgrades(Consumer)
-
requireMod
Return a newUpgradeDataProvider.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
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 theid
record component.- Returns:
- the value of the
id
record component
-
serialiser
Returns the value of theserialiser
record component.- Returns:
- the value of the
serialiser
record component
-
serialise
Returns the value of theserialise
record component.- Returns:
- the value of the
serialise
record component
-