From af07735e7c250a09dc8452cb4f2fbb75df3f3fa8 Mon Sep 17 00:00:00 2001 From: Chicken Bones Date: Tue, 10 Sep 2013 20:20:08 +1000 Subject: [PATCH] Made empty multipart block replaceable --- codechicken/multipart/BlockMultipart.scala | 17 +++++++++++++---- codechicken/multipart/TileMultipart.scala | 10 ++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/codechicken/multipart/BlockMultipart.scala b/codechicken/multipart/BlockMultipart.scala index 6d85dac..3641fea 100644 --- a/codechicken/multipart/BlockMultipart.scala +++ b/codechicken/multipart/BlockMultipart.scala @@ -174,7 +174,15 @@ trait BlockMultipart extends Block override def getRenderType() = TileMultipart.renderID - override def isAirBlock(world:World, x:Int, y:Int, z:Int) = getTile(world, x, y, z) == null || getTile(world, x, y, z).partList.isEmpty + override def isAirBlock(world:World, x:Int, y:Int, z:Int):Boolean = + { + return getTile(world, x, y, z) match { + case null => true + case tile => tile.partList.isEmpty + } + } + + override def isBlockReplaceable(world:World, x:Int, y:Int, z:Int) = isAirBlock(world, x, y, z) override def getRenderBlockPass = 1 @@ -291,9 +299,10 @@ trait BlockMultipart extends Block override def onNeighborTileChange(world:World, x:Int, y:Int, z:Int, tileX:Int, tileY:Int, tileZ:Int) { - val tile = getTile(world, x, y, z) - if(tile != null) - tile.onNeighborTileChange(tileX, tileY, tileZ) + getTile(world, x, y, z) match { + case null => world.setBlockToAir(x, y, z) + case tile => tile.onNeighborTileChange(tileX, tileY, tileZ) + } } override def weakTileChanges() = true diff --git a/codechicken/multipart/TileMultipart.scala b/codechicken/multipart/TileMultipart.scala index 14cbb2b..952298f 100644 --- a/codechicken/multipart/TileMultipart.scala +++ b/codechicken/multipart/TileMultipart.scala @@ -139,7 +139,7 @@ class TileMultipart extends TileEntity { internalPartChange(part) - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID) + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MultipartProxy.block.blockID) worldObj.updateAllLightTypes(xCoord, yCoord, zCoord) } @@ -291,15 +291,13 @@ class TileMultipart extends TileEntity { remPart_do(part, !worldObj.isRemote) - if(!isInvalid()) + if(!isInvalid) { notifyPartChange(part) markDirty() markRender() - } - - if(!isInvalid()) return MultipartGenerator.partRemoved(this, part) + } return null } @@ -428,7 +426,7 @@ class TileMultipart extends TileEntity def notifyNeighborChange(side:Int) { val pos = new BlockCoord(this).offset(side) - worldObj.notifyBlocksOfNeighborChange(pos.x, pos.y, pos.z, getBlockType().blockID) + worldObj.notifyBlocksOfNeighborChange(pos.x, pos.y, pos.z, MultipartProxy.block.blockID) } }