wip load pre flattening registry

This commit is contained in:
Bixilon 2023-03-20 19:07:06 +01:00
parent 8859dac578
commit 2a78b941d3
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
7 changed files with 55 additions and 25 deletions

View File

@ -137,7 +137,7 @@ object VerifyIntegratedBlockRegistry {
fun verify(registries: Registries, version: Version) {
val error = StringBuilder()
val data = PixLyzerUtil.loadPixlyzerData(version, ResourcesProfile())["blocks"]!!.unsafeCast<Map<String, JsonObject>>()
val data = PixLyzerUtil.loadPixlyzerData(ResourcesProfile(), version)["blocks"]!!.unsafeCast<Map<String, JsonObject>>()
for ((id, value) in data) {
if (value["class"] == "AirBlock") {

View File

@ -41,7 +41,7 @@ object ITUtil {
pixlyzer[version]?.let { return it }
val registries = Registries(false)
val data = PixLyzerUtil.loadPixlyzerData(version, profile)
val data = PixLyzerUtil.loadPixlyzerData(profile, version)
registries.load(version, data, SimpleLatch(0))
pixlyzer[version] = registries

View File

@ -40,6 +40,9 @@ object AssetsVersionProperties {
}
operator fun get(version: Version): AssetsVersionProperty? {
if (!version.flattened) {
return PROPERTIES[Versions[PreFlattening.VERSION]]
}
return PROPERTIES[version]
}
}

View File

@ -0,0 +1,46 @@
/*
* 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.assets.properties.version
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
import de.bixilon.minosoft.data.entities.entities.player.RemotePlayerEntity
import de.bixilon.minosoft.data.registries.dimension.Dimension
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
import de.bixilon.minosoft.data.registries.entities.EntityType
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.protocol.versions.Version
import de.bixilon.minosoft.util.KUtil.toResourceLocation
object PreFlattening {
const val VERSION = "1.12.2"
fun loadRegistry(profile: ResourcesProfile, version: Version, latch: CountUpAndDownLatch): Registries {
val registries = Registries()
registries.loadEntities(version)
registries.loadDimensions()
return registries
}
@Deprecated("test only")
private fun Registries.loadEntities(version: Version) {
entityType[RemotePlayerEntity] = EntityType(RemotePlayerEntity.identifier, null, 1.0f, 1.0f, false, false, mutableMapOf(), RemotePlayerEntity, null)
}
@Deprecated("test only")
private fun Registries.loadDimensions() {
dimension[0] = Dimension("minecraft:overworld".toResourceLocation(), DimensionProperties())
}
}

View File

@ -49,7 +49,7 @@ object PixLyzerUtil {
return data.data.read()
}
fun loadPixlyzerData(version: Version, profile: ResourcesProfile): JsonObject {
fun loadPixlyzerData(profile: ResourcesProfile, version: Version): JsonObject {
val pixlyzerHash = AssetsVersionProperties[version]?.pixlyzerHash ?: throw IllegalStateException("$version has no pixlyzer data available!")
return verify(profile.source.pixlyzer, pixlyzerHash)
@ -57,7 +57,7 @@ object PixLyzerUtil {
fun loadRegistry(version: Version, profile: ResourcesProfile, latch: AbstractLatch): Registries {
val registries = Registries()
val data = loadPixlyzerData(version, profile)
val data = loadPixlyzerData(profile, version)
registries.load(version, data, latch)

View File

@ -1,16 +0,0 @@
/*
* Minosoft
* Copyright (C) 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.data.registries.registries
class PreFlatteningLoadingError : Exception("Sorry, but pre flattening versions (<1.13) are currently broken. Please take a look at issue #26 for more information (and the current state)")

View File

@ -14,6 +14,7 @@
package de.bixilon.minosoft.data.registries.registries
import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.minosoft.assets.properties.version.PreFlattening
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
import de.bixilon.minosoft.protocol.versions.Version
@ -21,11 +22,7 @@ import de.bixilon.minosoft.protocol.versions.Version
object RegistriesLoader {
fun load(profile: ResourcesProfile, version: Version, latch: AbstractLatch): Registries {
if (!version.flattened) {
// ToDo: Pre flattening support
throw PreFlatteningLoadingError()
}
val registries = PixLyzerUtil.loadRegistry(version, profile, latch)
val registries = if (!version.flattened) PreFlattening.loadRegistry(profile, version, latch) else PixLyzerUtil.loadRegistry(profile, version, latch)
registries.setDefaultParents(version)