some renaming

This commit is contained in:
Moritz Zwerger committed 2025-12-30 18:30:43 +01:00
1 parent 86a2f5da12
commit d511019cbd
27 files changed
+59 -61

No files matched your search

@@ -31,8 +31,8 @@ class RenderTestLoader {
fun init() {
val session = createSession(5)
val latch = SimpleLatch(1)
session::assetsManager.forceSet(AssetsLoader.create(session.profiles.resources, session.version))
session.assetsManager.load(latch)
session::assets.forceSet(AssetsLoader.create(session.profiles.resources, session.version))
session.assets.load(latch)
session::error.forceSet(DataObserver(null))
RenderTestUtil.rendering = Rendering(session)
RenderTestUtil.rendering.start(latch, audio = false)
@@ -48,7 +48,7 @@ object BakedModelTestUtil {
for (name in names) {
assets.push(name.toResourceLocation().texture(), texture)
}
session::assetsManager.forceSet(assets.box())
session::assets.forceSet(assets.box())
return rendering.context.textures
}
@@ -26,10 +26,8 @@ import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.models.loader.SkeletalLoader.Companion.sModel
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalTransform
import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.system.dummy.DummyRenderSystem
import de.bixilon.minosoft.gui.rendering.system.dummy.texture.DummyTexture
import de.bixilon.minosoft.gui.rendering.system.dummy.texture.DummyTextureLoader
import de.bixilon.minosoft.gui.rendering.system.dummy.texture.DummyTextureManager
import de.bixilon.minosoft.protocol.network.session.play.SessionTestUtil
import de.bixilon.minosoft.test.ITUtil.allocate
@@ -49,7 +47,7 @@ class SkeletalLoaderTest {
val manager = MemoryAssetsManager()
manager.push(dummyModel, SkeletalLoaderTest::class.java.getResourceAsStream("/model/skeletal/dummy.smodel")!!.readAll())
context.session.assetsManager.add(manager)
context.session.assets.add(manager)
return context
@@ -58,7 +58,7 @@ object SessionTestUtil {
private val CONNECTION = PlaySession::connection.field
private val EVENTS = PlaySession::events.field
private val PROFILES = PlaySession::profiles.field
private val ASSETS_MANAGER = PlaySession::assetsManager.field
private val ASSETS_MANAGER = PlaySession::assets.field
private val STATE = PlaySession::state.field
private val TAGS = PlaySession::tags.field
private val LEGACY_TAGS = PlaySession::legacyTags.field
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 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.
*
@@ -22,16 +22,16 @@ import de.bixilon.minosoft.tags.TagManager
abstract class LeveledToolItem(identifier: ResourceLocation) : ToolItem(identifier), LeveledTool {
private fun isLevelSuitable(tagManager: TagManager, blockState: BlockState): Boolean? {
private fun isLevelSuitable(tags: TagManager, state: BlockState): Boolean? {
val miningTag = this.tag ?: return null
val blockTags = tagManager[MinecraftTagTypes.BLOCK] ?: return null
val tag = blockTags[miningTag] ?: return null
if (blockState.block !in tag) {
val tags = tags[MinecraftTagTypes.BLOCK] ?: return null
val tag = tags[miningTag] ?: return null
if (state.block !in tag) {
return false
}
for (level in ToolLevels.REVERSED) {
val levelTag = blockTags[level.tag ?: continue] ?: continue
if (blockState.block in levelTag) {
val levelTag = tags[level.tag ?: continue] ?: continue
if (state.block in levelTag) {
// minimum tool level required
return this.level >= level
}
@@ -39,7 +39,7 @@ abstract class LeveledToolItem(identifier: ResourceLocation) : ToolItem(identifi
return true
}
override fun isLevelSuitable(session: PlaySession, blockState: BlockState): Boolean? {
return isLevelSuitable(session.tags, blockState) ?: isLevelSuitable(session.legacyTags, blockState)
override fun isLevelSuitable(session: PlaySession, state: BlockState): Boolean? {
return isLevelSuitable(session.tags, state) ?: isLevelSuitable(session.legacyTags, state)
}
}
@@ -29,22 +29,22 @@ abstract class ToolItem(identifier: ResourceLocation) : Item(identifier), Mining
open val tag: ResourceLocation? get() = null
private fun isInTag(tagManager: TagManager, blockState: BlockState): Boolean? {
private fun isInTag(tags: TagManager, state: BlockState): Boolean? {
val miningTag = this.tag ?: return null
val blockTags = tagManager[MinecraftTagTypes.BLOCK] ?: return null
val tag = blockTags[miningTag] ?: return null
if (blockState.block !in tag) {
val tags = tags[MinecraftTagTypes.BLOCK] ?: return null
val tag = tags[miningTag] ?: return null
if (state.block !in tag) {
return false
}
return true
}
private fun isInTag(session: PlaySession, blockState: BlockState): Boolean? {
return isInTag(session.tags, blockState) ?: isInTag(session.legacyTags, blockState)
private fun isInTag(session: PlaySession, state: BlockState): Boolean? {
return isInTag(session.tags, state) ?: isInTag(session.legacyTags, state)
}
protected open fun isLevelSuitable(session: PlaySession, blockState: BlockState): Boolean? {
return isInTag(session, blockState)
protected open fun isLevelSuitable(session: PlaySession, state: BlockState): Boolean? {
return isInTag(session, state)
}
override fun isSuitableFor(session: PlaySession, state: BlockState, stack: ItemStack): Boolean {
@@ -23,7 +23,6 @@ import de.bixilon.kutil.unit.UnitFormatter.format
import de.bixilon.minosoft.gui.rendering.RenderUtil.pause
import de.bixilon.minosoft.gui.rendering.RenderUtil.runAsync
import de.bixilon.minosoft.gui.rendering.font.manager.FontManager
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
import de.bixilon.minosoft.gui.rendering.input.key.DebugKeyBindings
import de.bixilon.minosoft.gui.rendering.input.key.DefaultKeyBindings
import de.bixilon.minosoft.gui.rendering.renderer.renderer.DefaultRenderer
@@ -63,7 +62,7 @@ object RenderLoader {
registerRenderer()
window.init(session.profiles.rendering)
ignoreAll { window.setDefaultIcon(session.assetsManager) }
ignoreAll { window.setDefaultIcon(session.assets) }
camera.init()
@@ -78,7 +77,7 @@ object RenderLoader {
// Init stage
val initLatch = ParentLatch(1, renderLatch)
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "Generating font, gathering textures and loading models (after ${stopwatch.lab().format()})..." }
initLatch.inc(); runAsync { tints.init(session.assetsManager); initLatch.dec() }
initLatch.inc(); runAsync { tints.init(session.assets); initLatch.dec() }
textures.dynamic.load(initLatch); textures.dynamic.upload(initLatch)
textures.initializeSkins(session)
textures.loadDefaultTextures()
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 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.
*
@@ -33,7 +33,7 @@ object FontLoader {
fun load(context: RenderContext, manager: FontManager, fontIndex: ResourceLocation, latch: AbstractLatch?): Font? {
val fontIndex = context.session.assetsManager.getOrNull(fontIndex)?.readJsonObject() ?: return null
val fontIndex = context.session.assets.getOrNull(fontIndex)?.readJsonObject() ?: return null
val providersRaw = fontIndex["providers"].listCast<Map<String, Any>>()!!
val providers: Array<FontType?> = arrayOfNulls(providersRaw.size)
@@ -61,7 +61,7 @@ class LegacyUnicodeFontType(
private const val WIDTH_SCALE = FontProperties.CHAR_BASE_HEIGHT / CHAR_SIZE.toFloat()
override fun build(context: RenderContext, manager: FontManager, data: Map<String, Any>): LegacyUnicodeFontType? {
val assets = context.session.assetsManager
val assets = context.session.assets
val template = data["template"]?.toString() ?: throw IllegalArgumentException("template missing!")
val sizes = data.loadSizes(assets) ?: return null
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 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.
*
@@ -50,7 +50,7 @@ class UnihexFontType(
}
fun load(context: RenderContext, hexFile: ResourceLocation, sizes: List<SizeOverride>): UnihexFontType? {
val stream = ZipInputStream(context.session.assetsManager[hexFile])
val stream = ZipInputStream(context.session.assets[hexFile])
val buffered = BufferedInputStream(stream)
val chars = Int2ObjectOpenHashMap<ByteArray>()
@@ -50,7 +50,7 @@ class PowderSnowOverlay(context: RenderContext) : SimpleOverlay(context) {
private val OVERLAY_TEXTURE = "misc/powder_snow_outline".toResourceLocation().texture()
override fun build(context: RenderContext): PowderSnowOverlay? {
if (!context.session.assetsManager.contains(OVERLAY_TEXTURE)) {
if (!context.session.assets.contains(OVERLAY_TEXTURE)) {
// overlay not yet available (< 1.17)
return null
}
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 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.
*
@@ -31,7 +31,7 @@ class AtlasLoader(val context: RenderContext) {
fun loadElement(data: JsonObject): RawAtlasElement? {
val textureName = data["texture"]?.toResourceLocation()?.texture() ?: throw IllegalArgumentException("Missing texture!")
val assets = context.session.assetsManager.getAssetsManager(textureName) ?: return null
val assets = context.session.assets.getAssetsManager(textureName) ?: return null
return RawAtlasElement.deserialize(textureName, assets, data)
}
@@ -61,7 +61,7 @@ class AtlasLoader(val context: RenderContext) {
}
fun load(name: ResourceLocation) {
val all = context.session.assetsManager.getAll(name.atlas())
val all = context.session.assets.getAll(name.atlas())
val data: MutableJsonObject = mutableMapOf()
for (file in all) {
@@ -37,7 +37,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
class BlockLoader(private val loader: ModelLoader) {
private val cache: MutableMap<ResourceLocation, BlockModel> = LockMap(HashMap(loader.context.session.registries.block.size))
val assets = loader.context.session.assetsManager
val assets = loader.context.session.assets
val version = loader.context.session.version
fun loadBlock(name: ResourceLocation): BlockModel? {
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 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.
*
@@ -34,7 +34,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
class ItemLoader(private val loader: ModelLoader) {
private val cache: MutableMap<ResourceLocation, ItemModel> = HashMap(loader.context.session.registries.item.size)
val assets = loader.context.session.assetsManager
val assets = loader.context.session.assets
val version = loader.context.session.version
fun loadItem(name: ResourceLocation): ItemModel? {
@@ -28,7 +28,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
class ModelLoader(
val context: RenderContext,
) {
val packFormat = context.session.assetsManager.properties.pack.format
val packFormat = context.session.assets.properties.pack.format
val fluids = FluidModelLoader(this)
val block = BlockLoader(this)
val item = ItemLoader(this)
@@ -41,7 +41,7 @@ class SkeletalLoader(private val loader: ModelLoader) {
for ((_, registered) in this.registered) {
var template = templates[registered.template]
if (template == null) {
template = loader.context.session.assetsManager.getOrNull(registered.template)?.readJson()
template = loader.context.session.assets.getOrNull(registered.template)?.readJson()
if (template == null) {
Log.log(LogMessageType.LOADING, LogLevels.WARN) { "Can not find skeletal model ${registered.template}" }
continue
@@ -86,7 +86,7 @@ class CloudRenderer(
}
}
sky.profile.clouds::maxDistance.observe(this, instant = true) { this.maxDistance = it }
sky.profile.clouds::generator.observe(this, instant = true) { this.generator = CloudGenerator.of(it, context.session.assetsManager) } // TODO: flush cache
sky.profile.clouds::generator.observe(this, instant = true) { this.generator = CloudGenerator.of(it, context.session.assets) } // TODO: flush cache
session::state.observe(this) {
if (it == PlaySessionStates.SPAWNING) {
if (baseHeight == null) return@observe
@@ -199,7 +199,7 @@ class AudioPlayer(
}
position?.let { if (!shouldPlay(sound, position)) return }
queue += add@{
sound.load(session.assetsManager)
sound.load(session.assets)
position?.let { if (!shouldPlay(sound, position)) return@add }
val source = getAvailableSource()
if (source == null) {
@@ -34,7 +34,7 @@ class SoundManager(
fun load() {
val soundsIndex = session.assetsManager.getOrNull(SOUNDS_INDEX_FILE)?.readJsonObject()
val soundsIndex = session.assets.getOrNull(SOUNDS_INDEX_FILE)?.readJsonObject()
if (soundsIndex == null) {
Log.log(LogMessageType.AUDIO, LogLevels.WARN) { "Can not find $SOUNDS_INDEX_FILE. Can not load audio files!" }
return
@@ -62,7 +62,7 @@ class SoundManager(
if (!sound.preload) {
continue
}
sound.load(session.assetsManager)
sound.load(session.assets)
}
}
}
@@ -80,7 +80,7 @@ class GLSLShaderCode(
}
val includeCode = GLSLShaderCode(context, context.session.assetsManager[include].readAsString())
val includeCode = GLSLShaderCode(context, context.session.assets[include].readAsString())
code.appendLine()
code.append("// ").append(STAR).appendLine()
@@ -50,7 +50,7 @@ abstract class TextureManager {
fun initializeSkins(session: PlaySession) {
skins = SkinManager(this)
skins.initialize(session.account, session.assetsManager)
skins.initialize(session.account, session.assets)
}
fun use(shader: TextureShader, name: String = ShaderUniforms.TEXTURES) {
@@ -28,7 +28,7 @@ abstract class FileTextureLoader(val file: ResourceLocation) : TextureLoader {
protected abstract fun read(assets: AssetsManager): TextureBuffer
override fun load(context: RenderContext): TextureLoaderResult {
val assets = context.session.assetsManager
val assets = context.session.assets
val buffer = read(assets)
val properties = assets.readImageProperties(file)
@@ -94,7 +94,7 @@ class Texture(
if (error !is FileNotFoundException) {
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { error }
}
return TextureLoaderResult(context.session.assetsManager[RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION].readTexture(), null)
return TextureLoaderResult(context.session.assets[RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION].readTexture(), null)
}
}
@@ -54,7 +54,7 @@ class OpenGlNativeShader(
private val uniformLocations: Object2IntOpenHashMap<String> = Object2IntOpenHashMap()
private fun load(file: ResourceLocation, type: ShaderType, code: String?): Int {
val code = GLSLShaderCode(context, code ?: context.session.assetsManager[file].readAsString(), file)
val code = GLSLShaderCode(context, code ?: context.session.assets[file].readAsString(), file)
system.log { "Compiling shader $file" }
code.defines += defines
@@ -81,7 +81,7 @@ class OpenGlNativeShader(
}
override fun load() {
val geometryCode = geometry?.let { catchAll { context.session.assetsManager[it].readAsString() } }
val geometryCode = geometry?.let { catchAll { context.session.assets[it].readAsString() } }
if (geometryCode != null) {
defines["HAS_GEOMETRY_SHADER"] = " "
}
@@ -95,7 +95,7 @@ class PlaySession(
val sequence = AtomicInteger(1)
lateinit var assetsManager: SessionAssetsManager
lateinit var assets: SessionAssetsManager
private set
lateinit var language: Translator
@@ -144,7 +144,7 @@ class PlaySession(
}
} else {
established = true
assetsManager.unload()
assets.unload()
state = PlaySessionStates.DISCONNECTED
ACTIVE_CONNECTIONS -= this
if (CLI.session === this) {
@@ -204,8 +204,8 @@ class PlaySession(
worker += {
Log.log(LogMessageType.ASSETS, LogLevels.INFO) { "Downloading and verifying assets. This might take a while..." }
assetsManager = AssetsLoader.create(profiles.resources, version)
assetsManager.load(latch)
assets = AssetsLoader.create(profiles.resources, version)
assets.load(latch)
Log.log(LogMessageType.ASSETS, LogLevels.INFO) { "Assets verified!" }
}
@@ -219,7 +219,7 @@ class PlaySession(
state = PlaySessionStates.LOADING
language = LanguageUtil.load(profiles.session.language ?: profiles.eros.general.language, version, assetsManager)
language = LanguageUtil.load(profiles.session.language ?: profiles.eros.general.language, version, assets)
this::player.forceSet(LocalPlayerEntity(account, this, keyManagement))
world.entities.add(null, null, player)
@@ -236,8 +236,8 @@ class PlaySession(
}
} catch (exception: Throwable) {
Log.log(LogMessageType.LOADING, level = LogLevels.FATAL) { exception }
if (this::assetsManager.isInitialized) {
assetsManager.unload()
if (this::assets.isInitialized) {
assets.unload()
}
error = exception
retry = false
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 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.
*
@@ -63,7 +63,7 @@ class ClientSettingsManager(
return
}
this.language = language
session.language = LanguageUtil.load(language, session.version, session.assetsManager)
session.language = LanguageUtil.load(language, session.version, session.assets)
sendClientSettings()
}
@@ -13,6 +13,7 @@
package de.bixilon.minosoft.util
import de.bixilon.kutil.string.WhitespaceUtil.removeMultipleWhitespaces
import de.bixilon.kutil.unit.Bytes.Companion.bytes
import oshi.SystemInfo
@@ -25,5 +26,5 @@ object SystemInformation {
val SYSTEM_MEMORY = HARDWARE_SYSTEM_INFO.memory.total.bytes
val OS_TEXT: String = "${System.getProperty("os.name")}: ${SYSTEM_INFO.operatingSystem.family} ${SYSTEM_INFO.operatingSystem.bitness}bit"
val PROCESSOR_TEXT = "${RUNTIME.availableProcessors()}x ${HARDWARE_SYSTEM_INFO.processor.processorIdentifier.name.replace("\\s{2,}".toRegex(), "")}"
val PROCESSOR_TEXT = "${RUNTIME.availableProcessors()}x ${HARDWARE_SYSTEM_INFO.processor.processorIdentifier.name.removeMultipleWhitespaces()}"
}