use of net.minecraft.stats.ServerStatisticsManager in project Hostile-Mobs-and-Girls by Mechalopa.
the class InsomniaSwordItem method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {
if (!world.isClientSide) {
if (entity.tickCount % 5 == 0 && entity instanceof ServerPlayerEntity) {
CompoundNBT compoundnbt = stack.getOrCreateTag();
int level = !compoundnbt.contains(ModUtils.LEVEL_KEY) ? 0 : (int) compoundnbt.getByte(ModUtils.LEVEL_KEY);
ServerStatisticsManager serverstatisticsmanager = ((ServerPlayerEntity) entity).getStats();
final int i = 24000;
final int j = Math.max(serverstatisticsmanager.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1);
int k = j / i;
k = MathHelper.clamp(k - 2, 0, 5);
if (level != k) {
compoundnbt.putByte(ModUtils.LEVEL_KEY, (byte) k);
}
}
}
}
use of net.minecraft.stats.ServerStatisticsManager in project LoliServer by Loli-Server.
the class CraftOfflinePlayer method setStatistic.
@Override
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
if (isOnline()) {
getPlayer().setStatistic(statistic, entityType, newValue);
} else {
ServerStatisticsManager manager = getStatisticManager();
CraftStatistic.setStatistic(manager, statistic, entityType, newValue);
manager.save();
}
}
use of net.minecraft.stats.ServerStatisticsManager in project LoliServer by Loli-Server.
the class CraftOfflinePlayer method incrementStatistic.
@Override
public void incrementStatistic(Statistic statistic) {
if (isOnline()) {
getPlayer().incrementStatistic(statistic);
} else {
ServerStatisticsManager manager = getStatisticManager();
CraftStatistic.incrementStatistic(manager, statistic);
manager.save();
}
}
use of net.minecraft.stats.ServerStatisticsManager in project LoliServer by Loli-Server.
the class CraftOfflinePlayer method decrementStatistic.
@Override
public void decrementStatistic(Statistic statistic, EntityType entityType) {
if (isOnline()) {
getPlayer().decrementStatistic(statistic, entityType);
} else {
ServerStatisticsManager manager = getStatisticManager();
CraftStatistic.decrementStatistic(manager, statistic, entityType);
manager.save();
}
}
use of net.minecraft.stats.ServerStatisticsManager in project Magma-1.16.x by magmafoundation.
the class CraftOfflinePlayer method incrementStatistic.
@Override
public void incrementStatistic(Statistic statistic, Material material, int amount) {
if (isOnline()) {
getPlayer().incrementStatistic(statistic, material, amount);
} else {
ServerStatisticsManager manager = getStatisticManager();
CraftStatistic.incrementStatistic(manager, statistic, material, amount);
manager.save();
}
}
Aggregations