minecraft-src/net/minecraft/world/entity/player/Abilities.java
2025-07-04 03:45:38 +03:00

59 lines
2.1 KiB
Java

package net.minecraft.world.entity.player;
import net.minecraft.nbt.CompoundTag;
public class Abilities {
private static final boolean DEFAULT_INVULNERABLE = false;
private static final boolean DEFAULY_FLYING = false;
private static final boolean DEFAULT_MAY_FLY = false;
private static final boolean DEFAULT_INSTABUILD = false;
private static final boolean DEFAULT_MAY_BUILD = true;
private static final float DEFAULT_FLYING_SPEED = 0.05F;
private static final float DEFAULT_WALKING_SPEED = 0.1F;
public boolean invulnerable;
public boolean flying;
public boolean mayfly;
public boolean instabuild;
public boolean mayBuild = true;
private float flyingSpeed = 0.05F;
private float walkingSpeed = 0.1F;
public void addSaveData(CompoundTag compound) {
CompoundTag compoundTag = new CompoundTag();
compoundTag.putBoolean("invulnerable", this.invulnerable);
compoundTag.putBoolean("flying", this.flying);
compoundTag.putBoolean("mayfly", this.mayfly);
compoundTag.putBoolean("instabuild", this.instabuild);
compoundTag.putBoolean("mayBuild", this.mayBuild);
compoundTag.putFloat("flySpeed", this.flyingSpeed);
compoundTag.putFloat("walkSpeed", this.walkingSpeed);
compound.put("abilities", compoundTag);
}
public void loadSaveData(CompoundTag compound) {
CompoundTag compoundTag = compound.getCompoundOrEmpty("abilities");
this.invulnerable = compoundTag.getBooleanOr("invulnerable", false);
this.flying = compoundTag.getBooleanOr("flying", false);
this.mayfly = compoundTag.getBooleanOr("mayfly", false);
this.instabuild = compoundTag.getBooleanOr("instabuild", false);
this.flyingSpeed = compoundTag.getFloatOr("flySpeed", 0.05F);
this.walkingSpeed = compoundTag.getFloatOr("walkSpeed", 0.1F);
this.mayBuild = compoundTag.getBooleanOr("mayBuild", true);
}
public float getFlyingSpeed() {
return this.flyingSpeed;
}
public void setFlyingSpeed(float flyingSpeed) {
this.flyingSpeed = flyingSpeed;
}
public float getWalkingSpeed() {
return this.walkingSpeed;
}
public void setWalkingSpeed(float walkingSpeed) {
this.walkingSpeed = walkingSpeed;
}
}