Initial fixes for 1.20.2

This commit is contained in:
DBotThePony 2023-10-11 17:40:21 +07:00
parent d841a5fe1a
commit aa513343a5
Signed by: DBot
GPG Key ID: DCC23B5715498507
5 changed files with 20 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -13,7 +14,8 @@ import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.pushScissorRect
public abstract class GuiGraphicsMixin {
@Overwrite
public void enableScissor(int x0, int y0, int x1, int y1) {
pushScissorRect(x0, y0, x1 - x0, y1 - y0);
double scale = Minecraft.getInstance().getWindow().getGuiScale();
pushScissorRect((int) (scale * x0), (int) (scale * y0), (int) (scale * (x1 - x0)), (int) (scale * (y1 - y0)));
}
@Overwrite

View File

@ -6,6 +6,7 @@ import net.minecraft.nbt.DoubleTag
import net.minecraft.nbt.ListTag
import net.minecraft.nbt.Tag
import net.minecraft.server.level.ServerLevel
import net.minecraft.util.datafix.DataFixTypes
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Explosion
import net.minecraft.world.level.ExplosionDamageCalculator
@ -671,7 +672,7 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() {
val factory = ExplosionQueue(level)
factory.load(it)
factory
}, TODO()),
}, DataFixTypes.LEVEL),
"otm_blackhole_explosion_queue"
)
}

View File

@ -290,7 +290,7 @@ fun GuiGraphics.drawLine(
drawLine(pose().last().pose(), startX, startY, endX, endY, width, z, color)
}
data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) {
data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int, val lock: Boolean = false) {
fun withinBounds(x: Int, y: Int): Boolean {
return (x in this.x .. this.x + width) && (y in this.y .. this.y + height)
}
@ -330,7 +330,8 @@ data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int)
private val scissorStack = ArrayDeque<ScissorRect>()
@Suppress("NAME_SHADOWING")
fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) {
@JvmOverloads
fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = false) {
var x = x
var y = y
var width = width
@ -339,6 +340,11 @@ fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) {
val peek = scissorStack.lastOrNull()
if (peek != null) {
if (peek.lock) {
scissorStack.add(peek)
return
}
x = x.coerceAtLeast(peek.x)
y = y.coerceAtLeast(peek.y)
width = width.coerceAtMost(peek.width)
@ -350,7 +356,7 @@ fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) {
}
}
scissorStack.add(ScissorRect(x, y, width, height))
scissorStack.add(ScissorRect(x, y, width, height, lock))
y = minecraft.window.height - y - height
RenderSystem.enableScissor(x, y, width, height)
}

View File

@ -319,6 +319,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
// Обрезать отрисовку потомков?
var scissor = false
var scissorLock = false
var scissorPadding = DockProperty.EMPTY
var dock = Dock.NONE
set(value) {
@ -868,6 +869,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
((absoluteY + top) * scale).toInt(),
((width - right - left) * scale).toInt() + 1,
((height - bottom - top) * scale).toInt() + 1,
scissorLock
)
}

View File

@ -132,6 +132,7 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
init {
dock = Dock.FILL
scissor = true
scissorLock = true
}
private val cosButton: EditablePanel<S>?
@ -169,18 +170,14 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
return
}
val renderX = this.width.toInt() / 2
val renderY = (this.height * 0.9f).toInt()
InventoryScreen.renderEntityInInventoryFollowsMouse(
graphics,
renderX,
renderY,
0, 0,
this.width.toInt(), this.height.toInt(),
renderScale,
0f,
absoluteX.toInt() + renderX - mouseX,
absoluteY + height * 0.15f - mouseY,
mouseX - absoluteX.toInt(),
mouseY - absoluteY + height * 0.15f,
entity
)
}