Merge branch 'main' of https://gitea.codersquack.nl/NeoFlock/NeoComputers
# Conflicts: # src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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,29 +18,9 @@ import org.neoflock.neocomputers.utils.GenericContainerScreen
|
||||
|
||||
class CaseScreen : GenericContainerScreen<CaseMenu> {
|
||||
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) {
|
||||
super.renderBg(guiGraphics, f, i ,j)
|
||||
@@ -54,14 +33,6 @@ class CaseScreen : GenericContainerScreen<CaseMenu> {
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 598 B |
Binary file not shown.
|
Before Width: | Height: | Size: 628 B |
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB |
Reference in New Issue
Block a user