44import appeng .api .config .PowerMultiplier ;
55import appeng .api .networking .IGrid ;
66import appeng .me .cache .EnergyGridCache ;
7- import appeng .tile .networking .TileCreativeEnergyCell ;
87import com .circulation .random_complement .RCConfig ;
9- import com .circulation .random_complement .common .interfaces .RCGridPowerStorage ;
8+ import com .circulation .random_complement .common .interfaces .RCEnergyGridCache ;
9+ import com .circulation .random_complement .common .interfaces .RCGrid ;
1010import org .spongepowered .asm .mixin .Final ;
1111import org .spongepowered .asm .mixin .Mixin ;
1212import org .spongepowered .asm .mixin .Shadow ;
1313import org .spongepowered .asm .mixin .Unique ;
1414import org .spongepowered .asm .mixin .injection .At ;
1515import org .spongepowered .asm .mixin .injection .Inject ;
16- import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
1716import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
1817
19- import java .lang .reflect .Field ;
20-
2118@ Mixin (value = EnergyGridCache .class , remap = false )
22- public abstract class MixinEnergyGridCache {
23-
24- @ Unique
25- private static Field r$localStorage ;
26-
27- static {
28- try {
29- r$localStorage = EnergyGridCache .class .getDeclaredField ("localStorage" );
30- } catch (NoSuchFieldException ignored ) {
31-
32- }
33- }
19+ public abstract class MixinEnergyGridCache implements RCEnergyGridCache {
3420
3521 @ Shadow
3622 @ Final
3723 private IGrid myGrid ;
3824
39- @ Inject (method = "<init>" , at = @ At ("TAIL" ))
40- public void onInit (IGrid g , CallbackInfo ci ) {
41- if (r$localStorage != null ) {
42- try {
43- RCGridPowerStorage rg = (RCGridPowerStorage ) r$localStorage .get (this );
44- rg .r$setGrid (g );
45- } catch (IllegalAccessException ignored ) {
46-
47- }
48- }
49- }
50-
5125 @ Inject (method = "isNetworkPowered" , at = @ At ("HEAD" ), cancellable = true )
5226 public void isNetworkPowered (CallbackInfoReturnable <Boolean > cir ) {
5327 if (RCConfig .AE2 .debugEnergy || r$hasCreativeEnergyCell ()) {
@@ -56,9 +30,8 @@ public void isNetworkPowered(CallbackInfoReturnable<Boolean> cir) {
5630 }
5731
5832 @ Unique
59- private boolean r$hasCreativeEnergyCell () {
60- final var m = ((AccessorGrid ) this .myGrid ).r$getMachines ().get (TileCreativeEnergyCell .class );
61- return m != null && !m .isEmpty ();
33+ public boolean r$hasCreativeEnergyCell () {
34+ return ((RCGrid ) this .myGrid ).r$hasCreativeEnergyCell ();
6235 }
6336
6437 @ Inject (method = "extractAEPower" , at = @ At ("HEAD" ), cancellable = true )
0 commit comments