mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
wawla: config, more entity information
This commit is contained in:
parent
799d34203f
commit
ae5e45f454
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 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 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.
|
||||||
*
|
*
|
||||||
@ -16,8 +16,10 @@ package de.bixilon.minosoft.config.profile.profiles.gui.hud
|
|||||||
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfile
|
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfile
|
||||||
import de.bixilon.minosoft.config.profile.profiles.gui.hud.crosshair.CrosshairC
|
import de.bixilon.minosoft.config.profile.profiles.gui.hud.crosshair.CrosshairC
|
||||||
import de.bixilon.minosoft.config.profile.profiles.gui.hud.hotbar.HotbarC
|
import de.bixilon.minosoft.config.profile.profiles.gui.hud.hotbar.HotbarC
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.gui.hud.wawla.WawlaC
|
||||||
|
|
||||||
class HudC(profile: GUIProfile) {
|
class HudC(profile: GUIProfile) {
|
||||||
val crosshair = CrosshairC(profile)
|
val crosshair = CrosshairC(profile)
|
||||||
val hotbar = HotbarC(profile)
|
val hotbar = HotbarC(profile)
|
||||||
|
val wawla = WawlaC(profile)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2023 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.gui.hud.wawla
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfile
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.gui.hud.wawla.block.BlockC
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.gui.hud.wawla.entity.EntityC
|
||||||
|
|
||||||
|
class WawlaC(profile: GUIProfile) {
|
||||||
|
var enabled by BooleanDelegate(profile, true)
|
||||||
|
var limitReach by BooleanDelegate(profile, true)
|
||||||
|
|
||||||
|
val block = BlockC(profile)
|
||||||
|
val entity = EntityC(profile)
|
||||||
|
}
|
@ -11,8 +11,11 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.data.entities.wawla
|
package de.bixilon.minosoft.config.profile.profiles.gui.hud.wawla.block
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.wawla.WawlaInformation
|
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfile
|
||||||
|
|
||||||
interface EntityWawlaInformation : WawlaInformation
|
class BlockC(profile: GUIProfile) {
|
||||||
|
var enabled by BooleanDelegate(profile, true)
|
||||||
|
}
|
@ -11,8 +11,14 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.data.registries.blocks.wawla
|
package de.bixilon.minosoft.config.profile.profiles.gui.hud.wawla.entity
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.wawla.WawlaInformation
|
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfile
|
||||||
|
|
||||||
interface BlockWawlaInformation : WawlaInformation
|
class EntityC(profile: GUIProfile) {
|
||||||
|
var enabled by BooleanDelegate(profile, true)
|
||||||
|
var health by BooleanDelegate(profile, true)
|
||||||
|
|
||||||
|
var hand by BooleanDelegate(profile, true)
|
||||||
|
}
|
@ -20,6 +20,7 @@ import de.bixilon.minosoft.data.entities.Poses
|
|||||||
import de.bixilon.minosoft.data.entities.data.EntityData
|
import de.bixilon.minosoft.data.entities.data.EntityData
|
||||||
import de.bixilon.minosoft.data.entities.data.EntityDataField
|
import de.bixilon.minosoft.data.entities.data.EntityDataField
|
||||||
import de.bixilon.minosoft.data.entities.entities.player.Hands
|
import de.bixilon.minosoft.data.entities.entities.player.Hands
|
||||||
|
import de.bixilon.minosoft.data.entities.wawla.EntityWawlaProvider
|
||||||
import de.bixilon.minosoft.data.registries.effects.attributes.DefaultStatusEffectAttributeNames
|
import de.bixilon.minosoft.data.registries.effects.attributes.DefaultStatusEffectAttributeNames
|
||||||
import de.bixilon.minosoft.data.registries.entities.EntityType
|
import de.bixilon.minosoft.data.registries.entities.EntityType
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||||
@ -30,7 +31,7 @@ import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.sp
|
|||||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.horizontal
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.horizontal
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
abstract class LivingEntity(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation) : Entity(connection, entityType, data, position, rotation) {
|
abstract class LivingEntity(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation) : Entity(connection, entityType, data, position, rotation), EntityWawlaProvider {
|
||||||
private val entityEffectParticle = connection.registries.particleType[EntityEffectParticle]
|
private val entityEffectParticle = connection.registries.particleType[EntityEffectParticle]
|
||||||
private val ambientEntityEffectParticle = connection.registries.particleType[AmbientEntityEffectParticle]
|
private val ambientEntityEffectParticle = connection.registries.particleType[AmbientEntityEffectParticle]
|
||||||
|
|
||||||
|
@ -19,14 +19,17 @@ import de.bixilon.minosoft.data.entities.EntityRotation
|
|||||||
import de.bixilon.minosoft.data.entities.data.EntityData
|
import de.bixilon.minosoft.data.entities.data.EntityData
|
||||||
import de.bixilon.minosoft.data.entities.data.EntityDataField
|
import de.bixilon.minosoft.data.entities.data.EntityDataField
|
||||||
import de.bixilon.minosoft.data.entities.entities.SynchronizedEntityData
|
import de.bixilon.minosoft.data.entities.entities.SynchronizedEntityData
|
||||||
|
import de.bixilon.minosoft.data.entities.wawla.EntityWawlaProvider
|
||||||
import de.bixilon.minosoft.data.registries.entities.EntityFactory
|
import de.bixilon.minosoft.data.registries.entities.EntityFactory
|
||||||
import de.bixilon.minosoft.data.registries.entities.EntityType
|
import de.bixilon.minosoft.data.registries.entities.EntityType
|
||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
|
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.util.KUtil
|
|
||||||
|
|
||||||
open class ItemFrame(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation) : HangingEntity(connection, entityType, data, position, rotation) {
|
open class ItemFrame(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation) : HangingEntity(connection, entityType, data, position, rotation), EntityWawlaProvider {
|
||||||
|
|
||||||
@get:SynchronizedEntityData
|
@get:SynchronizedEntityData
|
||||||
val item: ItemStack?
|
val item: ItemStack?
|
||||||
@ -39,10 +42,15 @@ open class ItemFrame(connection: PlayConnection, entityType: EntityType, data: E
|
|||||||
@get:SynchronizedEntityData
|
@get:SynchronizedEntityData
|
||||||
var facing: Directions = Directions.NORTH
|
var facing: Directions = Directions.NORTH
|
||||||
|
|
||||||
|
|
||||||
override fun setObjectData(data: Int) {
|
override fun setObjectData(data: Int) {
|
||||||
facing = Directions[data]
|
facing = Directions[data]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getWawlaInformation(connection: PlayConnection, target: EntityTarget): ChatComponent {
|
||||||
|
return TextComponent("Item: $item")
|
||||||
|
}
|
||||||
|
|
||||||
companion object : EntityFactory<ItemFrame> {
|
companion object : EntityFactory<ItemFrame> {
|
||||||
override val identifier: ResourceLocation = minecraft("item_frame")
|
override val identifier: ResourceLocation = minecraft("item_frame")
|
||||||
private val ITEM_DATA = EntityDataField("ITEM_FRAME_ITEM")
|
private val ITEM_DATA = EntityDataField("ITEM_FRAME_ITEM")
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.entities.wawla
|
package de.bixilon.minosoft.data.entities.wawla
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
interface EntityWawlaProvider {
|
interface EntityWawlaProvider {
|
||||||
|
|
||||||
fun getWawlaInformation(connection: PlayConnection, target: EntityTarget): EntityWawlaInformation
|
fun getWawlaInformation(connection: PlayConnection, target: EntityTarget): ChatComponent
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.registries.blocks.wawla
|
package de.bixilon.minosoft.data.registries.blocks.wawla
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
interface BlockWawlaProvider {
|
interface BlockWawlaProvider {
|
||||||
|
|
||||||
fun getWawlaInformation(connection: PlayConnection, target: BlockTarget): BlockWawlaInformation
|
fun getWawlaInformation(connection: PlayConnection, target: BlockTarget): ChatComponent
|
||||||
}
|
}
|
||||||
|
@ -35,15 +35,28 @@ import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
|||||||
class WawlaHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedElement, AsyncDrawable {
|
class WawlaHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedElement, AsyncDrawable {
|
||||||
private var element: WawlaElement? = null
|
private var element: WawlaElement? = null
|
||||||
|
|
||||||
|
val profile = guiRenderer.connection.profiles.gui.hud.wawla
|
||||||
|
|
||||||
override val layoutOffset: Vec2i
|
override val layoutOffset: Vec2i
|
||||||
get() = Vec2i((guiRenderer.scaledSize.x - ((element?.size?.x ?: 0) + BACKGROUND_SIZE)) / 2, BACKGROUND_SIZE)
|
get() = Vec2i((guiRenderer.scaledSize.x - ((element?.size?.x ?: 0) + BACKGROUND_SIZE)) / 2, BACKGROUND_SIZE)
|
||||||
|
override val skipDraw: Boolean
|
||||||
|
get() = !profile.enabled
|
||||||
|
|
||||||
|
|
||||||
override fun drawAsync() {
|
override fun drawAsync() {
|
||||||
val target = context.camera.targetHandler.target
|
val target = context.camera.targetHandler.target
|
||||||
val element: WawlaElement? = when (target) {
|
|
||||||
is BlockTarget -> BlockWawlaElement(this, target)
|
if (target == null) {
|
||||||
is EntityTarget -> EntityWawlaElement(this, target)
|
this.element = null
|
||||||
|
forceSilentApply()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val distance = target.distance
|
||||||
|
|
||||||
|
|
||||||
|
val element: WawlaElement? = when {
|
||||||
|
target is BlockTarget && profile.block.enabled && (!profile.limitReach || distance <= context.connection.player.reachDistance) -> BlockWawlaElement(this, target)
|
||||||
|
target is EntityTarget && profile.entity.enabled && (!profile.limitReach || distance <= 3.0) -> EntityWawlaElement(this, target) // TODO: use constant for distance
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
this.element = element
|
this.element = element
|
||||||
|
@ -71,11 +71,11 @@ class BlockWawlaElement(wawla: WawlaHUDElement, private val target: BlockTarget)
|
|||||||
val component = BaseComponent()
|
val component = BaseComponent()
|
||||||
|
|
||||||
if (target.blockState.block is BlockWawlaProvider) {
|
if (target.blockState.block is BlockWawlaProvider) {
|
||||||
component += target.blockState.block.getWawlaInformation(context.connection, target).text
|
component += target.blockState.block.getWawlaInformation(context.connection, target)
|
||||||
component += "\n"
|
component += "\n"
|
||||||
}
|
}
|
||||||
if (target.entity is BlockWawlaProvider) {
|
if (target.entity is BlockWawlaProvider) {
|
||||||
component += target.entity.getWawlaInformation(context.connection, target).text
|
component += target.entity.getWawlaInformation(context.connection, target)
|
||||||
component += "\n"
|
component += "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,13 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.wawla.entity
|
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.wawla.entity
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||||
|
import de.bixilon.kutil.math.simple.DoubleMath.rounded10
|
||||||
|
import de.bixilon.minosoft.data.container.EquipmentSlots
|
||||||
|
import de.bixilon.minosoft.data.entities.entities.LivingEntity
|
||||||
import de.bixilon.minosoft.data.entities.wawla.EntityWawlaProvider
|
import de.bixilon.minosoft.data.entities.wawla.EntityWawlaProvider
|
||||||
|
import de.bixilon.minosoft.data.registries.effects.attributes.DefaultStatusEffectAttributeNames
|
||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces
|
import de.bixilon.minosoft.data.registries.identified.Namespaces
|
||||||
|
import de.bixilon.minosoft.data.text.BaseComponent
|
||||||
import de.bixilon.minosoft.data.text.TextComponent
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
||||||
@ -27,6 +32,7 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
|||||||
|
|
||||||
class EntityWawlaElement(wawla: WawlaHUDElement, private val target: EntityTarget) : WawlaElement(wawla) {
|
class EntityWawlaElement(wawla: WawlaHUDElement, private val target: EntityTarget) : WawlaElement(wawla) {
|
||||||
private val name = createName()
|
private val name = createName()
|
||||||
|
private val base = createBaseInformation()
|
||||||
private val additional = createAdditionalInformation()
|
private val additional = createAdditionalInformation()
|
||||||
private val mod = createMod()
|
private val mod = createMod()
|
||||||
|
|
||||||
@ -64,10 +70,32 @@ class EntityWawlaElement(wawla: WawlaHUDElement, private val target: EntityTarge
|
|||||||
return TextElement(guiRenderer, TextComponent(namespace).color(ChatColors.BLUE), background = false)
|
return TextElement(guiRenderer, TextComponent(namespace).color(ChatColors.BLUE), background = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createBaseInformation(): TextElement? {
|
||||||
|
val entity = target.entity
|
||||||
|
val component = BaseComponent()
|
||||||
|
if (entity is LivingEntity && wawla.profile.entity.health) {
|
||||||
|
component += TextComponent("Health: ${entity.health.rounded10}/${java.lang.Float.max(0.0f, entity.getAttributeValue(DefaultStatusEffectAttributeNames.GENERIC_MAX_HEALTH).toFloat() + entity.absorptionHearts)}")
|
||||||
|
component += "\n"
|
||||||
|
}
|
||||||
|
val hand = entity.equipment[EquipmentSlots.MAIN_HAND]
|
||||||
|
if (wawla.profile.entity.hand && hand != null) {
|
||||||
|
component += TextComponent("Hand: ${hand.item.count}x ${hand.item.item}")
|
||||||
|
component += "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.length == 0) return null
|
||||||
|
|
||||||
|
component.setFallbackColor(ChatColors.GRAY)
|
||||||
|
|
||||||
|
return TextElement(guiRenderer, component, background = false)
|
||||||
|
}
|
||||||
|
|
||||||
private fun createAdditionalInformation(): TextElement? {
|
private fun createAdditionalInformation(): TextElement? {
|
||||||
if (target.entity !is EntityWawlaProvider) return null
|
if (target.entity !is EntityWawlaProvider) return null
|
||||||
|
|
||||||
val text = target.entity.getWawlaInformation(context.connection, target).text
|
val text = target.entity.getWawlaInformation(context.connection, target)
|
||||||
|
|
||||||
|
if (text.length == 0) return null // isEmpty
|
||||||
|
|
||||||
text.setFallbackColor(ChatColors.GRAY)
|
text.setFallbackColor(ChatColors.GRAY)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user