fix some bugs when trying to join versions without pixlyzer data

This commit is contained in:
Bixilon 2021-04-18 15:58:56 +02:00
parent f30de97e31
commit d71f687f44
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 7 additions and 7 deletions

View File

@ -97,11 +97,11 @@ data class Version(
}
val pixlyzerData = try {
Util.readJsonFromStream(assetsManager.readAssetAsStream(Resources.getPixLyzerDataHashByVersion(this)))
} catch (e: Throwable) {
} catch (exception: Throwable) {
// should not happen, but if this version is not flattened, we can fallback to the flatten mappings. Some things might not work...
Log.printException(e, LogLevels.VERBOSE)
Log.printException(exception, LogLevels.VERBOSE)
if (isFlattened()) {
throw e
throw exception
}
if (versionId == ProtocolDefinition.PRE_FLATTENING_VERSION_ID) {
Versions.PRE_FLATTENING_MAPPING = null

View File

@ -135,7 +135,7 @@ class VersionMapping {
// pre init stuff
loadShapes(pixlyzerData["shapes"]?.asJsonObject)
loadBlockModels(pixlyzerData["models"].asJsonObject.toResourceLocationMap())
loadBlockModels(pixlyzerData["models"]?.asJsonObject?.toResourceLocationMap() ?: mutableMapOf())
// enums
loadEnumRegistry(version, pixlyzerData["equipment_slots"], equipmentSlotRegistry, DefaultRegistries.EQUIPMENT_SLOTS_REGISTRY)

View File

@ -157,6 +157,8 @@ class PlayConnection(
}
latch.waitForChange()
}
Log.info("Connecting to server: $address")
network.connect(address)
} catch (exception: Throwable) {
Log.printException(exception, LogLevels.DEBUG)
Log.fatal("Could not load version $version. This version seems to be unsupported!")
@ -164,8 +166,6 @@ class PlayConnection(
lastException = MappingsLoadingException("Mappings could not be loaded", exception)
connectionState = ConnectionStates.FAILED_NO_RETRY
}
Log.info("Connecting to server: $address")
network.connect(address)
latch.countDown()
}

View File

@ -107,7 +107,7 @@ class PacketJoinGame(buffer: PlayInByteBuffer) : PlayS2CPacket() {
hashedSeed = buffer.readLong()
}
if (buffer.versionId < ProtocolVersions.V_19W11A) {
difficulty = Difficulties.byId(buffer.readUnsignedByte().toInt())
difficulty = Difficulties.byId(buffer.readUnsignedByte())
}
maxPlayers = if (buffer.versionId < ProtocolVersions.V_1_16_2_RC1) {
buffer.readByte().toInt()