mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
remove some code warnings
This commit is contained in:
parent
046c9b3b4b
commit
7452020727
@ -126,6 +126,8 @@ class MinecraftAssetsManager(
|
||||
)
|
||||
), hash, false)
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ class Camera(
|
||||
lastMouseY = yPos
|
||||
xOffset *= mouseSensitivity
|
||||
yOffset *= mouseSensitivity
|
||||
var yaw = xOffset.toFloat() + (playerEntity.rotation?.headYaw ?: 0f)
|
||||
var pitch = yOffset.toFloat() + (playerEntity.rotation?.pitch ?: 0f)
|
||||
var yaw = xOffset.toFloat() + playerEntity.rotation.headYaw
|
||||
var pitch = yOffset.toFloat() + playerEntity.rotation.pitch
|
||||
|
||||
// make sure that when pitch is out of bounds, screen doesn't get flipped
|
||||
if (pitch > 89.9) {
|
||||
|
@ -50,7 +50,7 @@ object RenderConstants {
|
||||
|
||||
const val MAXIMUM_CALLS_PER_FRAME = 10
|
||||
|
||||
const val DISABLE_LIGHTING = true
|
||||
const val DISABLE_LIGHTING = false
|
||||
|
||||
const val RENDER_BLOCKS = true
|
||||
const val RENDER_FLUIDS = true
|
||||
|
@ -250,7 +250,7 @@ class RenderWindow(
|
||||
|
||||
textures.preLoad(connection.version.assetsManager)
|
||||
|
||||
font.loadAtlas(textures)
|
||||
font.loadAtlas()
|
||||
textures.load()
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ class Font {
|
||||
preLoaded = true
|
||||
}
|
||||
|
||||
fun loadAtlas(textureArray: TextureArray) {
|
||||
fun loadAtlas() {
|
||||
check(!loaded) { "Font has already a atlas texture!" }
|
||||
check(preLoaded) { "Font hasn't been preloaded!" }
|
||||
|
||||
|
@ -52,7 +52,7 @@ class HUDRenderer(val connection: Connection, val renderWindow: RenderWindow) :
|
||||
override fun init() {
|
||||
hudShader.load(Minosoft.MINOSOFT_ASSETS_MANAGER)
|
||||
|
||||
val hudImages = HUDAtlasElement.deserialize(Minosoft.MINOSOFT_ASSETS_MANAGER.readJsonAsset(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "mapping/atlas.json")).toResourceLocationMap(), connection.version.versionId)
|
||||
val hudImages = HUDAtlasElement.deserialize(Minosoft.MINOSOFT_ASSETS_MANAGER.readJsonAsset(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "mapping/atlas.json")).toResourceLocationMap())
|
||||
this.hudAtlasElements = hudImages.second
|
||||
|
||||
renderWindow.textures.allTextures.addAll(hudImages.first.toList())
|
||||
|
@ -41,16 +41,16 @@ data class HUDAtlasElement(
|
||||
private val UV_START_ADD = Vec2(0, 0.000015f) // ToDo: This fixes the "half pixel bug"
|
||||
|
||||
|
||||
fun deserialize(json: Map<ResourceLocation, JsonObject>, versionId: Int): Pair<Collection<Texture>, Map<ResourceLocation, HUDAtlasElement>> {
|
||||
fun deserialize(json: Map<ResourceLocation, JsonObject>): Pair<Collection<Texture>, Map<ResourceLocation, HUDAtlasElement>> {
|
||||
val textures: MutableMap<ResourceLocation, Texture> = mutableMapOf()
|
||||
val ret: MutableMap<ResourceLocation, HUDAtlasElement> = mutableMapOf()
|
||||
for ((resourceLocation, data) in json) {
|
||||
ret[resourceLocation] = deserialize(data, textures, versionId)
|
||||
ret[resourceLocation] = deserialize(data, textures)
|
||||
}
|
||||
return Pair(textures.values, ret)
|
||||
}
|
||||
|
||||
fun deserialize(json: JsonObject, textures: MutableMap<ResourceLocation, Texture>, versionId: Int): HUDAtlasElement {
|
||||
fun deserialize(json: JsonObject, textures: MutableMap<ResourceLocation, Texture>): HUDAtlasElement {
|
||||
val keys: MutableSet<Int> = mutableSetOf()
|
||||
var textureResourceLocation: ResourceLocation? = json["texture"]?.asString?.let { ResourceLocation(it) }
|
||||
for (key in json["versions"].asJsonObject.keySet()) {
|
||||
|
@ -107,8 +107,7 @@ class HUDWorldDebugElement(hudRenderer: HUDRenderer) : DebugScreen(hudRenderer)
|
||||
|
||||
|
||||
private fun getPosition(): String {
|
||||
return "${formatCoordinate(camera.cameraPosition.x)} / ${formatCoordinate(camera.cameraPosition.y)} / ${formatCoordinate(camera.cameraPosition.z)}"
|
||||
return "${formatCoordinate(camera.playerEntity.position?.x!!)} / ${formatCoordinate(camera.playerEntity.position?.y!!)} / ${formatCoordinate(camera.playerEntity.position?.z!!)}"
|
||||
return "${formatCoordinate(camera.playerEntity.position.x)} / ${formatCoordinate(camera.playerEntity.position.y)} / ${formatCoordinate(camera.playerEntity.position.z)}"
|
||||
}
|
||||
|
||||
private fun getBlockPosition(): String {
|
||||
@ -120,8 +119,8 @@ class HUDWorldDebugElement(hudRenderer: HUDRenderer) : DebugScreen(hudRenderer)
|
||||
}
|
||||
|
||||
private fun getFacing(): String {
|
||||
val yaw = hudRenderer.renderWindow.camera.playerEntity.rotation?.yaw!!
|
||||
val pitch = hudRenderer.renderWindow.camera.playerEntity.rotation?.pitch!!
|
||||
val yaw = hudRenderer.renderWindow.camera.playerEntity.rotation.yaw
|
||||
val pitch = hudRenderer.renderWindow.camera.playerEntity.rotation.pitch
|
||||
val direction = Directions.byDirection(camera.cameraFront)
|
||||
return "${Directions.byDirection(camera.cameraFront).name.toLowerCase()} ${direction.directionVector} (${formatRotation(yaw.toDouble())} / ${formatRotation(pitch.toDouble())})"
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ class PacketMultiBlockChange() : ClientboundPacket() {
|
||||
buffer.readChunkPosition()
|
||||
}
|
||||
val count = buffer.readShort()
|
||||
val dataSize = buffer.readInt() // should be count * 4
|
||||
val dataSize = buffer.readInt()
|
||||
check(dataSize == count * 4) { "MultiBlockChangePacket needs 4 bytes per block change!" }
|
||||
for (i in 0 until count) {
|
||||
val raw = buffer.readInt()
|
||||
val meta = (raw and 0xF)
|
||||
|
@ -40,22 +40,20 @@ class PacketUpdateLight(buffer: InByteBuffer) : ClientboundPacket() {
|
||||
|
||||
val skyLightMask: BitSet
|
||||
val blockLightMask: BitSet
|
||||
val emptySkyLightMask: BitSet
|
||||
val emptyBlockLightMask: BitSet
|
||||
|
||||
if (buffer.versionId < ProtocolVersions.V_20W49A) {
|
||||
skyLightMask = KUtil.bitSetOf(buffer.readVarLong())
|
||||
blockLightMask = KUtil.bitSetOf(buffer.readVarLong())
|
||||
emptyBlockLightMask = KUtil.bitSetOf(buffer.readVarLong())
|
||||
emptySkyLightMask = KUtil.bitSetOf(buffer.readVarLong())
|
||||
buffer.readVarLong() // emptyBlockLightMask
|
||||
buffer.readVarLong() // emptySkyLightMask
|
||||
} else {
|
||||
skyLightMask = BitSet.valueOf(buffer.readLongArray())
|
||||
blockLightMask = BitSet.valueOf(buffer.readLongArray())
|
||||
emptySkyLightMask = BitSet.valueOf(buffer.readLongArray())
|
||||
emptyBlockLightMask = BitSet.valueOf(buffer.readLongArray())
|
||||
buffer.readLongArray() // emptySkyLightMask
|
||||
buffer.readLongArray() // emptyBlockLightMask
|
||||
}
|
||||
|
||||
lightAccessor = readLightPacket(buffer, skyLightMask, blockLightMask, emptyBlockLightMask, emptySkyLightMask, buffer.connection.world.dimension!!)
|
||||
lightAccessor = readLightPacket(buffer, skyLightMask, blockLightMask, buffer.connection.world.dimension!!)
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
|
@ -22,9 +22,9 @@ object CombatEventPacketFactory {
|
||||
|
||||
fun createPacket(buffer: InByteBuffer): ClientboundPacket {
|
||||
return when (CombatEvents.VALUES[buffer.readVarInt()]) {
|
||||
CombatEvents.ENTER_COMBAT -> EnterCombatEventPacket(buffer)
|
||||
CombatEvents.END_COMBAT -> EnterCombatEventPacket(buffer)
|
||||
CombatEvents.ENTITY_DEATH -> EnterCombatEventPacket(buffer)
|
||||
CombatEvents.ENTER_COMBAT -> EnterCombatEventPacket()
|
||||
CombatEvents.END_COMBAT -> EnterCombatEventPacket()
|
||||
CombatEvents.ENTITY_DEATH -> EnterCombatEventPacket()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,9 @@
|
||||
package de.bixilon.minosoft.protocol.packets.clientbound.play.combat
|
||||
|
||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
|
||||
class EnterCombatEventPacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||
class EnterCombatEventPacket : ClientboundPacket() {
|
||||
|
||||
override fun log() {
|
||||
Log.protocol("[IN] Received enter combat event")
|
||||
|
@ -14,10 +14,9 @@
|
||||
package de.bixilon.minosoft.protocol.packets.clientbound.play.title
|
||||
|
||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
|
||||
class HideTitlePacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||
class HideTitlePacket : ClientboundPacket() {
|
||||
|
||||
override fun log() {
|
||||
Log.protocol("[IN] Received hide title")
|
||||
|
@ -14,10 +14,9 @@
|
||||
package de.bixilon.minosoft.protocol.packets.clientbound.play.title
|
||||
|
||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
|
||||
class ResetTitlePacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||
class ResetTitlePacket : ClientboundPacket() {
|
||||
|
||||
override fun log() {
|
||||
Log.protocol("[IN] Received reset title")
|
||||
|
@ -26,8 +26,8 @@ object TitlePacketFactory {
|
||||
TitleActions.SET_SUBTITLE -> SetSubTitlePacket(buffer)
|
||||
TitleActions.SET_ACTION_BAR -> SetActionBarTextPacket(buffer)
|
||||
TitleActions.SET_TIMES_AND_DISPLAY -> SetTimesAndDisplayPacket(buffer)
|
||||
TitleActions.HIDE -> HideTitlePacket(buffer)
|
||||
TitleActions.RESET -> ResetTitlePacket(buffer)
|
||||
TitleActions.HIDE -> HideTitlePacket()
|
||||
TitleActions.RESET -> ResetTitlePacket()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ object ChunkUtil {
|
||||
|
||||
for (blockNumber in 0 until ProtocolDefinition.BLOCKS_PER_SECTION) {
|
||||
var blockId = (blockData[arrayPosition].toInt() and 0xFF) shl 4
|
||||
var blockMeta = 0
|
||||
var blockMeta: Int
|
||||
// get block meta and shift and add (merge) id if needed
|
||||
if (arrayPosition % 2 == 0) {
|
||||
// high bits
|
||||
|
@ -22,7 +22,7 @@ import java.util.*
|
||||
|
||||
object LightUtil {
|
||||
|
||||
fun readLightPacket(buffer: InByteBuffer, skyLightMask: BitSet, blockLightMask: BitSet, emptyBlockLightMask: BitSet, emptySkyLightMask: BitSet, dimension: Dimension): LightAccessor {
|
||||
fun readLightPacket(buffer: InByteBuffer, skyLightMask: BitSet, blockLightMask: BitSet, dimension: Dimension): LightAccessor {
|
||||
// ToDo
|
||||
val skyLight = if (dimension.hasSkyLight) {
|
||||
readLightArray(buffer, skyLightMask, dimension)
|
||||
|
Loading…
x
Reference in New Issue
Block a user