From 60304f5c14efc83307798a62dfe45eb741daa4b1 Mon Sep 17 00:00:00 2001 From: xtex Date: Wed, 19 Jul 2023 19:46:10 +0800 Subject: [PATCH] refactor: use TAG constants --- .../main/kotlin/quaedam/projector/ProjectorBlockEntity.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt index 5e41e76..db3b1e8 100644 --- a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt +++ b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt @@ -21,6 +21,10 @@ import quaedam.utils.sendBlockUpdated class ProjectorBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(Projector.blockEntity.get(), pos, state) { + companion object { + const val TAG_PROJECTION_EFFECTS = "ProjectionEffects" + } + val effectAreaChunk by lazy { val chunk = level!!.getChunk(pos).pos ChunkPos(chunk.x - Projector.EFFECT_RADIUS, chunk.z - Projector.EFFECT_RADIUS) to @@ -53,12 +57,12 @@ class ProjectorBlockEntity(pos: BlockPos, state: BlockState) : effects.map { (type, effect) -> effectsTag.put(type.id.toString(), effect.toNbt()) } - tag.put("ProjectionEffects", effectsTag) + tag.put(TAG_PROJECTION_EFFECTS, effectsTag) } override fun load(tag: CompoundTag) { super.load(tag) - val effectsTag = tag["ProjectionEffects"] + val effectsTag = tag[TAG_PROJECTION_EFFECTS] val effects = mutableMapOf, ProjectionEffect>() if (effectsTag != null && effectsTag is CompoundTag) { effectsTag.allKeys.forEach { id ->