mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
pumpkin overlay
This commit is contained in:
parent
379126a95a
commit
590b72bcdd
@ -26,7 +26,15 @@ class ShaderManager(
|
||||
|
||||
fun postInit() {
|
||||
genericColorShader.load()
|
||||
genericTextureShader.load()
|
||||
genericTexture2dShader.load()
|
||||
genericTextureShader.apply {
|
||||
load()
|
||||
renderWindow.textureManager.staticTextures.use(this)
|
||||
renderWindow.textureManager.staticTextures.animator.use(this)
|
||||
}
|
||||
genericTexture2dShader.apply {
|
||||
load()
|
||||
renderWindow.textureManager.staticTextures.use(this)
|
||||
renderWindow.textureManager.staticTextures.animator.use(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class Camera(
|
||||
val matrixHandler = MatrixHandler(renderWindow, fogManager)
|
||||
val targetHandler = TargetHandler(renderWindow, this)
|
||||
|
||||
val firstPerson: Boolean = true // ToDo
|
||||
|
||||
fun init() {
|
||||
matrixHandler.init()
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.overlays
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.overlays.simple.PumpkinOverlay
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.overlays.simple.WallOverlay
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.overlays.simple.WaterOverlay
|
||||
|
||||
@ -20,5 +21,6 @@ object DefaultOverlays {
|
||||
val OVERLAYS = listOf(
|
||||
WallOverlay,
|
||||
WaterOverlay,
|
||||
PumpkinOverlay,
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.simple
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
|
||||
abstract class FirstPersonOverlay(renderWindow: RenderWindow, z: Float) : SimpleOverlay(renderWindow, z) {
|
||||
protected val player = renderWindow.connection.player
|
||||
override val render: Boolean
|
||||
get() = renderWindow.camera.firstPerson
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.simple
|
||||
|
||||
import de.bixilon.minosoft.data.inventory.InventorySlots
|
||||
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.world.overlay.OverlayFactory
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class PumpkinOverlay(renderWindow: RenderWindow, z: Float) : FirstPersonOverlay(renderWindow, z) {
|
||||
override val texture: AbstractTexture = renderWindow.textureManager.staticTextures.createTexture("misc/pumpkinblur".toResourceLocation().texture())
|
||||
override val render: Boolean
|
||||
get() {
|
||||
if (!super.render) {
|
||||
return false
|
||||
}
|
||||
val head = player.equipment[InventorySlots.EquipmentSlots.HEAD] ?: return false
|
||||
if (head.item.resourceLocation != MinecraftBlocks.CARVED_PUMPKIN) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
companion object : OverlayFactory<PumpkinOverlay> {
|
||||
|
||||
override fun build(renderWindow: RenderWindow, z: Float): PumpkinOverlay {
|
||||
return PumpkinOverlay(renderWindow, z)
|
||||
}
|
||||
}
|
||||
}
|
@ -35,8 +35,17 @@ class WallOverlay(renderWindow: RenderWindow, z: Float) : SimpleOverlay(renderWi
|
||||
private var position: Vec3i = Vec3i.EMPTY
|
||||
override val render: Boolean
|
||||
get() {
|
||||
val blockState = blockState
|
||||
return player.gamemode != Gamemodes.SPECTATOR && blockState != null && blockState.block !is FluidBlock
|
||||
if (player.gamemode == Gamemodes.SPECTATOR) {
|
||||
return false
|
||||
}
|
||||
val blockState = blockState ?: return false
|
||||
if (blockState.block is FluidBlock) {
|
||||
return false
|
||||
}
|
||||
if (!blockState.collisionShape.intersect(player.aabb)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
override var uvEnd: Vec2
|
||||
get() = Vec2(0.3f, renderWindow.window.sizef.x / renderWindow.window.sizef.y / 3.0f) // To make pixels squares and make it look more like minecraft
|
||||
|
@ -101,10 +101,10 @@ abstract class Mesh(
|
||||
|
||||
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) {
|
||||
val texturePositions = arrayOf(
|
||||
Vec2(uvEnd.x, uvStart.y),
|
||||
uvStart,
|
||||
Vec2(uvStart.x, uvEnd.y),
|
||||
uvEnd,
|
||||
Vec2(uvEnd.x, uvStart.y),
|
||||
)
|
||||
|
||||
for ((vertexIndex, textureIndex) in order) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user