diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index a3e9ae8ff..051c01158 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -52,16 +52,21 @@ class EntityRendererPanel @JvmOverloads constructor( scissor = true } + private val cosButton: EditablePanel? + private val exosuitButton: EditablePanel? + init { if (entity is Player && isCosmeticArmorLoaded) { - CosmeticToggleRenderButton(screen, this, x = this.width - 7f, y = this.height - 7f) + cosButton = CosmeticToggleRenderButton(screen, this, x = this.width - 7f, y = this.height - 7f) + } else { + cosButton = null } if (entity is Player) { val matteryPlayer = entity.matteryPlayer if (matteryPlayer != null && matteryPlayer.hasExoSuit) { - SmallBooleanRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f, + exosuitButton = SmallBooleanRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f, prop = matteryPlayer::displayExoSuit.asGetterOnly(), skinElementActive = Widgets8.EXOSUIT_SHOWN, skinElementInactive = Widgets8.EXOSUIT_HIDDEN, @@ -73,7 +78,11 @@ class EntityRendererPanel @JvmOverloads constructor( } } ) + } else { + exosuitButton = null } + } else { + exosuitButton = null } } @@ -98,18 +107,14 @@ class EntityRendererPanel @JvmOverloads constructor( override fun performLayout() { super.performLayout() - val cosButton = children.firstOrNull { it is CosmeticToggleRenderButton } as CosmeticToggleRenderButton? - if (cosButton != null) { cosButton.x = this.width - 7f cosButton.y = this.height - 7f } - val toggleButton = children.firstOrNull { it is SmallBooleanRectangleButtonPanel } as SmallBooleanRectangleButtonPanel? - - if (toggleButton != null) { - toggleButton.x = this.width - 2f - toggleButton.width - toggleButton.y = 2f + if (exosuitButton != null) { + exosuitButton.x = this.width - 2f - exosuitButton.width + exosuitButton.y = 2f } } }