Skip to content

Commit 817cc57

Browse files
committed
阻止NEE的GhostIngredientHandler与AE2UEL的重复注册
1 parent 73ba514 commit 817cc57

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

src/main/java/com/circulation/random_complement/mixin/ae2/MixinEnergyGridCache.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ public void isNetworkPowered(CallbackInfoReturnable<Boolean> cir) {
5757

5858
@Unique
5959
private boolean r$hasCreativeEnergyCell() {
60-
if (((AccessorGrid) this.myGrid).r$getMachines().containsKey(TileCreativeEnergyCell.class)) {
61-
return !this.myGrid.getMachines(TileCreativeEnergyCell.class).isEmpty();
62-
}
63-
return false;
60+
final var m = ((AccessorGrid) this.myGrid).r$getMachines().get(TileCreativeEnergyCell.class);
61+
return m != null && !m.isEmpty();
6462
}
6563

6664
@Inject(method = "extractAEPower", at = @At("HEAD"), cancellable = true)

src/main/java/com/circulation/random_complement/mixin/ae2/MixinGridPowerStorage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ public abstract class MixinGridPowerStorage implements RCGridPowerStorage {
2020
@Unique
2121
private boolean r$hasCreativeEnergyCell() {
2222
if (r$grid == null) return false;
23-
if (((AccessorGrid) this.r$grid).r$getMachines().containsKey(TileCreativeEnergyCell.class)) {
24-
return !this.r$grid.getMachines(TileCreativeEnergyCell.class).isEmpty();
25-
}
26-
return false;
23+
final var m = ((AccessorGrid) this.r$grid).r$getMachines().get(TileCreativeEnergyCell.class);
24+
return m != null && !m.isEmpty();
2725
}
2826

2927
@Inject(method = "extractAEPower", at = @At("HEAD"), cancellable = true)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.circulation.random_complement.mixin.nee;
2+
3+
import com.github.vfyjxf.nee.jei.NEEJeiPlugin;
4+
import mezz.jei.api.IModRegistry;
5+
import mezz.jei.api.gui.IGhostIngredientHandler;
6+
import net.minecraft.client.gui.GuiScreen;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Redirect;
10+
11+
@Mixin(value = NEEJeiPlugin.class,remap = false)
12+
public class MixinNEEJeiPlugin {
13+
14+
@Redirect(method = "register",at = @At(value = "INVOKE", target = "Lmezz/jei/api/IModRegistry;addGhostIngredientHandler(Ljava/lang/Class;Lmezz/jei/api/gui/IGhostIngredientHandler;)V"))
15+
public void cancelNEEGhostIngredient(IModRegistry instance, Class<Object> tClass, IGhostIngredientHandler<GuiScreen> tiGhostIngredientHandler) {
16+
17+
}
18+
}

src/main/resources/mixins.random_complement.nee.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
"MixinPacketCraftingRequest"
1010
],
1111
"server": [],
12-
"client": []
12+
"client": [
13+
"MixinNEEJeiPlugin"
14+
]
1315
}

0 commit comments

Comments
 (0)