Fix tile change event firing before part is added to tile.

This commit is contained in:
Chicken-Bones committed 2013-12-03 16:30:51 +10:00
1 parent 595ef5a0ea
commit c351a71edf
2 files changed
+22 -3

No files matched your search

+13 -3
View File
@@ -76,7 +76,7 @@ object MultipartGenerator
{
ntile.partList(0).invalidateConvertedTile()
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block.blockID, 0, 0)
world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile)
silentAddTile(world, pos, ntile)
PacketCustom.sendToChunk(new Packet53BlockChange(pos.x, pos.y, pos.z, world), world, pos.x>>4, pos.z>>4)
ntile.partList(0).onConverted()
ntile.writeAddPart(ntile.partList(0))
@@ -88,7 +88,7 @@ object MultipartGenerator
{
ntile = factory.generateTile(partTraits++tileTraits, world.isRemote)
tile.setValid(false)
world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile)
silentAddTile(world, pos, ntile)
ntile.from(tile)
}
}
@@ -96,12 +96,22 @@ object MultipartGenerator
{
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block.blockID, 0, 0)
ntile = factory.generateTile(partTraits, world.isRemote)
world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile)
silentAddTile(world, pos, ntile)
}
ntile.addPart_impl(part)
return ntile
}
/**
* Adds a tile entity to the world without notifying neighbor blocks or adding it to the tick list
*/
def silentAddTile(world:World, pos:BlockCoord, tile:TileEntity)
{
val chunk = world.getChunkFromBlockCoords(pos.x, pos.z)
if(chunk != null)
chunk.setChunkBlockTileEntity(pos.x & 15, pos.y, pos.z & 15, tile);
}
/**
* Check if tile satisfies all the interfaces required by parts. If not, return a new generated copy of tile
*/
@@ -178,6 +178,14 @@ class TileMultipart extends TileEntity
operate(p => if(!parts.contains(p)) parts.foreach(p.onPartChanged(_)))
}
/**
* Notifies neighboring blocks that this tile has changed
*/
def notifyTileChange()
{
worldObj.func_96440_m(xCoord, yCoord, zCoord, 0)
}
def onNeighborBlockChange()
{
operate(_.onNeighborChanged())
@@ -292,6 +300,7 @@ class TileMultipart extends TileEntity
part.onAdded()
partAdded(part)
notifyPartChange(part)
notifyTileChange()
markDirty()
markRender()
}