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.
- All Implemented Interfaces:
net.minecraft.core.component.DataComponentGetter
public record UpgradeData<T extends UpgradeBase>(net.minecraft.core.Holder.Reference<T extends UpgradeBase> holder, net.minecraft.core.component.DataComponentPatch data)
extends Record
implements net.minecraft.core.component.DataComponentGetter
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.<U> @Nullable Uget(net.minecraft.core.component.DataComponentType<? extends U> component) Get a component from the upgrade'sdata().net.minecraft.world.item.ItemStackTemplateGet 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.Methods inherited from interface net.minecraft.core.component.DataComponentGetter
getOrDefault, getTyped
-
Constructor Details
-
UpgradeData
-
-
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
-
getUpgradeItem
public net.minecraft.world.item.ItemStackTemplate getUpgradeItem()Get the upgrade item for this upgrade.- Returns:
- This upgrade's item.
-
get
public <U> @Nullable U get(net.minecraft.core.component.DataComponentType<? extends U> component) Get a component from the upgrade'sdata().- Specified by:
getin interfacenet.minecraft.core.component.DataComponentGetter- Type Parameters:
U- The type of the component's value.- Parameters:
component- The component get.- Returns:
- The component, or
nullif not present.
-
toString
-
hashCode
-
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
-
data
-