diff --git a/common/src/main/kotlin/quaedam/projection/SimpleProjectionUpdate.kt b/common/src/main/kotlin/quaedam/projection/SimpleProjectionUpdate.kt index fa2cc59..9e1eef9 100644 --- a/common/src/main/kotlin/quaedam/projection/SimpleProjectionUpdate.kt +++ b/common/src/main/kotlin/quaedam/projection/SimpleProjectionUpdate.kt @@ -19,7 +19,7 @@ object SimpleProjectionUpdate { NetworkManager.registerReceiver(NetworkManager.Side.C2S, id, ::handle) } - private fun handle(buf: FriendlyByteBuf, ctx: PacketContext) { + private fun handle(buf: FriendlyByteBuf, ctx: PacketContext) = runCatching { val player = ctx.player!! as ServerPlayer val level = player.level() @@ -31,7 +31,7 @@ object SimpleProjectionUpdate { if (player.blockPosition().distSqr(pos) > 50 * 50) { player.connection.disconnect(Component.literal("[Quaedam] wth r u doing? why not waiting for server?")) } - return + return@runCatching } level.server!!.execute { @@ -47,10 +47,13 @@ object SimpleProjectionUpdate { player.connection.disconnect(Component.literal("[Quaedam] ? wait what did you send to the server?")) return@execute } + entity.setChanged() blockEntity.sendBlockUpdated() ProjectionBlock.sendUpdateToProjectors(level, pos) } } + .onFailure { Quaedam.logger.error("Error handling simple projection update packet", it) } + .getOrThrow() fun send(pos: BlockPos, data: CompoundTag) { val buf = FriendlyByteBuf(Unpooled.buffer()) diff --git a/common/src/main/kotlin/quaedam/projection/misc/NoiseProjection.kt b/common/src/main/kotlin/quaedam/projection/misc/NoiseProjection.kt index ccdaecc..975bd3d 100644 --- a/common/src/main/kotlin/quaedam/projection/misc/NoiseProjection.kt +++ b/common/src/main/kotlin/quaedam/projection/misc/NoiseProjection.kt @@ -101,7 +101,7 @@ object NoiseProjectionBlock : EntityProjectionBlock(creat } -data class NoiseProjectionEffect(var rate: Int = 120, var amount: Int = 3) : ProjectionEffect(), +data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3) : ProjectionEffect(), ProjectionEffectShell.Provider { companion object { diff --git a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt index 91dac6f..d36594f 100644 --- a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt +++ b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt @@ -106,6 +106,7 @@ class ProjectorBlockEntity(pos: BlockPos, state: BlockState) : if (!level.isClientSide && notify) { sendBlockUpdated() } + setChanged() val addedEffects = effects.filterKeys { it !in oldEffects } val removedEffects = oldEffects.filterKeys { it !in effects } val updatedEffects = effects.filter { (k, v) -> oldEffects[k] != null && oldEffects[k] != v } diff --git a/common/src/main/kotlin/quaedam/shell/ProjectionShellScreen.kt b/common/src/main/kotlin/quaedam/shell/ProjectionShellScreen.kt index d51afd6..bade2f1 100644 --- a/common/src/main/kotlin/quaedam/shell/ProjectionShellScreen.kt +++ b/common/src/main/kotlin/quaedam/shell/ProjectionShellScreen.kt @@ -34,10 +34,6 @@ class ProjectionShellScreen(val level: Level, val pos: BlockPos, val shell: Proj run { // Buttons rows.addChild(StringWidget(Component.empty(), font)) rows.addChild(Button.builder(Component.translatable("quaedam.screen.projection_shell.save")) { - val block = level.getBlockState(pos).block - if (block is ProjectionShellBlock) { - block.applyFromShell(level, pos, shell) - } GameInstance.getClient().setScreen(null) }.build().apply(::setInitialFocus)) } @@ -78,6 +74,10 @@ class ProjectionShellScreen(val level: Level, val pos: BlockPos, val shell: Proj override fun removed() { super.removed() + val block = level.getBlockState(pos).block + if (block is ProjectionShellBlock) { + block.applyFromShell(level, pos, shell) + } ProjectionShell.channel.sendToServer(ServerboundPSHLockReleasePacket(pos)) }