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 thecomponentType
record component.private final boolean
The field for theignoreDefault
record component.static final com.mojang.serialization.MapCodec
<HasComponent> -
Constructor Summary
ConstructorsConstructorDescriptionHasComponent
(DataComponentType<?> componentType, boolean ignoreDefault) Creates an instance of aHasComponent
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecomponentType
record component.final boolean
Indicates whether some other object is "equal to" this one.boolean
get
(ItemStack p_388222_, ClientLevel p_386715_, LivingEntity p_386871_, int p_387461_, ItemDisplayContext p_389562_) final int
hashCode()
Returns a hash code value for this object.boolean
Returns the value of theignoreDefault
record component.final String
toString()
Returns a string representation of this record class.com.mojang.serialization.MapCodec
<HasComponent> type()
-
Field Details
-
componentType
The field for thecomponentType
record component. -
ignoreDefault
private final boolean ignoreDefaultThe field for theignoreDefault
record component. -
MAP_CODEC
-
-
Constructor Details
-
HasComponent
Creates an instance of aHasComponent
record class.- Parameters:
componentType
- the value for thecomponentType
record componentignoreDefault
- the value for theignoreDefault
record 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:
get
in interfaceItemModelPropertyTest
-
type
- Specified by:
type
in 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 thecomponentType
record component.- Returns:
- the value of the
componentType
record component
-
ignoreDefault
public boolean ignoreDefault()Returns the value of theignoreDefault
record component.- Returns:
- the value of the
ignoreDefault
record component
-