6
6
7
7
import com .google .common .collect .ImmutableSet ;
8
8
import com .google .common .collect .Sets ;
9
- import com .llamalad7 .mixinextras .sugar . Local ;
9
+ import com .llamalad7 .mixinextras .injector . ModifyReceiver ;
10
10
11
11
import org .jetbrains .annotations .Nullable ;
12
12
import org .spongepowered .asm .mixin .Final ;
22
22
23
23
import appeng .api .networking .IGridNode ;
24
24
import appeng .api .stacks .AEItemKey ;
25
- import appeng .api .stacks .AEKey ;
26
- import appeng .api .stacks .KeyCounter ;
25
+ import appeng .api .storage .AEKeyFilter ;
27
26
import appeng .api .storage .ITerminalHost ;
27
+ import appeng .core .network .clientbound .MEInventoryUpdatePacket ;
28
28
import appeng .menu .AEBaseMenu ;
29
29
import appeng .menu .me .common .IncrementalUpdateHelper ;
30
30
import appeng .menu .me .common .MEStorageMenu ;
31
31
32
- import gripe ._90 .appliede .me .reporting .MEInventoryUpdatePacketBuilder ;
32
+ import gripe ._90 .appliede .me .reporting .TransmutablePacketBuilder ;
33
33
import gripe ._90 .appliede .me .service .KnowledgeService ;
34
34
35
35
@ Mixin (MEStorageMenu .class )
36
36
public abstract class MEStorageMenuMixin extends AEBaseMenu {
37
- @ Shadow
38
- private Set <AEKey > previousCraftables ;
39
-
40
- @ Shadow
41
- private KeyCounter previousAvailableStacks ;
42
-
43
37
@ Shadow
44
38
@ Final
45
39
private IncrementalUpdateHelper updateHelper ;
46
40
41
+ @ Unique
42
+ private Set <AEItemKey > appliede$transmutables = new HashSet <>();
43
+
47
44
@ Unique
48
45
private Set <AEItemKey > appliede$previousTransmutables = new HashSet <>();
49
46
@@ -54,9 +51,6 @@ public MEStorageMenuMixin(MenuType<?> menuType, int id, Inventory playerInventor
54
51
@ Shadow
55
52
protected abstract boolean showsCraftables ();
56
53
57
- @ Shadow
58
- public abstract boolean isKeyVisible (AEKey key );
59
-
60
54
@ Shadow
61
55
public abstract @ Nullable IGridNode getGridNode ();
62
56
@@ -71,36 +65,32 @@ public MEStorageMenuMixin(MenuType<?> menuType, int id, Inventory playerInventor
71
65
: Collections .emptySet ();
72
66
}
73
67
74
- // spotless:off
75
- @ SuppressWarnings ("Convert2MethodRef" )
76
68
@ Inject (
69
+ method = "broadcastChanges" ,
70
+ at = @ At (value = "INVOKE" , target = "Lappeng/menu/me/common/IncrementalUpdateHelper;hasChanges()Z" ))
71
+ private void addTransmutables (CallbackInfo ci ) {
72
+ appliede$transmutables = appliede$getTransmutablesFromGrid ();
73
+ Sets .difference (appliede$previousTransmutables , appliede$transmutables ).forEach (updateHelper ::addChange );
74
+ Sets .difference (appliede$transmutables , appliede$previousTransmutables ).forEach (updateHelper ::addChange );
75
+ }
76
+
77
+ // spotless:off
78
+ @ ModifyReceiver (
77
79
method = "broadcastChanges" ,
78
80
at = @ At (
79
81
value = "INVOKE" ,
80
- target = "Lappeng/menu/me/common/IncrementalUpdateHelper;hasChanges()Z" ),
81
- cancellable = true )
82
+ target = "Lappeng/core/network/clientbound/MEInventoryUpdatePacket$Builder;setFilter(Lappeng/api/storage/AEKeyFilter;)V" ))
82
83
// spotless:on
83
- private void replacePacket (
84
- CallbackInfo ci , @ Local Set <AEKey > craftable , @ Local (name = "availableStacks" ) KeyCounter availableStacks ) {
85
- ci .cancel ();
86
-
87
- var transmutable = appliede$getTransmutablesFromGrid ();
88
- Sets .difference (appliede$previousTransmutables , transmutable ).forEach (updateHelper ::addChange );
89
- Sets .difference (transmutable , appliede$previousTransmutables ).forEach (updateHelper ::addChange );
90
-
91
- if (updateHelper .hasChanges ()) {
92
- var builder = new MEInventoryUpdatePacketBuilder (
93
- containerId , updateHelper .isFullUpdate (), getPlayer ().registryAccess ());
94
- builder .setFilter (key -> isKeyVisible (key ));
95
- builder .addChanges (updateHelper , availableStacks , craftable , new KeyCounter (), transmutable );
96
- builder .buildAndSend (packet -> sendPacketToClient (packet ));
97
- updateHelper .commitChanges ();
98
- }
99
-
100
- previousCraftables = ImmutableSet .copyOf (craftable );
101
- previousAvailableStacks = availableStacks ;
102
- appliede$previousTransmutables = ImmutableSet .copyOf (transmutable );
84
+ private MEInventoryUpdatePacket .Builder addTransmutables (
85
+ MEInventoryUpdatePacket .Builder builder , AEKeyFilter filter ) {
86
+ ((TransmutablePacketBuilder ) builder ).appliede$addTransmutables (appliede$transmutables );
87
+ return builder ;
88
+ }
103
89
104
- super .broadcastChanges ();
90
+ @ Inject (
91
+ method = "broadcastChanges" ,
92
+ at = @ At (value = "INVOKE" , target = "Lappeng/menu/AEBaseMenu;broadcastChanges()V" ))
93
+ private void addPreviousTransmutables (CallbackInfo ci ) {
94
+ appliede$previousTransmutables = ImmutableSet .copyOf (appliede$transmutables );
105
95
}
106
96
}
0 commit comments