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, eitherITurtleUpgradeorIPocketUpgrade.- 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 aUpgradeDatarecord class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.core.component.DataComponentPatchdata()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.net.minecraft.world.item.ItemStackGet the upgrade item for this upgrade.final inthashCode()Returns a hash code value for this object.net.minecraft.core.Holder.Reference<T> holder()Returns the value of theholderrecord 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 newUpgradeDatainstance.static <T extends UpgradeBase>
UpgradeData<T> ofDefault(net.minecraft.core.Holder.Reference<T> holder) Create anUpgradeDatacontaining the default data for an upgrade.final StringtoString()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 newUpgradeDatainstance.- Type Parameters:
T- The type of upgrade.- Parameters:
holder- An upgrade.data- The upgrade's data.- Returns:
- The new
UpgradeDatainstance.
-
ofDefault
public static <T extends UpgradeBase> UpgradeData<T> ofDefault(net.minecraft.core.Holder.Reference<T> holder) Create anUpgradeDatacontaining 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 theholderrecord component.- Returns:
- the value of the
holderrecord component
-
data
public net.minecraft.core.component.DataComponentPatch data()Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-