1010
1111import dev .dfonline .codeclient .CodeClient ;
1212import dev .dfonline .codeclient .actiondump .ActionDump ;
13- import dev .dfonline .codeclient .actiondump .CodeBlock ;
13+ import dev .dfonline .codeclient .actiondump .Item ;
1414import net .fabricmc .api .EnvType ;
1515import net .fabricmc .api .Environment ;
1616import net .minecraft .client .MinecraftClient ;
2727import net .minecraft .inventory .SimpleInventory ;
2828import net .minecraft .item .ItemStack ;
2929import net .minecraft .item .Items ;
30- import net .minecraft .nbt .NbtHelper ;
3130import net .minecraft .screen .ScreenHandler ;
3231import net .minecraft .screen .ScreenTexts ;
3332import net .minecraft .screen .slot .Slot ;
@@ -81,7 +80,9 @@ protected void onMouseClick(@Nullable Slot slot, int slotId, int button, SlotAct
8180
8281 if (slot .inventory instanceof SimpleInventory ) {
8382 if (actionType == SlotActionType .PICKUP ) {
84- this .handler .setCursorStack (slot .getStack ());
83+ CodeClient .LOGGER .info (String .valueOf (this .handler .getCursorStack ()));
84+ if (this .handler .getCursorStack ().getItem ().equals (Items .AIR )) this .handler .setCursorStack (slot .getStack ());
85+ else this .handler .setCursorStack (Items .AIR .getDefaultStack ());
8586 }
8687 }
8788 if (slot .inventory instanceof PlayerInventory ) {
@@ -90,6 +91,10 @@ protected void onMouseClick(@Nullable Slot slot, int slotId, int button, SlotAct
9091
9192 slot .setStack (cursorItem );
9293 this .handler .setCursorStack (slotStack );
94+ this .handler .syncState ();
95+ this .listener .onSlotUpdate (this .handler ,slot .id - 9 ,slot .getStack ());
96+ CodeClient .LOGGER .info (String .valueOf (slot .id ));
97+ // CodeClient.MC.getNetworkHandler().sendPacket(new CreativeInventoryActionC2SPacket(slot.id,slot.getStack()));
9398 }
9499 }
95100 protected void init () {
@@ -213,6 +218,7 @@ else if(this.slots != null) {
213218 this .handler .slots .addAll (this .slots );
214219 this .slots = null ;
215220 }
221+ this .scrollPosition = 0 ;
216222 populate ();
217223 }
218224 private void populate () {
0 commit comments