Skip to content

Commit

Permalink
Update readme & add crossbow patch
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Sep 13, 2024
1 parent 3d4bf81 commit 072c159
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ If you are still using 0.1.0 Cleanroom, use 0.5.4. But that's not recommended.
* In Control!
* More Refined Storage
* Better Formatting Code
* 5zig
* Ears
* Colytra
* Crossbow

## Note
Add + to start of the file if it's not there.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ public class FugueLoadingPlugin implements IFMLLoadingPlugin {
if (FugueConfig.modPatchConfig.enableColytra) {
TransformerDelegate.registerExplicitTransformerByInstance(new EntityLivingBaseTransformer(), "net.minecraft.entity.EntityLivingBase");
}
if (FugueConfig.modPatchConfig.enableCrossbow) {
TransformerDelegate.registerExplicitTransformerByInstance(new TransformerEntityArrowTransformer(), "git.jbredwards.crossbow.mod.asm.transformer.TransformerEntityArrow");
}
if (FugueConfig.getCodeSourcePatchTargets.length > 0) {
TransformerDelegate.registerExplicitTransformerByInstance(new ITweakerTransformer(), FugueConfig.getCodeSourcePatchTargets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ public class ModPatchConfig {
public boolean enableColytra = true;
@Config.Name("Enable InfinityLib Patch")
public boolean enableInfLib = true;
@Config.Name("Enable Crossbow(jbredwards) Patch")
public boolean enableCrossbow = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.cleanroommc.fugue.transformer;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;
import top.outlands.foundation.IExplicitTransformer;

public class TransformerEntityArrowTransformer implements IExplicitTransformer {
@Override
public byte[] transform(byte[] bytes) {
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
if (classNode.methods != null)
{
for (MethodNode methodNode : classNode.methods)
{
if (methodNode.name.equals("transform")) {
InsnList instructions = methodNode.instructions;
if (instructions != null)
{
for (AbstractInsnNode insnNode : instructions)
{
if (insnNode.getOpcode() == Opcodes.ICONST_0 && insnNode.getPrevious() instanceof LdcInsnNode ldcInsnNode && ldcInsnNode.cst.equals("(Lnet/minecraftforge/common/capabilities/ICapabilityProvider;)Lgit/jbredwards/crossbow/mod/common/capability/ICrossbowArrowData;"))
{
instructions.insert(insnNode, new InsnNode(Opcodes.ICONST_1));
instructions.remove(insnNode);
}
}
}
}
}
}
ClassWriter classWriter = new ClassWriter(0);

classNode.accept(classWriter);
return classWriter.toByteArray();
}
}

0 comments on commit 072c159

Please sign in to comment.