mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 18:45:54 +01:00
#601: Implement Player#sendExperienceChange
This commit is contained in:
parent
661bebc642
commit
b91ce1192a
@ -47,6 +47,7 @@ import net.minecraft.server.PacketPlayOutBlockChange;
|
||||
import net.minecraft.server.PacketPlayOutChat;
|
||||
import net.minecraft.server.PacketPlayOutCustomPayload;
|
||||
import net.minecraft.server.PacketPlayOutCustomSoundEffect;
|
||||
import net.minecraft.server.PacketPlayOutExperience;
|
||||
import net.minecraft.server.PacketPlayOutMap;
|
||||
import net.minecraft.server.PacketPlayOutNamedSoundEffect;
|
||||
import net.minecraft.server.PacketPlayOutPlayerInfo;
|
||||
@ -946,6 +947,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void setLevel(int level) {
|
||||
Preconditions.checkArgument(level >= 0, "Experience level must not be negative (%s)", level);
|
||||
getHandle().expLevel = level;
|
||||
getHandle().lastSentExp = -1;
|
||||
}
|
||||
@ -957,9 +959,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int exp) {
|
||||
Preconditions.checkArgument(exp >= 0, "Total experience points must not be negative (%s)", exp);
|
||||
getHandle().expTotal = exp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExperienceChange(float progress) {
|
||||
sendExperienceChange(progress, getLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExperienceChange(float progress, int level) {
|
||||
Preconditions.checkArgument(progress >= 0.0 && progress <= 1.0, "Experience progress must be between 0.0 and 1.0 (%s)", progress);
|
||||
Preconditions.checkArgument(level >= 0, "Experience level must not be negative (%s)", level);
|
||||
|
||||
if (getHandle().playerConnection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketPlayOutExperience packet = new PacketPlayOutExperience(progress, getTotalExperience(), level);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion() {
|
||||
return getHandle().getFoodData().exhaustionLevel;
|
||||
|
Loading…
Reference in New Issue
Block a user