@@ -110,37 +110,37 @@ private final void loadMapArtFromBundles(){
110110 }
111111// client.player.sendMessage(Text.literal("Scheduling clicks: "+clicks.size()), true);
112112 Main .LOGGER .info ("MapLoadBundle: STARTED" );
113- Main .clickUtils .executeClicks (clicks ,
114- c ->{
115- if (client .player == null || client .world == null ) return true ;
116- Integer skipIfLoaded = ableToSkipClicks .get (c );
113+ Main .clickUtils .executeClicks (c ->{
114+ if (client .player == null || client .world == null ) return true ;
115+ Integer skipIfLoaded = ableToSkipClicks .get (c );
117116// Main.LOGGER.info("click for slot: "+c.slotId()+", clicksLeft: "+clicks.size());
118- if (skipIfLoaded != null ){
119- //Main.LOGGER.info("MapLoadBundle: potentially skippable");
120- BundleContentsComponent contents = client .player .currentScreenHandler .slots .get (c .slot ()).getStack ().get (DataComponentTypes .BUNDLE_CONTENTS );
121- if (contents != null && contents .stream ().allMatch (s -> isLoadedMapArt (client .world , s ))){
117+ if (skipIfLoaded != null ){
118+ //Main.LOGGER.info("MapLoadBundle: potentially skippable");
119+ BundleContentsComponent contents = client .player .currentScreenHandler .slots .get (c .slot ()).getStack ().get (DataComponentTypes .BUNDLE_CONTENTS );
120+ if (contents != null && contents .stream ().allMatch (s -> isLoadedMapArt (client .world , s ))){
122121// Main.LOGGER.info("MapLoadBundle: skippable! whoop whoop: "+(skipIfLoaded));
123- for (int i =0 ; i <skipIfLoaded ; ++i ) clicks .remove ();
124- return false ;
125- }
122+ for (int i =0 ; i <skipIfLoaded ; ++i ) clicks .remove ();
123+ return false ;
126124 }
127- if (c .slot () != emptySlot ) return true ;
128- if (stateUpdateWaitStart == 0 ){stateUpdateWaitStart = -1 ; return true ;}
129- ItemStack item = client .player .currentScreenHandler .slots .get (emptySlot ).getStack ();
125+ }
126+ if (c .slot () != emptySlot ) return true ;
127+ if (stateUpdateWaitStart == 0 ){stateUpdateWaitStart = -1 ; return true ;}
128+ ItemStack item = client .player .currentScreenHandler .slots .get (emptySlot ).getStack ();
130129// if(!isLoadedMapArt(client.world, item)) return false;
131- if (!isLoadedMapArt (client .world , item )){
132- if (stateLoadWaitStart == 0 ) stateLoadWaitStart = System .currentTimeMillis ();
133- if (System .currentTimeMillis () - stateLoadWaitStart < STATE_LOAD_TIMEOUT ) return false ;
134- stateUpdateWaitStart = stateLoadWaitStart = 0 ;
135- Main .LOGGER .warn ("MapLoadBundle: Timed out while waiting for map state to load!" );
136- return true ;
137- }
138- // Wait a bit even aft map state is loaded, to ensure it REALLY gets loaded
139- else if (stateUpdateWaitStart <= 0 ){stateUpdateWaitStart = System .currentTimeMillis (); return false ;}
140- else if (System .currentTimeMillis () - stateUpdateWaitStart < WAIT_FOR_STATE_UPDATE ) return false ;
141- else {stateUpdateWaitStart = 0 ; return true ;}
142- },
143- ()->Main .LOGGER .info ("MapLoadBundle: DONE!" )
130+ if (!isLoadedMapArt (client .world , item )){
131+ if (stateLoadWaitStart == 0 ) stateLoadWaitStart = System .currentTimeMillis ();
132+ if (System .currentTimeMillis () - stateLoadWaitStart < STATE_LOAD_TIMEOUT ) return false ;
133+ stateUpdateWaitStart = stateLoadWaitStart = 0 ;
134+ Main .LOGGER .warn ("MapLoadBundle: Timed out while waiting for map state to load!" );
135+ return true ;
136+ }
137+ // Wait a bit even aft map state is loaded, to ensure it REALLY gets loaded
138+ else if (stateUpdateWaitStart <= 0 ){stateUpdateWaitStart = System .currentTimeMillis (); return false ;}
139+ else if (System .currentTimeMillis () - stateUpdateWaitStart < WAIT_FOR_STATE_UPDATE ) return false ;
140+ else {stateUpdateWaitStart = 0 ; return true ;}
141+ },
142+ ()->Main .LOGGER .info ("MapLoadBundle: DONE!" ),
143+ clicks
144144 );
145145 }
146146
@@ -187,37 +187,37 @@ public final void loadMapArtFromContainer(){
187187 for (int j =0 ; j <hbi ; ++j ) clicks .add (new InvAction (putBackSlots [j ], hbButtons [j ], ActionType .HOTBAR_SWAP ));
188188
189189 Main .LOGGER .info ("MapLoad: STARTED, clicks: " +clicks .size ()+", extraPutBackIndex: " +extraPutBackIndex );
190- Main .clickUtils .executeClicks (clicks ,
191- c ->{
192- if (client .player == null || client .world == null ) return true ;
190+ Main .clickUtils .executeClicks (c ->{
191+ if (client .player == null || client .world == null ) return true ;
193192// if(isUnloadedMapArt(/*client.player.clientWorld*/client.world, item)) return false;
194- if (clickIndex % hbButtons .length != 0 && clickIndex != extraPutBackIndex ){++clickIndex ; return true ;}
195- if (Main .clickUtils .calcAvailableClicks () < MAX_BATCH_SIZE ) return false ; // Wait for clicks
193+ if (clickIndex % hbButtons .length != 0 && clickIndex != extraPutBackIndex ){++clickIndex ; return true ;}
194+ if (Main .clickUtils .calcAvailableClicks () < MAX_BATCH_SIZE ) return false ; // Wait for clicks
196195
197- if ((clickIndex /hbButtons .length )%2 == 0 && clickIndex < extraPutBackIndex ){++clickIndex ; return true ;} // Moving TO hotbar
196+ if ((clickIndex /hbButtons .length )%2 == 0 && clickIndex < extraPutBackIndex ){++clickIndex ; return true ;} // Moving TO hotbar
198197// ItemStack item = client.player.getInventory().getStack(c.button());
199- //if(!isLoadedMapArt(client.world, item)){ // Weird issue rn with non-maps getting moved around? (bundles?)
200- //if(isUnloadedMapArt(client.world, s){
201- // Ugh just wait if any unloaded map in hotbar(or inv)
202- if (client .player .getInventory ().main .stream ().anyMatch (s -> isUnloadedMapArt (client .world , s ))){
198+ //if(!isLoadedMapArt(client.world, item)){ // Weird issue rn with non-maps getting moved around? (bundles?)
199+ //if(isUnloadedMapArt(client.world, s){
200+ // Ugh just wait if any unloaded map in hotbar(or inv)
201+ if (client .player .getInventory ().main .stream ().anyMatch (s -> isUnloadedMapArt (client .world , s ))){
203202// Main.LOGGER.info("MapLoad: still waiting for map state to load from hotbar slot: "+c.button());
204- if (stateLoadWaitStart == 0 ) stateLoadWaitStart = System .currentTimeMillis ();
205- if (System .currentTimeMillis () - stateLoadWaitStart < STATE_LOAD_TIMEOUT ) return false ;
206- stateUpdateWaitStart = stateLoadWaitStart = 0 ;
207- Main .LOGGER .warn ("MapLoad: Timed out while waiting for map state to load!" );
208- return true ;
209- }
210- else if (stateUpdateWaitStart == 0 ){stateUpdateWaitStart = System .currentTimeMillis (); return false ;}
211- else if (System .currentTimeMillis () - stateUpdateWaitStart < WAIT_FOR_STATE_UPDATE ) return false ;
212- Main .LOGGER .info ("MapLoad: map state loaded and updated" );
203+ if (stateLoadWaitStart == 0 ) stateLoadWaitStart = System .currentTimeMillis ();
204+ if (System .currentTimeMillis () - stateLoadWaitStart < STATE_LOAD_TIMEOUT ) return false ;
213205 stateUpdateWaitStart = stateLoadWaitStart = 0 ;
214- ++ clickIndex ;
206+ Main . LOGGER . warn ( "MapLoad: Timed out while waiting for map state to load!" ) ;
215207 return true ;
216- },
208+ }
209+ else if (stateUpdateWaitStart == 0 ){stateUpdateWaitStart = System .currentTimeMillis (); return false ;}
210+ else if (System .currentTimeMillis () - stateUpdateWaitStart < WAIT_FOR_STATE_UPDATE ) return false ;
211+ Main .LOGGER .info ("MapLoad: map state loaded and updated" );
212+ stateUpdateWaitStart = stateLoadWaitStart = 0 ;
213+ ++clickIndex ;
214+ return true ;
215+ },
217216 ()->{
218217 clickIndex = 0 ;
219218 Main .LOGGER .info ("MapLoad: DONE!" );
220- }
219+ },
220+ clicks
221221 );
222222 }
223223
0 commit comments