mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
fire overlay
This commit is contained in:
parent
caa40b2245
commit
d55c9171d4
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.config.profile.profiles.rendering.overlay
|
||||
|
||||
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate
|
||||
import de.bixilon.minosoft.config.profile.profiles.rendering.overlay.fire.FireC
|
||||
|
||||
class OverlayC {
|
||||
/**
|
||||
@ -25,4 +26,6 @@ class OverlayC {
|
||||
* Enabled the pumpkin blur overlay if the player is waring a carved pumpkin
|
||||
*/
|
||||
var pumpkin by delegate(true)
|
||||
|
||||
val fire = FireC()
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.config.profile.profiles.rendering.overlay.fire
|
||||
|
||||
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate
|
||||
|
||||
class FireC {
|
||||
|
||||
/**
|
||||
* Enables the fire/burning overlay
|
||||
*/
|
||||
var enabled by delegate(true)
|
||||
|
||||
/**
|
||||
* Enables the overlay if in creative
|
||||
*/
|
||||
var creative by delegate(true)
|
||||
|
||||
/**
|
||||
* Enables the fire overlay if in lava
|
||||
*/
|
||||
var lava by delegate(true)
|
||||
}
|
@ -24,5 +24,6 @@ object DefaultOverlays {
|
||||
WaterOverlay,
|
||||
PumpkinOverlay,
|
||||
PowderSnowOverlay,
|
||||
FireOverlay,
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.overlays
|
||||
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.Overlay
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.OverlayFactory
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.SimpleTextureMesh
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import glm_.vec3.Vec3
|
||||
|
||||
class FireOverlay(
|
||||
private val renderWindow: RenderWindow,
|
||||
private val z: Float,
|
||||
) : Overlay {
|
||||
private val config = renderWindow.connection.profiles.rendering.overlay.fire
|
||||
private val player = renderWindow.connection.player
|
||||
private val shader: Shader = renderWindow.shaderManager.genericTexture2dShader
|
||||
private var texture: AbstractTexture = renderWindow.textureManager.staticTextures.createTexture("block/fire_1".toResourceLocation().texture())
|
||||
override val render: Boolean
|
||||
get() = config.enabled && player.isOnFire && !((player.gamemode == Gamemodes.CREATIVE && config.creative) || (player.fluidHeights[DefaultFluids.LAVA] != null && config.lava))
|
||||
private lateinit var mesh: SimpleTextureMesh
|
||||
private val tintColor = RGBColor(1.0f, 1.0f, 1.0f, 0.9f)
|
||||
|
||||
|
||||
override fun postInit() {
|
||||
mesh = SimpleTextureMesh(renderWindow)
|
||||
|
||||
// left
|
||||
mesh.addQuad(arrayOf(
|
||||
Vec3(-1.0f, -1.0f, +0.0f),
|
||||
Vec3(-1.0f, +1.0f, +0.0f),
|
||||
Vec3(+0.0f, +1.0f, +1.0f),
|
||||
Vec3(+0.0f, -1.0f, +1.0f),
|
||||
)) { position, uv -> mesh.addVertex(position, texture, uv, tintColor) }
|
||||
|
||||
// right
|
||||
mesh.addQuad(arrayOf(
|
||||
Vec3(+0.0f, -1.0f, +1.0f),
|
||||
Vec3(+0.0f, +1.0f, +1.0f),
|
||||
Vec3(+1.0f, +1.0f, +0.0f),
|
||||
Vec3(+1.0f, -1.0f, +0.0f),
|
||||
)) { position, uv -> mesh.addVertex(position, texture, uv, tintColor) }
|
||||
|
||||
mesh.load()
|
||||
}
|
||||
|
||||
|
||||
override fun draw() {
|
||||
renderWindow.renderSystem.reset(blending = true, depthMask = false)
|
||||
shader.use()
|
||||
mesh.draw()
|
||||
}
|
||||
|
||||
|
||||
companion object : OverlayFactory<FireOverlay> {
|
||||
|
||||
override fun build(renderWindow: RenderWindow, z: Float): FireOverlay {
|
||||
return FireOverlay(renderWindow, z)
|
||||
}
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ abstract class Mesh(
|
||||
addQuad(positions, uvStart, uvEnd, vertexConsumer)
|
||||
}
|
||||
|
||||
private fun addQuad(positions: Array<Vec3>, uvStart: Vec2 = Vec2(0.0f, 0.0f), uvEnd: Vec2 = Vec2(1.0f, 1.0f), vertexConsumer: (position: Vec3, uv: Vec2) -> Unit) {
|
||||
fun addQuad(positions: Array<Vec3>, uvStart: Vec2 = Vec2(0.0f, 0.0f), uvEnd: Vec2 = Vec2(1.0f, 1.0f), vertexConsumer: (position: Vec3, uv: Vec2) -> Unit) {
|
||||
val texturePositions = arrayOf(
|
||||
uvStart,
|
||||
Vec2(uvStart.x, uvEnd.y),
|
||||
|
Loading…
x
Reference in New Issue
Block a user