@@ -152,7 +152,7 @@ public void onUpdateServer() {
152152 int stackId = entry .getIntKey ();
153153 TransporterStack stack = entry .getValue ();
154154 if (!stack .initiatedPath ) {//Initiate any paths and remove things that can't go places
155- if (stack .itemStack .isEmpty () || !recalculate (stackId , stack , null )) {
155+ if (stack .itemStack .isEmpty () || !recalculate (stackId , stack , Long . MAX_VALUE )) {
156156 deletes .add (stackId );
157157 continue ;
158158 }
@@ -161,15 +161,16 @@ public void onUpdateServer() {
161161 int prevProgress = stack .progress ;
162162 stack .progress += tier .getSpeed ();
163163 if (stack .progress >= 100 ) {
164- BlockPos prevSet = null ;
164+ long prevSet = Long . MAX_VALUE ;
165165 if (stack .hasPath ()) {
166- int currentIndex = stack .getPath ().indexOf (pos );
166+ int currentIndex = stack .getPath ().indexOf (pos . asLong () );
167167 if (currentIndex == 0 ) { //Necessary for transition reasons, not sure why
168168 deletes .add (stackId );
169169 continue ;
170170 }
171- BlockPos next = stack .getPath ().get (currentIndex - 1 );
172- if (next != null ) {
171+ long next = stack .getPath ().getLong (currentIndex - 1 );
172+ if (next != Long .MAX_VALUE ) {
173+ BlockPos nextPos = BlockPos .of (next );
173174 if (!stack .isFinal (this )) {
174175 //If this is not the final transporter try transferring it to the next one
175176 LogisticalTransporterBase transmitter = network .getTransmitter (next );
@@ -183,13 +184,13 @@ public void onUpdateServer() {
183184 //Otherwise, try to insert it into the destination inventory
184185 //Get the handler we are trying to insert into from the network's acceptor cache
185186 Direction side = stack .getSide (this ).getOpposite ();
186- IItemHandler acceptor = network .getCachedAcceptor (next , side );
187+ IItemHandler acceptor = network .getCachedAcceptor (nextPos , side );
187188 if (acceptor == null && stack .getPathType ().isHome ()) {
188189 //TODO: Cache this capability. The issue is that when we are sending it back home
189190 // if it pulled the item itself, then it isn't in our cached acceptors, and thus won't be able to insert it
190- acceptor = Capabilities .ITEM .getCapabilityIfLoaded (getLevel (), next , side );
191+ acceptor = Capabilities .ITEM .getCapabilityIfLoaded (getLevel (), nextPos , side );
191192 }
192- TransitResponse response = TransitRequest .simple (stack .itemStack ).addToInventory (getLevel (), next , acceptor , 0 ,
193+ TransitResponse response = TransitRequest .simple (stack .itemStack ).addToInventory (getLevel (), nextPos , acceptor , 0 ,
193194 stack .getPathType ().isHome ());
194195 if (!response .isEmpty ()) {
195196 //We were able to add at least part of the stack to the inventory
@@ -211,7 +212,7 @@ public void onUpdateServer() {
211212 }
212213 if (!recalculate (stackId , stack , prevSet )) {
213214 deletes .add (stackId );
214- } else if (prevSet == null ) {
215+ } else if (prevSet == Long . MAX_VALUE ) {
215216 stack .progress = 50 ;
216217 } else {
217218 stack .progress = 0 ;
@@ -224,14 +225,14 @@ public void onUpdateServer() {
224225 Direction side = stack .getSide (this );
225226 ConnectionType connectionType = getConnectionType (side );
226227 tryRecalculate = !connectionType .canSendTo () ||
227- !TransporterUtils .canInsert (getLevel (), stack .getDest (), stack .color , stack .itemStack , side , pathType .isHome ());
228+ !TransporterUtils .canInsert (getLevel (), BlockPos . of ( stack .getDest () ), stack .color , stack .itemStack , side , pathType .isHome ());
228229 } else {
229230 //Try to recalculate idles once they reach their destination
230231 tryRecalculate = true ;
231232 }
232233 } else {
233- BlockPos nextPos = stack .getNext (this );
234- if (nextPos == null ) {
234+ long nextPos = stack .getNext (this );
235+ if (nextPos == Long . MAX_VALUE ) {
235236 tryRecalculate = true ;
236237 } else {
237238 Direction nextSide = stack .getSide (pos , nextPos );
@@ -246,7 +247,7 @@ public void onUpdateServer() {
246247 }
247248 }
248249 }
249- if (tryRecalculate && !recalculate (stackId , stack , null )) {
250+ if (tryRecalculate && !recalculate (stackId , stack , Long . MAX_VALUE )) {
250251 deletes .add (stackId );
251252 }
252253 }
@@ -379,7 +380,7 @@ public void addStack(int id, TransporterStack s) {
379380 transit .put (id , s );
380381 }
381382
382- private boolean recalculate (int stackId , TransporterStack stack , BlockPos from ) {
383+ private boolean recalculate (int stackId , TransporterStack stack , long from ) {
383384 //TODO: Why do we skip recalculating the path if it is idle. Is it possible for idle paths to eventually stop being idle or are they just idle forever??
384385 boolean noPath = stack .getPathType ().noTarget () || stack .recalculatePath (TransitRequest .simple (stack .itemStack ), this , 0 ).isEmpty ();
385386 if (noPath && !stack .calculateIdle (this )) {
@@ -389,8 +390,8 @@ private boolean recalculate(int stackId, TransporterStack stack, BlockPos from)
389390
390391 //Only add to needsSync if true is being returned; otherwise it gets added to deletes
391392 needsSync .put (stackId , stack );
392- if (from != null ) {
393- stack .originalLocation = from ;
393+ if (from != Long . MAX_VALUE ) {
394+ stack .originalLocation = BlockPos . of ( from ) ;
394395 }
395396 return true ;
396397 }
0 commit comments