|
20 | 20 | import com.lambda.event.EventFlow; |
21 | 21 | import com.lambda.event.events.InventoryEvent; |
22 | 22 | import com.lambda.event.events.PlayerEvent; |
23 | | -import com.lambda.interaction.handlers.BaritoneHandler; |
24 | | -import com.lambda.interaction.managers.inventory.InventoryManager; |
25 | | -import com.lambda.interaction.managers.rotating.RotationManager; |
| 23 | +import com.lambda.interaction.handler.handlers.BaritoneHandler; |
| 24 | +import com.lambda.interaction.manager.managers.inventory.InventoryManager; |
| 25 | +import com.lambda.interaction.manager.managers.rotating.RotationManager; |
| 26 | +import com.lambda.module.modules.client.Client; |
26 | 27 | import com.llamalad7.mixinextras.injector.ModifyExpressionValue; |
27 | 28 | import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; |
28 | 29 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
@@ -111,6 +112,17 @@ public void clickSlotHead(int syncId, int slotId, int button, SlotActionType act |
111 | 112 | if (EventFlow.post(click).isCanceled()) ci.cancel(); |
112 | 113 | } |
113 | 114 |
|
| 115 | + @Inject(method = "clickSlot", at = @At("TAIL")) |
| 116 | + public void clickSlotTail(int syncId, int slotId, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo ci) { |
| 117 | + if (syncId != player.currentScreenHandler.syncId) return; |
| 118 | + EventFlow.post(new PlayerEvent.SlotClick.Post(syncId, slotId, button, actionType, player.currentScreenHandler)); |
| 119 | + } |
| 120 | + |
| 121 | + @ModifyExpressionValue(method = "clickSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/ScreenHandler;getRevision()I")) |
| 122 | + private int modifyClickSlotRevision(int originalRevision) { |
| 123 | + return Client.INSTANCE.getAvoidInventoryDesync() ? -1 : originalRevision; |
| 124 | + } |
| 125 | + |
114 | 126 | /** |
115 | 127 | * Posts {@link InventoryEvent.HotbarSlot.Update} and returns the event value as the selected slot |
116 | 128 | * <pre>{@code |
@@ -144,7 +156,7 @@ private void cancelBlockBreakingPre(CallbackInfo ci) { |
144 | 156 | @WrapMethod(method = "createPlayer(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/stat/StatHandler;Lnet/minecraft/client/recipebook/ClientRecipeBook;)Lnet/minecraft/client/network/ClientPlayerEntity;") |
145 | 157 | private ClientPlayerEntity wrapCreatePlayer(ClientWorld world, StatHandler statHandler, ClientRecipeBook recipeBook, Operation<ClientPlayerEntity> original) { |
146 | 158 | var player = original.call(world, statHandler, recipeBook); |
147 | | - InventoryManager.INSTANCE.setScreenHandler(player.playerScreenHandler); |
| 159 | + InventoryManager.onSetScreenHandler(player.playerScreenHandler); |
148 | 160 | return player; |
149 | 161 | } |
150 | 162 | } |
0 commit comments