diff --git a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/NetworkCluster.kt b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/NetworkCluster.kt index a5343872524..c8cbc6afe8c 100644 --- a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/NetworkCluster.kt +++ b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/NetworkCluster.kt @@ -55,6 +55,10 @@ class NetworkCluster(val uuid: UUID, val networks: List>) { } } + override fun toString(): String { + return "NetworkCluster(uuid=$uuid, networks=$networks)" + } + } /** diff --git a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/energy/EnergyNetwork.kt b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/energy/EnergyNetwork.kt index 2d7a01287ae..dcec69e5a5e 100644 --- a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/energy/EnergyNetwork.kt +++ b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/energy/EnergyNetwork.kt @@ -223,6 +223,10 @@ class EnergyNetwork internal constructor( private val EnergyHolder.fillFrac: Double get() = energy.toDouble() / maxEnergy.toDouble() + override fun toString(): String { + return "EnergyNetwork(nodes=$nodes)" + } + companion object { private val ENERGY_NETWORK = MAIN_CONFIG.node("network", "energy") diff --git a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/fluid/FluidNetwork.kt b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/fluid/FluidNetwork.kt index a28c7b64d93..183d7e39fef 100644 --- a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/fluid/FluidNetwork.kt +++ b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/fluid/FluidNetwork.kt @@ -84,6 +84,10 @@ class FluidNetwork internal constructor( } } + override fun toString(): String { + return "FluidNetwork(nodes=$nodes)" + } + companion object { private val FLUID_NETWORK = MAIN_CONFIG.node("network", "fluid") diff --git a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/item/ItemNetwork.kt b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/item/ItemNetwork.kt index 00b5db00bb3..7c664ca7c79 100644 --- a/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/item/ItemNetwork.kt +++ b/nova/src/main/kotlin/xyz/xenondevs/nova/world/block/tileentity/network/type/item/ItemNetwork.kt @@ -69,6 +69,10 @@ class ItemNetwork internal constructor( } while (transfersLeft != 0 && nextChannel != startingChannel) } + override fun toString(): String { + return "ItemNetwork(nodes=$nodes)" + } + companion object { private val ITEM_NETWORK = MAIN_CONFIG.node("network", "item") diff --git a/nova/src/main/kotlin/xyz/xenondevs/nova/world/format/NetworkState.kt b/nova/src/main/kotlin/xyz/xenondevs/nova/world/format/NetworkState.kt index af3f3070ac3..dfea2158ddc 100644 --- a/nova/src/main/kotlin/xyz/xenondevs/nova/world/format/NetworkState.kt +++ b/nova/src/main/kotlin/xyz/xenondevs/nova/world/format/NetworkState.kt @@ -169,12 +169,14 @@ class NetworkState internal constructor( if (!file.exists()) return null - val network = file.inputStream().buffered().use { inp -> - val reader = ByteReader.fromStream(inp) - ProtoNetwork.read(networkId, world, this, reader) + try { + return file.inputStream().buffered().use { inp -> + val reader = ByteReader.fromStream(inp) + ProtoNetwork.read(networkId, world, this, reader) + } + } catch (e: Exception) { + throw Exception("Failed to load network from file $file", e) } - - return network } /**