From d731a2bc138c172508d6642e28711770754978dc Mon Sep 17 00:00:00 2001 From: mewhenthe Date: Tue, 21 Apr 2026 10:24:38 +0200 Subject: [PATCH 1/2] more stuff, case button except it sucks, I HATE MINECRAFT --- .../neocomputers/gui/render/ProgressBar.kt | 18 +++--- .../neocomputers/gui/screen/CaseScreen.kt | 53 +++++++++++++----- .../neocomputers/gui/widget/ImagerButton.kt | 27 +++++++++ .../assets/neocomputers/textures/gui/bar.png | Bin 598 -> 0 bytes .../neocomputers/textures/gui/bar_old.png | Bin 628 -> 0 bytes .../neocomputers/textures/gui/combustgui.png | Bin 4460 -> 0 bytes 6 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 src/main/kotlin/org/neoflock/neocomputers/gui/widget/ImagerButton.kt delete mode 100644 src/main/resources/assets/neocomputers/textures/gui/bar.png delete mode 100644 src/main/resources/assets/neocomputers/textures/gui/bar_old.png delete mode 100644 src/main/resources/assets/neocomputers/textures/gui/combustgui.png diff --git a/src/main/kotlin/org/neoflock/neocomputers/gui/render/ProgressBar.kt b/src/main/kotlin/org/neoflock/neocomputers/gui/render/ProgressBar.kt index ac999f6..6a6860a 100644 --- a/src/main/kotlin/org/neoflock/neocomputers/gui/render/ProgressBar.kt +++ b/src/main/kotlin/org/neoflock/neocomputers/gui/render/ProgressBar.kt @@ -24,15 +24,19 @@ import kotlin.math.ceil // #66CC66 -object ProgressBar { // TODO: variable length +object ProgressBar { - val BAR: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/bar.png") - - // NOTE: OC never uses a different width and height, changing height is not recommended + // NOTE: OC never uses a different width and height fun render(guiGraphics: GuiGraphics, x: Int, y: Int, value: Long, max: Long, mouseX: Int, mouseY: Int, width: Int=142, height: Int=14, tooltipfunc: (Int) -> String?) { - guiGraphics.blit(BAR, x, y, 1, height, 0F, 0F, 1, 14, 3, 14) - guiGraphics.blit(BAR, x+1, y, width-2, height, 1F, 0F, 1, 14, 3, 14) - guiGraphics.blit(BAR, x+width-1, y, 1, height, 2F, 0F, 1, 14, 3, 14) + RenderSystem.disableBlend() + guiGraphics.fill(x, y, x+width-1, y+1, 0xFF373737.toInt()) // top left corner + top edge + guiGraphics.fill(x, y+1, x+1, y+height-1, 0xFF373737.toInt()) // left edge + + guiGraphics.fill(x, y+height-1, x+1, y+height, 0xFF8B8B8B.toInt()) // bottom left corner + guiGraphics.fill(x+width-1, y, x+width, y+1, 0xFF8B8B8B.toInt()) // top right corner + + guiGraphics.fill(x+1, y+height-1, x+width, y+height, 0xFFFFFFFF.toInt()) // bottom right corner + bottom edge + guiGraphics.fill(x+width-1, y+height-1, x+width, y+1, 0xFFFFFFFF.toInt()) // right edge val frac = value.toFloat() / max.toFloat() val linew = ceil(frac*(width-2).toFloat()) diff --git a/src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt b/src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt index e4bb314..51de9ad 100644 --- a/src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt +++ b/src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt @@ -4,40 +4,65 @@ import com.mojang.blaze3d.vertex.BufferBuilder import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.Tesselator import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.components.Button import net.minecraft.client.gui.components.ImageButton +import net.minecraft.client.gui.components.WidgetSprites import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import org.neoflock.neocomputers.NeoComputers import org.neoflock.neocomputers.gui.menu.CaseMenu -import org.neoflock.neocomputers.gui.widget.DynamicSlot -import org.neoflock.neocomputers.gui.widget.ProgressBar +import org.neoflock.neocomputers.gui.widget.ButtonSprites +import org.neoflock.neocomputers.gui.widget.ImagerButton import org.neoflock.neocomputers.utils.GenericContainerScreen class CaseScreen : GenericContainerScreen { private val PCB: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/computer.png") + private val BTN: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button_power.png") +// private val BTN_ENABLED: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button/power/enabled.png") // gonna do this later +// private val BTN_DISABLED: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button/power/disabled.png") +// private val BTN_ENABLED_HOVER: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button/power/enabled_hover.png") +// private val BTN_DISABLED_HOVER: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/power/disabled_hover.png") + + private var btn: ImagerButton? = null; override fun shouldCenterTitle(): Boolean = false - constructor(abstractContainerMenu: CaseMenu, inventory: Inventory, component: Component) : super(abstractContainerMenu, inventory, component) + constructor(abstractContainerMenu: CaseMenu, inventory: Inventory, component: Component) : super(abstractContainerMenu, inventory, component) { + btn = ImagerButton( + 15, 15, + 18, 18, + ButtonSprites(BTN, 18, 18, 36, 36) + ) { + var btn = it as ImagerButton + btn.pressed = !btn.pressed + } +// addRenderableWidget(btn!!) + } override fun renderBg(guiGraphics: GuiGraphics, f: Float, i: Int, j: Int) { super.renderBg(guiGraphics, f, i ,j) val relX = (this.width - this.imageWidth) / 2 val relY = (this.height - this.imageHeight) / 2 - - guiGraphics.blit(PCB, relX, relY, 0, 0, this.imageWidth, this.imageHeight) - // this.renderSlots(relX, relY) - + + btn!!.x = relX+70 + btn!!.y = relY+33 + btn!!.render(guiGraphics, i, j, f) // minecraft SUCKSSS + guiGraphics.blit(PCB, relX, relY, 0, 0, this.imageWidth, this.imageHeight) } - // private fun renderSlots(relX: Int, relY: Int) { // TODO: put this in some generic screen class - // for (slot in menu.slots) { - // if (slot is DynamicSlot) { - // slot.draw(relX, relY) - // } - // } - // } + override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { // todo: make a better widget system than mojang, practically not even using the fact it's a widget atp + NeoComputers.LOGGER.info(String.format("btn: %d %d %d %d, mouse %s %s", btn!!.x, btn!!.y, btn!!.x+btn!!.width, btn!!.y+btn!!.height, mouseX.toString(), mouseY.toString())) + if (button != 0) return false + if (btn!!.x < mouseX.toInt() && mouseX.toInt() < btn!!.x+btn!!.width && btn!!.y < mouseY.toInt() && mouseY.toInt() < btn!!.y+btn!!.height) { + btn!!.playDownSound(Minecraft.getInstance().soundManager) + btn!!.onClick(mouseX, mouseY) + return true + } else return false + } + + } \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/gui/widget/ImagerButton.kt b/src/main/kotlin/org/neoflock/neocomputers/gui/widget/ImagerButton.kt new file mode 100644 index 0000000..edca224 --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/gui/widget/ImagerButton.kt @@ -0,0 +1,27 @@ +package org.neoflock.neocomputers.gui.widget + +import net.minecraft.client.gui.Gui +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.components.Button +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import org.neoflock.neocomputers.NeoComputers + +data class ButtonSprites(val sheet: ResourceLocation, val spriteWidth: Int, val spriteHeight: Int, val texWidth: Int, val texHeight: Int) + +// minecraft sux +class ImagerButton(x: Int, y: Int, width: Int, height: Int, val sprites: ButtonSprites, onPress: Button.OnPress) : Button(x, y, width, height, Component.literal(""), onPress, DEFAULT_NARRATION) { +// public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { +// ResourceLocation resourceLocation = this.sprites.get(this.isActive(), this.isHoveredOrFocused()); +// guiGraphics.blitSprite(resourceLocation, this.getX(), this.getY(), this.width, this.height); +// } + var pressed = false + + override fun renderWidget(graphics: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) { + val u = if (pressed) 18F else 0F // no clue why it's swapped? prob cooked the coordinates, we gotta get parchment so bad + val v = if (this.isHoveredOrFocused) 18F else 0F + + graphics.blit(sprites.sheet, x, y, width, height, u, v, sprites.spriteWidth, sprites.spriteHeight, sprites.texWidth, sprites.texHeight) + } + +} \ No newline at end of file diff --git a/src/main/resources/assets/neocomputers/textures/gui/bar.png b/src/main/resources/assets/neocomputers/textures/gui/bar.png deleted file mode 100644 index c2c4b18b03d8b4d6aca0e8d175524e31d22131b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 598 zcmV-c0;&CpP)b9m~0004nX+uL$Nkc;* zaB^>EX>4Tx04R}tk-tmBKpe$i(@I4v3T6;-$WWc^q9TGztwIqhgj%6h2lJ!9ph-iL z;^HW{799MsSaoo5*44pP5CngK_y>rSqKlOHy`<10#)IQNyu0_fdk1ihilSMeIH2ja znNB8zY;IKuzaj)41DHjxq*%tBD5l^$zU~oV>s^dx`Jel9^r?AE0RjSXTro_Wc!PL) z(>56I6Z1+*Qi;!r$4$B*@gvh^kKY&|nWrm6E9uPZ38|O{aV= z>#@psi?LRzDXn|57e?~>$}-bwjv$FeEJ1_-88wtqfsGigIw=;?w4dDl|y0AM6i)cWV_UC%mLc0_b{ioR3i;ybCnzj`Mx&IL#9v_zYa>ZGW`^%zTnw zZ)?#bpnn^3_Tf=DY;URCRZo`?`QN)IbiS>=vni6YwhFo0mx8SsT<(n z5Ev^`_PWozyE}XP_e`t5AGN)5!CD*bV*mgE24YJ`L;yDcHvl(t+lli4000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2kHbA5eFncR!_CX>@2HM@dakSAh-}0000jNklZ`Vv7c)2@zpNwz kR23v~W>nog{)g`NI=LVgL9H@Q`2YX_07*qoM6N<$f+D-~Qvd(} diff --git a/src/main/resources/assets/neocomputers/textures/gui/bar_old.png b/src/main/resources/assets/neocomputers/textures/gui/bar_old.png deleted file mode 100644 index 89c3e2daf5ca8f374e11698304463234eb29a3cc..0000000000000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znyy0!426>rNcGBMJj>%oHueSLk6jg7^{#qiY; zb{??@4Dcos3iB5snU_w%Q$HfJ=jIrZ^^<3sVPlHdTf+G5Nq3VuHH#qQ|(%=nkTWFMhcBZiBU)<>=Q1}o{gpR+6LTI;%u zh1KV-J@@S&m+$}T`P1O!M(;-{?QG(%0@=wbSzB&rZJ%s9;@GsLP%Hd@IAhYK95n#>IvV zbtW!0%v55$9xZ#@9;SHf)SQSbeY&=*$2JVq`OLC;)g9zu^9hCJjoD*<4Ywa%*4A)u SZSS(hqNl}_Z|qvIqW-^Q;xAnQ From f3ebc4f684d6976d5176c65b673ecb0f799539ce Mon Sep 17 00:00:00 2001 From: mewhenthe Date: Tue, 21 Apr 2026 12:35:03 +0200 Subject: [PATCH 2/2] save water by using parchmentmc --- build.gradle.kts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f3d9417..1bea69b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,11 +42,29 @@ repositories { name = "Kotlin for Forge" setUrl("https://thedarkcolour.github.io/KotlinForForge/") } + maven { + name = "ParchmentMC" + setUrl("https://maven.parchmentmc.org") + } } dependencies { minecraft("com.mojang:minecraft:$minecraft") - mappings(loom.officialMojangMappings()) +// mappings(loom.officialMojangMappings()) + mappings(loom.layered(){ + var date = "" + when (minecraft) { + "1.20.1" -> date = "2023.09.03" + "1.20.4" -> date = "2024.04.14" + "1.21.1" -> date = "2024.11.17" + "1.21.9" -> date = "2025.10.05" + "1.21.11" -> date = "2025.12.20" + else -> date="idk lol 67" + } + + officialMojangMappings() // TODO: versions + parchment("org.parchmentmc.data:parchment-${minecraft}:${date}@zip") + }) var archversion = "idk" when(minecraft) { // NOTE: add more entries if you want to add more versions "1.20.1" -> archversion = "9.2.14"