mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 01:17:44 +01:00
SPIGOT-4834: API for Villager levels and experience
This commit is contained in:
parent
78616513e8
commit
c441dba815
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.server.EntityVillager;
|
||||
import net.minecraft.server.IRegistry;
|
||||
@ -51,4 +52,28 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
Validate.notNull(type);
|
||||
getHandle().setVillagerData(getHandle().getVillagerData().withType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVillagerLevel() {
|
||||
return getHandle().getVillagerData().getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVillagerLevel(int level) {
|
||||
Preconditions.checkArgument(0 <= level && level <= 5, "level must be between [0, 5]");
|
||||
|
||||
getHandle().setVillagerData(getHandle().getVillagerData().withLevel(level));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVillagerExperience() {
|
||||
return getHandle().dV();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVillagerExperience(int experience) {
|
||||
Preconditions.checkArgument(experience >= 0, "Experience must be positive");
|
||||
|
||||
getHandle().t(experience);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user