1.1.6
All checks were successful
SorceryCraft/pipeline/head This commit looks good

Add Spell-related Statistics
This commit is contained in:
TheBrokenRail 2020-03-09 21:27:10 -04:00
parent 815fd3d7a7
commit dca3e4718d
6 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,8 @@
### Changelog ### Changelog
**1.1.6**
* Add Spell-related Statistics
**1.1.5** **1.1.5**
* Tweak Spell Particles * Tweak Spell Particles

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
loader_version = 0.7.8+build.187 loader_version = 0.7.8+build.187
# Mod Properties # Mod Properties
mod_version = 1.1.5 mod_version = 1.1.6
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
archives_base_name = sorcerycraft archives_base_name = sorcerycraft

View File

@ -41,6 +41,8 @@ import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.StatFormatter;
import net.minecraft.stat.Stats;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPointer;
@ -70,8 +72,9 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
LootTables.PILLAGER_OUTPOST_CHEST, LootTables.PILLAGER_OUTPOST_CHEST,
LootTables.WOODLAND_MANSION_CHEST LootTables.WOODLAND_MANSION_CHEST
}; };
public static final double SPELL_FAILURE_CHANCE = 0.3d; 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) { private boolean isSelectedLootTable(Identifier lootTable) {
for (Identifier id : LOOT_TABLES) { for (Identifier id : LOOT_TABLES) {
@ -137,6 +140,16 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
playSpellSound(pointer); 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; private static final SoundEvent SPELL_SOUND_EFFECT = SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE;

View File

@ -29,6 +29,7 @@ public class CastingTableBlock extends Block {
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient()) { if (!world.isClient()) {
ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos)); 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; return ActionResult.SUCCESS;
} }

View File

@ -31,6 +31,8 @@ public class SpellItem extends Item {
@Override @Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) { public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
playerEntity.incrementStat(SorceryCraft.STAT_CAST_SPELL);
ItemStack itemStack = playerEntity.getStackInHand(hand); ItemStack itemStack = playerEntity.getStackInHand(hand);
SorceryCraft.playSpellSound(playerEntity); SorceryCraft.playSpellSound(playerEntity);

View File

@ -12,6 +12,8 @@
"command.sorcerycraft.spell.not_holding_spell": "%s is not holding a Spell", "command.sorcerycraft.spell.not_holding_spell": "%s is not holding a Spell",
"command.sorcerycraft.spell.applied_spell": "Applied Spell %s", "command.sorcerycraft.spell.applied_spell": "Applied Spell %s",
"command.sorcerycraft.spell.removed_spell": "Removed 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.damage_spell": "Damage",
"spell.sorcerycraft.heal_spell": "Heal", "spell.sorcerycraft.heal_spell": "Heal",
"spell.sorcerycraft.dissolve_spell": "Dissolve", "spell.sorcerycraft.dissolve_spell": "Dissolve",