Workaround OF breaking spectator hand mixin
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.replaymod.core;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
//#if MC>=11400
|
||||
import java.io.InputStream;
|
||||
//#else
|
||||
//$$ import net.minecraft.launchwrapper.Launch;
|
||||
//#endif
|
||||
|
||||
public class ReplayModMixinConfigPlugin implements IMixinConfigPlugin {
|
||||
static boolean hasClass(String name) throws IOException {
|
||||
//#if MC>=11400
|
||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name.replace('.', '/') + ".class");
|
||||
if (stream != null) stream.close();
|
||||
return stream != null;
|
||||
//#else
|
||||
//$$ return Launch.classLoader.getClassBytes(name) != null;
|
||||
//#endif
|
||||
}
|
||||
|
||||
private final Logger logger = LogManager.getLogger("replaymod/mixin");
|
||||
private final boolean hasOF = hasClass("optifine.OptiFineForgeTweaker") || hasClass("me.modmuss50.optifabric.mod.Optifabric");
|
||||
|
||||
{
|
||||
logger.error("hasOF: " + hasOF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
if (mixinClassName.endsWith("_OF")) return hasOF;
|
||||
if (mixinClassName.endsWith("_NoOF")) return !hasOF;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
public ReplayModMixinConfigPlugin() throws IOException {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user