1+ package github .kasuminova .novaeng .mixin .ae2 ;
2+
3+ import appeng .api .networking .crafting .ICraftingPatternDetails ;
4+ import appeng .helpers .DualityInterface ;
5+ import com .circulation .random_complement .client .RCSettings ;
6+ import com .circulation .random_complement .client .buttonsetting .IntelligentBlocking ;
7+ import com .circulation .random_complement .common .interfaces .RCIConfigurableObject ;
8+ import com .llamalad7 .mixinextras .sugar .Local ;
9+ import net .minecraft .inventory .InventoryCrafting ;
10+ import org .spongepowered .asm .mixin .Mixin ;
11+ import org .spongepowered .asm .mixin .Shadow ;
12+ import org .spongepowered .asm .mixin .Unique ;
13+ import org .spongepowered .asm .mixin .injection .At ;
14+ import org .spongepowered .asm .mixin .injection .Inject ;
15+ import org .spongepowered .asm .mixin .injection .Redirect ;
16+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
17+
18+ @ Mixin (value = DualityInterface .class ,remap = false )
19+ public abstract class MixinDualityInterface implements RCIConfigurableObject {
20+
21+ @ Shadow
22+ protected abstract boolean isBlocking ();
23+
24+ @ Unique
25+ private int r$lastInputHash ;
26+
27+ @ Inject (method = "isBusy" , at = @ At (value = "INVOKE" , target = "Lappeng/helpers/DualityInterface;isBlocking()Z" , shift = At .Shift .AFTER ), cancellable = true )
28+ public void isIntelligentBlocking (CallbackInfoReturnable <Boolean > cir ) {
29+ if (this .r$getConfigManager ().getSetting (RCSettings .IntelligentBlocking ) == IntelligentBlocking .OPEN ) {
30+ cir .setReturnValue (false );
31+ }
32+ }
33+
34+ @ Inject (method = "pushPattern" , at = @ At ("RETURN" ))
35+ public void intelligentBlocking (ICraftingPatternDetails pattern , InventoryCrafting table , CallbackInfoReturnable <Boolean > cir ) {
36+ if (this .r$getConfigManager ().getSetting (RCSettings .IntelligentBlocking ) == IntelligentBlocking .OPEN && cir .getReturnValue ()) {
37+ this .r$lastInputHash = pattern .hashCode ();
38+ }
39+ }
40+
41+ @ Redirect (method = "pushPattern" , at = @ At (value = "INVOKE" , target = "Lappeng/helpers/DualityInterface;isBlocking()Z" ))
42+ public boolean intelligentBlocking (DualityInterface instance , @ Local (name = "patternDetails" ) ICraftingPatternDetails patternDetails ) {
43+ boolean b = this .isBlocking ();
44+ if (b ) {
45+ return this .r$getConfigManager ()
46+ .getSetting (RCSettings .IntelligentBlocking ) != IntelligentBlocking .OPEN
47+ || this .r$lastInputHash != patternDetails .hashCode ();
48+ }
49+ return b ;
50+ }
51+
52+ }
0 commit comments