mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
wip load pre flattening registry
This commit is contained in:
parent
8859dac578
commit
2a78b941d3
@ -137,7 +137,7 @@ object VerifyIntegratedBlockRegistry {
|
|||||||
|
|
||||||
fun verify(registries: Registries, version: Version) {
|
fun verify(registries: Registries, version: Version) {
|
||||||
val error = StringBuilder()
|
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) {
|
for ((id, value) in data) {
|
||||||
if (value["class"] == "AirBlock") {
|
if (value["class"] == "AirBlock") {
|
||||||
|
@ -41,7 +41,7 @@ object ITUtil {
|
|||||||
pixlyzer[version]?.let { return it }
|
pixlyzer[version]?.let { return it }
|
||||||
val registries = Registries(false)
|
val registries = Registries(false)
|
||||||
|
|
||||||
val data = PixLyzerUtil.loadPixlyzerData(version, profile)
|
val data = PixLyzerUtil.loadPixlyzerData(profile, version)
|
||||||
|
|
||||||
registries.load(version, data, SimpleLatch(0))
|
registries.load(version, data, SimpleLatch(0))
|
||||||
pixlyzer[version] = registries
|
pixlyzer[version] = registries
|
||||||
|
@ -40,6 +40,9 @@ object AssetsVersionProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(version: Version): AssetsVersionProperty? {
|
operator fun get(version: Version): AssetsVersionProperty? {
|
||||||
|
if (!version.flattened) {
|
||||||
|
return PROPERTIES[Versions[PreFlattening.VERSION]]
|
||||||
|
}
|
||||||
return PROPERTIES[version]
|
return PROPERTIES[version]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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())
|
||||||
|
}
|
||||||
|
}
|
@ -49,7 +49,7 @@ object PixLyzerUtil {
|
|||||||
return data.data.read()
|
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!")
|
val pixlyzerHash = AssetsVersionProperties[version]?.pixlyzerHash ?: throw IllegalStateException("$version has no pixlyzer data available!")
|
||||||
|
|
||||||
return verify(profile.source.pixlyzer, pixlyzerHash)
|
return verify(profile.source.pixlyzer, pixlyzerHash)
|
||||||
@ -57,7 +57,7 @@ object PixLyzerUtil {
|
|||||||
|
|
||||||
fun loadRegistry(version: Version, profile: ResourcesProfile, latch: AbstractLatch): Registries {
|
fun loadRegistry(version: Version, profile: ResourcesProfile, latch: AbstractLatch): Registries {
|
||||||
val registries = Registries()
|
val registries = Registries()
|
||||||
val data = loadPixlyzerData(version, profile)
|
val data = loadPixlyzerData(profile, version)
|
||||||
|
|
||||||
registries.load(version, data, latch)
|
registries.load(version, data, latch)
|
||||||
|
|
||||||
|
@ -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)")
|
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.data.registries.registries
|
package de.bixilon.minosoft.data.registries.registries
|
||||||
|
|
||||||
import de.bixilon.kutil.latch.AbstractLatch
|
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.config.profile.profiles.resources.ResourcesProfile
|
||||||
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
|
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
|
||||||
import de.bixilon.minosoft.protocol.versions.Version
|
import de.bixilon.minosoft.protocol.versions.Version
|
||||||
@ -21,11 +22,7 @@ import de.bixilon.minosoft.protocol.versions.Version
|
|||||||
object RegistriesLoader {
|
object RegistriesLoader {
|
||||||
|
|
||||||
fun load(profile: ResourcesProfile, version: Version, latch: AbstractLatch): Registries {
|
fun load(profile: ResourcesProfile, version: Version, latch: AbstractLatch): Registries {
|
||||||
if (!version.flattened) {
|
val registries = if (!version.flattened) PreFlattening.loadRegistry(profile, version, latch) else PixLyzerUtil.loadRegistry(profile, version, latch)
|
||||||
// ToDo: Pre flattening support
|
|
||||||
throw PreFlatteningLoadingError()
|
|
||||||
}
|
|
||||||
val registries = PixLyzerUtil.loadRegistry(version, profile, latch)
|
|
||||||
|
|
||||||
registries.setDefaultParents(version)
|
registries.setDefaultParents(version)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user