Skip to content

Commit

Permalink
Get smarter about applying mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
OreCruncher committed Feb 3, 2024
1 parent fb77994 commit db3d8ee
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/main/java/org/orecruncher/dsurround/mixins/MixinPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.orecruncher.dsurround.mixins;

import com.llamalad7.mixinextras.MixinExtrasBootstrap;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.orecruncher.dsurround.Constants;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class MixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
MixinExtrasBootstrap.init();
}

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

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.equals("org.orecruncher.dsurround.mixins.core.MixinClothAbstractConfigEntry"))
return FabricLoader.getInstance().isModLoaded(Constants.CLOTH_CONFIG);
return true;
}

@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) {

}
}
3 changes: 2 additions & 1 deletion src/main/resources/dsurround.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"server": [],
"injectors": {
"defaultRequire": 1
}
},
"plugin": "org.orecruncher.dsurround.mixins.MixinPlugin"
}

0 comments on commit db3d8ee

Please sign in to comment.