1
1
package com .ultramega .universalgrid .common .mixin ;
2
2
3
- import com .refinedmods .refinedstorage .common .api .RefinedStorageApi ;
4
- import com .refinedmods .refinedstorage .common .api .support .slotreference .SlotReference ;
5
- import com .refinedmods .refinedstorage .common .support .AbstractBaseContainerMenu ;
6
-
3
+ import com .ultramega .universalgrid .common .ClientUtils ;
7
4
import com .ultramega .universalgrid .common .Platform ;
8
5
import com .ultramega .universalgrid .common .gui .view .GridTypes ;
9
6
import com .ultramega .universalgrid .common .interfaces .MixinDisabledSlot ;
10
7
import com .ultramega .universalgrid .common .interfaces .MixinGridType ;
11
- import com .ultramega .universalgrid .common .packet .SetCursorPacketOntoStackPacket ;
12
8
import com .ultramega .universalgrid .common .registry .Items ;
13
9
14
- import java .nio .DoubleBuffer ;
10
+ import com .refinedmods .refinedstorage .common .api .RefinedStorageApi ;
11
+ import com .refinedmods .refinedstorage .common .api .support .slotreference .SlotReference ;
12
+ import com .refinedmods .refinedstorage .common .support .AbstractBaseContainerMenu ;
13
+
15
14
import javax .annotation .Nullable ;
16
15
17
- import net .minecraft .client .Minecraft ;
18
16
import net .minecraft .world .entity .player .Player ;
19
- import org . lwjgl . BufferUtils ;
20
- import org . lwjgl . glfw . GLFW ;
17
+ import net . minecraft . world . inventory . AbstractContainerMenu ;
18
+ import net . minecraft . world . inventory . MenuType ;
21
19
import org .spongepowered .asm .mixin .Mixin ;
22
20
import org .spongepowered .asm .mixin .Shadow ;
23
21
import org .spongepowered .asm .mixin .Unique ;
24
22
25
23
@ Mixin (AbstractBaseContainerMenu .class )
26
- public class MixinAbstractBaseContainerMenu implements MixinDisabledSlot , MixinGridType {
27
- @ Shadow @ Nullable protected SlotReference disabledSlot ;
24
+ public abstract class MixinAbstractBaseContainerMenu extends AbstractContainerMenu implements MixinDisabledSlot , MixinGridType {
25
+ @ Shadow
26
+ @ Nullable
27
+ protected SlotReference disabledSlot ;
28
+
29
+ protected MixinAbstractBaseContainerMenu (@ Nullable final MenuType <?> menuType , final int containerId ) {
30
+ super (menuType , containerId );
31
+ }
28
32
29
33
@ Unique
30
34
@ Override
31
35
public @ Nullable SlotReference universalgrid$getDisabledSlot () {
32
36
return this .disabledSlot ;
33
37
}
34
38
39
+ @ Override
40
+ public void universalgrid$setDisabledSlot (final SlotReference disabledSlot ) {
41
+ this .disabledSlot = disabledSlot ;
42
+ }
43
+
35
44
@ Unique
36
45
@ Override
37
46
public GridTypes universalgrid$getGridType () {
@@ -40,27 +49,16 @@ public class MixinAbstractBaseContainerMenu implements MixinDisabledSlot, MixinG
40
49
41
50
@ Unique
42
51
@ Override
43
- public void universalgrid$setGridType (final GridTypes gridType ) {
52
+ public void universalgrid$setGridType (final GridTypes gridType , @ Nullable final Player player ) {
44
53
Platform .getConfig ().getWirelessUniversalGrid ().setGridType (gridType );
45
54
46
- Player player = Minecraft .getInstance ().player ;
47
-
48
55
// Save cursor position
49
- SlotReference gridSlot = this .universalgrid$getDisabledSlot ();
50
- if (gridSlot != null ) {
51
- DoubleBuffer x = BufferUtils .createDoubleBuffer (1 );
52
- DoubleBuffer y = BufferUtils .createDoubleBuffer (1 );
53
-
54
- GLFW .glfwGetCursorPos (Minecraft .getInstance ().getWindow ().getWindow (), x , y );
55
-
56
- com .refinedmods .refinedstorage .common .Platform .INSTANCE .sendPacketToServer (new SetCursorPacketOntoStackPacket (
57
- gridSlot ,
58
- (int ) Math .round (x .get ()),
59
- (int ) Math .round (y .get ()),
60
- true ));
61
- }
56
+ final SlotReference gridSlot = this .universalgrid$getDisabledSlot ();
57
+ if (player != null && gridSlot != null ) {
58
+ if (player .level ().isClientSide ()) {
59
+ ClientUtils .updateCursorPos (gridSlot );
60
+ }
62
61
63
- if (player != null ) {
64
62
// Re-open screen with new grid type (the old screen/container will automatically be closed)
65
63
RefinedStorageApi .INSTANCE .useSlotReferencedItem (
66
64
player ,
0 commit comments