Record Class VillagerData
java.lang.Object
java.lang.Record
net.minecraft.world.entity.npc.villager.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 currentLevel) final booleanIndicates whether some other object is "equal to" this one.static intgetMaxXpPerLevel(int level) static intgetMinXpPerLevel(int level) 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 level) withProfession(Holder<VillagerProfession> profession) withProfession(HolderGetter.Provider registries, ResourceKey<VillagerProfession> profession) withType(Holder<VillagerType> type) withType(HolderGetter.Provider registries, ResourceKey<VillagerType> type)
-
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 registries, ResourceKey<VillagerProfession> profession) -
withLevel
-
getMinXpPerLevel
public static int getMinXpPerLevel(int level) -
getMaxXpPerLevel
public static int getMaxXpPerLevel(int level) -
canLevelUp
public static boolean canLevelUp(int currentLevel) -
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. -
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
-