From 32ebe03ace7d06a26e7a9af16babf36866bd4c01 Mon Sep 17 00:00:00 2001 From: Jesse Ward Date: Sun, 28 Sep 2014 01:20:48 -0400 Subject: [PATCH] ChunkLoader Upgrade now loads a 3x3 chunk area centered on the robot. --- .../common/event/ChunkloaderUpgradeHandler.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala b/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala index 9ed821022..603e28d59 100644 --- a/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala +++ b/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala @@ -59,15 +59,21 @@ object ChunkloaderUpgradeHandler extends LoadingCallback { } def updateLoadedChunk(loader: UpgradeChunkloader) { - val robotChunk = new ChunkCoordIntPair(math.floor(loader.owner.xPosition).toInt >> 4, math.floor(loader.owner.zPosition).toInt >> 4) + val centerChunk = new ChunkCoordIntPair(math.floor(loader.owner.xPosition).toInt >> 4, math.floor(loader.owner.zPosition).toInt >> 4) + val robotChunks = (for (x <- -1 to 1; z <- -1 to 1) yield new ChunkCoordIntPair(centerChunk.chunkXPos+x, centerChunk.chunkZPos+z)) + loader.ticket.foreach(ticket => { ticket.getChunkList.collect { - case chunk: ChunkCoordIntPair if chunk != robotChunk => ForgeChunkManager.unforceChunk(ticket, chunk) + case chunk: ChunkCoordIntPair if !robotChunks.contains(chunk) => ForgeChunkManager.unforceChunk(ticket, chunk) } - ForgeChunkManager.forceChunk(ticket, robotChunk) + + for (chunk <- robotChunks) { + ForgeChunkManager.forceChunk(ticket, chunk) + } + ticket.getModData.setString("address", loader.node.address) - ticket.getModData.setInteger("x", robotChunk.chunkXPos) - ticket.getModData.setInteger("z", robotChunk.chunkZPos) + ticket.getModData.setInteger("x", centerChunk.chunkXPos) + ticket.getModData.setInteger("z", centerChunk.chunkZPos) }) } }