當前位置: 首頁>>代碼示例>>Java>>正文


Java IClassTransformer類代碼示例

本文整理匯總了Java中net.minecraft.launchwrapper.IClassTransformer的典型用法代碼示例。如果您正苦於以下問題:Java IClassTransformer類的具體用法?Java IClassTransformer怎麽用?Java IClassTransformer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IClassTransformer類屬於net.minecraft.launchwrapper包,在下文中一共展示了IClassTransformer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convert

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
@NotNull
@SuppressWarnings("unchecked")
static <T extends IClassTransformer> Class<T> convert(@NotNull Class<? extends OrionTransformer> transformer) {
    if(Arrays.asList(transformer.getInterfaces()).contains(IClassTransformer.class))
        return (Class<T>) transformer; /* no-op */

    // Orion transformer name
    String rawTransformerName = transformer.getName().replace('.', '/');

    // New wrapper class name
    String newWrapperName = getNewName(transformer);

    // Start generating new TransformerWrapper
    ClassReader cr = new ClassReader(TW_DATA);
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    ClassNode cn = new ClassNode();
    cr.accept(cn, 0);

    cn.accept(new WrapperGenerator(cw, TW_TYPE.getInternalName(), newWrapperName.replace('.', '/'), rawTransformerName));

    return requireNonNull((Class<T>) ClassLoaderTools.defineClass(Launch.classLoader, newWrapperName, cw.toByteArray()));
}
 
開發者ID:OrionMinecraft,項目名稱:Orion,代碼行數:23,代碼來源:ClassTransformerConverter.java

示例2: call

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
@Override
public Void call() throws Exception {
	AlchemyThrowables.checkThrowables();
	logger.info("Setup: " + AlchemySetup.class.getName());
	LaunchClassLoader loader = AlchemyEngine.getLaunchClassLoader();
	// Support for optifine in a development environment
	if (!AlchemyEngine.isRuntimeDeobfuscationEnabled())
		if (AlchemyEngine.runtimeSide().isClient())
			TransformerInjectOptifine.tryInject(loader);
	// Injection is used to modify the at(AccessTransformer) logic of forge
	// See build.gradle#L73 & ast.gradle
	injectAccessTransformer(AlchemyEngine.getAlchemyCoreLocation(), loader);
	// Should not be transformer javafx
	loader.addTransformerExclusion("javafx.");
	// An extension to net.minecraftforge.fml.common.asm.transformers.SideTransformer when transformer Alchemy's class
	TransformerSide.inject(loader);
	// Init DLC main class
	AlchemyDLCLoader.stream().forEach(IDLCInfo::clinitDLCMainClass);
	// Debug info
	List<IClassTransformer> transformers = $(loader, "transformers");
	AlchemyTransformerManager.logger.info(Joiner.on('\n').appendTo(new StringBuilder("Transformers: \n"), transformers).toString());
	return Tool.VOID;
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:24,代碼來源:AlchemySetup.java

示例3: injectAccessTransformer

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public static void injectAccessTransformer(File file, String atName, LaunchClassLoader loader) throws IOException {
if (!AlchemyEngine.isRuntimeDeobfuscationEnabled() || file == null)
	return;
String at = null;
try (JarFile jar = new JarFile(file)) {
	ZipEntry entry = jar.getEntry("META-INF/" + atName);
       if (entry != null)
       	at = Tool.read(jar.getInputStream(entry));
}
if (at != null) {
	List<IClassTransformer> transformers = $(loader, "transformers");
	for (IClassTransformer t : transformers)
		if (t instanceof AccessTransformer) {
			AccessTransformer transformer = (AccessTransformer) t;
			$(transformer, "processATFile", CharSource.wrap(at));
			break;
		}
}
  }
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:20,代碼來源:AlchemySetup.java

示例4: build

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public static IClassTransformer build() {
	return ASMTweaksBuilder.create()
			.addFldSrg("net/minecraft/world/World.worldInfo", "net/minecraft/world/World.field_72986_A")
			.addMthdSrg("net/minecraft/world/storage/WorldInfo.getWorldTime",
					"net/minecraft/world/storage/WorldInfo.func_76073_f", "()J")
			.addMthdSrg("net/minecraft/world/storage/WorldInfo.setWorldTime",
					"net/minecraft/world/storage/WorldInfo.func_76068_b", "(J)V")
			.addMthdSrg("net/minecraft/world/WorldServer.tick",
					"net/minecraft/world/WorldServer.func_72835_b", "()V")
			.addMthdSrg("net/minecraft/world/WorldProvider.calculateCelestialAngle",
					"net/minecraft/world/WorldProvider.func_76563_a", "(JF)F")
			.addMthdSrg("net/minecraft/world/World.getWorldTime",
					"net/minecraft/world/World.func_72820_D", "()J")
			.addMthdSrg("net/minecraft/client/multiplayer/WorldClient.tick",
					"net/minecraft/client/multiplayer/WorldClient.func_72835_b", "()V")
			.addMthdSrg("net/minecraft/client/multiplayer/WorldClient.setWorldTime",
					"net/minecraft/client/multiplayer/WorldClient.func_72877_b", "(J)V")
			.addMthdSrg("net/minecraft/world/World.getWorldTime",
					"net/minecraft/world/World.func_72820_D", "()J")
			.addMthdSrg("net/minecraft/block/Block.addCollisionBoxToList",
					"net/minecraft/block/Block.func_185477_a",
					"(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;)V")
			.addTweak(new NonSolidLeaves())
			.addTweak(new DayNightCycle())
			.build();
}
 
開發者ID:hea3ven,項目名稱:Hea3venTweaks,代碼行數:27,代碼來源:TweaksBuilder.java

示例5: addModAPITransformer

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public ModAPITransformer addModAPITransformer(ASMDataTable dataTable)
{
    mainClassLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ModAPITransformer");
    List<IClassTransformer> transformers = mainClassLoader.getTransformers();
    ModAPITransformer modAPI = (ModAPITransformer) transformers.get(transformers.size()-1);
    modAPI.initTable(dataTable);
    return modAPI;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:9,代碼來源:ModClassLoader.java

示例6: TransformerWrapper

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public TransformerWrapper()
{
    try
    {
        this.parent = (IClassTransformer)this.getClass().getClassLoader().loadClass(getParentClass()).newInstance();
    }
    catch(Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:12,代碼來源:ASMTransformerWrapper.java

示例7: TrackingClassTransformerWrapper

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public TrackingClassTransformerWrapper(IClassTransformer transformer) {
	this.parent = transformer;
	String className = transformer.getClass().getName();
	if (className.startsWith("$wrapper.")) {
		className = className.substring("$wrapper.".length());
	}
	this.id = className;
	TransformerTracker.INSTANCE.transformers.add(id);
}
 
開發者ID:asiekierka,項目名稱:EnvironmentCheckerMC,代碼行數:10,代碼來源:TrackingClassTransformerWrapper.java

示例8: DelegatedTransformer

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public DelegatedTransformer()
{
    delegatedTransformers = new ArrayList<IClassTransformer>();
    try
    {
        m_defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE);
        m_defineClass.setAccessible(true);
        f_cachedClasses = LaunchClassLoader.class.getDeclaredField("cachedClasses");
        f_cachedClasses.setAccessible(true);
    }
    catch(Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:16,代碼來源:DelegatedTransformer.java

示例9: transform

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
@Override
public byte[] transform(String name, String tname, byte[] bytes)
{
    if (bytes == null) return null;
    for(IClassTransformer trans : delegatedTransformers)
        bytes = trans.transform(name, tname, bytes);
    return bytes;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:9,代碼來源:DelegatedTransformer.java

示例10: addModAPITransformer

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public ModAPITransformer addModAPITransformer(ASMDataTable dataTable)
{
    mainClassLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAPITransformer");
    List<IClassTransformer> transformers = mainClassLoader.getTransformers();
    ModAPITransformer modAPI = (ModAPITransformer) transformers.get(transformers.size()-1);
    modAPI.initTable(dataTable);
    return modAPI;
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:9,代碼來源:ModClassLoader.java

示例11: get

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
@Override
public List<IClassTransformer> get(Object key) {
	List<IClassTransformer> result = super.get(key);
	if (result == null)
		put((String) key, result = Lists.newLinkedList());
	return result;
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:8,代碼來源:AlchemyTransformerManager.java

示例12: tryInject

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public static void tryInject(LaunchClassLoader classLoader) {
	try {
		List<IClassTransformer> transformers = $(classLoader, "transformers");
		transformers.removeIf(t -> t.getClass().getName().startsWith("optifine."));
		transformers.add(0, new TransformerInjectOptifine(classLoader));
	} catch (Exception e) { e.printStackTrace(); }
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:8,代碼來源:TransformerInjectOptifine.java

示例13: inject

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public static void inject(LaunchClassLoader classLoader) {
	try {
		List<IClassTransformer> transformers = $(classLoader, "transformers");
		transformers.stream().filter(TransformerWrapper.class::isInstance).forEach(t -> {
			IClassTransformer parent = $(t, "parent");
			if (parent instanceof SideTransformer)
				$(t, "parent<", new TransformerSide(parent));
		});
	} catch (Exception e) { AlchemyRuntimeException.onException(e); }
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:11,代碼來源:TransformerSide.java

示例14: getTransformers

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private static List<IClassTransformer> getTransformers() {
    return (List<IClassTransformer>) get(f_transformers, Launch.classLoader);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:5,代碼來源:MCPDeobfuscationTransformer.java

示例15: main

import net.minecraft.launchwrapper.IClassTransformer; //導入依賴的package包/類
public static void main(String[] args) {

		if (args.length < 3) {
			System.out.println("usage: Prebaker [-m mapping-file] <input-jar> <output-jar> <mod-jars...>");
			return;
		}

		int argOffset;
		for (argOffset = 0; argOffset < args.length; argOffset++) {
			if ("-m".equals(args[argOffset])) {

			} else {
				break;
			}
		}

		Set<File> modFiles = new HashSet<>();
		for (int i = argOffset + 2; i < args.length; i++) {
			modFiles.add(new File(args[i]));
		}

		URLClassLoader ucl = (URLClassLoader) Prebaker.class.getClassLoader();
		Launch.classLoader = new LaunchClassLoader(ucl.getURLs());
		Launch.blackboard = new HashMap<>();


		Loader modLoader = new Loader();
		modLoader.load(modFiles);


		try {
			JarInputStream input = new JarInputStream(new FileInputStream(new File(args[argOffset + 0])));
			JarOutputStream output = new JarOutputStream(new FileOutputStream(new File(args[argOffset + 1])));
			JarEntry entry;
			while ((entry = input.getNextJarEntry()) != null) {
				if (entry.getName().endsWith(".class")) {
					byte[] classIn = ByteStreams.toByteArray(input);
					String className = entry.getName().substring(0, entry.getName().length() - 6).replace('/', '.');
					byte[] classOut = classIn;
					for(IClassTransformer transformer : Launch.classLoader.getTransformers()){
						classOut = transformer.transform(className, className, classOut);
					}

					if (classIn != classOut) {
						System.out.println("Transformed " + className);
						classOut = desprinkle(classOut);
					}
					JarEntry newEntry = new JarEntry(entry.getName());
					newEntry.setComment(entry.getComment());
					newEntry.setSize(classOut.length);
					newEntry.setLastModifiedTime(FileTime.from(Instant.now()));
					output.putNextEntry(newEntry);
					output.write(classOut);
				} else {
					output.putNextEntry(entry);
					ByteStreams.copy(input, output);
				}
			}
			input.close();
			output.close();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
開發者ID:FabricMC,項目名稱:fabric-base,代碼行數:65,代碼來源:Prebaker.java


注:本文中的net.minecraft.launchwrapper.IClassTransformer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。