Record Class UpgradeData<T extends UpgradeBase>
java.lang.Object
java.lang.Record
dan200.computercraft.api.upgrades.UpgradeData<T>
- Type Parameters:
T
- The type of upgrade, eitherITurtleUpgrade
orIPocketUpgrade
.- Record Components:
holder
- The current upgrade holder.data
- The upgrade's data.
public record UpgradeData<T extends UpgradeBase>(net.minecraft.core.Holder.Reference<T extends UpgradeBase> holder, net.minecraft.core.component.DataComponentPatch data)
extends Record
An upgrade (i.e. a
ITurtleUpgrade
) and its current upgrade data.-
Constructor Summary
ConstructorsConstructorDescriptionUpgradeData
(net.minecraft.core.Holder.Reference<T> holder, net.minecraft.core.component.DataComponentPatch data) Creates an instance of aUpgradeData
record class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.core.component.DataComponentPatch
data()
Returns the value of thedata
record component.final boolean
Indicates whether some other object is "equal to" this one.net.minecraft.world.item.ItemStack
Get the upgrade item for this upgrade.final int
hashCode()
Returns a hash code value for this object.net.minecraft.core.Holder.Reference
<T> holder()
Returns the value of theholder
record component.static <T extends UpgradeBase>
UpgradeData<T> of
(net.minecraft.core.Holder.Reference<T> holder, net.minecraft.core.component.DataComponentPatch data) A utility method to construct a newUpgradeData
instance.static <T extends UpgradeBase>
UpgradeData<T> ofDefault
(net.minecraft.core.Holder.Reference<T> holder) Create anUpgradeData
containing the default data for an upgrade.final String
toString()
Returns a string representation of this record class.upgrade()
Get the current upgrade.
-
Constructor Details
-
Method Details
-
of
public static <T extends UpgradeBase> UpgradeData<T> of(net.minecraft.core.Holder.Reference<T> holder, net.minecraft.core.component.DataComponentPatch data) A utility method to construct a newUpgradeData
instance.- Type Parameters:
T
- The type of upgrade.- Parameters:
holder
- An upgrade.data
- The upgrade's data.- Returns:
- The new
UpgradeData
instance.
-
ofDefault
public static <T extends UpgradeBase> UpgradeData<T> ofDefault(net.minecraft.core.Holder.Reference<T> holder) Create anUpgradeData
containing the default data for an upgrade.- Type Parameters:
T
- The type of upgrade.- Parameters:
holder
- The upgrade instance.- Returns:
- The default upgrade data.
-
upgrade
Get the current upgrade.- Returns:
- The current upgrade.
-
getUpgradeItem
public net.minecraft.world.item.ItemStack getUpgradeItem()Get the upgrade item for this upgrade.This returns a defensive copy of the item, to prevent accidental mutation of the upgrade data or original upgrade stack.
- Returns:
- This upgrade's item.
-
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)
. -
holder
Returns the value of theholder
record component.- Returns:
- the value of the
holder
record component
-
data
public net.minecraft.core.component.DataComponentPatch data()Returns the value of thedata
record component.- Returns:
- the value of the
data
record component
-