Search in sources :

Example 1 with ServerStatisticsManager

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);
            }
        }
    }
}
Also used : ServerStatisticsManager(net.minecraft.stats.ServerStatisticsManager) CompoundNBT(net.minecraft.nbt.CompoundNBT) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 2 with ServerStatisticsManager

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();
    }
}
Also used : ServerStatisticsManager(net.minecraft.stats.ServerStatisticsManager)

Example 3 with ServerStatisticsManager

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();
    }
}
Also used : ServerStatisticsManager(net.minecraft.stats.ServerStatisticsManager)

Example 4 with ServerStatisticsManager

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();
    }
}
Also used : ServerStatisticsManager(net.minecraft.stats.ServerStatisticsManager)

Example 5 with ServerStatisticsManager

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();
    }
}
Also used : ServerStatisticsManager(net.minecraft.stats.ServerStatisticsManager)

Aggregations

ServerStatisticsManager (net.minecraft.stats.ServerStatisticsManager)32 Lists (com.google.common.collect.Lists)1 VariousOddities (com.lying.variousoddities.VariousOddities)1 IDefaultSpecies (com.lying.variousoddities.api.entity.IDefaultSpecies)1 AbilityGetBreathableFluidEvent (com.lying.variousoddities.api.event.AbilityEvent.AbilityGetBreathableFluidEvent)1 TypeApplyEvent (com.lying.variousoddities.api.event.CreatureTypeEvent.TypeApplyEvent)1 TypeRemoveEvent (com.lying.variousoddities.api.event.CreatureTypeEvent.TypeRemoveEvent)1 SpeciesEvent (com.lying.variousoddities.api.event.SpeciesEvent)1 TemplateApplied (com.lying.variousoddities.api.event.SpeciesEvent.TemplateApplied)1 BodyCondition (com.lying.variousoddities.capabilities.PlayerData.BodyCondition)1 Condition (com.lying.variousoddities.condition.Condition)1 ConditionInstance (com.lying.variousoddities.condition.ConditionInstance)1 ConfigVO (com.lying.variousoddities.config.ConfigVO)1 AbstractBody (com.lying.variousoddities.entity.AbstractBody)1 EntityBodyUnconscious (com.lying.variousoddities.entity.EntityBodyUnconscious)1 VOPotions (com.lying.variousoddities.init.VOPotions)1 VORegistries (com.lying.variousoddities.init.VORegistries)1 PacketHandler (com.lying.variousoddities.network.PacketHandler)1 PacketSyncAir (com.lying.variousoddities.network.PacketSyncAir)1 PacketSyncBludgeoning (com.lying.variousoddities.network.PacketSyncBludgeoning)1