Stats!
This commit is contained in:
parent
7c5bfb1b36
commit
9f7cc25ef5
@ -56,6 +56,7 @@ public class OverdriveThatMatters {
|
|||||||
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.Menus.class);
|
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.Menus.class);
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.AndroidFeatures.class);
|
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.AndroidFeatures.class);
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.AndroidResearch.class);
|
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.AndroidResearch.class);
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().register(Registry.Stats.class);
|
||||||
|
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(AndroidCapability::registerEffects);
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(AndroidCapability::registerEffects);
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import net.minecraft.client.gui.screens.MenuScreens;
|
|||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.stats.StatFormatter;
|
||||||
|
import net.minecraft.stats.StatType;
|
||||||
|
import net.minecraft.stats.Stats;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.food.FoodProperties;
|
import net.minecraft.world.food.FoodProperties;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
@ -14,6 +17,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.registries.ForgeRegistry;
|
import net.minecraftforge.registries.ForgeRegistry;
|
||||||
import net.minecraftforge.registries.RegistryBuilder;
|
import net.minecraftforge.registries.RegistryBuilder;
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidFeature;
|
import ru.dbotthepony.mc.otm.android.AndroidFeature;
|
||||||
@ -153,6 +157,11 @@ public class Registry {
|
|||||||
public static final ResourceLocation HYDRAULICS_OVERLOAD_1 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "hydraulics_overload_1");
|
public static final ResourceLocation HYDRAULICS_OVERLOAD_1 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "hydraulics_overload_1");
|
||||||
public static final ResourceLocation HYDRAULICS_OVERLOAD_2 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "hydraulics_overload_2");
|
public static final ResourceLocation HYDRAULICS_OVERLOAD_2 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "hydraulics_overload_2");
|
||||||
public static final ResourceLocation HYDRAULICS_OVERLOAD_3 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "hydraulics_overload_3");
|
public static final ResourceLocation HYDRAULICS_OVERLOAD_3 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "hydraulics_overload_3");
|
||||||
|
|
||||||
|
// stats
|
||||||
|
public static final ResourceLocation DAMAGE_ABSORBED = new ResourceLocation(OverdriveThatMatters.MOD_ID, "damage_absorbed");
|
||||||
|
public static final ResourceLocation HEALTH_REGENERATED = new ResourceLocation(OverdriveThatMatters.MOD_ID, "health_regenerated");
|
||||||
|
public static final ResourceLocation POWER_CONSUMED = new ResourceLocation(OverdriveThatMatters.MOD_ID, "power_consumed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Blocks {
|
public static class Blocks {
|
||||||
@ -606,4 +615,17 @@ public class Registry {
|
|||||||
// OverdriveThatMatters.LOGGER.info("Registered screens");
|
// OverdriveThatMatters.LOGGER.info("Registered screens");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Stats {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void registerVanilla(final FMLCommonSetupEvent event) {
|
||||||
|
net.minecraft.core.Registry.register(net.minecraft.core.Registry.CUSTOM_STAT, Names.DAMAGE_ABSORBED, Names.DAMAGE_ABSORBED);
|
||||||
|
net.minecraft.core.Registry.register(net.minecraft.core.Registry.CUSTOM_STAT, Names.HEALTH_REGENERATED, Names.HEALTH_REGENERATED);
|
||||||
|
net.minecraft.core.Registry.register(net.minecraft.core.Registry.CUSTOM_STAT, Names.POWER_CONSUMED, Names.POWER_CONSUMED);
|
||||||
|
|
||||||
|
net.minecraft.stats.Stats.CUSTOM.get(Names.DAMAGE_ABSORBED, StatFormatter.DIVIDE_BY_TEN);
|
||||||
|
net.minecraft.stats.Stats.CUSTOM.get(Names.HEALTH_REGENERATED, StatFormatter.DIVIDE_BY_TEN);
|
||||||
|
net.minecraft.stats.Stats.CUSTOM.get(Names.POWER_CONSUMED, StatFormatter.DIVIDE_BY_TEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ru.dbotthepony.mc.otm.android.feature;
|
package ru.dbotthepony.mc.otm.android.feature;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
||||||
|
import ru.dbotthepony.mc.otm.Registry;
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidFeature;
|
import ru.dbotthepony.mc.otm.android.AndroidFeature;
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidFeatureType;
|
import ru.dbotthepony.mc.otm.android.AndroidFeatureType;
|
||||||
import ru.dbotthepony.mc.otm.capability.IAndroidCapability;
|
import ru.dbotthepony.mc.otm.capability.IAndroidCapability;
|
||||||
@ -78,7 +80,13 @@ public class AndroidNanobotsArmor extends AndroidFeature {
|
|||||||
if (absorbed > 0.1f) {
|
if (absorbed > 0.1f) {
|
||||||
var required = ENERGY_PER_HITPOINT.multiply(new BigDecimal(Float.toString(absorbed)));
|
var required = ENERGY_PER_HITPOINT.multiply(new BigDecimal(Float.toString(absorbed)));
|
||||||
var extracted = capability.extractEnergyInner(required, false);
|
var extracted = capability.extractEnergyInner(required, false);
|
||||||
event.setAmount(event.getAmount() - absorbed * extracted.divide(required, MatteryCapability.ROUND_RULES).floatValue());
|
var real_absorbed = absorbed * extracted.divide(required, MatteryCapability.ROUND_RULES).floatValue();
|
||||||
|
event.setAmount(event.getAmount() - real_absorbed);
|
||||||
|
|
||||||
|
if (capability.getEntity() instanceof ServerPlayer ply) {
|
||||||
|
ply.awardStat(Registry.Names.DAMAGE_ABSORBED, Math.round(real_absorbed * 10f));
|
||||||
|
}
|
||||||
|
|
||||||
layers--;
|
layers--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package ru.dbotthepony.mc.otm.android.feature;
|
package ru.dbotthepony.mc.otm.android.feature;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
|
import ru.dbotthepony.mc.otm.Registry;
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidFeature;
|
import ru.dbotthepony.mc.otm.android.AndroidFeature;
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidFeatureType;
|
import ru.dbotthepony.mc.otm.android.AndroidFeatureType;
|
||||||
import ru.dbotthepony.mc.otm.capability.IAndroidCapability;
|
import ru.dbotthepony.mc.otm.capability.IAndroidCapability;
|
||||||
@ -41,7 +43,13 @@ public class AndroidNanobotsRegeneration extends AndroidFeature {
|
|||||||
|
|
||||||
if (extract.compareTo(BigDecimal.ZERO) > 0) {
|
if (extract.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
heal_ticks = Math.min(heal_ticks + 1, level);
|
heal_ticks = Math.min(heal_ticks + 1, level);
|
||||||
ent.heal(missing * extract.divide(ENERGY_PER_HITPOINT, MatteryCapability.ROUND_RULES).floatValue());
|
var heal = missing * extract.divide(ENERGY_PER_HITPOINT, MatteryCapability.ROUND_RULES).floatValue();
|
||||||
|
ent.heal(heal);
|
||||||
|
|
||||||
|
if (capability.getEntity() instanceof ServerPlayer ply) {
|
||||||
|
ply.awardStat(Registry.Names.HEALTH_REGENERATED, Math.round(heal * 10f));
|
||||||
|
}
|
||||||
|
|
||||||
ticks_passed = 0;
|
ticks_passed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,6 +417,10 @@ public class AndroidCapability implements ICapabilityProvider, IAndroidCapabilit
|
|||||||
|
|
||||||
if (!simulate) {
|
if (!simulate) {
|
||||||
energy_stored = new_energy;
|
energy_stored = new_energy;
|
||||||
|
|
||||||
|
if (ent instanceof ServerPlayer ply) {
|
||||||
|
ply.awardStat(Registry.Names.POWER_CONSUMED, drained.intValue() * 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return drained;
|
return drained;
|
||||||
|
@ -76,6 +76,10 @@
|
|||||||
"android_research.overdrive_that_matters.nanobots_armor_strength": "Nanobots armor build speed %s",
|
"android_research.overdrive_that_matters.nanobots_armor_strength": "Nanobots armor build speed %s",
|
||||||
"android_research.overdrive_that_matters.nanobots_armor_strength.description": "Increases impact absorption strength of nanobots",
|
"android_research.overdrive_that_matters.nanobots_armor_strength.description": "Increases impact absorption strength of nanobots",
|
||||||
|
|
||||||
|
"stat.overdrive_that_matters.health_regenerated": "Damage regenerated by nanobots",
|
||||||
|
"stat.overdrive_that_matters.damage_absorbed": "Damage absorbed by nanobots",
|
||||||
|
"stat.overdrive_that_matters.power_consumed": "MtE burnt as Android",
|
||||||
|
|
||||||
"otm.suffix.merge": "%s %s",
|
"otm.suffix.merge": "%s %s",
|
||||||
|
|
||||||
"otm.suffix.kilo": "%s k%s",
|
"otm.suffix.kilo": "%s k%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user