Package net.minecraft.world.entity.npc
Record Class VillagerData
java.lang.Object
java.lang.Record
net.minecraft.world.entity.npc.VillagerData
public record VillagerData(Holder<VillagerType> type, Holder<VillagerProfession> profession, int level)
extends Record
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<VillagerData> private final intThe field for thelevelrecord component.static final intstatic final intprivate static final int[]private final Holder<VillagerProfession> The field for theprofessionrecord component.static final StreamCodec<RegistryFriendlyByteBuf, VillagerData> private final Holder<VillagerType> The field for thetyperecord component. -
Constructor Summary
ConstructorsConstructorDescriptionVillagerData(Holder<VillagerType> type, Holder<VillagerProfession> profession, int level) Creates an instance of aVillagerDatarecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanLevelUp(int pLevel) final booleanIndicates whether some other object is "equal to" this one.static intgetMaxXpPerLevel(int pLevel) static intgetMinXpPerLevel(int pLevel) final inthashCode()Returns a hash code value for this object.intlevel()Returns the value of thelevelrecord component.Returns the value of theprofessionrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.withLevel(int pLevel) withProfession(Holder<VillagerProfession> pProfession) withProfession(HolderGetter.Provider pRegistries, ResourceKey<VillagerProfession> pProfession) withType(Holder<VillagerType> pType) withType(HolderGetter.Provider pRegistries, ResourceKey<VillagerType> pType)
-
Field Details
-
type
The field for thetyperecord component. -
profession
The field for theprofessionrecord component. -
level
private final int levelThe field for thelevelrecord component. -
MIN_VILLAGER_LEVEL
public static final int MIN_VILLAGER_LEVEL- See Also:
-
MAX_VILLAGER_LEVEL
public static final int MAX_VILLAGER_LEVEL- See Also:
-
NEXT_LEVEL_XP_THRESHOLDS
private static final int[] NEXT_LEVEL_XP_THRESHOLDS -
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
VillagerData
Creates an instance of aVillagerDatarecord class.- Parameters:
type- the value for thetyperecord componentprofession- the value for theprofessionrecord componentlevel- the value for thelevelrecord component
-
-
Method Details
-
withType
-
withType
-
withProfession
-
withProfession
public VillagerData withProfession(HolderGetter.Provider pRegistries, ResourceKey<VillagerProfession> pProfession) -
withLevel
-
getMinXpPerLevel
public static int getMinXpPerLevel(int pLevel) -
getMaxXpPerLevel
public static int getMaxXpPerLevel(int pLevel) -
canLevelUp
public static boolean canLevelUp(int pLevel) -
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 '=='. -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
profession
Returns the value of theprofessionrecord component.- Returns:
- the value of the
professionrecord component
-
level
public int level()Returns the value of thelevelrecord component.- Returns:
- the value of the
levelrecord component
-