From 064a8520f969919b95d3e71dfc03cdd5d4595160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 7 Mar 2014 07:49:16 +0100 Subject: [PATCH] fixed crash when using analyzer on hologram projector (and other sided environments returning returning null on some sides), closes #148; made the analyzer work on any side of the hologram projector --- build.gradle | 3 +-- src/main/scala/li/cil/oc/common/item/Analyzer.scala | 2 +- src/main/scala/li/cil/oc/common/tileentity/Hologram.scala | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index c9b3ba823..151967e63 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ - buildscript { repositories { mavenCentral() @@ -30,7 +29,7 @@ compileScala { version = "1.2.2" group= "li.cil.oc" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "OpenComputers" +archivesBaseName = "OpenComputers-MC1.6.4" if (System.getenv("BUILD_NUMBER") != null) version += ".${System.getenv("BUILD_NUMBER")}" diff --git a/src/main/scala/li/cil/oc/common/item/Analyzer.scala b/src/main/scala/li/cil/oc/common/item/Analyzer.scala index b6063da29..c14ffa137 100644 --- a/src/main/scala/li/cil/oc/common/item/Analyzer.scala +++ b/src/main/scala/li/cil/oc/common/item/Analyzer.scala @@ -45,7 +45,7 @@ class Analyzer(val parent: Delegator) extends Delegate { } } - private def analyzeNodes(nodes: Array[Node], player: EntityPlayerMP) = if (nodes != null) for (node <- nodes) { + private def analyzeNodes(nodes: Array[Node], player: EntityPlayerMP) = if (nodes != null) for (node <- nodes if node != null) { node match { case connector: Connector => if (connector.localBufferSize > 0) { diff --git a/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala b/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala index 437782be7..4af82edb1 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala @@ -7,8 +7,9 @@ import li.cil.oc.{Settings, api} import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.AxisAlignedBB import net.minecraftforge.common.ForgeDirection +import net.minecraft.entity.player.EntityPlayer -class Hologram extends Environment with SidedEnvironment { +class Hologram extends Environment with SidedEnvironment with Analyzable { val node = api.Network.newNode(this, Visibility.Network). withComponent("hologram"). withConnector(). @@ -65,6 +66,8 @@ class Hologram extends Environment with SidedEnvironment { override def sidedNode(side: ForgeDirection) = if (side == ForgeDirection.DOWN) node else null + override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(node) + // ----------------------------------------------------------------------- // @Callback(doc = """function() -- Clears the hologram.""")