-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made AppliedFlux an optional dependency
- Loading branch information
Showing
10 changed files
with
309 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/net/pedroksl/advanced_ae/mixins/AAEMixinPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package net.pedroksl.advanced_ae.mixins; | ||
|
||
import net.neoforged.fml.ModList; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
import net.neoforged.fml.loading.LoadingModList; | ||
import net.neoforged.fml.loading.moddiscovery.ModInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class AAEMixinPlugin implements IMixinConfigPlugin { | ||
|
||
private static final Object2ObjectMap<String, String> MOD_MIXINS = new Object2ObjectOpenHashMap<>( | ||
new String[]{"net.pedroksl.advanced_ae.mixins.appflux.MixinAdvPatternProviderMenu", | ||
"net.pedroksl.advanced_ae.mixins.appflux.MixinAdvPatternProviderGui", | ||
"net.pedroksl.advanced_ae.mixins.appflux.MixinAdvPatternProviderLogic", | ||
"net.pedroksl.advanced_ae.mixins.appflux.MixinAdvPatternProviderLogicHost"}, | ||
new String[]{"appflux", "appflux", "appflux", "appflux"}, | ||
Object2ObjectOpenHashMap.DEFAULT_LOAD_FACTOR | ||
); | ||
|
||
@Override | ||
public void onLoad(String s) { | ||
String[] str; | ||
|
||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return !MOD_MIXINS.containsKey(mixinClassName) || isModLoaded(MOD_MIXINS.get(mixinClassName)); | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> set, Set<String> set1) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) { | ||
|
||
} | ||
|
||
private static boolean isModLoaded(String modId) { | ||
if (ModList.get() == null) { | ||
return LoadingModList.get().getMods() | ||
.stream().map(ModInfo::getModId) | ||
.anyMatch(modId::equals); | ||
} else { | ||
return ModList.get().isLoaded(modId); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/net/pedroksl/advanced_ae/mixins/appflux/MixinAdvPatternProviderGui.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package net.pedroksl.advanced_ae.mixins.appflux; | ||
|
||
import appeng.api.upgrades.Upgrades; | ||
import appeng.client.gui.AEBaseScreen; | ||
import appeng.client.gui.style.ScreenStyle; | ||
import appeng.client.gui.widgets.UpgradesPanel; | ||
import appeng.core.localization.GuiText; | ||
import appeng.menu.SlotSemantics; | ||
import com.glodblock.github.appflux.util.helpers.IUpgradableMenu; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.pedroksl.advanced_ae.gui.advpatternprovider.AdvPatternProviderContainer; | ||
import net.pedroksl.advanced_ae.gui.advpatternprovider.AdvPatternProviderGui; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Mixin(AdvPatternProviderGui.class) | ||
public abstract class MixinAdvPatternProviderGui extends AEBaseScreen<AdvPatternProviderContainer> { | ||
|
||
@Inject( | ||
method = "<init>", | ||
at = @At("TAIL"), | ||
remap = false | ||
) | ||
private void initUpgrade(AdvPatternProviderContainer menu, Inventory playerInventory, Component title, ScreenStyle style, CallbackInfo ci) { | ||
this.widgets.add("upgrades", new UpgradesPanel(menu.getSlots(SlotSemantics.UPGRADE), this::af_$getCompatibleUpgrades)); | ||
} | ||
|
||
@Unique | ||
private List<Component> af_$getCompatibleUpgrades() { | ||
var list = new ArrayList<Component>(); | ||
list.add(GuiText.CompatibleUpgrades.text()); | ||
list.addAll(Upgrades.getTooltipLinesForMachine(((IUpgradableMenu) menu).getUpgrades().getUpgradableItem())); | ||
return list; | ||
} | ||
|
||
public MixinAdvPatternProviderGui(AdvPatternProviderContainer menu, Inventory playerInventory, Component title, ScreenStyle style) { | ||
super(menu, playerInventory, title, style); | ||
} | ||
|
||
} |
Oops, something went wrong.