Skip to content

Commit

Permalink
Conditionally load bridge mixins
Browse files Browse the repository at this point in the history
Removes needless console spam
  • Loading branch information
Su5eD committed Oct 27, 2023
1 parent 63d24e3 commit 810a75e
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
@Mod("connectorextras_emi_bridge")
public class EMIBridge {
private static final Logger LOGGER = LogUtils.getLogger();
public static final String EMI_MODID = "emi";

public static void injectModule() {
LOGGER.info("Injecting EMI API classes");
HackyModuleInjector.injectModuleSources("emi", EMIBridge.class.getResource("/relocate"));
HackyModuleInjector.injectModuleSources(EMI_MODID, EMIBridge.class.getResource("/relocate"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package dev.su5ed.sinytra.connectorextras.emibridge;

import com.google.common.base.Suppliers;
import net.minecraftforge.fml.loading.LoadingModList;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;
import java.util.function.Supplier;

public class EMIBridgeMixinPlugin implements IMixinConfigPlugin {
private static final Supplier<Boolean> EMI_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById(EMIBridge.EMI_MODID) != null);

@Override
public void onLoad(String mixinPackage) {}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return EMI_LOADED.get();
}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
}
1 change: 1 addition & 0 deletions emi-bridge/src/main/resources/mixins.emibridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compatibilityLevel": "JAVA_16",
"required": true,
"package": "dev.su5ed.sinytra.connectorextras.emibridge.mixin",
"plugin": "dev.su5ed.sinytra.connectorextras.emibridge.EMIBridgeMixinPlugin",
"mixins": [
"EmiAgnosForgeMixin",
"MainEntrypointMixin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

@Mod("connectorextras_rei_bridge")
public class REIBridge {

public static final String REI_MODID = "roughlyenoughitems";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package dev.su5ed.sinytra.connectorextras.reibridge;

import com.google.common.base.Suppliers;
import net.minecraftforge.fml.loading.LoadingModList;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;
import java.util.function.Supplier;

public class REIBridgeMixinPlugin implements IMixinConfigPlugin {
private static final Supplier<Boolean> REI_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById(REIBridge.REI_MODID) != null);

@Override
public void onLoad(String mixinPackage) {}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return REI_LOADED.get();
}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
}
1 change: 1 addition & 0 deletions rei-bridge/src/main/resources/mixins.reibridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compatibilityLevel": "JAVA_16",
"required": true,
"package": "dev.su5ed.sinytra.connectorextras.reibridge.mixin",
"plugin": "dev.su5ed.sinytra.connectorextras.reibridge.REIBridgeMixinPlugin",
"client": [
"client.RoughlyEnoughItemsCoreClientMixin"
],
Expand Down

0 comments on commit 810a75e

Please sign in to comment.