diff --git a/src/main/java/io/github/afamiliarquiet/familiar_magic/block/FamiliarBlocks.java b/src/main/java/io/github/afamiliarquiet/familiar_magic/block/FamiliarBlocks.java index 308d557..2b85df0 100644 --- a/src/main/java/io/github/afamiliarquiet/familiar_magic/block/FamiliarBlocks.java +++ b/src/main/java/io/github/afamiliarquiet/familiar_magic/block/FamiliarBlocks.java @@ -30,7 +30,9 @@ public class FamiliarBlocks { public static final DeferredBlock ENCHANTED_CANDLE_BLOCK = registerBlockWithItem( "enchanted_candle", - () -> new EnchantedCandleBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CANDLE)) // maybe toy with properties later + () -> new EnchantedCandleBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CANDLE) + .mapColor(MapColor.COLOR_ORANGE) + ) // maybe toy with properties later ); public static final DeferredBlock SUMMONING_TABLE_BLOCK = registerBlockWithItem( @@ -38,7 +40,7 @@ public class FamiliarBlocks { () -> new SummoningTableBlock(BlockBehaviour.Properties.of() .mapColor(MapColor.COLOR_PURPLE) .instrument(NoteBlockInstrument.BASEDRUM) - .requiresCorrectToolForDrops() // hmm good point. i should fix this by adding this to stone pick tag or whatever + .requiresCorrectToolForDrops() .lightLevel(state -> state.getValue(SummoningTableBlock.SUMMONING_TABLE_STATE).lightLevel()) .strength(5.0F, 1200.0F) ) diff --git a/src/main/java/io/github/afamiliarquiet/familiar_magic/block/SummoningTableBlock.java b/src/main/java/io/github/afamiliarquiet/familiar_magic/block/SummoningTableBlock.java index f00e47c..a9d0a7e 100644 --- a/src/main/java/io/github/afamiliarquiet/familiar_magic/block/SummoningTableBlock.java +++ b/src/main/java/io/github/afamiliarquiet/familiar_magic/block/SummoningTableBlock.java @@ -174,7 +174,8 @@ protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSou @Override public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { - if (state.getValue(SUMMONING_TABLE_STATE) == SummoningTableState.SUMMONING) { + SummoningTableState tableState = state.getValue(SUMMONING_TABLE_STATE); + if (tableState == SummoningTableState.SUMMONING) { if (random.nextInt(100) == 0) { // truly just ripping this whole thing from respawn anchor. as usual, might change sound later. unlikely level.playLocalSound(pos, SoundEvents.RESPAWN_ANCHOR_AMBIENT, SoundSource.BLOCKS, 1.0F, 1.0F, false); @@ -185,6 +186,21 @@ public void animateTick(BlockState state, Level level, BlockPos pos, RandomSourc double d2 = (double)pos.getZ() + 0.5 + (0.5 - random.nextDouble()); double d3 = (double)random.nextFloat() * 0.04; level.addParticle(ParticleTypes.REVERSE_PORTAL, d0, d1, d2, 0.0, d3, 0.0); + } else if (tableState == SummoningTableState.BURNING) { + if (random.nextInt(31) == 0) { + level.playLocalSound(pos, SoundEvents.CAMPFIRE_CRACKLE, SoundSource.BLOCKS, 1, 1, false); + } + + if (random.nextInt(2) == 0) { + double x = pos.getX() + 0.5 + 0.5 * (0.5 - random.nextDouble()); + double y = pos.getY() + 0.8375; + double z = pos.getZ() + 0.5 + 0.5 * (0.5 - random.nextDouble()); + level.addParticle( + random.nextInt(6) == 0 ? ParticleTypes.FLAME : ParticleTypes.SMOKE, + x, y, z, + 0.0, 0.0, 0.0 + ); + } } } diff --git a/src/main/java/io/github/afamiliarquiet/familiar_magic/block/entity/SummoningTableBlockEntity.java b/src/main/java/io/github/afamiliarquiet/familiar_magic/block/entity/SummoningTableBlockEntity.java index fa9f3c8..325ed5a 100644 --- a/src/main/java/io/github/afamiliarquiet/familiar_magic/block/entity/SummoningTableBlockEntity.java +++ b/src/main/java/io/github/afamiliarquiet/familiar_magic/block/entity/SummoningTableBlockEntity.java @@ -20,6 +20,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.LockCode; import net.minecraft.world.MenuProvider; import net.minecraft.world.Nameable; @@ -37,6 +39,7 @@ import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.neoforged.neoforge.items.IItemHandler; import net.neoforged.neoforge.items.IItemHandlerModifiable; import net.neoforged.neoforge.items.ItemStackHandler; @@ -135,11 +138,12 @@ public SummoningTableBlockEntity(BlockPos pos, BlockState blockState) { public BlockState startSummoning(BlockState state, boolean simulate) { // todo - check for unlits, then blow out candles on summoning start - if (this.level instanceof ServerLevel serverLevel) { + if (!this.anyUnlit() && this.level instanceof ServerLevel serverLevel) { LivingEntity livingTarget = findTargetByUuid(this.getCandleTarget(), serverLevel.getServer()); if (livingTarget != null) { if (!simulate) { this.summoningTimer = FamiliarTricks.SUMMONING_TIME_SECONDS; + //this.unlightAll(); if (livingTarget instanceof ServerPlayer player) { SummoningRequestData requestData = new SummoningRequestData( @@ -210,7 +214,7 @@ public void cancelSummoning() { public void acceptSummoning(LivingEntity livingTarget) { if (this.level == null) { - // this really shouldn't ever be real + // this really shouldn't ever be real. also this should always be on server side? return; } if (livingTarget.getUUID().equals(this.getCandleTarget()) && this.getBlockState().getValue(SummoningTableBlock.SUMMONING_TABLE_STATE) == SummoningTableState.SUMMONING) { @@ -221,6 +225,10 @@ public void acceptSummoning(LivingEntity livingTarget) { pathfindermob.getNavigation().stop(); } + 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); + // todo - replace these with more happy variants, and also give offerings to accepting player cancelSummoning(); SummoningTableBlock.extinguish(null, this.getBlockState(), this.level, this.getBlockPos()); @@ -303,6 +311,25 @@ public boolean anyUnlit() { return false; } + private void unlightAll() { + if (this.level == null) { + return; + } + + for (int i = 0; i < 32; i++) { + // boldly unchecked because this should only be called when all the things are there... err i should check actually + BlockPos targetPos = this.getBlockPos().offset(CANDLE_COLUMN_OFFSETS[2*i], 0, CANDLE_COLUMN_OFFSETS[2*i+1]); + targetPos = targetPos.offset(0, ((this.targetFromCandlesInNybbles[i] >> 2) & 0b11) + 1, 0); + BlockState targetState = this.level.getBlockState(targetPos); + if (targetState.is(FamiliarBlocks.ENCHANTED_CANDLE_BLOCK)) { + this.level.setBlock(targetPos, targetState.setValue(EnchantedCandleBlock.LIT, false), Block.UPDATE_CLIENTS); + } + } + + // todo - custom sound/event + level.playSound(null, this.getBlockPos(), SoundEvents.BREEZE_LAND, SoundSource.BLOCKS, 1, 1); + } + // written with the aid of our lady luna :innocent: private static byte[] processCandles(Level level, BlockPos pos) { byte[] nybbles = new byte[32]; diff --git a/src/main/java/io/github/afamiliarquiet/familiar_magic/network/SummoningRequestPayload.java b/src/main/java/io/github/afamiliarquiet/familiar_magic/network/SummoningRequestPayload.java index fa54ba0..b21c4f0 100644 --- a/src/main/java/io/github/afamiliarquiet/familiar_magic/network/SummoningRequestPayload.java +++ b/src/main/java/io/github/afamiliarquiet/familiar_magic/network/SummoningRequestPayload.java @@ -2,11 +2,12 @@ import io.github.afamiliarquiet.familiar_magic.data.SummoningRequestData; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.player.Player; import net.neoforged.neoforge.network.handling.IPayloadContext; import org.jetbrains.annotations.NotNull; @@ -42,6 +43,7 @@ public static void ayeAyeRequestReceived(final SummoningRequestPayload summoning } else { // also set like, request time? to 30? and fade screen in and out at the ends setRequest(hehehe, summoningRequestPayload.requestData); + hehehe.level().playLocalSound(hehehe, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundSource.BLOCKS, 1, 1); } } }