Fix various block entity rendering issues
This commit is contained in:
parent
6c5b7fc72f
commit
6f75ca785d
@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
||||
@ -98,7 +99,9 @@ abstract class BankRenderer<T : MatteryDeviceBlockEntity>(private val context: B
|
||||
y = 30f,
|
||||
width = width,
|
||||
height = heightMax * gaugeLevel(blockEntity),
|
||||
color = RGBAColor.WHITE
|
||||
color = RGBAColor.WHITE,
|
||||
winding = UVWindingOrder.FLIP,
|
||||
topDown = false
|
||||
)
|
||||
|
||||
stack.rotateY(PI.toFloat())
|
||||
@ -111,7 +114,9 @@ abstract class BankRenderer<T : MatteryDeviceBlockEntity>(private val context: B
|
||||
y = 30f,
|
||||
width = width,
|
||||
height = heightMax * gaugeLevel(blockEntity),
|
||||
color = RGBAColor.WHITE
|
||||
color = RGBAColor.WHITE,
|
||||
winding = UVWindingOrder.FLIP,
|
||||
topDown = false
|
||||
)
|
||||
|
||||
stack.popPose()
|
||||
|
@ -163,14 +163,16 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv
|
||||
TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)),
|
||||
1f, -font.lineHeight.toFloat() / 2f + 1f,
|
||||
color = RGBAColor.WHITE, buffer = sorse, gravity = RenderGravity.TOP_CENTER,
|
||||
drawOutline = true)
|
||||
drawOutline = true,
|
||||
outlineZ = 0.1f)
|
||||
|
||||
font.draw(
|
||||
poseStack,
|
||||
TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)),
|
||||
1f, font.lineHeight.toFloat() / 2f + 1f,
|
||||
color = RGBAColor.WHITE, buffer = sorse, gravity = RenderGravity.TOP_CENTER,
|
||||
drawOutline = true)
|
||||
drawOutline = true,
|
||||
outlineZ = 0.1f)
|
||||
|
||||
poseStack.popPose()
|
||||
}
|
||||
|
@ -191,11 +191,34 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords {
|
||||
z: Float = 0f,
|
||||
color: RGBAColor? = null,
|
||||
winding: UVWindingOrder = this.winding,
|
||||
topDown: Boolean = true,
|
||||
leftRight: Boolean = true,
|
||||
) {
|
||||
val u1 = (u0 + linearInterpolation(width / this.width, 0f, u1 - u0)).coerceAtLeast(0f).coerceAtMost(1f)
|
||||
val v1 = (v0 + linearInterpolation(height / this.height, 0f, v1 - v0)).coerceAtLeast(0f).coerceAtMost(1f)
|
||||
val (u0_, v0_, u1_, v1_) = winding.translate(u0, v0, u1, v1)
|
||||
val u0: Float
|
||||
val v0: Float
|
||||
val u1: Float
|
||||
val v1: Float
|
||||
|
||||
val diffV = linearInterpolation((height / this.height).coerceIn(0f, 1f), 0f, this.v1 - this.v0)
|
||||
val diffU = linearInterpolation((width / this.width).coerceIn(0f, 1f), 0f, this.u1 - this.u0)
|
||||
|
||||
if (topDown) {
|
||||
v0 = this.v0
|
||||
v1 = this.v0 + diffV
|
||||
} else {
|
||||
v0 = this.v1 - diffV
|
||||
v1 = this.v1
|
||||
}
|
||||
|
||||
if (leftRight) {
|
||||
u0 = this.u0
|
||||
u1 = this.u0 + diffU
|
||||
} else {
|
||||
u0 = this.u1 - diffU
|
||||
u1 = this.u1
|
||||
}
|
||||
|
||||
val (u0_, v0_, u1_, v1_) = winding.translate(u0, v0, u1, v1)
|
||||
uploadOnto(pose, builder, x, y, width, height, z, color, u0_, v0_, u1_, v1_)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user