Make EntityRendererPanel clip 1 pixel on each side
This commit is contained in:
parent
0d45f0b612
commit
85ebbbf905
@ -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 {
|
||||
|
@ -179,6 +179,7 @@ open class EditablePanel<out S : Screen> @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<out S : Screen> @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,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,8 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
||||
) : EditablePanel<S>(screen, parent, x, y, gridWidth * (SQUARE_THIN.width + 2f), gridHeight * (SQUARE_THIN.height + 2f)) {
|
||||
val scroll: DiscreteScrollBarPanel<out S> = 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<out S : Screen> @JvmOverloads constructor(
|
||||
var x = 0
|
||||
|
||||
for (panel in sorted) {
|
||||
if (alignOnRight) {
|
||||
panel.setPos((gridWidth - x - 1) * 26f, y * 26f)
|
||||
} else {
|
||||
panel.setPos(x * 26f, y * 26f)
|
||||
}
|
||||
|
||||
x++
|
||||
|
||||
|
@ -33,12 +33,16 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
var renderScale: Int = calculateScale(width, height)
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
init {
|
||||
dockPadding = DockProperty(1f, 1f, 1.5f, 1f)
|
||||
}
|
||||
|
||||
val canvas = object : EditablePanel<S>(screen, this@EntityRendererPanel) {
|
||||
init {
|
||||
dock = Dock.FILL
|
||||
scissor = true
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
ExoSuitInventoryScreen.ENTITY_RECTANGLE.render(stack)
|
||||
|
||||
if (entity.isDeadOrDying) {
|
||||
return
|
||||
}
|
||||
@ -55,6 +59,11 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
ExoSuitInventoryScreen.ENTITY_RECTANGLE.render(stack)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ENTITY_RECTANGLE = AbstractContainerScreen.INVENTORY_LOCATION.element(25f, 7f, 51f, 72f)
|
||||
|
Loading…
Reference in New Issue
Block a user