diff --git a/common/src/main/kotlin/quaedam/projector/ProjectorBlock.kt b/common/src/main/kotlin/quaedam/projector/ProjectorBlock.kt index 3a398ed..5779276 100644 --- a/common/src/main/kotlin/quaedam/projector/ProjectorBlock.kt +++ b/common/src/main/kotlin/quaedam/projector/ProjectorBlock.kt @@ -1,6 +1,7 @@ package quaedam.projector import net.minecraft.core.BlockPos +import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.util.RandomSource import net.minecraft.world.InteractionHand @@ -15,6 +16,8 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.MapColor import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.BlockHitResult +import quaedam.shell.ProjectionShellItem +import quaedam.utils.sendBlockUpdated object ProjectorBlock : Block(Properties.of() .jumpFactor(0.8f) @@ -41,6 +44,21 @@ object ProjectorBlock : Block(Properties.of() interactionHand: InteractionHand, blockHitResult: BlockHitResult ): InteractionResult { + if (player.getItemInHand(interactionHand).item == ProjectionShellItem) { + if (!level.isClientSide) { + val entity = level.getBlockEntity(blockPos) as ProjectorBlockEntity + var newRadius = entity.effectRadius + 1 + if (newRadius > Projector.currentEffectRadius) { + newRadius = 0 + } + entity.updateEffectArea(newRadius) + entity.setChanged() + entity.sendBlockUpdated() + checkUpdate(level, blockPos) + player.sendSystemMessage(Component.translatable("quaedam.projector.radius_updated", newRadius)) + } + return InteractionResult.sidedSuccess(level.isClientSide) + } checkUpdate(level, blockPos) return InteractionResult.PASS } diff --git a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt index 48424ed..49a024d 100644 --- a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt +++ b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt @@ -70,7 +70,7 @@ class ProjectorBlockEntity(pos: BlockPos, state: BlockState) : updateEffects(effects, notify = false) } - private fun updateEffectArea(radius: Int) { + fun updateEffectArea(radius: Int) { effectRadius = radius val chunk = ChunkPos(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z)) val minChunk = ChunkPos(chunk.x - radius, chunk.z - radius) diff --git a/common/src/main/resources/assets/quaedam/lang/en_us.json b/common/src/main/resources/assets/quaedam/lang/en_us.json index 50ddc7c..15650ce 100644 --- a/common/src/main/resources/assets/quaedam/lang/en_us.json +++ b/common/src/main/resources/assets/quaedam/lang/en_us.json @@ -13,6 +13,7 @@ "item.quaedam.projection_shell": "Projection Shell", "item.quaedam.iron_copper_metal": "Copper-iron Alloy", "item.quaedam.projection_metal": "Projection Metal", + "quaedam.projector.radius_updated": "Current effect radius: %s", "quaedam.screen.projection_shell": "Projection Shell", "quaedam.screen.projection_shell.lock_revoked": "Timeout! Connection Lost", "quaedam.screen.projection_shell.lock_failed": "Permission denied!", diff --git a/common/src/main/resources/assets/quaedam/lang/zh_cn.json b/common/src/main/resources/assets/quaedam/lang/zh_cn.json index e48a7a3..ebacb7a 100644 --- a/common/src/main/resources/assets/quaedam/lang/zh_cn.json +++ b/common/src/main/resources/assets/quaedam/lang/zh_cn.json @@ -13,6 +13,7 @@ "item.quaedam.projection_shell": "投影操作面板", "item.quaedam.iron_copper_metal": "铜铁合金", "item.quaedam.projection_metal": "投影金属", + "quaedam.projector.radius_updated": "当前效果半径:%s", "quaedam.screen.projection_shell": "投影操作", "quaedam.screen.projection_shell.lock_revoked": "超时!连接丢失", "quaedam.screen.projection_shell.lock_failed": "正被使用", diff --git a/common/src/main/resources/assets/quaedam/lang/zh_meme.json b/common/src/main/resources/assets/quaedam/lang/zh_meme.json index 7e651e1..5cb7f1c 100644 --- a/common/src/main/resources/assets/quaedam/lang/zh_meme.json +++ b/common/src/main/resources/assets/quaedam/lang/zh_meme.json @@ -13,6 +13,7 @@ "item.quaedam.projection_shell": "投射滥权终端", "item.quaedam.iron_copper_metal": "有点生锈的铁锭", "item.quaedam.projection_metal": "投影Metal©", + "quaedam.projector.radius_updated": "现在乱七八糟的效果能碰到的范围:%s", "quaedam.screen.projection_shell": "控制面板", "quaedam.screen.projection_shell.lock_revoked": "土豆熟了", "quaedam.screen.projection_shell.lock_failed": "宁配吗?",