Skip to content

Commit

Permalink
Backport of switch fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Jun 20, 2014
1 parent 781cc89 commit bac4b77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/li/cil/oc/common/tileentity/Router.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Router extends traits.Hub with traits.NotAnalyzable with IPeripheral {
val answerPort = checkPort(arguments, 1)
val data = Seq(Int.box(answerPort)) ++ arguments.drop(2)
val packet = api.Network.newPacket(s"cc${computerId}_$attachmentName", null, sendPort, data.toArray)
result(tryEnqueuePacket(null, packet))
result(tryEnqueuePacket(ForgeDirection.UNKNOWN, packet))
case "isWireless" => result(this.isInstanceOf[WirelessRouter])
case _ => null
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/scala/li/cil/oc/server/network/Network.scala
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package li.cil.oc.server.network

import codechicken.lib.vec.Cuboid6
import codechicken.multipart.{TFacePart, JNormalOcclusion, NormalOcclusionTest, TileMultipart}
import codechicken.multipart.{JNormalOcclusion, NormalOcclusionTest, TFacePart, TileMultipart}
import cpw.mods.fml.common.FMLCommonHandler
import cpw.mods.fml.relauncher.Side
import li.cil.oc.api.network
import li.cil.oc.api.network.{Node => ImmutableNode, WirelessEndpoint, SidedEnvironment, Environment, Visibility}
import li.cil.oc.api.network.{Environment, SidedEnvironment, Visibility, WirelessEndpoint, Node => ImmutableNode}
import li.cil.oc.common.block.Cable
import li.cil.oc.common.multipart.CablePart
import li.cil.oc.common.tileentity
import li.cil.oc.server.network.{Node => MutableNode}
import li.cil.oc.util.mods.Mods
import li.cil.oc.{Settings, api}
import li.cil.oc.{OpenComputers, Settings, api}
import net.minecraft.nbt._
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.ForgeDirection

import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
Expand Down Expand Up @@ -478,6 +479,7 @@ object Network extends api.detail.NetworkAPI {
if (nbt.hasKey("data" + i)) {
nbt.getTag("data" + i) match {
case boolean: NBTTagByte => Boolean.box(boolean.data == 1)
case integer: NBTTagInt => Int.box(integer.data)
case double: NBTTagDouble => Double.box(double.data)
case string: NBTTagString => string.data: AnyRef
case array: NBTTagByteArray => array.byteArray
Expand Down Expand Up @@ -628,9 +630,11 @@ object Network extends api.detail.NetworkAPI {
for (i <- 0 until dataArray.length) dataArray(i) match {
case null | Unit | None =>
case value: java.lang.Boolean => nbt.setBoolean("data" + i, value)
case value: java.lang.Integer => nbt.setInteger("data" + i, value)
case value: java.lang.Double => nbt.setDouble("data" + i, value)
case value: java.lang.String => nbt.setString("data" + i, value)
case value: Array[Byte] => nbt.setByteArray("data" + i, value)
case value => OpenComputers.log.warning("Unexpected type while saving network packet: " + value.getClass.getName)
}
}
}
Expand Down

0 comments on commit bac4b77

Please sign in to comment.