Record Class HasComponent
java.lang.Object
java.lang.Record
net.minecraft.client.renderer.item.properties.conditional.HasComponent
- All Implemented Interfaces:
ConditionalItemModelProperty,ItemModelPropertyTest
public record HasComponent(DataComponentType<?> componentType, boolean ignoreDefault)
extends Record
implements ConditionalItemModelProperty
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataComponentType<?> The field for thecomponentTyperecord component.private final booleanThe field for theignoreDefaultrecord component.static final com.mojang.serialization.MapCodec<HasComponent> -
Constructor Summary
ConstructorsConstructorDescriptionHasComponent(DataComponentType<?> componentType, boolean ignoreDefault) Creates an instance of aHasComponentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecomponentTyperecord component.final booleanIndicates whether some other object is "equal to" this one.booleanget(ItemStack p_388222_, ClientLevel p_386715_, LivingEntity p_386871_, int p_387461_, ItemDisplayContext p_389562_) final inthashCode()Returns a hash code value for this object.booleanReturns the value of theignoreDefaultrecord component.final StringtoString()Returns a string representation of this record class.com.mojang.serialization.MapCodec<HasComponent> type()
-
Field Details
-
componentType
The field for thecomponentTyperecord component. -
ignoreDefault
private final boolean ignoreDefaultThe field for theignoreDefaultrecord component. -
MAP_CODEC
-
-
Constructor Details
-
HasComponent
Creates an instance of aHasComponentrecord class.- Parameters:
componentType- the value for thecomponentTyperecord componentignoreDefault- the value for theignoreDefaultrecord component
-
-
Method Details
-
get
public boolean get(ItemStack p_388222_, @Nullable ClientLevel p_386715_, @Nullable LivingEntity p_386871_, int p_387461_, ItemDisplayContext p_389562_) - Specified by:
getin interfaceItemModelPropertyTest
-
type
- Specified by:
typein interfaceConditionalItemModelProperty
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
componentType
Returns the value of thecomponentTyperecord component.- Returns:
- the value of the
componentTyperecord component
-
ignoreDefault
public boolean ignoreDefault()Returns the value of theignoreDefaultrecord component.- Returns:
- the value of the
ignoreDefaultrecord component
-