Add polyfill guigraphics

This commit is contained in:
DBotThePony 2024-01-01 02:39:58 +07:00
parent 2e23ce1a04
commit 311de079fa
Signed by: DBot
GPG Key ID: DCC23B5715498507
64 changed files with 532 additions and 348 deletions

View File

@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.client.multiplayer.ClientLevel
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.nbt.set
@ -47,7 +48,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma
// TODO: GuiGraphics is stripped from server dist // TODO: GuiGraphics is stripped from server dist
// but it doesn't seem to cause issues? // but it doesn't seem to cause issues?
abstract fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor = RGBAColor.WHITE) abstract fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor = RGBAColor.WHITE)
override fun serializeNBT(): CompoundTag { override fun serializeNBT(): CompoundTag {
return super.serializeNBT().also { return super.serializeNBT().also {

View File

@ -30,6 +30,7 @@ import ru.dbotthepony.mc.otm.android.AndroidActiveFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType
@ -373,7 +374,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
} }
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
if (cooldown > 0) { if (cooldown > 0) {
RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f)
} }

View File

@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.config.AndroidConfig
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.Vector
@ -119,7 +120,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
} }
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height, color = color) ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height, color = color)
} }
} }

View File

@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.AndroidConfig
import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.config.ClientConfig
@ -96,7 +97,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
} }
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
ResearchIcons.ICON_JUMP_BOOST.render(graphics, x, y, width, height, color = if (cooldown > 0) color * RGBAColor.REDDISH else color) ResearchIcons.ICON_JUMP_BOOST.render(graphics, x, y, width, height, color = if (cooldown > 0) color * RGBAColor.REDDISH else color)
} }
} }

View File

@ -6,6 +6,7 @@ import net.minecraft.world.effect.MobEffects
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.AndroidConfig
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
@ -33,7 +34,7 @@ class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFe
} }
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
ResearchIcons.ICON_NIGHT_VISION.render(graphics, x, y, width, height, color = color) ResearchIcons.ICON_NIGHT_VISION.render(graphics, x, y, width, height, color = color)
} }
} }

View File

@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.AndroidConfig
import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.damageType
@ -225,7 +226,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
ticker(false) ticker(false)
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
ResearchIcons.ICON_SHOCKWAVE.render(graphics, x, y, width, height, color = if (isOnCooldown) color * RGBAColor.REDDISH else color) ResearchIcons.ICON_SHOCKWAVE.render(graphics, x, y, width, height, color = if (isOnCooldown) color * RGBAColor.REDDISH else color)
} }
} }

View File

@ -6,6 +6,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier
import net.minecraftforge.common.ForgeMod import net.minecraftforge.common.ForgeMod
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.AndroidFeatures
@ -55,7 +56,7 @@ class StepAssistFeature(android: MatteryPlayerCapability) : AndroidSwitchableFea
sharedTick() sharedTick()
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
ResearchIcons.ICON_STEP_ASSIST.render(graphics, x, y, width, height, color = color) ResearchIcons.ICON_STEP_ASSIST.render(graphics, x, y, width, height, color = color)
} }

View File

@ -5,6 +5,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier
import net.minecraftforge.common.ForgeMod import net.minecraftforge.common.ForgeMod
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.ResearchIcons
import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.AndroidConfig
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
@ -29,7 +30,7 @@ class SwimBoostersFeature(android: MatteryPlayerCapability) : AndroidSwitchableF
ply.getAttribute(ForgeMod.SWIM_SPEED.get())?.removeModifier(MODIFIER_ID) ply.getAttribute(ForgeMod.SWIM_SPEED.get())?.removeModifier(MODIFIER_ID)
} }
override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) {
ResearchIcons.ICON_LIMB_OVERCLOCKING.render(graphics, x, y, width, height, color = color) ResearchIcons.ICON_LIMB_OVERCLOCKING.render(graphics, x, y, width, height, color = color)
} }

View File

@ -57,18 +57,19 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f
val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f
val wrap = MGUIGraphics(event.guiGraphics)
feature.renderIcon(event.guiGraphics, x, y, iconSize, iconSize) feature.renderIcon(wrap, x, y, iconSize, iconSize)
if (feature.isOnCooldown) { if (feature.isOnCooldown) {
val cooldownPct = feature.cooldownPercent val cooldownPct = feature.cooldownPercent
if (cooldownPct > 0.0f) { if (cooldownPct > 0.0f) {
val nodrawpixels = (iconSize * (1 - cooldownPct)).roundToInt().toFloat() val nodrawpixels = (iconSize * (1 - cooldownPct)).roundToInt().toFloat()
event.guiGraphics.renderRect(x, y + nodrawpixels, iconSize, iconSize - nodrawpixels, color = RGBAColor.HALF_TRANSPARENT) wrap.renderRect(x, y + nodrawpixels, iconSize, iconSize - nodrawpixels, color = RGBAColor.HALF_TRANSPARENT)
} }
Widgets18.COOLDOWN.render(event.guiGraphics, x, y + iconSize, iconSize, iconSize) Widgets18.COOLDOWN.render(wrap, x, y + iconSize, iconSize, iconSize)
} }
} }

View File

@ -246,6 +246,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
val poseStack = event.guiGraphics.pose() val poseStack = event.guiGraphics.pose()
poseStack.pushPose() poseStack.pushPose()
poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0) poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0)
val wrap = MGUIGraphics(event.guiGraphics)
for ((index, feature) in features.withIndex()) { for ((index, feature) in features.withIndex()) {
var sin = sin((index + 0.5) * degreePerSlice).toFloat() var sin = sin((index + 0.5) * degreePerSlice).toFloat()
@ -257,17 +258,17 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
} }
val shift = size * 0.6f val shift = size * 0.6f
feature.renderIcon(event.guiGraphics, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) feature.renderIcon(wrap, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize)
event.guiGraphics.draw(minecraft.font, feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) wrap.draw(minecraft.font, feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER)
event.guiGraphics.draw(minecraft.font, feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER) wrap.draw(minecraft.font, feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER)
if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) {
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble())
RenderSystem.setShaderColor(1f, 1f, 1f, 1f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
event.guiGraphics.draw(minecraft.font, formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) wrap.draw(minecraft.font, formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER)
} }
} }
@ -296,15 +297,16 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
val y = minecraft.window.guiScaledHeight * 0.2f val y = minecraft.window.guiScaledHeight * 0.2f
var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f)) var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f))
val wrap = MGUIGraphics(event.guiGraphics)
for (feature in features) { for (feature in features) {
feature.renderIcon(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE)
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false)
RenderSystem.setShaderColor(1f, 1f, 1f, 1f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
event.guiGraphics.draw(font, formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) wrap.draw(font, formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER)
x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN
} }

View File

@ -0,0 +1,259 @@
package ru.dbotthepony.mc.otm.client
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.Font
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.texture.TextureAtlasSprite
import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.util.FormattedCharSequence
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.client.render.GravityRounding
import ru.dbotthepony.mc.otm.client.render.IUVCoords
import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.UVCoords
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.draw
import ru.dbotthepony.mc.otm.core.math.RGBAColor
// polyfill class for 1.19.4 and older
class MGUIGraphics(val parent: GuiGraphics) {
val pose: PoseStack get() = parent.pose()
val bufferSource: MultiBufferSource.BufferSource get() = parent.bufferSource()
val width get() = parent.guiWidth()
val height get() = parent.guiHeight()
val font: Font get() = minecraft.font
fun setColor(red: Float, green: Float, blue: Float, alpha: Float) {
parent.setColor(red, green, blue, alpha)
}
fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) {
parent.renderFakeItem(itemStack, x, y)
}
fun drawLine(
startX: Float,
startY: Float,
endX: Float,
endY: Float,
width: Float,
z: Float = 0f,
color: RGBAColor = RGBAColor.WHITE
) {
ru.dbotthepony.mc.otm.client.render.drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color)
}
fun renderRect(
x: Float,
y: Float,
width: Float,
height: Float,
z: Float = 0f,
color: RGBAColor = RGBAColor.WHITE
) {
ru.dbotthepony.mc.otm.client.render.renderRect(pose.last().pose(), x, y, width, height, z, color)
}
fun renderTexturedRect(
x: Float,
y: Float,
width: Float,
height: Float,
z: Float = 0f,
uv: IUVCoords = defaultUV,
uvWinding: UVWindingOrder = UVWindingOrder.NORMAL,
color: RGBAColor = RGBAColor.WHITE,
texture: ResourceLocation? = null
) {
ru.dbotthepony.mc.otm.client.render.renderTexturedRect(pose.last().pose(), x, y, width, height, z, uv, uvWinding, color, texture)
}
fun renderCheckerboard(
x: Float,
y: Float,
width: Float,
height: Float,
z: Float = 0f,
color: RGBAColor = RGBAColor.WHITE
) {
ru.dbotthepony.mc.otm.client.render.renderCheckerboard(pose.last().pose(), x, y, width, height, z, color)
}
fun renderComponentTooltip(font: Font, lines: MutableList<Component>, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) {
parent.renderComponentTooltip(font, lines, x, y, itemStack)
}
fun flush() {
parent.flush()
}
fun draw(
font: Font,
text: String,
x: Float = 0f,
y: Float = 0f,
gravity: RenderGravity = RenderGravity.TOP_LEFT,
scale: Float = 1f,
color: RGBAColor = RGBAColor.WHITE,
drawShadow: Boolean = false,
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
packedLightCoords: Int = 15728880,
effectColor: Int = 0,
shadowColor: RGBAColor = RGBAColor.BLACK,
shadowX: Float = 1f,
shadowY: Float = 1f,
shadowZ: Float = -0.1f,
customShadow: Boolean = false,
rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO,
drawOutline: Boolean = false,
outlineColor: RGBAColor = RGBAColor.BLACK,
outlineZ: Float = -0.1f,
): Float {
val width = font.draw(
poseStack = pose,
text = text,
x = x,
y = y,
buffer = bufferSource,
gravity = gravity,
scale = scale,
color = color,
drawShadow = drawShadow,
displayMode = displayMode,
packedLightCoords = packedLightCoords,
effectColor = effectColor,
shadowColor = shadowColor,
shadowX = shadowX,
shadowY = shadowY,
shadowZ = shadowZ,
customShadow = customShadow,
rounding = rounding,
drawOutline = drawOutline,
outlineColor = outlineColor,
outlineZ = outlineZ,
)
flush()
return width
}
fun draw(
font: Font,
text: Component,
x: Float = 0f,
y: Float = 0f,
gravity: RenderGravity = RenderGravity.TOP_LEFT,
scale: Float = 1f,
color: RGBAColor = RGBAColor.WHITE,
drawShadow: Boolean = false,
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
packedLightCoords: Int = 15728880,
effectColor: Int = 0,
shadowColor: RGBAColor = RGBAColor.BLACK,
shadowX: Float = 1f,
shadowY: Float = 1f,
shadowZ: Float = -0.1f,
customShadow: Boolean = false,
rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO,
drawOutline: Boolean = false,
outlineColor: RGBAColor = RGBAColor.BLACK,
outlineZ: Float = -0.1f,
): Float {
val width = font.draw(
poseStack = pose,
text = text,
x = x,
y = y,
buffer = bufferSource,
gravity = gravity,
scale = scale,
color = color,
drawShadow = drawShadow,
displayMode = displayMode,
packedLightCoords = packedLightCoords,
effectColor = effectColor,
shadowColor = shadowColor,
shadowX = shadowX,
shadowY = shadowY,
shadowZ = shadowZ,
customShadow = customShadow,
rounding = rounding,
drawOutline = drawOutline,
outlineColor = outlineColor,
outlineZ = outlineZ,
)
flush()
return width
}
fun draw(
font: Font,
text: FormattedCharSequence,
x: Float = 0f,
y: Float = 0f,
gravity: RenderGravity = RenderGravity.TOP_LEFT,
scale: Float = 1f,
color: RGBAColor = RGBAColor.WHITE,
drawShadow: Boolean = false,
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
packedLightCoords: Int = 15728880,
effectColor: Int = 0,
shadowColor: RGBAColor = RGBAColor.BLACK,
shadowX: Float = 1f,
shadowY: Float = 1f,
shadowZ: Float = -0.1f,
customShadow: Boolean = false,
rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO,
drawOutline: Boolean = false,
outlineColor: RGBAColor = RGBAColor.BLACK,
outlineZ: Float = -0.1f,
): Float {
val width = font.draw(
poseStack = pose,
text = text,
x = x,
y = y,
buffer = bufferSource,
gravity = gravity,
scale = scale,
color = color,
drawShadow = drawShadow,
displayMode = displayMode,
packedLightCoords = packedLightCoords,
effectColor = effectColor,
shadowColor = shadowColor,
shadowX = shadowX,
shadowY = shadowY,
shadowZ = shadowZ,
customShadow = customShadow,
rounding = rounding,
drawOutline = drawOutline,
outlineColor = outlineColor,
outlineZ = outlineZ,
)
flush()
return width
}
fun renderSprite(
sprite: TextureAtlasSprite, x: Float, y: Float,
width: Float = sprite.contents().width().toFloat(),
height: Float = sprite.contents().height().toFloat(),
color: RGBAColor = RGBAColor.WHITE
) {
renderTexturedRect(
x, y, width, height,
uv = UVCoords(sprite.u0, sprite.v0, sprite.u1, sprite.v1),
texture = sprite.atlasLocation(),
color = color
)
}
companion object {
private val defaultUV = UVCoords(0f, 0f, 1f, 1f)
}
}

View File

@ -141,7 +141,8 @@ object MatteryGUI {
return return
} }
val stack = event.guiGraphics.pose() val guiGraphics = MGUIGraphics(event.guiGraphics)
val stack = guiGraphics.pose
val window = event.window val window = event.window
stack.pushPose() stack.pushPose()
@ -164,7 +165,7 @@ object MatteryGUI {
pushScissorRect(0, (scissorBase + scissorHeight * (1f - progress)).toInt(), window.width, (scissorHeight * progress * 2f).toInt()) pushScissorRect(0, (scissorBase + scissorHeight * (1f - progress)).toInt(), window.width, (scissorHeight * progress * 2f).toInt())
event.guiGraphics.renderRect( guiGraphics.renderRect(
0f, 0f,
y - 12f, y - 12f,
window.guiScaledWidth.toFloat(), window.guiScaledWidth.toFloat(),
@ -173,8 +174,8 @@ object MatteryGUI {
val text = TranslatableComponent("otm.iteration", iteration) val text = TranslatableComponent("otm.iteration", iteration)
event.guiGraphics.draw(minecraft.font, text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) guiGraphics.draw(minecraft.font, text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER)
event.guiGraphics.draw(minecraft.font, text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) guiGraphics.draw(minecraft.font, text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER)
stack.scale(0.35f, 0.35f, 0.35f) stack.scale(0.35f, 0.35f, 0.35f)
@ -190,8 +191,8 @@ object MatteryGUI {
for (i in deathLog.indices.reversed()) { for (i in deathLog.indices.reversed()) {
val component = deathLog[i] val component = deathLog[i]
event.guiGraphics.draw(minecraft.font, component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) guiGraphics.draw(minecraft.font, component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER)
event.guiGraphics.draw(minecraft.font, component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER) guiGraphics.draw(minecraft.font, component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER)
y += minecraft.font.lineHeight y += minecraft.font.lineHeight
color = (color - 0x20).coerceAtLeast(0x0) color = (color - 0x20).coerceAtLeast(0x0)
@ -252,18 +253,20 @@ object MatteryGUI {
val leftPadding = ceil(level * 80f - 0.5f) val leftPadding = ceil(level * 80f - 0.5f)
val guiGraphics = MGUIGraphics(event.guiGraphics)
if (ply.hasEffect(MobEffects.HUNGER)) { if (ply.hasEffect(MobEffects.HUNGER)) {
CHARGE_HUNGER_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) CHARGE_HUNGER_BG.render(guiGraphics, left.toFloat(), top.toFloat())
CHARGE_HUNGER.renderPartial(event.guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) CHARGE_HUNGER.renderPartial(guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding)
} else { } else {
CHARGE_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) CHARGE_BG.render(guiGraphics, left.toFloat(), top.toFloat())
CHARGE.renderPartial(event.guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) CHARGE.renderPartial(guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding)
} }
val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() val formattedPower = mattery.androidEnergy.batteryLevel.formatPower()
val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat()
event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true)
} }
} }
@ -320,18 +323,20 @@ object MatteryGUI {
val top: Int = height - gui.leftHeight val top: Int = height - gui.leftHeight
gui.leftHeight += 10 gui.leftHeight += 10
HEALTH_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) val guiGraphics = MGUIGraphics(event.guiGraphics)
HEALTH_BG.render(guiGraphics, left.toFloat(), top.toFloat())
if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) { if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) {
val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature
val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f, 1.0f) val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f, 1.0f)
HEALTH_BG_NANOBOTS.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) HEALTH_BG_NANOBOTS.renderPartial(guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f))
} }
getSpriteForPlayer(ply).renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) getSpriteForPlayer(ply).renderPartial(guiGraphics, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f))
if (levelAbsorb > 0) { if (levelAbsorb > 0) {
HEALTH_ABSORB.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) HEALTH_ABSORB.renderPartial(guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f))
} }
var formattedHealth = TextComponent("%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt())) var formattedHealth = TextComponent("%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt()))
@ -340,7 +345,7 @@ object MatteryGUI {
formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()))
val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat()
event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true)
} }
} }

View File

@ -327,11 +327,12 @@ fun Font.draw(
) )
} }
fun GuiGraphics.draw( fun Font.draw(
font: Font, poseStack: PoseStack,
text: Component, text: FormattedCharSequence,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
buffer: MultiBufferSource = buffer(),
gravity: RenderGravity = RenderGravity.TOP_LEFT, gravity: RenderGravity = RenderGravity.TOP_LEFT,
scale: Float = 1f, scale: Float = 1f,
color: RGBAColor = RGBAColor.WHITE, color: RGBAColor = RGBAColor.WHITE,
@ -342,19 +343,19 @@ fun GuiGraphics.draw(
shadowColor: RGBAColor = RGBAColor.BLACK, shadowColor: RGBAColor = RGBAColor.BLACK,
shadowX: Float = 1f, shadowX: Float = 1f,
shadowY: Float = 1f, shadowY: Float = 1f,
shadowZ: Float = -0.1f, shadowZ: Float = 0.1f,
customShadow: Boolean = false, customShadow: Boolean = false,
rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO,
drawOutline: Boolean = false, drawOutline: Boolean = false,
outlineColor: RGBAColor = RGBAColor.BLACK, outlineColor: RGBAColor = RGBAColor.BLACK,
outlineZ: Float = -0.1f, outlineZ: Float = 0.1f,
): Float { ): Float {
val width = font.draw( return drawInternal(
poseStack = pose(), poseStack = poseStack,
text = text, text = text,
x = x, x = x,
y = y, y = y,
buffer = bufferSource(), buffer = buffer,
gravity = gravity, gravity = gravity,
scale = scale, scale = scale,
color = color, color = color,
@ -372,57 +373,4 @@ fun GuiGraphics.draw(
outlineColor = outlineColor, outlineColor = outlineColor,
outlineZ = outlineZ, outlineZ = outlineZ,
) )
flush()
return width
}
fun GuiGraphics.draw(
font: Font,
text: String,
x: Float = 0f,
y: Float = 0f,
gravity: RenderGravity = RenderGravity.TOP_LEFT,
scale: Float = 1f,
color: RGBAColor = RGBAColor.WHITE,
drawShadow: Boolean = false,
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
packedLightCoords: Int = 15728880,
effectColor: Int = 0,
shadowColor: RGBAColor = RGBAColor.BLACK,
shadowX: Float = 1f,
shadowY: Float = 1f,
shadowZ: Float = -0.1f,
customShadow: Boolean = false,
rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO,
drawOutline: Boolean = false,
outlineColor: RGBAColor = RGBAColor.BLACK,
outlineZ: Float = -0.1f,
): Float {
val width = font.draw(
poseStack = pose(),
text = text,
x = x,
y = y,
buffer = bufferSource(),
gravity = gravity,
scale = scale,
color = color,
drawShadow = drawShadow,
displayMode = displayMode,
packedLightCoords = packedLightCoords,
effectColor = effectColor,
shadowColor = shadowColor,
shadowX = shadowX,
shadowY = shadowY,
shadowZ = shadowZ,
customShadow = customShadow,
rounding = rounding,
drawOutline = drawOutline,
outlineColor = outlineColor,
outlineZ = outlineZ,
)
flush()
return width
} }

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.systemTime import ru.dbotthepony.mc.otm.systemTime
import kotlin.math.sin import kotlin.math.sin
@ -23,7 +24,7 @@ interface IGUIRenderable {
val winding: UVWindingOrder get() = UVWindingOrder.NORMAL val winding: UVWindingOrder get() = UVWindingOrder.NORMAL
fun render( fun render(
guiGraphics: GuiGraphics, guiGraphics: MGUIGraphics,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
gravity: RenderGravity = RenderGravity.TOP_LEFT, gravity: RenderGravity = RenderGravity.TOP_LEFT,
@ -37,7 +38,7 @@ interface IGUIRenderable {
* Render at specified position [x], [y] with size of [width] x [height], optionally with UV [winding], if we are rendering flat texture/sprite * Render at specified position [x], [y] with size of [width] x [height], optionally with UV [winding], if we are rendering flat texture/sprite
*/ */
fun render( fun render(
guiGraphics: GuiGraphics, guiGraphics: MGUIGraphics,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
width: Float = this.width, width: Float = this.width,
@ -53,7 +54,7 @@ interface IGUIRenderable {
override val height: Float override val height: Float
get() = this@IGUIRenderable.height.coerceAtLeast(other.height) get() = this@IGUIRenderable.height.coerceAtLeast(other.height)
override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) {
this@IGUIRenderable.render(guiGraphics, x, y, width, height, winding, color) this@IGUIRenderable.render(guiGraphics, x, y, width, height, winding, color)
other.render(guiGraphics, x, y, width, height, winding, color) other.render(guiGraphics, x, y, width, height, winding, color)
} }
@ -71,7 +72,7 @@ interface IGUIRenderable {
override val height: Float override val height: Float
get() = this@IGUIRenderable.height get() = this@IGUIRenderable.height
override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) {
this@IGUIRenderable.render(guiGraphics, x + left, y + top, width + right + left, height + bottom + top, winding, color) this@IGUIRenderable.render(guiGraphics, x + left, y + top, width + right + left, height + bottom + top, winding, color)
} }
} }
@ -94,7 +95,7 @@ interface IGUIRenderable {
override val height: Float override val height: Float
get() = this@IGUIRenderable.height get() = this@IGUIRenderable.height
override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) {
var realX = x var realX = x
var realY = y var realY = y
@ -123,8 +124,8 @@ interface IGUIRenderable {
} }
data class ItemStackIcon(private val itemStack: ItemStack, override val width: Float = 16f, override val height: Float = 16f) : IGUIRenderable { data class ItemStackIcon(private val itemStack: ItemStack, override val width: Float = 16f, override val height: Float = 16f) : IGUIRenderable {
override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) {
val pose = guiGraphics.pose() val pose = guiGraphics.pose
pose.pushPose() pose.pushPose()
pose.translate(x, y, 0f) pose.translate(x, y, 0f)
@ -140,7 +141,7 @@ data class ItemStackIcon(private val itemStack: ItemStack, override val width: F
} }
data class FlatRectangleIcon(override val width: Float = 1f, override val height: Float = 1f, val color: RGBAColor) : IGUIRenderable { data class FlatRectangleIcon(override val width: Float = 1f, override val height: Float = 1f, val color: RGBAColor) : IGUIRenderable {
override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) {
guiGraphics.renderRect(x, y, width, height, color = this.color) guiGraphics.renderRect(x, y, width, height, color = this.color)
} }
} }

View File

@ -17,6 +17,7 @@ import org.joml.Matrix4f
import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_ALWAYS
import org.lwjgl.opengl.GL11.GL_LESS import org.lwjgl.opengl.GL11.GL_LESS
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import java.util.* import java.util.*
@ -94,17 +95,6 @@ fun renderRect(
tess.end() tess.end()
} }
fun GuiGraphics.renderRect(
x: Float,
y: Float,
width: Float,
height: Float,
z: Float = 0f,
color: RGBAColor = RGBAColor.WHITE
) {
renderRect(pose().last().pose(), x, y, width, height, z, color)
}
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
fun renderCheckerboard( fun renderCheckerboard(
matrix: Matrix4f, matrix: Matrix4f,
@ -146,17 +136,6 @@ fun renderCheckerboard(
tess.end() tess.end()
} }
fun GuiGraphics.renderCheckerboard(
x: Float,
y: Float,
width: Float,
height: Float,
z: Float = 0f,
color: RGBAColor = RGBAColor.WHITE
) {
renderCheckerboard(pose().last().pose(), x, y, width, height, z, color)
}
fun renderTexturedRect( fun renderTexturedRect(
matrix: Matrix4f, matrix: Matrix4f,
x: Float, x: Float,
@ -209,20 +188,6 @@ fun renderTexturedRect(
BufferUploader.drawWithShader(builder.end()) BufferUploader.drawWithShader(builder.end())
} }
fun GuiGraphics.renderTexturedRect(
x: Float,
y: Float,
width: Float,
height: Float,
z: Float = 0f,
uv: IUVCoords = defaultUV,
uvWinding: UVWindingOrder = UVWindingOrder.NORMAL,
color: RGBAColor = RGBAColor.WHITE,
texture: ResourceLocation? = null
) {
renderTexturedRect(pose().last().pose(), x, y, width, height, z, uv, uvWinding, color, texture)
}
fun renderColoredSphere(pose: PoseStack, radius: Float, color: RGBAColor = RGBAColor.WHITE) { fun renderColoredSphere(pose: PoseStack, radius: Float, color: RGBAColor = RGBAColor.WHITE) {
val fragments = 32 val fragments = 32
RenderSystem.enableBlend() RenderSystem.enableBlend()
@ -330,18 +295,6 @@ fun drawLine(
tess.end() tess.end()
} }
fun GuiGraphics.drawLine(
startX: Float,
startY: Float,
endX: Float,
endY: Float,
width: Float,
z: Float = 0f,
color: RGBAColor = RGBAColor.WHITE
) {
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, val lock: Boolean = false) { 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 { fun withinBounds(x: Int, y: Int): Boolean {
return (x in this.x .. this.x + width) && (y in this.y .. this.y + height) return (x in this.x .. this.x + width) && (y in this.y .. this.y + height)
@ -447,13 +400,13 @@ fun TextureAtlasSprite.render(
} }
fun TextureAtlasSprite.render( fun TextureAtlasSprite.render(
graphics: GuiGraphics, graphics: MGUIGraphics,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
width: Float, width: Float,
height: Float, height: Float,
winding: UVWindingOrder = UVWindingOrder.NORMAL winding: UVWindingOrder = UVWindingOrder.NORMAL
) = render(graphics.pose(), x, y, width, height, winding) ) = render(graphics.pose, x, y, width, height, winding)
fun determineTooltipPosition(x: Float, y: Float, width: Float, height: Float): Pair<Float, Float> { fun determineTooltipPosition(x: Float, y: Float, width: Float, height: Float): Pair<Float, Float> {
val windowWidth = minecraft.window.guiScaledWidth.toFloat() val windowWidth = minecraft.window.guiScaledWidth.toFloat()
@ -513,7 +466,7 @@ fun clearDepth(stack: PoseStack, x: Float, y: Float, width: Float, height: Float
} }
@JvmOverloads @JvmOverloads
fun clearDepth(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, depth: Float = -500f) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics.pose(), x, y, width, height, depth) fun clearDepth(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, depth: Float = -500f) = clearDepth(graphics.pose, x, y, width, height, depth)
fun drawArc( fun drawArc(
stack: PoseStack, stack: PoseStack,

View File

@ -13,6 +13,7 @@ import net.minecraft.client.renderer.RenderType
import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.FriendlyByteBuf
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_ALWAYS
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
import ru.dbotthepony.mc.otm.client.render.IUVCoords import ru.dbotthepony.mc.otm.client.render.IUVCoords
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
@ -51,7 +52,7 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords {
* See [ru.dbotthepony.mc.otm.client.render.clearDepth] * See [ru.dbotthepony.mc.otm.client.render.clearDepth]
*/ */
fun clearDepth( fun clearDepth(
graphics: GuiGraphics, graphics: MGUIGraphics,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
width: Float = this.width, width: Float = this.width,
@ -70,7 +71,7 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords {
} }
override fun render( override fun render(
guiGraphics: GuiGraphics, guiGraphics: MGUIGraphics,
x: Float, x: Float,
y: Float, y: Float,
width: Float, width: Float,
@ -105,14 +106,14 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords {
} }
fun renderPartial( fun renderPartial(
graphics: GuiGraphics, graphics: MGUIGraphics,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
width: Float = this.width, width: Float = this.width,
height: Float = this.height, height: Float = this.height,
winding: UVWindingOrder = this.winding, winding: UVWindingOrder = this.winding,
color: RGBAColor = RGBAColor.WHITE color: RGBAColor = RGBAColor.WHITE
) = renderPartial(graphics.pose(), x, y, width, height, winding, color) ) = renderPartial(graphics.pose, x, y, width, height, winding, color)
protected fun uploadOnto( protected fun uploadOnto(
pose: PoseStack, pose: PoseStack,

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.render.sprites
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
data class StretchingRectangleElement( data class StretchingRectangleElement(
@ -46,12 +47,12 @@ data class StretchingRectangleElement(
@JvmOverloads @JvmOverloads
fun render( fun render(
graphics: GuiGraphics, graphics: MGUIGraphics,
x: Float = 0f, x: Float = 0f,
y: Float = 0f, y: Float = 0f,
width: Float, width: Float,
height: Float, height: Float,
) = render(graphics.pose(), x, y, width, height) ) = render(graphics.pose, x, y, width, height)
companion object { companion object {
fun square( fun square(

View File

@ -17,6 +17,7 @@ import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground
import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.MinecraftForge
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.moveMousePosScaled
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.Widgets18
@ -86,13 +87,13 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
val quickCraftingType: Int get() = super.quickCraftingType val quickCraftingType: Int get() = super.quickCraftingType
val isQuickCrafting: Boolean get() = super.isQuickCrafting val isQuickCrafting: Boolean get() = super.isQuickCrafting
fun renderItemStack(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { fun renderItemStack(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) {
if (!itemstack.isEmpty) { if (!itemstack.isEmpty) {
RenderSystem.enableDepthTest() RenderSystem.enableDepthTest()
val (x, y) = graphics.pose().translation() val (x, y) = graphics.pose.translation()
graphics.renderItem( graphics.parent.renderItem(
requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" },
itemstack, itemstack,
1, 1,
@ -101,7 +102,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
) )
RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.depthFunc(GL11.GL_ALWAYS)
graphics.renderItemDecorations( graphics.parent.renderItemDecorations(
super.font, super.font,
itemstack, itemstack,
1, 1,
@ -643,6 +644,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
} }
override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) { override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
val wrap = MGUIGraphics(graphics)
val mouseXf = mouseX.toFloat() val mouseXf = mouseX.toFloat()
val mouseYf = mouseY.toFloat() val mouseYf = mouseY.toFloat()
@ -667,7 +669,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
for (panel in panels.asReversed()) { for (panel in panels.asReversed()) {
RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.depthFunc(GL11.GL_ALWAYS)
RenderSystem.setShaderColor(1f, 1f, 1f, 1f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
panel.render(graphics, mouseXf, mouseYf, partialTick) panel.render(wrap, mouseXf, mouseYf, partialTick)
} }
RenderSystem.depthFunc(GL11.GL_LESS) RenderSystem.depthFunc(GL11.GL_LESS)
@ -711,7 +713,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
for (panel in panels) { for (panel in panels) {
RenderSystem.disableDepthTest() RenderSystem.disableDepthTest()
if (panel.renderTooltips(graphics, mouseXf, mouseYf, partialTick)) { if (panel.renderTooltips(wrap, mouseXf, mouseYf, partialTick)) {
break break
} }
} }

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.client.screen.decorative package ru.dbotthepony.mc.otm.client.screen.decorative
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.util.RandomSource import net.minecraft.util.RandomSource
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
@ -11,10 +10,9 @@ import net.minecraft.world.item.Items
import net.minecraftforge.common.Tags import net.minecraftforge.common.Tags
import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistries
import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
import ru.dbotthepony.mc.otm.client.render.renderCheckerboard
import ru.dbotthepony.mc.otm.client.render.renderRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode
@ -49,7 +47,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
tooltips.add(TextComponent("")) tooltips.add(TextComponent(""))
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY) graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY)
val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor) val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor)
@ -156,7 +154,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
get() = !recipe.value.canCraft(menu.dyeStoredDirect) get() = !recipe.value.canCraft(menu.dyeStoredDirect)
set(value) {} set(value) {}
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
val list = getTooltipFromItem(minecraft!!, recipeOutput) val list = getTooltipFromItem(minecraft!!, recipeOutput)
recipe.value.dyes.forEach { recipe.value.dyes.forEach {

View File

@ -1,12 +1,12 @@
package ru.dbotthepony.mc.otm.client.screen.matter package ru.dbotthepony.mc.otm.client.screen.matter
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState
import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.render.*
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
@ -205,7 +205,7 @@ class MatterPanelScreen(
return list return list
} }
override fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String?) { override fun renderRegular(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String?) {
if (isPatternView) { if (isPatternView) {
super.renderRegular(graphics, itemstack, "") super.renderRegular(graphics, itemstack, "")

View File

@ -8,12 +8,12 @@ import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.renderRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel
@ -47,7 +47,7 @@ open class ColorBoxPanel<out S : Screen>(
var isPressed = false var isPressed = false
private set private set
override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun shouldRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed
} }
@ -103,7 +103,7 @@ open class ColorBoxPanel<out S : Screen>(
return super.mouseReleasedInner(x, y, button) return super.mouseReleasedInner(x, y, button)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
graphics.renderRect(0f, 0f, width, height, color = RGBAColor.WHITE) graphics.renderRect(0f, 0f, width, height, color = RGBAColor.WHITE)
GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = backgroundColor) GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = backgroundColor)
GRADIENT_DOWN.render(graphics, 0f, 0f, width, height, color = RGBAColor.BLACK) GRADIENT_DOWN.render(graphics, 0f, 0f, width, height, color = RGBAColor.BLACK)
@ -192,18 +192,18 @@ abstract class AbstractColorWangPanel<out S : Screen>(
return super.mouseReleasedInner(x, y, button) return super.mouseReleasedInner(x, y, button)
} }
protected fun renderGradients(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { protected fun renderGradients(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
ColorBoxPanel.GRADIENT_RIGHT.render(graphics, 0f, 0f, width, height, color = rightColor) ColorBoxPanel.GRADIENT_RIGHT.render(graphics, 0f, 0f, width, height, color = rightColor)
ColorBoxPanel.GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = leftColor) ColorBoxPanel.GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = leftColor)
} }
protected fun renderWang(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { protected fun renderWang(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (wangPosition in 0f .. 1f) { if (wangPosition in 0f .. 1f) {
ColorBoxPanel.LINE_VERTICAL.render(graphics, x = wangPosition * width - 1f, height = height) ColorBoxPanel.LINE_VERTICAL.render(graphics, x = wangPosition * width - 1f, height = height)
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
renderGradients(graphics, mouseX, mouseY, partialTick) renderGradients(graphics, mouseX, mouseY, partialTick)
renderWang(graphics, mouseX, mouseY, partialTick) renderWang(graphics, mouseX, mouseY, partialTick)
} }
@ -334,7 +334,7 @@ open class HueWangPanel<out S : Screen>(
hueCallback?.accept(newPosition * 360f) hueCallback?.accept(newPosition * 360f)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
HSV_BAR.render(graphics, 0f, 0f, width, height) HSV_BAR.render(graphics, 0f, 0f, width, height)
renderWang(graphics, mouseX, mouseY, partialTick) renderWang(graphics, mouseX, mouseY, partialTick)
} }
@ -457,7 +457,7 @@ open class ColorPalettePanel<out S : Screen>(
onColorChoose(color) onColorChoose(color)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK) graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK)
graphics.renderRect(1f, 1f, width - 2f, height - 2f, color = color) graphics.renderRect(1f, 1f, width - 2f, height - 2f, color = color)
} }

View File

@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.IntAVLTreeSet
import it.unimi.dsi.fastutil.objects.ReferenceArraySet import it.unimi.dsi.fastutil.objects.ReferenceArraySet
import net.minecraft.client.gui.ComponentPath import net.minecraft.client.gui.ComponentPath
import net.minecraft.client.gui.Font import net.minecraft.client.gui.Font
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.components.events.GuiEventListener
import net.minecraft.client.gui.navigation.FocusNavigationEvent import net.minecraft.client.gui.navigation.FocusNavigationEvent
import net.minecraft.client.gui.navigation.ScreenRectangle import net.minecraft.client.gui.navigation.ScreenRectangle
@ -18,6 +17,7 @@ import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import ru.dbotthepony.mc.otm.SystemTime import ru.dbotthepony.mc.otm.SystemTime
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.moveMousePosScaled
import ru.dbotthepony.mc.otm.client.render.currentScissorRect import ru.dbotthepony.mc.otm.client.render.currentScissorRect
@ -25,7 +25,6 @@ import ru.dbotthepony.mc.otm.client.render.popScissorRect
import ru.dbotthepony.mc.otm.client.render.pushScissorRect import ru.dbotthepony.mc.otm.client.render.pushScissorRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel
import ru.dbotthepony.mc.otm.core.collect.any
import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.concatIterators
import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.collect.flatMap
import java.util.* import java.util.*
@ -786,14 +785,14 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
} }
} }
protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
protected open fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun preRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
protected open fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRenderPost(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { protected open fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
return false return false
} }
protected open fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { protected open fun shouldRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
return isEverHovered || isGrabbingMouseInput() return isEverHovered || isGrabbingMouseInput()
} }
@ -840,14 +839,14 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
} }
} }
fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { fun render(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
once = true once = true
if (!isVisible()) { if (!isVisible()) {
return return
} }
val poseStack = graphics.pose() val poseStack = graphics.pose
performLayoutIfNeeded() performLayoutIfNeeded()
@ -1041,7 +1040,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
return null to ItemStack.EMPTY return null to ItemStack.EMPTY
} }
fun renderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { fun renderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (!isVisible()) { if (!isVisible()) {
return false return false
} }
@ -1829,7 +1828,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
/** /**
* See [ru.dbotthepony.mc.otm.client.render.clearDepth] * See [ru.dbotthepony.mc.otm.client.render.clearDepth]
*/ */
fun clearDepth(graphics: GuiGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height) fun clearDepth(graphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height)
fun queryUser(title: Component, text: Component, onConfirm: Runnable, onCancel: Runnable? = null): QueryUserPanel<S> { fun queryUser(title: Component, text: Component, onConfirm: Runnable, onCancel: Runnable? = null): QueryUserPanel<S> {
return QueryUserPanel(screen, title, listOf(text), onConfirm, onCancel).also { blockingWindow = it } return QueryUserPanel(screen, title, listOf(text), onConfirm, onCancel).also { blockingWindow = it }

View File

@ -3,13 +3,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.LivingEntity
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition
@ -109,7 +108,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
clearDepth(graphics) clearDepth(graphics)
SQUARE_THIN.render(graphics, width = width, height = height) SQUARE_THIN.render(graphics, width = width, height = height)
@ -120,7 +119,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
graphics.draw(font, formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) graphics.draw(font, formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE)
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
val (x, y) = determineTooltipPosition(mouseX + 4f, mouseY - 12f, BAR.width, BAR.height) val (x, y) = determineTooltipPosition(mouseX + 4f, mouseY - 12f, BAR.width, BAR.height)
@ -131,7 +130,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
val renderHeight = 18f val renderHeight = 18f
minecraft.mobEffectTextures.get(effect.effect).render( minecraft.mobEffectTextures.get(effect.effect).render(
graphics.pose(), graphics.pose,
x = x + 8f, x = x + 8f,
y = y + BAR.height / 2f - renderHeight / 2f, y = y + BAR.height / 2f - renderHeight / 2f,
width = renderWidth, width = renderWidth,

View File

@ -1,6 +1,5 @@
package ru.dbotthepony.mc.otm.client.screen.panels package ru.dbotthepony.mc.otm.client.screen.panels
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
import net.minecraft.client.gui.screens.inventory.InventoryScreen import net.minecraft.client.gui.screens.inventory.InventoryScreen
@ -8,6 +7,7 @@ import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.Widgets8
import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.render.sprites.sprite
import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen
@ -165,13 +165,13 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (entity.isDeadOrDying) { if (entity.isDeadOrDying) {
return return
} }
InventoryScreen.renderEntityInInventoryFollowsMouse( InventoryScreen.renderEntityInInventoryFollowsMouse(
graphics, graphics.parent,
0, 0, 0, 0,
this.width.toInt(), this.height.toInt(), this.width.toInt(), this.height.toInt(),
renderScale, renderScale,
@ -197,7 +197,7 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
ExopackInventoryScreen.ENTITY_RECTANGLE.render(graphics) ExopackInventoryScreen.ENTITY_RECTANGLE.render(graphics)
} }

View File

@ -2,13 +2,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.narration.NarratableEntry import net.minecraft.client.gui.narration.NarratableEntry
import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
import net.minecraft.client.gui.narration.NarrationElementOutput import net.minecraft.client.gui.narration.NarrationElementOutput
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import org.lwjgl.opengl.GL30 import org.lwjgl.opengl.GL30
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.render.*
import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement
import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel
@ -76,7 +76,7 @@ open class FramePanel<out S : Screen>(
return tabs.indexOf(this) return tabs.indexOf(this)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isActive) { if (isActive) {
if (tabIndex() == 0) { if (tabIndex() == 0) {
if (isDisabled) { if (isDisabled) {
@ -167,7 +167,7 @@ open class FramePanel<out S : Screen>(
close() close()
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isPressed) { if (isPressed) {
CLOSE_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height) CLOSE_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)
} else if (isHovered) { } else if (isHovered) {
@ -193,7 +193,7 @@ open class FramePanel<out S : Screen>(
isActive = !isActive isActive = !isActive
}*/ }*/
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
/*if (isPressed) { /*if (isPressed) {
HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height) HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)
} else*/ if (isHovered /*|| isActive */) { } else*/ if (isHovered /*|| isActive */) {
@ -364,7 +364,7 @@ open class FramePanel<out S : Screen>(
return super.keyPressedInternal(key, scancode, mods) return super.keyPressedInternal(key, scancode, mods)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
RECTANGLE.render(graphics, width = width, height = height) RECTANGLE.render(graphics, width = width, height = height)
// title // title

View File

@ -1,8 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.panels package ru.dbotthepony.mc.otm.client.screen.panels
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.draw
import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TextComponent
@ -31,7 +31,7 @@ open class Label<out S : Screen> @JvmOverloads constructor(
var color = RGBAColor.SLATE_GRAY var color = RGBAColor.SLATE_GRAY
var gravity = RenderGravity.TOP_LEFT var gravity = RenderGravity.TOP_LEFT
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
clearDepth(graphics) clearDepth(graphics)
if (shadow) { if (shadow) {

View File

@ -1,17 +1,15 @@
package ru.dbotthepony.mc.otm.client.screen.panels package ru.dbotthepony.mc.otm.client.screen.panels
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.draw
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants
import ru.dbotthepony.mc.otm.client.screen.storage.ItemMonitorScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.math.integerDivisionDown
import ru.dbotthepony.mc.otm.core.util.formatReadableNumber import ru.dbotthepony.mc.otm.core.util.formatReadableNumber
@ -79,7 +77,7 @@ open class NetworkedItemGridPanel<out S : MatteryScreen<*>>(
return true return true
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
renderSlotBackground(graphics, mouseX, mouseY, partialTick) renderSlotBackground(graphics, mouseX, mouseY, partialTick)
val itemStack = view.sortedView.getOrNull(index)?.stack ?: StorageStack.ITEMS.empty val itemStack = view.sortedView.getOrNull(index)?.stack ?: StorageStack.ITEMS.empty
renderRegular(graphics, itemStack.toItemStack(), "") renderRegular(graphics, itemStack.toItemStack(), "")

View File

@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.components.Renderable import net.minecraft.client.gui.components.Renderable
import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.components.events.GuiEventListener
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
// before 1.19.3 Renderable was Widget // before 1.19.3 Renderable was Widget
class Panel2Widget<out S: Screen, out P : EditablePanel<S>>( class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
@ -19,9 +20,11 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
val xFloat = mouseX.toFloat() val xFloat = mouseX.toFloat()
val yFloat = mouseY.toFloat() val yFloat = mouseY.toFloat()
val wrap = MGUIGraphics(graphics)
panel.tickHover(xFloat, yFloat) panel.tickHover(xFloat, yFloat)
panel.render(graphics, xFloat, yFloat, partialTick) panel.render(wrap, xFloat, yFloat, partialTick)
panel.renderTooltips(graphics, xFloat, yFloat, partialTick) panel.renderTooltips(wrap, xFloat, yFloat, partialTick)
} }
override fun mouseMoved(mouseX: Double, mouseY: Double) { override fun mouseMoved(mouseX: Double, mouseY: Double) {

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.screen.panels package ru.dbotthepony.mc.otm.client.screen.panels
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
@ -16,7 +16,7 @@ class SpritePanel<out S : Screen>(
var winding: UVWindingOrder = sprite.winding, var winding: UVWindingOrder = sprite.winding,
var centerSprite: Boolean = false var centerSprite: Boolean = false
) : EditablePanel<S>(screen, parent, x, y, width, height) { ) : EditablePanel<S>(screen, parent, x, y, width, height) {
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (centerSprite) { if (centerSprite) {
sprite.render(graphics, width / 2f - sprite.width / 2f, height / 2f - sprite.height / 2f, sprite.width, sprite.height, winding) sprite.render(graphics, width / 2f - sprite.width / 2f, height / 2f - sprite.height / 2f, sprite.width, sprite.height, winding)
} else { } else {

View File

@ -1,11 +1,10 @@
package ru.dbotthepony.mc.otm.client.screen.panels package ru.dbotthepony.mc.otm.client.screen.panels
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.components.AbstractWidget import net.minecraft.client.gui.components.AbstractWidget
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.client.MGUIGraphics
abstract class Widget2Panel<out S : Screen, T : AbstractWidget>( abstract class Widget2Panel<out S : Screen, T : AbstractWidget>(
screen: S, screen: S,
@ -90,9 +89,9 @@ abstract class Widget2Panel<out S : Screen, T : AbstractWidget>(
return instance return instance
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.depthFunc(GL11.GL_ALWAYS)
getOrCreateWidget().render(graphics, mouseX.toInt(), mouseY.toInt(), partialTick) getOrCreateWidget().render(graphics.parent, mouseX.toInt(), mouseY.toInt(), partialTick)
RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.depthFunc(GL11.GL_ALWAYS)
} }

View File

@ -1,8 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.panels.button package ru.dbotthepony.mc.otm.client.screen.panels.button
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import java.util.function.IntPredicate import java.util.function.IntPredicate
@ -65,7 +65,7 @@ abstract class AbstractButtonPanel<out S : Screen>(
return true return true
} }
override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun shouldRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed
} }
} }

View File

@ -1,9 +1,9 @@
package ru.dbotthepony.mc.otm.client.screen.panels.button package ru.dbotthepony.mc.otm.client.screen.panels.button
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
@ -33,7 +33,7 @@ abstract class BooleanRectangleButtonPanel<out S : Screen>(
onChange?.invoke(newValue) onChange?.invoke(newValue)
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
val tooltipActive = tooltipActive val tooltipActive = tooltipActive
val tooltipInactive = tooltipInactive val tooltipInactive = tooltipInactive
@ -79,7 +79,7 @@ abstract class BooleanRectangleButtonPanel<out S : Screen>(
} }
set(value) { super.isDisabled = value } set(value) { super.isDisabled = value }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
super.innerRender(graphics, mouseX, mouseY, partialTick) super.innerRender(graphics, mouseX, mouseY, partialTick)
if (prop.value) { if (prop.value) {

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.draw
@ -39,7 +40,7 @@ open class ButtonPanel<out S : Screen>(
onPress?.accept(mouseButton) onPress?.accept(mouseButton)
} }
protected fun renderStretchableBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { protected fun renderStretchableBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isDisabled) { if (isDisabled) {
Widgets18.BUTTON_DISABLED_STRETCHABLE.render(graphics, width = width, height = height) Widgets18.BUTTON_DISABLED_STRETCHABLE.render(graphics, width = width, height = height)
} else if (isPressed) { } else if (isPressed) {
@ -51,7 +52,7 @@ open class ButtonPanel<out S : Screen>(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
renderStretchableBackground(graphics, mouseX, mouseY, partialTick) renderStretchableBackground(graphics, mouseX, mouseY, partialTick)
graphics.draw(font, label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER) graphics.draw(font, label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER)
} }

View File

@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
@ -10,6 +9,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isCtrlDown
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
@ -100,7 +100,7 @@ private class PullPushButton<out S : MatteryScreen<*>, T : Enum<T>>(
sprites[State(pull, push, value)] = sprite sprites[State(pull, push, value)] = sprite
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
super.innerRender(graphics, mouseX, mouseY, partialTick) super.innerRender(graphics, mouseX, mouseY, partialTick)
sprites[State(pullProp.value, pushProp.value, prop.get())]?.render(graphics, 0f, 0f, width, height) sprites[State(pullProp.value, pushProp.value, prop.get())]?.render(graphics, 0f, 0f, width, height)
} }
@ -486,7 +486,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
tooltips.add(TranslatableComponent("otm.gui.upgrades")) tooltips.add(TranslatableComponent("otm.gui.upgrades"))
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
graphics.renderComponentTooltip(font, ArrayList<Component>().also { graphics.renderComponentTooltip(font, ArrayList<Component>().also {
it.add(TranslatableComponent("otm.gui.upgrades")) it.add(TranslatableComponent("otm.gui.upgrades"))
it.add(TextComponent("")) it.add(TextComponent(""))
@ -624,7 +624,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
} }
} }
override fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun preRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (parent is FramePanel<*>) { if (parent is FramePanel<*>) {
x = parent!!.width + 3f x = parent!!.width + 3f
y = dockTop y = dockTop

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
@ -25,7 +26,7 @@ open class CheckBoxPanel<out S : Screen>(
open val DISABLED_UNCHECKED: AbstractMatterySprite = Companion.DISABLED_UNCHECKED open val DISABLED_UNCHECKED: AbstractMatterySprite = Companion.DISABLED_UNCHECKED
open val DISABLED_CHECKED: AbstractMatterySprite = Companion.DISABLED_CHECKED open val DISABLED_CHECKED: AbstractMatterySprite = Companion.DISABLED_CHECKED
protected fun renderCheckboxBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { protected fun renderCheckboxBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isDisabled) { if (isDisabled) {
if (isChecked.get()) { if (isChecked.get()) {
DISABLED_CHECKED.render(graphics, width = width, height = height) DISABLED_CHECKED.render(graphics, width = width, height = height)
@ -55,7 +56,7 @@ open class CheckBoxPanel<out S : Screen>(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
renderCheckboxBackground(graphics, mouseX, mouseY, partialTick) renderCheckboxBackground(graphics, mouseX, mouseY, partialTick)
} }

View File

@ -2,9 +2,9 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
@ -70,7 +70,7 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
return this return this
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
check(!isBuilding) { "Still building this button!" } check(!isBuilding) { "Still building this button!" }
super.innerRender(graphics, mouseX, mouseY, partialTick) super.innerRender(graphics, mouseX, mouseY, partialTick)
val entry = enumMapping[prop.get()] ?: return val entry = enumMapping[prop.get()] ?: return
@ -144,7 +144,7 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
} }
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (tooltips.isEmpty() && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) { if (tooltips.isEmpty() && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) {
return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick)
} }

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.screen.panels.button package ru.dbotthepony.mc.otm.client.screen.panels.button
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
@ -26,7 +26,7 @@ open class LargeRectangleButtonPanel<out S : Screen>(
final override val PRESSED = Widgets18.BUTTON_PRESSED final override val PRESSED = Widgets18.BUTTON_PRESSED
final override val DISABLED = Widgets18.BUTTON_DISABLED final override val DISABLED = Widgets18.BUTTON_DISABLED
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
super.innerRender(graphics, mouseX, mouseY, partialTick) super.innerRender(graphics, mouseX, mouseY, partialTick)
val color = if (isDisabled || isPressed) RGBAColor.DARK_GRAY else RGBAColor.WHITE val color = if (isDisabled || isPressed) RGBAColor.DARK_GRAY else RGBAColor.WHITE

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import java.util.function.IntConsumer import java.util.function.IntConsumer
@ -25,7 +26,7 @@ abstract class RectangleButtonPanel<out S : Screen>(
onPress?.accept(mouseButton) onPress?.accept(mouseButton)
} }
protected fun renderSquareButton(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { protected fun renderSquareButton(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isDisabled) { if (isDisabled) {
DISABLED.render(graphics, 0f, 0f, width, height) DISABLED.render(graphics, 0f, 0f, width, height)
} else if (isPressed) { } else if (isPressed) {
@ -37,7 +38,7 @@ abstract class RectangleButtonPanel<out S : Screen>(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
renderSquareButton(graphics, mouseX, mouseY, partialTick) renderSquareButton(graphics, mouseX, mouseY, partialTick)
} }
} }

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.screen.panels.button package ru.dbotthepony.mc.otm.client.screen.panels.button
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.Widgets8
@ -23,7 +23,7 @@ open class SmallRectangleButtonPanel<out S : Screen>(
final override val PRESSED = Widgets8.BUTTON_PRESSED final override val PRESSED = Widgets8.BUTTON_PRESSED
final override val DISABLED = Widgets8.BUTTON_DISABLED final override val DISABLED = Widgets8.BUTTON_DISABLED
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
super.innerRender(graphics, mouseX, mouseY, partialTick) super.innerRender(graphics, mouseX, mouseY, partialTick)
if (skinElementWinding != null) { if (skinElementWinding != null) {

View File

@ -9,11 +9,11 @@ import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap
import it.unimi.dsi.fastutil.chars.CharOpenHashSet import it.unimi.dsi.fastutil.chars.CharOpenHashSet
import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap
import it.unimi.dsi.fastutil.ints.Int2ObjectMap import it.unimi.dsi.fastutil.ints.Int2ObjectMap
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import org.joml.Vector2i import org.joml.Vector2i
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isCtrlDown
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
@ -21,7 +21,6 @@ import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.draw
import ru.dbotthepony.mc.otm.client.render.renderRect
import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.render.tesselator
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
@ -1117,7 +1116,7 @@ open class TextInputPanel<out S : Screen>(
return accumulate return accumulate
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (!backgroundColor.isFullyTransparent) if (!backgroundColor.isFullyTransparent)
graphics.renderRect(0f, 0f, width, height, color = backgroundColor) graphics.renderRect(0f, 0f, width, height, color = backgroundColor)
@ -1153,7 +1152,7 @@ open class TextInputPanel<out S : Screen>(
scrollPixels = 0f scrollPixels = 0f
} }
val stack = graphics.pose() val stack = graphics.pose
stack.pushPose() stack.pushPose()
stack.translate(-scrollPixels, 0f, 0f) stack.translate(-scrollPixels, 0f, 0f)

View File

@ -1,12 +1,12 @@
package ru.dbotthepony.mc.otm.client.screen.panels.slot package ru.dbotthepony.mc.otm.client.screen.panels.slot
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen.getTooltipFromItem import net.minecraft.client.gui.screens.Screen.getTooltipFromItem
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraftforge.client.extensions.common.IClientItemExtensions import net.minecraftforge.client.extensions.common.IClientItemExtensions
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.render.*
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
@ -24,12 +24,12 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
open var slotBackground: IGUIRenderable? = null open var slotBackground: IGUIRenderable? = null
open var slotBackgroundEmpty: IGUIRenderable? = null open var slotBackgroundEmpty: IGUIRenderable? = null
protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { protected open fun renderSlotBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
SLOT_BACKGROUND.render(graphics, width = width, height = height) SLOT_BACKGROUND.render(graphics, width = width, height = height)
slotBackground?.render(graphics, 0f, 0f, width, height) slotBackground?.render(graphics, 0f, 0f, width, height)
} }
protected open fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { protected open fun renderRegular(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) {
RenderSystem.setShader(GameRenderer::getPositionTexShader) RenderSystem.setShader(GameRenderer::getPositionTexShader)
if (!itemstack.isEmpty) { if (!itemstack.isEmpty) {
@ -46,7 +46,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
renderSlotBackground(graphics, mouseX, mouseY, partialTick) renderSlotBackground(graphics, mouseX, mouseY, partialTick)
val itemStack = itemStack val itemStack = itemStack
renderRegular(graphics, itemStack) renderRegular(graphics, itemStack)
@ -56,7 +56,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
} }
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
val itemstack = itemStack val itemstack = itemStack

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.isAltDown import ru.dbotthepony.mc.otm.client.isAltDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.playGuiClickSound
@ -22,7 +23,7 @@ open class InventorySlotPanel<out S : MatteryScreen<*>, out T : MatteryMenu.Inve
get() = slot.filter?.get() get() = slot.filter?.get()
set(value) { slot.filter?.accept(value) } set(value) { slot.filter?.accept(value) }
override fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun renderBackgroundBeforeFilter(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (slot.chargeFlag?.get() == true) { if (slot.chargeFlag?.get() == true) {
Widgets18.CHARGE_SLOT_BACKGROUND.render(graphics, 0f, 0f, width, height) Widgets18.CHARGE_SLOT_BACKGROUND.render(graphics, 0f, 0f, width, height)
} }

View File

@ -4,14 +4,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.AbstractContainerMenu
import net.minecraft.world.inventory.Slot import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.render.renderRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.client.screen.panels.ISlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.ISlotPanel
@ -52,7 +51,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
slot.x = absoluteX.roundToInt() - screen.guiLeft slot.x = absoluteX.roundToInt() - screen.guiLeft
slot.y = absoluteY.roundToInt() - screen.guiTop slot.y = absoluteY.roundToInt() - screen.guiTop
renderSlotBackground(graphics, mouseX, mouseY, partialTick) renderSlotBackground(graphics, mouseX, mouseY, partialTick)
@ -99,7 +98,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
if (icon != null) { if (icon != null) {
val texture = minecraft.getTextureAtlas(icon.first).apply(icon.second) val texture = minecraft.getTextureAtlas(icon.first).apply(icon.second)
RenderSystem.setShaderTexture(0, texture.atlasLocation()) RenderSystem.setShaderTexture(0, texture.atlasLocation())
graphics.blit(1, 1, 0, 16, 16, texture) graphics.renderSprite(texture, 1f, 1f, 16f, 16f)
} else { } else {
slotBackgroundEmpty?.render(graphics, 0f, 0f, width = width, height = height) slotBackgroundEmpty?.render(graphics, 0f, 0f, width = width, height = height)
} }
@ -112,7 +111,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
} }
} }
override fun innerRenderTooltips(@Nonnull graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(@Nonnull graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
// no op, screen does it for us (completely) // no op, screen does it for us (completely)
return false return false
} }

View File

@ -9,10 +9,10 @@ import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
import net.minecraftforge.client.extensions.common.IClientItemExtensions import net.minecraftforge.client.extensions.common.IClientItemExtensions
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isCtrlDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.renderRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.GetterSetter
@ -32,9 +32,9 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
) : SlotPanel<S, T>(screen, parent, slot, x, y, width, height) { ) : SlotPanel<S, T>(screen, parent, slot, x, y, width, height) {
abstract var slotFilter: Item? abstract var slotFilter: Item?
protected open fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun renderBackgroundBeforeFilter(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
override fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun renderSlotBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
super.renderSlotBackground(graphics, mouseX, mouseY, partialTick) super.renderSlotBackground(graphics, mouseX, mouseY, partialTick)
renderBackgroundBeforeFilter(graphics, mouseX, mouseY, partialTick) renderBackgroundBeforeFilter(graphics, mouseX, mouseY, partialTick)
@ -53,7 +53,7 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
} }
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered && slotFilter != null && slotFilter !== Items.AIR && itemStack.isEmpty) { if (isHovered && slotFilter != null && slotFilter !== Items.AIR && itemStack.isEmpty) {
val itemstack = ItemStack(slotFilter!!, 1) val itemstack = ItemStack(slotFilter!!, 1)

View File

@ -1,9 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.panels.util package ru.dbotthepony.mc.otm.client.screen.panels.util
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.core.math.linearInterpolation
@ -27,7 +26,7 @@ open class AnalogScrollBarPanel<out S : Screen>(
var isScrolling = false var isScrolling = false
private set private set
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (this@AnalogScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) { if (this@AnalogScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) {
if (isScrolling) { if (isScrolling) {
ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height) ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height)
@ -99,7 +98,7 @@ open class AnalogScrollBarPanel<out S : Screen>(
private var lastRender = milliTimeD private var lastRender = milliTimeD
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (width == ScrollBarConstants.SLIM_WIDTH) { if (width == ScrollBarConstants.SLIM_WIDTH) {
ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f) ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f)
ScrollBarConstants.SLIM_TOP.render(graphics) ScrollBarConstants.SLIM_TOP.render(graphics)

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.screen.panels.util package ru.dbotthepony.mc.otm.client.screen.panels.util
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
@ -19,7 +19,7 @@ open class BackgroundPanel<out S : Screen>(
dockPadding = DockProperty(3f, 3f, 3f, 3f) dockPadding = DockProperty(3f, 3f, 3f, 3f)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
RECTANGLE.render(graphics, width = width, height = height) RECTANGLE.render(graphics, width = width, height = height)
} }

View File

@ -1,9 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.panels.util package ru.dbotthepony.mc.otm.client.screen.panels.util
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import kotlin.math.roundToInt import kotlin.math.roundToInt
@ -21,7 +20,7 @@ open class DiscreteScrollBarPanel<out S : Screen>(
var isScrolling = false var isScrolling = false
private set private set
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (this@DiscreteScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) { if (this@DiscreteScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) {
if (isScrolling) { if (isScrolling) {
ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height) ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height)
@ -91,7 +90,7 @@ open class DiscreteScrollBarPanel<out S : Screen>(
val scrollButton = Button() val scrollButton = Button()
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (width == ScrollBarConstants.SLIM_WIDTH) { if (width == ScrollBarConstants.SLIM_WIDTH) {
ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f) ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f)
ScrollBarConstants.SLIM_TOP.render(graphics) ScrollBarConstants.SLIM_TOP.render(graphics)

View File

@ -1,12 +1,11 @@
package ru.dbotthepony.mc.otm.client.screen.storage package ru.dbotthepony.mc.otm.client.screen.storage
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings
import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode
@ -14,8 +13,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.panels.NetworkedItemGridPanel import ru.dbotthepony.mc.otm.client.screen.panels.NetworkedItemGridPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallEnumRectangleButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
@ -24,7 +21,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.asGetterSetter
@ -73,7 +69,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
} }
val arrowAndButtons = object : EditablePanel<ItemMonitorScreen>(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.width) { val arrowAndButtons = object : EditablePanel<ItemMonitorScreen>(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.width) {
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.height / 2f) ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.height / 2f)
} }
} }

View File

@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectFunction
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
@ -14,15 +13,13 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearch
import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchManager
import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidResearchType
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.render.drawLine
import ru.dbotthepony.mc.otm.client.render.renderRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel
@ -287,7 +284,7 @@ private class AndroidResearchButton(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
val hovered = screen.hoveredResearch val hovered = screen.hoveredResearch
val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking
@ -314,7 +311,7 @@ private class AndroidResearchButton(
} else if (itemIcon != null) { } else if (itemIcon != null) {
val itemstack = ItemStack(itemIcon, 1) val itemstack = ItemStack(itemIcon, 1)
val stack = graphics.pose() val stack = graphics.pose
stack.pushPose() stack.pushPose()
stack.translate(1f, 1f, 0f) stack.translate(1f, 1f, 0f)
screen.renderItemStack(graphics, itemstack) screen.renderItemStack(graphics, itemstack)
@ -334,7 +331,7 @@ private class AndroidResearchButton(
val text = node.type.iconText val text = node.type.iconText
if (text != null) { if (text != null) {
graphics.drawString(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, -0x1, true) graphics.draw(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, color = RGBAColor.WHITE, drawShadow = true)
} }
for (line in lines) { for (line in lines) {
@ -408,7 +405,7 @@ private class AndroidResearchButton(
return true return true
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
val list = ArrayList<Component>().also { it.addAll(node.screenTooltipLines) } val list = ArrayList<Component>().also { it.addAll(node.screenTooltipLines) }
@ -501,7 +498,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] } private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] }
private var firstTick = false private var firstTick = false
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK) graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK)
} }
@ -648,7 +645,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
gravity = RenderGravity.TOP_RIGHT gravity = RenderGravity.TOP_RIGHT
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) { if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) {
text = POWER_OK text = POWER_OK
color = RGBAColor.LIGHT_GREEN color = RGBAColor.LIGHT_GREEN

View File

@ -1,8 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.tech package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
@ -61,7 +61,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp
width = ProgressGaugePanel.GAUGE_BACKGROUND.width width = ProgressGaugePanel.GAUGE_BACKGROUND.width
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics) ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics)
} }
} }

View File

@ -1,12 +1,12 @@
package ru.dbotthepony.mc.otm.client.screen.tech package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.item.enchantment.Enchantments
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas
@ -57,7 +57,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
dockMargin = DockProperty(bottom = 3f) dockMargin = DockProperty(bottom = 3f)
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
BAR_BACKGROUND.render(graphics, width = width, height = height) BAR_BACKGROUND.render(graphics, width = width, height = height)
val level = getLevelFromXp(menu.experienceStored) val level = getLevelFromXp(menu.experienceStored)
val progress = (menu.experienceStored - getTotalXpRequiredForLevel(level)).toDouble() / getXpRequiredForLevelUp(level).toDouble() val progress = (menu.experienceStored - getTotalXpRequiredForLevel(level)).toDouble() / getXpRequiredForLevelUp(level).toDouble()

View File

@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.widget
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.VertexFormat import com.mojang.blaze3d.vertex.VertexFormat
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
@ -12,6 +11,7 @@ import net.minecraft.world.inventory.InventoryMenu
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
@ -43,7 +43,7 @@ open class FluidGaugePanel<out S : Screen>(
) )
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt())
return true return true
@ -52,7 +52,7 @@ open class FluidGaugePanel<out S : Screen>(
return false return false
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) { if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) {
val data = IClientFluidTypeExtensions.of(widget.fluid.fluid) val data = IClientFluidTypeExtensions.of(widget.fluid.fluid)
val texture = data.stillTexture!! val texture = data.stillTexture!!
@ -61,7 +61,7 @@ open class FluidGaugePanel<out S : Screen>(
var height = (height * widget.percentage) / 16f var height = (height * widget.percentage) / 16f
var bottom = this.height var bottom = this.height
val matrix = graphics.pose().last().pose() val matrix = graphics.pose.last().pose()
val builder = tesselator.builder val builder = tesselator.builder
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX)

View File

@ -2,13 +2,14 @@ package ru.dbotthepony.mc.otm.client.screen.widget
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
private fun PowerGaugePanel<*>.doRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { private fun PowerGaugePanel<*>.doRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) {
if (height >= 18f) { if (height >= 18f) {
if (flop) { if (flop) {
HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1)
@ -43,7 +44,7 @@ open class HorizontalPowerGaugePanel<out S : Screen>(
) : PowerGaugePanel<S>(screen, parent, widget, x, y, width, height) { ) : PowerGaugePanel<S>(screen, parent, widget, x, y, width, height) {
var flop = false var flop = false
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
doRender(graphics, mouseX, mouseY, partialTick, flop) doRender(graphics, mouseX, mouseY, partialTick, flop)
} }
@ -81,7 +82,7 @@ open class HorizontalProfiledPowerGaugePanel<out S : Screen>(
) : ProfiledPowerGaugePanel<S>(screen, parent, widget, x, y, width, height) { ) : ProfiledPowerGaugePanel<S>(screen, parent, widget, x, y, width, height) {
var flop = false var flop = false
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
doRender(graphics, mouseX, mouseY, partialTick, flop) doRender(graphics, mouseX, mouseY, partialTick, flop)
} }
} }

View File

@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.widget
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.BufferUploader import com.mojang.blaze3d.vertex.BufferUploader
import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.blaze3d.vertex.VertexFormat import com.mojang.blaze3d.vertex.VertexFormat
import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntArrayList
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
@ -13,7 +12,7 @@ import net.minecraft.client.renderer.GameRenderer
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
@ -25,7 +24,6 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatMatter
import ru.dbotthepony.mc.otm.core.util.formatMatterLevel import ru.dbotthepony.mc.otm.core.util.formatMatterLevel
import ru.dbotthepony.mc.otm.core.util.formatPower
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.nanoTime import ru.dbotthepony.mc.otm.nanoTime
@ -61,7 +59,7 @@ open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor(
) )
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (lastAbsoluteX == 0f && lastAbsoluteY == 0f) { if (lastAbsoluteX == 0f && lastAbsoluteY == 0f) {
lastAbsoluteX = absoluteX lastAbsoluteX = absoluteX
lastAbsoluteY = absoluteY lastAbsoluteY = absoluteY
@ -85,7 +83,7 @@ open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor(
} }
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt())
return true return true
@ -98,9 +96,9 @@ open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor(
val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 18f, width = 9f) val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 18f, width = 9f)
val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f) val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f)
fun renderLevel(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, percentage: Float, wavesStrength: Float = 0.5f) { fun renderLevel(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, percentage: Float, wavesStrength: Float = 0.5f) {
graphics.pose().pushPose() graphics.pose.pushPose()
graphics.pose().translate(x, y, 0f) graphics.pose.translate(x, y, 0f)
RenderSystem.setShader(GameRenderer::getPositionTexShader) RenderSystem.setShader(GameRenderer::getPositionTexShader)
RenderSystem.enableBlend() RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc() RenderSystem.defaultBlendFunc()
@ -112,7 +110,7 @@ open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor(
val u1 = GAUGE_FOREGROUND.u1 val u1 = GAUGE_FOREGROUND.u1
val v1 = GAUGE_FOREGROUND.v1 val v1 = GAUGE_FOREGROUND.v1
val matrix = graphics.pose().last().pose() val matrix = graphics.pose.last().pose()
val builder = tesselator.builder val builder = tesselator.builder
builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_TEX) builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_TEX)
@ -134,7 +132,7 @@ open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor(
} }
BufferUploader.drawWithShader(builder.end()) BufferUploader.drawWithShader(builder.end())
graphics.pose().popPose() graphics.pose.popPose()
} }
} }
} }

View File

@ -1,9 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.widget package ru.dbotthepony.mc.otm.client.screen.widget
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
@ -30,13 +29,13 @@ open class PatternGaugePanel<out S : Screen> @JvmOverloads constructor(
) )
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
GAUGE_BACKGROUND.render(graphics) GAUGE_BACKGROUND.render(graphics)
val height = this.height * widget.percentage val height = this.height * widget.percentage
GAUGE_FOREGROUND.renderPartial(graphics, y = this.height - height, height = height) GAUGE_FOREGROUND.renderPartial(graphics, y = this.height - height, height = height)
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt())
return true return true

View File

@ -2,11 +2,10 @@ package ru.dbotthepony.mc.otm.client.screen.widget
import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntArrayList
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
@ -15,7 +14,6 @@ import ru.dbotthepony.mc.otm.client.render.*
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TextComponent
import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.core.stream
import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.util.formatPower
import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.core.util.formatPowerLevel
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
@ -41,7 +39,7 @@ open class PowerGaugePanel<out S : Screen>(
) )
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
val height = this.height * widget.percentage val height = this.height * widget.percentage
if (width >= 18f) { if (width >= 18f) {
@ -63,7 +61,7 @@ open class PowerGaugePanel<out S : Screen>(
} }
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (isHovered) { if (isHovered) {
graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt())
return true return true

View File

@ -2,12 +2,11 @@ package ru.dbotthepony.mc.otm.client.screen.widget
import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.platform.InputConstants
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.RecipeType
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
@ -62,7 +61,7 @@ open class ProgressGaugePanel<out S : Screen>(
return tooltip return tooltip
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (widget.isStuck && tickCount % 40 <= 20) { if (widget.isStuck && tickCount % 40 <= 20) {
RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f) RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f)
} }
@ -82,7 +81,7 @@ open class ProgressGaugePanel<out S : Screen>(
} }
} }
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
if (shouldRenderTooltips(graphics, mouseX, mouseY, partialTick)) { if (shouldRenderTooltips(graphics, mouseX, mouseY, partialTick)) {
graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt())
return true return true

View File

@ -5,7 +5,6 @@ import lain.mods.cos.impl.ModObjects
import lain.mods.cos.impl.client.PlayerRenderHandler import lain.mods.cos.impl.client.PlayerRenderHandler
import lain.mods.cos.impl.client.gui.GuiCosArmorInventory import lain.mods.cos.impl.client.gui.GuiCosArmorInventory
import lain.mods.cos.impl.network.packet.PacketSetSkinArmor import lain.mods.cos.impl.network.packet.PacketSetSkinArmor
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
@ -16,6 +15,7 @@ import net.minecraft.world.inventory.InventoryMenu
import net.minecraft.world.inventory.Slot import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraftforge.fml.ModList import net.minecraftforge.fml.ModList
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.render.sprites.sprite
@ -175,7 +175,7 @@ class CosmeticToggleButton<out S : Screen>(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
val inv = ModObjects.invMan.getCosArmorInventoryClient(minecraft.player?.uuid ?: throw ConcurrentModificationException()) val inv = ModObjects.invMan.getCosArmorInventoryClient(minecraft.player?.uuid ?: throw ConcurrentModificationException())
if (inv.isSkinArmor(index)) { if (inv.isSkinArmor(index)) {
@ -214,7 +214,7 @@ class CosmeticToggleRenderButton<out S : Screen>(
} }
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (PlayerRenderHandler.Disabled) { if (PlayerRenderHandler.Disabled) {
BUTTON_ACTIVE.render(graphics, width = width, height = height) BUTTON_ACTIVE.render(graphics, width = width, height = height)
} else { } else {

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
@ -12,7 +13,7 @@ import ru.dbotthepony.mc.otm.core.util.formatPower
import ru.dbotthepony.mc.otm.systemTime import ru.dbotthepony.mc.otm.systemTime
fun renderMatterGauge( fun renderMatterGauge(
guiGraphics: GuiGraphics, guiGraphics: MGUIGraphics,
x: Float, x: Float,
y: Float, y: Float,
width: Float = MatterGaugePanel.GAUGE_BACKGROUND.width, width: Float = MatterGaugePanel.GAUGE_BACKGROUND.width,
@ -25,7 +26,7 @@ fun renderMatterGauge(
} }
fun renderEnergyGauge( fun renderEnergyGauge(
guiGraphics: GuiGraphics, guiGraphics: MGUIGraphics,
x: Float, x: Float,
y: Float, y: Float,
width: Float = PowerGaugePanel.GAUGE_BACKGROUND.width, width: Float = PowerGaugePanel.GAUGE_BACKGROUND.width,

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei
import mezz.jei.api.gui.drawable.IDrawable import mezz.jei.api.gui.drawable.IDrawable
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable { class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable {
@ -14,6 +15,6 @@ class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable {
} }
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
parent.render(guiGraphics, xOffset.toFloat(), yOffset.toFloat()) parent.render(MGUIGraphics(guiGraphics), xOffset.toFloat(), yOffset.toFloat())
} }
} }

View File

@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.draw
@ -63,21 +64,25 @@ object MatterEntanglerRecipeCategory : IRecipeCategory<IMatterEntanglerRecipe>,
} }
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
val wrap = MGUIGraphics(guiGraphics)
for (x in 0 until 3) { for (x in 0 until 3) {
for (y in 0 until 3) { for (y in 0 until 3) {
AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset + x * 18f + 29f, yOffset + y * 18f + 3f) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset + x * 18f + 29f, yOffset + y * 18f + 3f)
} }
} }
AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset + 115f, yOffset + 18f + 3f) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset + 115f, yOffset + 18f + 3f)
ProgressGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, xOffset + 89f, yOffset + 18f + 4f) ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f)
} }
override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) { override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) {
renderMatterGauge(guiGraphics, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) val wrap = MGUIGraphics(guiGraphics)
renderEnergyGauge(guiGraphics, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat())
guiGraphics.draw(minecraft.font, x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true) renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat())
renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat())
wrap.draw(wrap.font, x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true)
} }
override fun getTooltipStrings(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, mouseX: Double, mouseY: Double): MutableList<Component> { override fun getTooltipStrings(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, mouseX: Double, mouseY: Double): MutableList<Component> {

View File

@ -13,6 +13,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Ingredient
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.draw
@ -52,12 +53,14 @@ object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
@Suppress("name_shadowing") @Suppress("name_shadowing")
val yOffset = yOffset.toFloat() val yOffset = yOffset.toFloat()
AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset) val wrap = MGUIGraphics(graphics)
AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset)
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, X_ARROW + xOffset, Y_ARROW + yOffset)
ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial( ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial(
graphics, wrap,
X_ARROW + xOffset, X_ARROW + xOffset,
Y_ARROW + yOffset, Y_ARROW + yOffset,
width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat()) width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat())
@ -70,12 +73,13 @@ object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
mouseX: Double, mouseX: Double,
mouseY: Double mouseY: Double
) { ) {
graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val wrap = MGUIGraphics(graphics)
wrap.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
val average = recipe.experience.toString() val average = recipe.experience.toString()
if (average != "0.0") { if (average != "0.0") {
graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) wrap.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
} }
} }

View File

@ -14,6 +14,7 @@ import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Ingredient
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
@ -71,15 +72,17 @@ object PainterRecipeCategory : IRecipeCategory<PainterRecipe>, IDrawable {
} }
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
val wrap = MGUIGraphics(guiGraphics)
for (x in 0 .. 1) { for (x in 0 .. 1) {
for (y in 0 .. 2) { for (y in 0 .. 2) {
AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + x * 18f, yOffset.toFloat() + y * 18f) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset.toFloat() + x * 18f, yOffset.toFloat() + y * 18f)
} }
} }
AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 49f, yOffset.toFloat() + 21f) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset.toFloat() + 49f, yOffset.toFloat() + 21f)
AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 99f, yOffset.toFloat() + 21f) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset.toFloat() + 99f, yOffset.toFloat() + 21f)
ProgressGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 73f, yOffset.toFloat() + 22f) ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset.toFloat() + 73f, yOffset.toFloat() + 22f)
} }
} }

View File

@ -13,6 +13,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Ingredient
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.MGUIGraphics
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.draw
@ -52,12 +53,14 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
@Suppress("name_shadowing") @Suppress("name_shadowing")
val yOffset = yOffset.toFloat() val yOffset = yOffset.toFloat()
AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset) val wrap = MGUIGraphics(graphics)
AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset)
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, X_ARROW + xOffset, Y_ARROW + yOffset)
ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial( ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial(
graphics, wrap,
X_ARROW + xOffset, X_ARROW + xOffset,
Y_ARROW + yOffset, Y_ARROW + yOffset,
width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat()) width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat())
@ -70,12 +73,14 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
mouseX: Double, mouseX: Double,
mouseY: Double mouseY: Double
) { ) {
graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val wrap = MGUIGraphics(graphics)
wrap.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
val average = recipe.experience.toString() val average = recipe.experience.toString()
if (average != "0.0") { if (average != "0.0") {
graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) wrap.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
} }
} }