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

This commit is contained in:
Florian Nücke 2014-03-07 07:49:16 +01:00
parent 376d780042
commit 064a8520f9
3 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,3 @@
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
@ -30,7 +29,7 @@ compileScala {
version = "1.2.2" version = "1.2.2"
group= "li.cil.oc" // http://maven.apache.org/guides/mini/guide-naming-conventions.html 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) if (System.getenv("BUILD_NUMBER") != null)
version += ".${System.getenv("BUILD_NUMBER")}" version += ".${System.getenv("BUILD_NUMBER")}"

View File

@ -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 { node match {
case connector: Connector => case connector: Connector =>
if (connector.localBufferSize > 0) { if (connector.localBufferSize > 0) {

View File

@ -7,8 +7,9 @@ import li.cil.oc.{Settings, api}
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.AxisAlignedBB import net.minecraft.util.AxisAlignedBB
import net.minecraftforge.common.ForgeDirection 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). val node = api.Network.newNode(this, Visibility.Network).
withComponent("hologram"). withComponent("hologram").
withConnector(). 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 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.""") @Callback(doc = """function() -- Clears the hologram.""")