added checks for invalid coordinates when fetching tile entities for neighbors, fixes #63

This commit is contained in:
Florian Nücke 2014-01-06 01:00:51 +01:00
parent c1e283ca87
commit e266ccbcc3
2 changed files with 4 additions and 2 deletions

View File

@ -91,7 +91,8 @@ object Cable {
def neighbors(world: IBlockAccess, x: Int, y: Int, z: Int) = {
var result = 0
for (side <- ForgeDirection.VALID_DIRECTIONS) {
world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ) match {
val (tx, ty, tz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
if (world.getBlockId(tx, ty, tz) != 0) world.getBlockTileEntity(tx, ty, tz) match {
case robot: tileentity.RobotProxy =>
case host: SidedEnvironment =>
val connects = if (host.getWorldObj.isRemote) host.canConnect(side.getOpposite) else host.sidedNode(side.getOpposite) != null

View File

@ -101,7 +101,8 @@ class RobotAfterimage(val parent: SpecialDelegator) extends SpecialDelegate {
def findMovingRobot(world: IBlockAccess, x: Int, y: Int, z: Int): Option[tileentity.Robot] = {
for (side <- ForgeDirection.VALID_DIRECTIONS) {
world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ) match {
val (tx, ty, tz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
if (world.getBlockId(tx, ty, tz) != 0) world.getBlockTileEntity(tx, ty, tz) match {
case proxy: tileentity.RobotProxy if proxy.robot.moveFromX == x && proxy.robot.moveFromY == y && proxy.robot.moveFromZ == z => return Some(proxy.robot)
case _ =>
}