Fix JEI flickering

This commit is contained in:
DBotThePony 2022-09-24 18:09:37 +07:00
parent 24805fb15f
commit ab7473db6c
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 27 additions and 7 deletions

View File

@ -444,7 +444,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
result.add(Rect2f(absoluteX, absoluteY, width, height))
for (children in children) {
if (children.isOutsideOfParent) {
if (children.isOutsideOfParent && children.isVisible()) {
result.addAll(children.calculateAbsoluteRectangles())
}
}
@ -557,16 +557,36 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
return false
}
fun render(poseStack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
if (!isVisible()) {
return
}
fun performLayoutIfNeeded() {
if (layoutInvalidated) {
performLayout()
} else if (boundsInvalidated) {
updateBounds()
}
}
fun updateAbsoluteCoordinates() {
if (parent == null) {
absoluteX = x
absoluteY = y
}
for (child in children) {
if (child.isVisible()) {
child.absoluteX = absoluteX + child.x + xOffset
child.absoluteY = absoluteY + child.y + yOffset
child.updateAbsoluteCoordinates()
}
}
}
fun render(poseStack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
if (!isVisible()) {
return
}
performLayoutIfNeeded()
val parent = this.parent

View File

@ -217,7 +217,7 @@ class JEIPlugin : IModPlugin {
override fun registerGuiHandlers(registration: IGuiHandlerRegistration) {
registration.addGenericGuiContainerHandler(MatteryScreen::class.java, object : IGuiContainerHandler<MatteryScreen<*>> {
override fun getGuiExtraAreas(containerScreen: MatteryScreen<*>): MutableList<Rect2i> {
return containerScreen.panelsView.stream().map { it.calculateAbsoluteRectangles() }.flatMap { it.stream() }.map { it.toIntRect() }.collect(Collectors.toList())
return containerScreen.panelsView.stream().map { it.performLayoutIfNeeded(); it.updateAbsoluteCoordinates(); it.calculateAbsoluteRectangles() }.flatMap { it.stream() }.map { it.toIntRect() }.collect(Collectors.toList())
}
override fun getIngredientUnderMouse(