net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper Java Examples

The following examples show how to use net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeChickenAccessTransformer.java    From CodeChickenCore with MIT License 6 votes vote down vote up
private void loadPublicConfig() {
    if (ObfMapping.obfuscated)
        return;

    makeAllPublic = CodeChickenCoreModContainer.config.getTag("dev.runtimePublic")
            .setComment("Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader." +
                    "\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers." +
                    "\nSuch mods are doing the wrong thing and should be fixed.")
            .getBooleanValue(false);

    if (!makeAllPublic)
        return;

    try {
        f_classNameBiMap = FMLDeobfuscatingRemapper.class.getDeclaredField("classNameBiMap");
        f_classNameBiMap.setAccessible(true);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #2
Source File: FieldMatcher.java    From OpenModsLib with MIT License 5 votes vote down vote up
public boolean match(String fieldName, String fieldDesc) {
	if (!fieldDesc.equals(description)) return false;
	if (fieldName.equals(mcpName)) return true;
	if (!VisitorHelper.useSrgNames()) return false;
	String mapped = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(clsName, fieldName, fieldDesc);
	return mapped.equals(srgName);
}
 
Example #3
Source File: MethodMatcher.java    From OpenModsLib with MIT License 5 votes vote down vote up
public boolean match(String methodName, String methodDesc) {
	if (!methodDesc.equals(description)) return false;
	if (methodName.equals(mcpName)) return true;
	if (!VisitorHelper.useSrgNames()) return false;
	String mapped = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(clsName, methodName, methodDesc);
	return mapped.equals(srgName);
}
 
Example #4
Source File: ClassHeirachyManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static String getSuperClass(String name, boolean runtime) {
    name = toKey(name);
    SuperCache cache = declareClass(name);
    if (cache == null)
        return "java.lang.Object";

    cache.flatten();
    String s = cache.superclass;
    if (!runtime)
        s = FMLDeobfuscatingRemapper.INSTANCE.unmap(s);
    return s;
}
 
Example #5
Source File: ClassHeirachyManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getSuperClass(String name, boolean runtime) {
	name = toKey(name);
	SuperCache cache = declareClass(name);
	if (cache == null) {
		return "java.lang.Object";
	}

	cache.flatten();
	String s = cache.superclass;
	if (!runtime) {
		s = FMLDeobfuscatingRemapper.INSTANCE.unmap(s);
	}
	return s;
}
 
Example #6
Source File: ClassHeirachyManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getSuperClass(String name, boolean runtime) {
	name = toKey(name);
	SuperCache cache = declareClass(name);
	if (cache == null) {
		return "java.lang.Object";
	}

	cache.flatten();
	String s = cache.superclass;
	if (!runtime) {
		s = FMLDeobfuscatingRemapper.INSTANCE.unmap(s);
	}
	return s;
}
 
Example #7
Source File: CodeChickenAccessTransformer.java    From CodeChickenCore with MIT License 5 votes vote down vote up
private void setClassMap(String name) {
    try {
        f_classNameBiMap.set(FMLDeobfuscatingRemapper.INSTANCE, ImmutableBiMap.of(name.replace('.', '/'), ""));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #8
Source File: CodeChickenAccessTransformer.java    From CodeChickenCore with MIT License 5 votes vote down vote up
private void restoreClassMap() {
    try {
        f_classNameBiMap.set(FMLDeobfuscatingRemapper.INSTANCE, emptyMap);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #9
Source File: ObfHelper.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Obfuscates a deobfuscated class name regardless of {@link #isObfuscated()}.
 */
public static String forceToObfClassName(String deobfClassName)
{
	return FMLDeobfuscatingRemapper.INSTANCE.unmap(deobfClassName.replace('.', '/')).replace('/', '.');
}
 
Example #10
Source File: VisitorHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static String getMappedName(String clsName) {
	return useSrgNames()? FMLDeobfuscatingRemapper.INSTANCE.unmap(clsName) : clsName;
}
 
Example #11
Source File: ObfMapping.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public String unmap(String typeName) {
    return FMLDeobfuscatingRemapper.INSTANCE.map(typeName);
}
 
Example #12
Source File: ObfMapping.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public String map(String typeName) {
    return FMLDeobfuscatingRemapper.INSTANCE.unmap(typeName);
}
 
Example #13
Source File: ClassHeirachyManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static String unKey(String name) {
    if (ObfMapping.obfuscated)
        name = FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/', '.');
    return name;
}
 
Example #14
Source File: ClassHeirachyManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static String toKey(String name) {
    if (ObfMapping.obfuscated)
        name = FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.', '/')).replace('/', '.');
    return name;
}
 
Example #15
Source File: ObfMapping.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String map(String typeName) {
    return FMLDeobfuscatingRemapper.INSTANCE.unmap(typeName);
}
 
Example #16
Source File: ObfHelper.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Deobfuscates an obfuscated class name regardless of {@link #isObfuscated()}.
 */
public static String forceToDeobfClassName(String obfClassName)
{
	return FMLDeobfuscatingRemapper.INSTANCE.map(obfClassName.replace('.', '/')).replace('/', '.');
}
 
Example #17
Source File: ClassHeirachyManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String unKey(String name) {
	if (ObfMapping.obfuscated) {
		name = FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/', '.');
	}
	return name;
}
 
Example #18
Source File: ClassHeirachyManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String toKey(String name) {
	if (ObfMapping.obfuscated) {
		name = FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.', '/')).replace('/', '.');
	}
	return name;
}
 
Example #19
Source File: ClassHeirachyManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String unKey(String name) {
	if (ObfMapping.obfuscated) {
		name = FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/', '.');
	}
	return name;
}
 
Example #20
Source File: ClassHeirachyManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String toKey(String name) {
	if (ObfMapping.obfuscated) {
		name = FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.', '/')).replace('/', '.');
	}
	return name;
}
 
Example #21
Source File: ObfuscatedStateMapper.java    From ForgeHax with MIT License 4 votes vote down vote up
protected ObfuscatedStateMapper() {
  LOGGER.info("Using build mapping \"" + ForgeHaxProperties.getMcpMappingUrl() + "\"");
  
  MCPMappingLoader mcpMappingLoader = null;
  try {
    mcpMappingLoader = new MCPMappingLoader(ForgeHaxProperties.getMcpMappingUrl());
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
    ASMStackLogger.printStackTrace(e);
  }
  
  LOGGER.info("Mapping data successfully initialize");
  
  Objects.requireNonNull(mcpMappingLoader, "MCPMappingLoader failed to lookup obfuscation data");
  
  if (isObfuscated()) {
    LOGGER.info("initializing ObfuscatedStateMapper WITH obfuscation");
  } else {
    LOGGER.info("initializing ObfuscatedStateMapper WITHOUT obfuscation");
  }
  
  this.mcClasses =
    ImmutableBiMap.copyOf(
      FastReflectionForge.Fields.FMLDeobfuscatingRemapper_classNameBiMap.get(
        FMLDeobfuscatingRemapper.INSTANCE));
  
  this.mcpMethodData =
    buildMcpTypeData(
      mcpMappingLoader.getCsvMethodData(),
      mcpMappingLoader.getSrgFileData().class2MethodDataSet,
      getConvertedMap(
        FastReflectionForge.Fields.FMLDeobfuscatingRemapper_rawMethodMaps.get(
          FMLDeobfuscatingRemapper.INSTANCE),
        str -> str.split("\\(")[0]),
      ((csvData, data) -> csvData.getMcpName() + data.getSrgDescriptor()));
  this.mcpFieldData =
    buildMcpTypeData(
      mcpMappingLoader.getCsvFieldData(),
      mcpMappingLoader.getSrgFileData().class2FieldDataSet,
      getConvertedMap(
        FastReflectionForge.Fields.FMLDeobfuscatingRemapper_rawFieldMaps.get(
          FMLDeobfuscatingRemapper.INSTANCE),
        str -> str.split(":")[0]),
      ((csvData, data) -> csvData.getMcpName()));
}
 
Example #22
Source File: WurstClassVisitor.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
protected String unmap(String typeName)
{
	return FMLDeobfuscatingRemapper.INSTANCE.unmap(typeName);
}
 
Example #23
Source File: ForgeWurst.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event)
{
	if(event.getSide() == Side.SERVER)
		return;
	
	String mcClassName = Minecraft.class.getName().replace(".", "/");
	FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
	obfuscated = !mcClassName.equals(remapper.unmap(mcClassName));
	
	configFolder =
		Minecraft.getMinecraft().mcDataDir.toPath().resolve("wurst");
	try
	{
		Files.createDirectories(configFolder);
	}catch(IOException e)
	{
		throw new RuntimeException(e);
	}
	
	hax = new HackList(configFolder.resolve("enabled-hacks.json"),
		configFolder.resolve("settings.json"));
	hax.loadEnabledHacks();
	hax.loadSettings();
	
	cmds = new CommandList();
	
	keybinds = new KeybindList(configFolder.resolve("keybinds.json"));
	keybinds.init();
	
	gui = new ClickGui(configFolder.resolve("windows.json"));
	gui.init(hax);
	
	JGoogleAnalyticsTracker.setProxy(System.getenv("http_proxy"));
	analytics = new GoogleAnalytics("UA-52838431-17",
		"client.forge.wurstclient.net",
		configFolder.resolve("analytics.json"));
	analytics.loadConfig();
	
	Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	analytics.getConfigData()
		.setScreenResolution(screen.width + "x" + screen.height);
	
	hud = new IngameHUD(hax, gui);
	MinecraftForge.EVENT_BUS.register(hud);
	
	cmdProcessor = new CommandProcessor(cmds);
	MinecraftForge.EVENT_BUS.register(cmdProcessor);
	
	keybindProcessor = new KeybindProcessor(hax, keybinds, cmdProcessor);
	MinecraftForge.EVENT_BUS.register(keybindProcessor);
	
	updater = new WurstUpdater();
	MinecraftForge.EVENT_BUS.register(updater);
	
	analytics.trackPageView("/mc" + WMinecraft.VERSION + "/v" + VERSION,
		"ForgeWurst " + VERSION + " MC" + WMinecraft.VERSION);
}
 
Example #24
Source File: ObfMapping.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String unmap(String typeName) {
    return FMLDeobfuscatingRemapper.INSTANCE.map(typeName);
}