generated from kappa-maintainer/1.12.2-FG6-Template
-
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.
- Loading branch information
1 parent
3911466
commit e675241
Showing
3 changed files
with
32 additions
and
3 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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/cleanroommc/fugue/transformer/loliasm/ModIdentifierTransformer.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,30 @@ | ||
package com.cleanroommc.fugue.transformer.loliasm; | ||
|
||
import com.cleanroommc.fugue.common.Fugue; | ||
import javassist.ClassPool; | ||
import javassist.CtClass; | ||
import top.outlands.foundation.IExplicitTransformer; | ||
|
||
import java.io.ByteArrayInputStream; | ||
|
||
public class ModIdentifierTransformer implements IExplicitTransformer { | ||
@Override | ||
public byte[] transform(byte[] bytes) { | ||
try { | ||
var cp = ClassPool.getDefault(); | ||
CtClass cc = cp.makeClass(new ByteArrayInputStream(bytes)); | ||
var ifc = cc.getMethod("identifyFromClass", "(Ljava/lang/String;Ljava/util/Map;)Ljava/util/Set;"); | ||
ifc.insertAt(64, """ | ||
{ | ||
if (url.getProtocol().equals("jrt")) { | ||
return java.util.Collections#emptySet(); | ||
} | ||
} | ||
"""); | ||
bytes = cc.toBytecode(); | ||
} catch (Throwable t) { | ||
Fugue.LOGGER.error(t); | ||
} | ||
return bytes; | ||
} | ||
} |