mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
registries: properly update flattened state
This commit is contained in:
parent
5e0116a15e
commit
ef4de01564
@ -52,6 +52,7 @@ object ConnectionTestUtil {
|
||||
connection::account.forceSet(TestAccount)
|
||||
connection::version.forceSet(version)
|
||||
connection::registries.forceSet(Registries())
|
||||
connection.registries.updateFlattened(version.flattened)
|
||||
connection.registries.parent = if (version == IT.VERSION) IT.REGISTRIES else ITUtil.loadRegistries(version)
|
||||
connection::world.forceSet(createWorld(connection, light, (worldSize * 2 + 1).pow(2)))
|
||||
connection::player.forceSet(LocalPlayerEntity(connection.account, connection, SignatureKeyManagement(connection, TestAccount)))
|
||||
|
@ -132,8 +132,6 @@ class Registries(
|
||||
var isFullyLoaded = false
|
||||
private set
|
||||
|
||||
private var isFlattened = false
|
||||
|
||||
|
||||
override var parent: Registries? = null
|
||||
set(value) {
|
||||
@ -146,11 +144,15 @@ class Registries(
|
||||
return entityDataIndexMap[field] ?: parent?.getEntityDataIndex(field)
|
||||
}
|
||||
|
||||
fun updateFlattened(flattened: Boolean) {
|
||||
block.flattened = flattened
|
||||
blockState.flattened = flattened
|
||||
item.flattened = flattened
|
||||
}
|
||||
|
||||
fun load(version: Version, pixlyzerData: Map<String, Any>, latch: AbstractLatch) {
|
||||
isFlattened = version.flattened
|
||||
block.flattened = isFlattened
|
||||
blockState.flattened = isFlattened
|
||||
item.flattened = isFlattened
|
||||
updateFlattened(version.flattened)
|
||||
|
||||
|
||||
var error: Throwable? = null
|
||||
val worker = TaskWorker(errorHandler = { _, it -> if (error == null) error = it })
|
||||
|
@ -62,6 +62,7 @@ class BlockStateRegistry(var flattened: Boolean) : AbstractRegistry<BlockState?>
|
||||
fun forceGet(id: Int): BlockState? {
|
||||
val state = _get(id)
|
||||
if (state != null) return state
|
||||
if (flattened) return null
|
||||
|
||||
return _get((id shr 4) shl 4) // Remove meta and try again
|
||||
}
|
||||
@ -73,10 +74,11 @@ class BlockStateRegistry(var flattened: Boolean) : AbstractRegistry<BlockState?>
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun getOrNull(id: Int): BlockState? {
|
||||
if (id == ProtocolDefinition.AIR_BLOCK_ID) {
|
||||
return null
|
||||
if (flattened) {
|
||||
if (id == ProtocolDefinition.AIR_BLOCK_ID) return null
|
||||
} else {
|
||||
if (id shr 4 == ProtocolDefinition.AIR_BLOCK_ID) return null
|
||||
}
|
||||
if (!flattened && id shr 4 == ProtocolDefinition.AIR_BLOCK_ID) return null
|
||||
val state = forceGet(id) ?: return null
|
||||
if (state.block is AirBlock) {
|
||||
return null
|
||||
|
@ -83,7 +83,7 @@ class PlayConnection(
|
||||
) : Connection() {
|
||||
val sessionId = KUtil.secureRandomUUID()
|
||||
val settingsManager = ClientSettingsManager(this)
|
||||
val registries = Registries()
|
||||
val registries = Registries().apply { updateFlattened(version.flattened) }
|
||||
val world = World(this)
|
||||
val tabList = TabList()
|
||||
val scoreboardManager = ScoreboardManager(this)
|
||||
|
Loading…
x
Reference in New Issue
Block a user