rendering: show level above hotbar

This commit is contained in:
Bixilon 2021-03-08 00:34:53 +01:00
parent 0135b49f15
commit 71359eb51c
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 12 additions and 32 deletions

View File

@ -10,7 +10,7 @@ Minosoft is an open source minecraft client, written from scratch in java. It ai
- Multi protocol support (1.7 - latest)
- Stable modding API
- Unsafe modding API
- Fast performance (incredible start time of 3 - 5 seconds on modern hardware)
- Bleeding edge performance (incredible start time of 3 - 5 seconds on modern hardware)
- Free (as far as we consider original minecraft as free) and open source
- Multi accounting (also multiple account vendors: Offline, Mojang, Microsoft)
- Multi "sessions" (Connections to a server)

View File

@ -16,6 +16,8 @@ package de.bixilon.minosoft.gui.rendering.hud.elements.other
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames
import de.bixilon.minosoft.data.Gamemodes
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.gui.rendering.RenderConstants
import de.bixilon.minosoft.gui.rendering.hud.HUDElementProperties
import de.bixilon.minosoft.gui.rendering.hud.HUDRenderer
import de.bixilon.minosoft.gui.rendering.hud.atlas.HUDAtlasElement
@ -24,6 +26,7 @@ import de.bixilon.minosoft.gui.rendering.hud.elements.HUDElement
import de.bixilon.minosoft.gui.rendering.hud.elements.primitive.ElementListElement
import de.bixilon.minosoft.gui.rendering.hud.elements.primitive.ImageElement
import de.bixilon.minosoft.gui.rendering.hud.elements.primitive.ProgressBar
import de.bixilon.minosoft.gui.rendering.hud.elements.primitive.TextElement
import glm_.vec2.Vec2
class HotbarHUDElement(
@ -71,10 +74,15 @@ class HotbarHUDElement(
if (hudRenderer.connection.player.gamemode != Gamemodes.CREATIVE) {
// experience bar
val experienceBarEnd = Vec2(hotbarBaseAtlasElement.binding.size.x, experienceBarAtlasElement.emptyAtlasElement.binding.size.y)
// experience
val levelText = TextElement(TextComponent(hudRenderer.connection.player.level.toString()).setColor(RenderConstants.EXPERIENCE_BAR_LEVEL_COLOR), hudRenderer.renderWindow.font, Vec2(0, elementList.size.y), 3, false)
levelText.start.x = (hotbarBaseAtlasElement.binding.size.x - levelText.size.x) / 2
elementList.addChild(levelText)
val experienceBar = ProgressBar(Vec2(), experienceBarEnd, experienceBarAtlasElement, hudRenderer.connection.player.experienceBarProgress, 1)
// experience bar
val experienceBarEnd = Vec2(hotbarBaseAtlasElement.binding.size.x, experienceBarAtlasElement.emptyAtlasElement.binding.size.y + elementList.size.y - ELEMENT_PADDING)
val experienceBar = ProgressBar(Vec2(0, elementList.size.y - ELEMENT_PADDING), experienceBarEnd, experienceBarAtlasElement, hudRenderer.connection.player.experienceBarProgress, 1)
elementList.addChild(experienceBar)
}

View File

@ -36,33 +36,6 @@ class ProgressBar(
size = atlasElement.emptyAtlasElement.binding.size
}
// fun draw(elementMesh: ElementMesh, start: Vec2, end: Vec2, progress: Float, z: Int = 1) {
// elementMesh.addElement(start, end, emptyAtlasElement, z)
// if (progress == 0.0f) {
// return
// }
// val xDiff = abs(end.x - start.x)
// val ourXDiff = xDiff * progress
// val textureStart = Vec2((fullAtlasElement.binding.start.x * fullAtlasElement.texture.widthFactor) / fullAtlasElement.texture.width.toFloat(), (fullAtlasElement.binding.start.y * fullAtlasElement.texture.heightFactor) / fullAtlasElement.texture.height.toFloat())
// var textureEnd = Vec2(((fullAtlasElement.binding.end.x + 1) * fullAtlasElement.texture.widthFactor) / (fullAtlasElement.texture.width + 1.0f), ((fullAtlasElement.binding.end.y + 1) * fullAtlasElement.texture.heightFactor) / (fullAtlasElement.texture.height + 1.0f))
// textureEnd = Vec2((textureEnd.x - textureStart.x) * progress, textureEnd.y)
// elementMesh.addElement(start, Vec2(start.x + ourXDiff, end.y), object : TextureLike {
// override val texture: Texture
// get() = fullAtlasElement.texture
// override val uvStart: Vec2
// get() = textureStart
// override val uvEnd: Vec2
// get() = textureEnd
// }, z + 1)
// }
override fun prepareVertices(start: Vec2, scaleFactor: Float, hudMesh: HUDMesh, matrix: Mat4, z: Int) {
val emptyImageElement = ImageElement(this.start, end, atlasElement.emptyAtlasElement, z)
@ -84,6 +57,5 @@ class ProgressBar(
}, z + 1)
fullImageElement.prepareVertices(start, scaleFactor, hudMesh, matrix, z)
}
}