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 itemStack, @Nullable ClientLevel level, @Nullable LivingEntity owner, int seed, ItemDisplayContext displayContext) 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 itemStack, @Nullable ClientLevel level, @Nullable LivingEntity owner, int seed, ItemDisplayContext displayContext) - Specified by:
getin interfaceItemModelPropertyTest
-
type
- Specified by:
typein interfaceConditionalItemModelProperty
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
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
-