diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 13eccc6cf..36592a228 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -415,10 +415,12 @@ data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) } fun cross(x: Int, y: Int, width: Int, height: Int): Boolean { + // corssing any of rect points if (withinBounds(x, y) || withinBounds(x + width, y) || withinBounds(x, y + height) || withinBounds(x + width, y + height)) { return true } + // crossing at least one line if (y in this.y .. this.y + height) { if (x < this.x && x + width > this.x + this.width) { return true @@ -429,7 +431,8 @@ data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) } } - return false + // final test: check if scissor rect is completely inside provided rect + return this.x in x .. x + width && this.y in y .. y + height } fun crossScaled(x: Float, y: Float, width: Float, height: Float): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index c7350d13f..6a5c03dbe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -179,6 +179,7 @@ open class EditablePanel @JvmOverloads constructor( // Обрезать отрисовку потомков? var scissor = false + var scissorPadding = DockProperty.EMPTY var dock = Dock.NONE set(value) { if (field != value) { @@ -461,11 +462,13 @@ open class EditablePanel @JvmOverloads constructor( if (scissor) { val scale = minecraft.window.guiScale + val (left, top, right, bottom) = scissorPadding + pushScissorRect( - (absoluteX * scale).toInt(), - (absoluteY * scale).toInt(), - (width * scale).toInt() + 1, - (height * scale).toInt() + 1, + ((absoluteX + left) * scale).toInt(), + ((absoluteY + top) * scale).toInt(), + ((width - right - left) * scale).toInt() + 1, + ((height - bottom - top) * scale).toInt() + 1, ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 24e4789d1..15ae3d4a7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -34,6 +34,8 @@ open class EffectListPanel @JvmOverloads constructor( ) : EditablePanel(screen, parent, x, y, gridWidth * (SQUARE_THIN.width + 2f), gridHeight * (SQUARE_THIN.height + 2f)) { val scroll: DiscreteScrollBarPanel = DiscreteScrollBarPanel(screen, this, this::calculateMaxScroll, this::onScrolled, height = height) + var alignOnRight = true + var gridWidth: Int = gridWidth set(value) { if (field == value) @@ -183,7 +185,11 @@ open class EffectListPanel @JvmOverloads constructor( var x = 0 for (panel in sorted) { - panel.setPos((gridWidth - x - 1) * 26f, y * 26f) + if (alignOnRight) { + panel.setPos((gridWidth - x - 1) * 26f, y * 26f) + } else { + panel.setPos(x * 26f, y * 26f) + } x++ 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 5a5dc90ad..d890c3276 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 @@ -33,27 +33,36 @@ class EntityRendererPanel @JvmOverloads constructor( var renderScale: Int = calculateScale(width, height) ) : EditablePanel(screen, parent, x, y, width, height) { init { - scissor = true + dockPadding = DockProperty(1f, 1f, 1.5f, 1f) + } + + val canvas = object : EditablePanel(screen, this@EntityRendererPanel) { + init { + dock = Dock.FILL + scissor = true + } + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + if (entity.isDeadOrDying) { + return + } + + val renderX = absoluteX.toInt() + width.toInt() / 2 + val renderY = absoluteY.toInt() + (height * 0.9f).toInt() + + InventoryScreen.renderEntityInInventory( + renderX, + renderY, + renderScale, + renderX - mouseX, + absoluteY + height * 0.15f - mouseY, + entity + ) + } } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { ExoSuitInventoryScreen.ENTITY_RECTANGLE.render(stack) - - if (entity.isDeadOrDying) { - return - } - - val renderX = absoluteX.toInt() + width.toInt() / 2 - val renderY = absoluteY.toInt() + (height * 0.9f).toInt() - - InventoryScreen.renderEntityInInventory( - renderX, - renderY, - renderScale, - renderX - mouseX, - absoluteY + height * 0.15f - mouseY, - entity - ) } companion object {