Skip to content

Commit

Permalink
fix: advancement trigger on familiar summon
Browse files Browse the repository at this point in the history
Closes #940
  • Loading branch information
klikli-dev committed Jun 24, 2023
1 parent 324a982 commit 7fa8c32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
import com.github.klikli_dev.occultism.common.blockentity.GoldenSacrificialBowlBlockEntity;
import com.github.klikli_dev.occultism.common.entity.familiar.FamiliarEntity;
import com.github.klikli_dev.occultism.crafting.recipe.RitualRecipe;
import com.github.klikli_dev.occultism.registry.OccultismAdvancements;
import com.github.klikli_dev.occultism.registry.OccultismSounds;
import com.github.klikli_dev.occultism.util.ItemNBTUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobSpawnType;
Expand All @@ -47,6 +51,12 @@ public FamiliarRitual(RitualRecipe recipe) {
@Override
public void finish(Level level, BlockPos goldenBowlPosition, GoldenSacrificialBowlBlockEntity blockEntity,
Player castingPlayer, ItemStack activationItem) {
//manually call content of Ritual.finish(), because we cannot access it via super
level.playSound(null, goldenBowlPosition, OccultismSounds.POOF.get(), SoundSource.BLOCKS, 0.7f,
0.7f);
castingPlayer.displayClientMessage(Component.translatable(this.getFinishedMessage()), true);
OccultismAdvancements.RITUAL.trigger((ServerPlayer) castingPlayer, this);

String entityName = ItemNBTUtil.getBoundSpiritName(activationItem);
activationItem.shrink(1); //remove original activation item.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@

import com.github.klikli_dev.occultism.common.blockentity.GoldenSacrificialBowlBlockEntity;
import com.github.klikli_dev.occultism.crafting.recipe.RitualRecipe;
import com.github.klikli_dev.occultism.registry.OccultismAdvancements;
import com.github.klikli_dev.occultism.registry.OccultismSounds;
import com.github.klikli_dev.occultism.util.TextUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -44,7 +48,11 @@ public SummonWildHuntRitual(RitualRecipe recipe) {
@Override
public void finish(Level level, BlockPos goldenBowlPosition, GoldenSacrificialBowlBlockEntity blockEntity,
Player castingPlayer, ItemStack activationItem) {
super.finish(level, goldenBowlPosition, blockEntity, castingPlayer, activationItem);
//manually call content of Ritual.finish(), because we cannot access it via super
level.playSound(null, goldenBowlPosition, OccultismSounds.POOF.get(), SoundSource.BLOCKS, 0.7f,
0.7f);
castingPlayer.displayClientMessage(Component.translatable(this.getFinishedMessage()), true);
OccultismAdvancements.RITUAL.trigger((ServerPlayer) castingPlayer, this);

activationItem.shrink(1); //remove original activation item.

Expand Down

0 comments on commit 7fa8c32

Please sign in to comment.