Skip to content

Commit 5d18c1f

Browse files
Adding mark-dirty to core MultiblockController for convenience
1 parent d71e298 commit 5d18c1f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/main/java/erogenousbeef/core/multiblock/MultiblockControllerBase.java

+38
Original file line numberDiff line numberDiff line change
@@ -864,4 +864,42 @@ private void selectNewReferenceCoord() {
864864
}
865865
}
866866

867+
/**
868+
* Marks the reference coord dirty & updateable.
869+
*
870+
* On the server, this will mark the for a data-update, so that
871+
* nearby clients will receive an updated description packet from the server
872+
* after a short time. The block's chunk will also be marked dirty and the
873+
* block's chunk will be saved to disk the next time chunks are saved.
874+
*
875+
* On the client, this will mark the block for a rendering update.
876+
*/
877+
protected void markReferenceCoordForUpdate() {
878+
CoordTriplet rc = getReferenceCoord();
879+
if(worldObj != null && rc != null) {
880+
worldObj.markBlockForUpdate(rc.x, rc.y, rc.z);
881+
}
882+
}
883+
884+
/**
885+
* Marks the reference coord dirty.
886+
*
887+
* On the server, this marks the reference coord's chunk as dirty; the block (and chunk)
888+
* will be saved to disk the next time chunks are saved. This does NOT mark it dirty for
889+
* a description-packet update.
890+
*
891+
* On the client, does nothing.
892+
* @see MultiblockControllerBase#markReferenceCoordForUpdate()
893+
*/
894+
protected void markReferenceCoordDirty() {
895+
if(worldObj == null || worldObj.isRemote) { return; }
896+
897+
CoordTriplet referenceCoord = getReferenceCoord();
898+
if(referenceCoord == null) { return; }
899+
900+
TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
901+
worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe);
902+
}
903+
904+
867905
}

0 commit comments

Comments
 (0)