@@ -26,10 +26,9 @@ public class ScanPlot extends Action {
2626 private List <BlockPos > blocks = null ;
2727 private Action step = null ;
2828 private static final Vec3d goToOffset = new Vec3d (0 , 1.5 , 0 );
29- private Integer progress = 0 ;
30- private final ArrayList <Template > scanList ;
29+ private final ArrayList <ItemStack > scanList ;
3130
32- public ScanPlot (Callback callback , ArrayList <Template > scanList ) {
31+ public ScanPlot (Callback callback , ArrayList <ItemStack > scanList ) {
3332 super (callback );
3433 this .scanList = scanList ;
3534 if (!(CodeClient .location instanceof Dev )) {
@@ -61,23 +60,26 @@ public boolean onReceivePacket(Packet<?> packet) {
6160// }
6261 }
6362
63+ private void next (int progress ) {
64+ if (progress >= blocks .size ()) {
65+ callback ();
66+ return ;
67+ }
68+ step = new GoTo (blocks .get (progress ).toCenterPos ().add (goToOffset ), () -> {
69+ this .step = new pickUpBlock (blocks .get (progress ),() -> {
70+ CodeClient .LOGGER .info ("picked up block" );
71+ next (progress + 1 );
72+ });
73+ this .step .init ();
74+ });
75+ step .init ();
76+ }
77+
6478 @ Override
6579 public void onTick () {
6680 if (step != null ) step .onTick ();
6781 else {
68- if (progress >= blocks .size ()) {
69- callback ();
70- return ;
71- }
72- step = new GoTo (blocks .get (progress ).toCenterPos ().add (goToOffset ), () -> {
73- this .step = new pickUpBlock (blocks .get (progress ),() -> {
74- CodeClient .LOGGER .info ("picked up block" );
75- step = null ;
76- progress +=1 ;
77- });
78- this .step .init ();
79- });
80- step .init ();
82+ next (0 );
8183 }
8284 }
8385
@@ -109,7 +111,7 @@ public boolean onReceivePacket(Packet<?> packet) {
109111 var data = Utility .templateDataItem (slot .getStack ());
110112 var template = Template .parse64 (data );
111113 if (template == null ) return false ;
112- scanList .add (Template . parse64 ( data ));
114+ scanList .add (slot . getStack ( ));
113115 net .sendPacket (new CreativeInventoryActionC2SPacket (slot .getSlot (), ItemStack .EMPTY ));
114116 this .callback ();
115117 return true ;
0 commit comments