Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
SPIGOT-4834: API for Villager levels and experience
Dieser Commit ist enthalten in:
Ursprung
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);
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren