diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 8c75057fb..8ef214791 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -256,6 +256,13 @@ open class AndroidResearchType( set.addAll(research.allUnlocks) } + for (research in allPrerequisites) { + for (research2 in research.flatBlocking) { + set.add(research2) + set.addAll(research2.allUnlocks) + } + } + ListSet(set) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 2c7786f19..129b21805 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.blaze3d.vertex.Tesselator import com.mojang.blaze3d.vertex.VertexConsumer import com.mojang.math.Matrix4f import com.mojang.math.Vector3f @@ -10,6 +11,8 @@ import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence import ru.dbotthepony.mc.otm.core.* +val tesselator: Tesselator get() = Tesselator.getInstance() + fun VertexConsumer.normal(vector: Vector): VertexConsumer = normal(vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) fun VertexConsumer.vertex(matrix4f: Matrix4f, vector: Vector): VertexConsumer = vertex(matrix4f, vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) fun VertexConsumer.color(color: RGBAColor): VertexConsumer = color(color.red, color.green, color.blue, color.alpha) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 768b87467..24052188b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -40,7 +40,7 @@ fun drawTexturedRect( RenderSystem.defaultBlendFunc() RenderSystem.depthFunc(GL11.GL_ALWAYS) - val builder = Tesselator.getInstance().builder + val builder = tesselator.builder builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) builder.vertex(matrix, x, y + height, zLevel).uv(u0, v1).endVertex() @@ -105,7 +105,7 @@ fun colorSphere(matrix: Matrix4f, radius: Float) { RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() - val builder = Tesselator.getInstance().builder + val builder = tesselator.builder builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) val turnStep = Math.PI * (1 / fragments.toDouble()) * 2 @@ -299,7 +299,7 @@ fun drawRect( RenderSystem.setShader(GameRenderer::getPositionColorShader) RenderSystem.depthFunc(GL11.GL_ALWAYS) - val tess = Tesselator.getInstance() + val tess = tesselator val builder = tess.builder builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index 74bde26ee..22f3a28a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.capability.AndroidCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawColor import ru.dbotthepony.mc.otm.client.render.drawLine import ru.dbotthepony.mc.otm.client.render.drawRect @@ -281,28 +282,42 @@ private open class AndroidResearchButton( } override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) { - minecraft.player?.getCapability(MatteryCapability.ANDROID)?.ifPresentK { - if (node.isResearched) { - AndroidStationScreen.RESEARCHED.setSystemColor() - } else if (node.canResearch) { - AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor() - } else { - AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() - } + val hovered = (screen as AndroidStationScreen).hoveredResearch - val icon = node.skinIcon + val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking - if (icon != null) { - icon.render(stack, 0f, 0f, width, height) - } else { - drawRect(stack, 0f, 0f, width, height) - } + if (isBlockedByHovered) { + AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() - val text = node.iconText + drawRect(stack, 0f, 0f, width, height) + } - if (text != null) { - font.drawShadow(stack, text, width - font.width(text), height - font.lineHeight, -0x1) - } + if (node.isResearched) { + AndroidStationScreen.RESEARCHED.setSystemColor() + } else if (node.canResearch) { + AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor() + } else { + AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() + } + + val icon = node.skinIcon + + if (icon != null) { + icon.render(stack, 0f, 0f, width, height) + } else { + drawRect(stack, 0f, 0f, width, height) + } + + if (isBlockedByHovered) { + RGBAColor.RED.setSystemColor() + + Widgets18.CROSS.render(stack) + } + + val text = node.iconText + + if (text != null) { + font.drawShadow(stack, text, width - font.width(text), height - font.lineHeight, -0x1) } drawColor = RGBAColor.WHITE @@ -316,7 +331,7 @@ private open class AndroidResearchButton( drawLine(stack, x1, y1, x2, y2, 0.5f) } - val hovered = (screen as AndroidStationScreen).hoveredResearch ?: return + hovered ?: return val lines = highlightLines[hovered.type] ?: return drawColor = RGBAColor.LIGHT_GREEN diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt index c4b1b7458..c84eaf7e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt @@ -53,6 +53,7 @@ data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alph companion object { val BLACK = RGBAColor(0f, 0f, 0f, 1f) val WHITE = RGBAColor(1f, 1f, 1f, 1f) + val RED = RGBAColor(1f, 0f, 0f) val GREEN = RGBAColor(0f, 1f, 0f, 1f) val LIGHT_GREEN = RGBAColor(136, 255, 124) val SLATE_GRAY = RGBAColor(64, 64, 64) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png index faa5401c5..3ae0818c4 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png differ