-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
87587a3
commit e638f9a
Showing
10 changed files
with
136 additions
and
130 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
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
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
59 changes: 59 additions & 0 deletions
59
src/main/java/me/fengming/vaultpatcher_asm/forge/ForgeClassTransformer.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,59 @@ | ||
package me.fengming.vaultpatcher_asm.forge; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import cpw.mods.modlauncher.api.ITransformerVotingContext; | ||
import cpw.mods.modlauncher.api.TransformerVoteResult; | ||
import me.fengming.vaultpatcher_asm.Utils; | ||
import me.fengming.vaultpatcher_asm.VaultPatcher; | ||
import me.fengming.vaultpatcher_asm.config.DebugMode; | ||
import me.fengming.vaultpatcher_asm.config.TranslationInfo; | ||
import me.fengming.vaultpatcher_asm.config.VaultPatcherConfig; | ||
import me.fengming.vaultpatcher_asm.core.VPClassTransformer; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ForgeClassTransformer implements ITransformer<ClassNode> { | ||
|
||
private final TranslationInfo translationInfo; | ||
private final DebugMode debug = VaultPatcherConfig.getDebugMode(); | ||
|
||
public ForgeClassTransformer(TranslationInfo info) { | ||
this.translationInfo = info; | ||
// if (info != null && debug.isEnable()) { | ||
// VaultPatcher.LOGGER.debug(String.format("[VaultPatcher Debug] Loading VPTransformer for Class: %s, Method: %s, Local: %s, Pairs: %s", info.getTargetClassInfo().getName(), info.getTargetClassInfo().getMethod(), info.getTargetClassInfo().getLocal(), info.getPairs())); | ||
// } | ||
} | ||
|
||
// for Forge | ||
@Override | ||
public ClassNode transform(ClassNode input, ITransformerVotingContext context) { | ||
new VPClassTransformer(this.translationInfo).accept(input); | ||
return input; | ||
} | ||
|
||
@Override | ||
public TransformerVoteResult castVote(ITransformerVotingContext context) { | ||
return TransformerVoteResult.YES; | ||
} | ||
|
||
@Override | ||
public Set<Target> targets() { | ||
Set<Target> targets = new HashSet<>(); | ||
|
||
if (translationInfo == null) { | ||
targets.addAll(Utils.addConfigApplyMods()); // May cause unnecessary resource waste | ||
targets.addAll(Utils.addConfigClasses()); | ||
} else { | ||
Target t = Utils.addTargetClasses(this.translationInfo); | ||
if (t != null) targets.add(t); | ||
} | ||
|
||
if (debug.isEnable()) { | ||
targets.iterator().forEachRemaining(t -> VaultPatcher.LOGGER.debug(String.format("[VaultPatcher Debug] VPClassTransformer Target = %s", t.getClassName()))); | ||
} | ||
|
||
return targets; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/me/fengming/vaultpatcher_asm/forge/ForgeMinecraftTransformer.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,42 @@ | ||
package me.fengming.vaultpatcher_asm.forge; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import cpw.mods.modlauncher.api.ITransformerVotingContext; | ||
import cpw.mods.modlauncher.api.TransformerVoteResult; | ||
import me.fengming.vaultpatcher_asm.VaultPatcher; | ||
import me.fengming.vaultpatcher_asm.core.VPMinecraftTransformer; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ForgeMinecraftTransformer implements ITransformer<ClassNode> { | ||
public ForgeMinecraftTransformer() { | ||
VaultPatcher.LOGGER.info("[VaultPatcher] Loading MinecraftTransformer"); | ||
} | ||
|
||
// for Forge | ||
@Override | ||
public ClassNode transform(ClassNode input, ITransformerVotingContext context) { | ||
new VPMinecraftTransformer().accept(input); | ||
return input; | ||
} | ||
|
||
@Override | ||
public TransformerVoteResult castVote(ITransformerVotingContext context) { | ||
return TransformerVoteResult.YES; | ||
} | ||
|
||
|
||
@Override | ||
public Set<Target> targets() { | ||
Set<Target> targets = new HashSet<>(); | ||
// TextComponent | ||
targets.add(Target.targetClass("net.minecraft.util.text.StringTextComponent")); | ||
targets.add(Target.targetClass("net.minecraft.network.chat.TextComponent")); | ||
// Font | ||
targets.add(Target.targetClass("net.minecraft.client.gui.Font")); | ||
targets.add(Target.targetClass("net.minecraft.client.gui.FontRenderer")); | ||
return targets; | ||
} | ||
} |
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
Oops, something went wrong.