mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-22 13:09:44 +00:00
Add some better validation functions to TileMultipart for mass tile movement.
This commit is contained in:
1 parent
d181b226ae
commit
008a75c8fc
2 files changed
+16
-9
No files matched your search
@@ -76,7 +76,7 @@ object MultipartGenerator
|
||||
if(!partTraits.isEmpty)
|
||||
{
|
||||
ntile = factory.generateTile(partTraits++tileTraits, world.isRemote)
|
||||
tile.prepareSwap()
|
||||
tile.setValid(false)
|
||||
world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile)
|
||||
ntile.from(tile)
|
||||
}
|
||||
@@ -118,7 +118,7 @@ object MultipartGenerator
|
||||
if(!traitsForPart(part, client).forall(testSet(_)))
|
||||
{
|
||||
val ntile = factory.generateTile(testSet.toSeq, client)
|
||||
tile.prepareSwap()
|
||||
tile.setValid(false)
|
||||
tile.worldObj.setBlockTileEntity(tile.xCoord, tile.yCoord, tile.zCoord, ntile)
|
||||
ntile.from(tile)
|
||||
return ntile
|
||||
|
||||
@@ -110,16 +110,23 @@ class TileMultipart extends TileEntity
|
||||
{
|
||||
val wasInvalid = isInvalid
|
||||
super.validate()
|
||||
if(wasInvalid) {
|
||||
TileMultipart.startOperation(this)
|
||||
partList.foreach(_.onMoved())
|
||||
TileMultipart.finishOperation(this)
|
||||
}
|
||||
if(wasInvalid)
|
||||
onMoved()
|
||||
}
|
||||
|
||||
private[multipart] def prepareSwap()
|
||||
final def setValid(b:Boolean)
|
||||
{
|
||||
super.invalidate()
|
||||
if(b)
|
||||
super.validate()
|
||||
else
|
||||
super.invalidate()
|
||||
}
|
||||
|
||||
def onMoved()
|
||||
{
|
||||
TileMultipart.startOperation(this)
|
||||
partList.foreach(_.onMoved())
|
||||
TileMultipart.finishOperation(this)
|
||||
}
|
||||
|
||||
override def invalidate()
|
||||
|
||||
Reference in new issue
Block a user