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" 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 49c381a..504992a 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 = if(max == 0L) 0.0f else 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 ff6cc98..e4bb314 100644 --- a/src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt +++ b/src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt @@ -7,7 +7,6 @@ import com.mojang.blaze3d.vertex.VertexFormat import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.ImageButton import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen -import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory @@ -19,28 +18,8 @@ import org.neoflock.neocomputers.utils.GenericContainerScreen class CaseScreen : GenericContainerScreen { private val PCB: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/computer.png") - private val POWER_ATLAS: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button_power.png") - private val BTN_SIZE = 18 override fun shouldCenterTitle(): Boolean = false - - var isOn = false - var energy = 0L - var energyTotal = 0L - var memUsed = 0L - var memTotal = 0L - var compUsed = 0L - var compTotal = 0L - - override fun processScreenStatePacket(buf: FriendlyByteBuf) { - isOn = buf.readBoolean() - energy = buf.readLong() - energyTotal = buf.readLong() - memUsed = buf.readLong() - memTotal = buf.readLong() - compUsed = buf.readLong() - compTotal = buf.readLong() - } constructor(abstractContainerMenu: CaseMenu, inventory: Inventory, component: Component) : super(abstractContainerMenu, inventory, component) override fun renderBg(guiGraphics: GuiGraphics, f: Float, i: Int, j: Int) { @@ -54,14 +33,6 @@ class CaseScreen : GenericContainerScreen { } - override fun renderCustomOverlay(graphics: GuiGraphics, mouseX: Int, mouseY: Int, blend: Float) { - super.renderCustomOverlay(graphics, mouseX, mouseY, blend) - val relX = (this.width - this.imageWidth) / 2 - val relY = (this.height - this.imageHeight) / 2 - - graphics.blit(POWER_ATLAS, relX, relY, BTN_SIZE, BTN_SIZE, 0.5f, 0.5f, BTN_SIZE, BTN_SIZE, BTN_SIZE*2, BTN_SIZE*2) - } - // private fun renderSlots(relX: Int, relY: Int) { // TODO: put this in some generic screen class // for (slot in menu.slots) { // if (slot is DynamicSlot) { 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 c2c4b18..0000000 Binary files a/src/main/resources/assets/neocomputers/textures/gui/bar.png and /dev/null differ 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 89c3e2d..0000000 Binary files a/src/main/resources/assets/neocomputers/textures/gui/bar_old.png and /dev/null differ diff --git a/src/main/resources/assets/neocomputers/textures/gui/combustgui.png b/src/main/resources/assets/neocomputers/textures/gui/combustgui.png deleted file mode 100644 index 7f936d5..0000000 Binary files a/src/main/resources/assets/neocomputers/textures/gui/combustgui.png and /dev/null differ