Skip to content

Commit

Permalink
create skill stat tab to statistics screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jan 18, 2024
1 parent 654eec4 commit c203f64
Show file tree
Hide file tree
Showing 32 changed files with 190 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.teamlapen.vampirism.blockentity;

import de.teamlapen.lib.lib.util.SpawnHelper;
import de.teamlapen.vampirism.VampirismMod;
import de.teamlapen.vampirism.blocks.mother.IRemainsBlock;
import de.teamlapen.vampirism.blocks.mother.MotherTreeStructure;
import de.teamlapen.vampirism.core.*;
Expand Down Expand Up @@ -324,7 +323,7 @@ public void concludeFight() {
for (LivingEntity livingentity : involvedEntities) {
if (livingentity instanceof ServerPlayer serverplayer) {
ModAdvancements.TRIGGER_MOTHER_WIN.get().trigger(serverplayer);
serverplayer.awardStat(ModStats.mother_defeated.get(), 1);
serverplayer.awardStat(ModStats.MOTHER_DEFEATED.get(), 1);
FactionPlayerHandler.getOpt(serverplayer).filter(s -> s.getCurrentFaction() != null && s.getCurrentLevel() < s.getCurrentFaction().getHighestReachableLevel()).ifPresent(handler -> {
handler.setFactionLevel(handler.getCurrentFaction(), handler.getCurrentLevel() + 1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,11 @@ private void applyVictoryBonus(boolean attackWin) {
if (!attackWin) {
player.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, Math.max(this.badOmenLevel - 1, 0), false, false, true));
}
player.awardStat(ModStats.win_village_capture.get());
player.awardStat(ModStats.WIN_VILLAGE_CAPTURE.get());
if (attackWin) {
player.awardStat(ModStats.capture_village.get());
player.awardStat(ModStats.CAPTURE_VILLAGE.get());
} else {
player.awardStat(ModStats.defend_village.get());
player.awardStat(ModStats.DEFEND_VILLAGE.get());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void openContainer(@NotNull Level world, @NotNull BlockPos blockPos, @
BlockEntity tile = world.getBlockEntity(blockPos);
if (tile instanceof AlchemicalCauldronBlockEntity) {
playerEntity.openMenu((MenuProvider) tile);
playerEntity.awardStat(ModStats.interact_alchemical_cauldron.get());
playerEntity.awardStat(ModStats.INTERACT_ALCHEMICAL_CAULDRON.get());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @N
BlockEntity tileentity = level.getBlockEntity(pos);
if (tileentity instanceof AlchemyTableBlockEntity) {
player.openMenu((AlchemyTableBlockEntity) tileentity);
player.awardStat(ModStats.interact_with_alchemy_table.get());
player.awardStat(ModStats.INTERACT_WITH_ALCHEMY_TABLE.get());
}
} else {
player.displayClientMessage(Component.translatable("text.vampirism.unfamiliar"), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
case INVMISSING -> player.displayClientMessage(Component.translatable("text.vampirism.altar_infusion.ritual_missing_times"), true);
case OK -> {
if (heldItem.isEmpty()) {
player.awardStat(ModStats.altar_of_infusion_rituals_performed.get());
player.awardStat(ModStats.ALTAR_OF_INFUSION_RITUALS_PERFORMED.get());
te.startRitual(player);
return InteractionResult.SUCCESS;
}
Expand All @@ -135,7 +135,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
}
}
player.openMenu(te);
player.awardStat(ModStats.interact_with_altar_of_infusion.get());
player.awardStat(ModStats.INTERACT_WITH_ALTAR_OF_INFUSION.get());
return InteractionResult.SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
if (opt.isPresent()) {
AltarInspirationBlockEntity tileEntity = (AltarInspirationBlockEntity) worldIn.getBlockEntity(pos);
if (!player.isShiftKeyDown() && tileEntity != null) {
player.awardStat(ModStats.interact_with_altar_inspiration.get());
player.awardStat(ModStats.INTERACT_WITH_ALTAR_INSPIRATION.get());
FluidUtil.interactWithFluidHandler(player, hand, worldIn, pos, hit.getDirection());
}
return InteractionResult.SUCCESS;
}
} else {
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
if (tileEntity instanceof AltarInspirationBlockEntity altar) {
player.awardStat(ModStats.altar_of_inspiration_rituals_performed.get());
player.awardStat(ModStats.ALTAR_OF_INSPIRATION_RITUALS_PERFORMED.get());
altar.startRitual(player);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
return InteractionResult.CONSUME;
}
}
player.awardStat(ModStats.interact_with_coffin.get());
player.awardStat(ModStats.INTERACT_WITH_COFFIN.get());
if (player.isShiftKeyDown() && !state.getValue(BedBlock.OCCUPIED)) {
worldIn.setBlock(pos, state.setValue(CLOSED, !state.getValue(CLOSED)), 3);
BlockPos otherPos = getOtherPos(pos, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public FogDiffuserBlock(@NotNull Properties properties) {
public @NotNull InteractionResult use(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull Player pPlayer, @NotNull InteractionHand pHand, @NotNull BlockHitResult pHit) {
ItemStack itemInHand = pPlayer.getItemInHand(pHand);
getBlockEntity(pLevel, pPos).ifPresent(blockEntity -> {
pPlayer.awardStat(ModStats.interact_with_fog_diffuser.get());
pPlayer.awardStat(ModStats.INTERACT_WITH_FOG_DIFFUSER.get());
if(!blockEntity.interact(itemInHand)) {
VampirismMod.proxy.displayFogDiffuserScreen(blockEntity, getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public BlockState rotate(@NotNull BlockState state, @NotNull Rotation rot) {
@Override
public InteractionResult use(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) {
ItemStack heldItem = player.getItemInHand(hand);
player.awardStat(ModStats.interact_with_garlic_diffuser.get());
player.awardStat(ModStats.INTERACT_WITH_GARLIC_DIFFUSER.get());
if (!heldItem.isEmpty() && ModItems.PURIFIED_GARLIC.get() == heldItem.getItem()) {
if (!world.isClientSide) {
GarlicDiffuserBlockEntity t = getTile(world, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public BlockState rotate(@NotNull BlockState state, @NotNull Rotation rot) {
@Override
public InteractionResult use(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) {
if (world.isClientSide) return InteractionResult.SUCCESS;
player.awardStat(ModStats.interact_with_blood_grinder.get());
player.awardStat(ModStats.INTERACT_WITH_BLOOD_GRINDER.get());
player.openMenu(world.getBlockEntity(pos) instanceof BloodGrinderBlockEntity ? (BloodGrinderBlockEntity) world.getBlockEntity(pos) : null);
return InteractionResult.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void neighborChanged(@NotNull BlockState state, @NotNull Level worldIn, @
public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) {
if (!worldIn.isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {
serverPlayer.awardStat(ModStats.interact_with_research_table.get());
serverPlayer.awardStat(ModStats.INTERACT_WITH_RESEARCH_TABLE.get());
if (Helper.isHunter(serverPlayer)) {
player.openMenu(new SimpleMenuProvider((id, playerInventory, playerIn) -> new HunterTableMenu(id, playerInventory, ContainerLevelAccess.create(playerIn.level(), pos)), Component.translatable("container.crafting")), pos);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public MedChairBlock() {
public InteractionResult use(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) {
if (player.isAlive()) {
ItemStack stack = player.getItemInHand(hand);
player.awardStat(ModStats.interact_with_injection_chair.get());
player.awardStat(ModStats.INTERACT_WITH_INJECTION_CHAIR.get());
if (handleInjections(player, world, stack, pos)) {
stack.shrink(1);
if (stack.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level world, @N
ItemStack stack = player.getItemInHand(hand);
if (stack.isEmpty() && !tile.extractItem(0, 1, true).isEmpty()) {
ItemStack stack2 = tile.extractItem(0, 1, false);
player.awardStat(ModStats.items_filled_on_blood_pedestal.get());
player.awardStat(ModStats.ITEMS_FILLED_ON_BLOOD_PEDESTAL.get());
takeItemPlayer(player, hand, stack2);
return InteractionResult.SUCCESS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
if (tile instanceof PotionTableBlockEntity) {
if (((PotionTableBlockEntity) tile).canOpen(player)) {
player.openMenu((PotionTableBlockEntity) tile, buffer -> buffer.writeBoolean(((PotionTableBlockEntity) tile).isExtended()));
player.awardStat(ModStats.interact_with_potion_table.get());
player.awardStat(ModStats.INTERACT_WITH_POTION_TABLE.get());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ThroneBlock() {
public @NotNull InteractionResult use(@NotNull BlockState state, Level world, BlockPos pos, Player player, InteractionHand p_225533_5_, BlockHitResult traceResult) {
Part part = state.getValue(PART);
Direction oppFacing = state.getValue(FACING).getOpposite();
player.awardStat(ModStats.interact_with_throne.get());
player.awardStat(ModStats.INTERACT_WITH_THRONE.get());
if (part == Part.MAIN && (traceResult.getDirection() == Direction.UP || traceResult.getDirection() == oppFacing)) {
SitHandler.startSitting(player, world, pos, 0.5);
return InteractionResult.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level world, @N
if (world.isClientSide) return InteractionResult.SUCCESS;
TotemBlockEntity t = getTile(world, pos);
if (t != null && world.getBlockState(pos.below()).getBlock().equals(ModBlocks.TOTEM_BASE.get())) {
player.awardStat(ModStats.interact_with_totem.get());
player.awardStat(ModStats.INTERACT_WITH_TOTEM.get());
t.initiateCapture(player);
return InteractionResult.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level pLe
public @NotNull InteractionResult use(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull Player pPlayer, @NotNull InteractionHand pHand, @NotNull BlockHitResult pHit) {
if (!pLevel.isClientSide) {
if (pPlayer instanceof ServerPlayer serverPlayer) {
serverPlayer.awardStat(ModStats.interact_with_ancient_beacon.get());
serverPlayer.awardStat(ModStats.INTERACT_WITH_ANCIENT_BEACON.get());
if (Helper.isHunter(serverPlayer)) {
if (pLevel.getBlockEntity(pPos) instanceof VampireBeaconBlockEntity blockentity) {
pPlayer.openMenu(blockentity);
Expand Down
Loading

0 comments on commit c203f64

Please sign in to comment.