Skip to content

Commit

Permalink
give offerings
Browse files Browse the repository at this point in the history
  • Loading branch information
afamiliarquiet committed Nov 1, 2024
1 parent 6a15680 commit 3cbce46
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.Containers;
import net.minecraft.world.LockCode;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.Nameable;
Expand Down Expand Up @@ -225,6 +226,8 @@ public void acceptSummoning(LivingEntity livingTarget) {
pathfindermob.getNavigation().stop();
}

this.giveOfferings(livingTarget);

level.gameEvent(GameEvent.TELEPORT, livingTarget.position(), GameEvent.Context.of(livingTarget));
level.broadcastEntityEvent(livingTarget, (byte)46);
level.playSound(null, this.getBlockPos(), SoundEvents.PLAYER_TELEPORT, SoundSource.BLOCKS, 1, 1);
Expand All @@ -235,6 +238,25 @@ public void acceptSummoning(LivingEntity livingTarget) {
}
}

private void giveOfferings(LivingEntity target) {
if (level == null || level.isClientSide) {
// this isn't happening. chill out, relax, it's fine
return;
}
BlockPos pos = this.getBlockPos();
for (int i = 0; i < this.offerings.getSlots(); i++) {
ItemStack offering = this.offerings.getStackInSlot(i);
if (target instanceof ServerPlayer player) {
if (!player.getInventory().add(offering)) {
Containers.dropItemStack(level, pos.getX(), pos.getY()+1, pos.getZ(), offering);
}
} else {
// todo - feed the critters
Containers.dropItemStack(level, pos.getX(), pos.getY()+1, pos.getZ(), offering);
}
}
}

public BlockState tryBurnName(BlockState state, boolean simulate) {
// this fails on client because client can't see the true name. maybe that's a problem to deal with? idk

Expand Down

0 comments on commit 3cbce46

Please sign in to comment.