From dca3e4718db53b13aa2196f12596b245ea05930b Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Mon, 9 Mar 2020 21:27:10 -0400 Subject: [PATCH] 1.1.6 Add Spell-related Statistics --- CHANGELOG.md | 3 +++ gradle.properties | 2 +- .../thebrokenrail/sorcerycraft/SorceryCraft.java | 15 ++++++++++++++- .../sorcerycraft/block/CastingTableBlock.java | 1 + .../sorcerycraft/item/SpellItem.java | 2 ++ .../resources/assets/sorcerycraft/lang/en_us.json | 2 ++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e627b..f178414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ### Changelog +**1.1.6** +* Add Spell-related Statistics + **1.1.5** * Tweak Spell Particles diff --git a/gradle.properties b/gradle.properties index 7089bf4..6f22a0b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G loader_version = 0.7.8+build.187 # Mod Properties - mod_version = 1.1.5 + mod_version = 1.1.6 maven_group = com.thebrokenrail archives_base_name = sorcerycraft diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java b/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java index 71b90d8..9d4f674 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java @@ -41,6 +41,8 @@ import net.minecraft.loot.entry.ItemEntry; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; +import net.minecraft.stat.StatFormatter; +import net.minecraft.stat.Stats; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPointer; @@ -70,8 +72,9 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer { LootTables.PILLAGER_OUTPOST_CHEST, LootTables.WOODLAND_MANSION_CHEST }; - public static final double SPELL_FAILURE_CHANCE = 0.3d; + public static Identifier STAT_INTERACT_WITH_CASTING_TABLE; + public static Identifier STAT_CAST_SPELL; private boolean isSelectedLootTable(Identifier lootTable) { for (Identifier id : LOOT_TABLES) { @@ -137,6 +140,16 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer { playSpellSound(pointer); } }); + + STAT_INTERACT_WITH_CASTING_TABLE = registerStat("interact_with_casting_table"); + STAT_CAST_SPELL = registerStat("cast_spell"); + } + + private Identifier registerStat(String name) { + Identifier statID = new Identifier(NAMESPACE, name); + Registry.register(Registry.CUSTOM_STAT, name, statID); + Stats.CUSTOM.getOrCreateStat(statID, StatFormatter.DEFAULT); + return statID; } private static final SoundEvent SPELL_SOUND_EFFECT = SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java b/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java index bf9b7ca..04a5b96 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java @@ -29,6 +29,7 @@ public class CastingTableBlock extends Block { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { if (!world.isClient()) { ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos)); + player.incrementStat(SorceryCraft.STAT_INTERACT_WITH_CASTING_TABLE); } return ActionResult.SUCCESS; } diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java b/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java index 5b81d80..0221d22 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java @@ -31,6 +31,8 @@ public class SpellItem extends Item { @Override public TypedActionResult use(World world, PlayerEntity playerEntity, Hand hand) { + playerEntity.incrementStat(SorceryCraft.STAT_CAST_SPELL); + ItemStack itemStack = playerEntity.getStackInHand(hand); SorceryCraft.playSpellSound(playerEntity); diff --git a/src/main/resources/assets/sorcerycraft/lang/en_us.json b/src/main/resources/assets/sorcerycraft/lang/en_us.json index 31b7638..b441b20 100644 --- a/src/main/resources/assets/sorcerycraft/lang/en_us.json +++ b/src/main/resources/assets/sorcerycraft/lang/en_us.json @@ -12,6 +12,8 @@ "command.sorcerycraft.spell.not_holding_spell": "%s is not holding a Spell", "command.sorcerycraft.spell.applied_spell": "Applied Spell %s", "command.sorcerycraft.spell.removed_spell": "Removed Spell %s", + "stat.sorcerycraft.interact_with_casting_table": "Interactions with Casting Table", + "stat.sorcerycraft.cast_spell": "Spells Cast", "spell.sorcerycraft.damage_spell": "Damage", "spell.sorcerycraft.heal_spell": "Heal", "spell.sorcerycraft.dissolve_spell": "Dissolve",