@@ -97,8 +97,11 @@ class TravelingItemMover {
9797 this . coords = this . coordsToFixed ( newCoords ) ;
9898 }
9999
100- public findNewMoveVector ( region : BlockSource ) : boolean {
100+ public findNewMoveVector ( region : BlockSource ) : number {
101101 var relativePaths = this . getRelativePaths ( region ) ;
102+ if ( relativePaths === null ) {
103+ return - 1 ;
104+ }
102105 const nextPipes = this . filterPaths ( relativePaths , region ) ;
103106 const keys = Object . keys ( nextPipes ) ;
104107
@@ -110,10 +113,10 @@ class TravelingItemMover {
110113 this . prevCoords = this . Coords ;
111114 this . updateMoveSpeed ( region ) ;
112115 this . updateCoordsTime ( ) ;
113- return true ;
116+ return 1 ;
114117 }
115118
116- return false ;
119+ return 0 ;
117120 }
118121
119122 /**
@@ -150,9 +153,9 @@ class TravelingItemMover {
150153 }
151154
152155 /**
153- * @returns {object } which looks like {"sideIndex": pipeClass | container}
156+ * @returns {object } which looks like {"sideIndex": pipeClass | container} or null if chunk unloaded
154157 */
155- private getRelativePaths ( region : BlockSource ) : object {
158+ private getRelativePaths ( region : BlockSource ) : object | null {
156159 const targets = { } ;
157160 for ( let i = 0 ; i < 6 ; i ++ ) {
158161 const backVectorIndex = World . getInverseBlockSide ( this . moveVectorIndex ) ;
@@ -161,6 +164,9 @@ class TravelingItemMover {
161164 const curY = this . AbsoluteCoords . y ;
162165 const curZ = this . AbsoluteCoords . z ;
163166 const { x, y, z } = World . getRelativeCoords ( curX , curY , curZ , i ) ;
167+
168+ if ( ! region . isChunkLoadedAt ( x , z ) ) return null ;
169+
164170 const pipeBlockID = region . getBlockId ( x , y , z ) ;
165171 const pipeBlockData = region . getBlockData ( x , y , z ) ;
166172 const relativePipeClass = PipeIdMap . getClassById ( pipeBlockID ) ;
@@ -170,6 +176,9 @@ class TravelingItemMover {
170176 continue ;
171177 }
172178
179+ let tile = TileEntity . getTileEntity ( x , y , z , region ) ;
180+ if ( tile ?. __initialized === false ) return null ;
181+
173182 const storage = StorageInterface . getStorage ( region , x , y , z ) ;
174183 if ( this . isValidStorage ( storage , World . getInverseBlockSide ( i ) ) && ! currentConnector ?. hasBlacklistBlockID ( pipeBlockID , pipeBlockData ) ) {
175184 targets [ i ] = storage ;
0 commit comments