MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / ClassProxy

Class ClassProxy

Minecraft-Utils/1.12.2/src/ClassProxy.java:23–435  ·  view source on GitHub ↗

Created by 5zig. All rights reserved © 2015

Source from the content-addressed store, hash-verified

21 * All rights reserved © 2015
22 */
23public class ClassProxy {
24
25 private static final Field byteBuf;
26 private static Field buttonList;
27 private static final Field serverList;
28 private static final Field worldData;
29 private static final Field worldDataList;
30
31 private static final UUID SPRINT_MODIFIER_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
32
33 private static boolean tryFix = false;
34
35 private ClassProxy() {
36 }
37
38 static {
39 ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
40 try {
41 Class<?> c = classLoader.loadClass(Names.packetBuffer.getName());
42 byteBuf = Transformer.FORGE ? c.getDeclaredField("field_150794_a") : c.getDeclaredField("a");
43 byteBuf.setAccessible(true);
44
45 if (Transformer.FORGE) {
46 buttonList = classLoader.loadClass(Names.guiScreen.getName()).getDeclaredField("field_146292_n");
47 buttonList.setAccessible(true);
48
49 serverList = bnj.class.getDeclaredField("field_148198_l");
50 worldData = bol.class.getDeclaredField("field_186786_g");
51 worldDataList = bom.class.getDeclaredField("field_186799_w");
52 } else {
53 serverList = bnj.class.getDeclaredField("v");
54 worldData = bol.class.getDeclaredField("g");
55 worldDataList = bom.class.getDeclaredField("w");
56 }
57 serverList.setAccessible(true);
58 worldData.setAccessible(true);
59 worldDataList.setAccessible(true);
60 } catch (Exception e) {
61 throw new RuntimeException(e);
62 }
63
64 /*if (Transformer.FORGE) {
65 // Forge mod list
66 try {
67 Class<?> metadataClass = classLoader.loadClass("net.minecraftforge.fml.common.ModMetadata");
68 Object metadata = metadataClass.newInstance();
69 metadataClass.getField("modId").set(metadata, "the5zigmod");
70 metadataClass.getField("name").set(metadata, "The 5zig Mod");
71 metadataClass.getField("version").set(metadata, Version.VERSION);
72 metadataClass.getField("description").set(metadata, "A mod that enhances your Minecraft PvP experience by displaying all kinds of useful stats.");
73 metadataClass.getField("url").set(metadata, "https://5zig.eu");
74 metadataClass.getField("authorList").set(metadata, Collections.singletonList("5zig"));
75 Class<?> modContainerClass = classLoader.loadClass("net.minecraftforge.fml.common.DummyModContainer");
76 Object modContainer = modContainerClass.getConstructor(metadataClass).newInstance(metadata);
77
78 Class<?> loaderClass = classLoader.loadClass("net.minecraftforge.fml.common.Loader");
79 Object loader = loaderClass.getMethod("instance").invoke(null);
80 Field modListField = loaderClass.getDeclaredField("mods");

Callers

nothing calls this directly

Calls 1

getNameMethod · 0.45

Tested by

no test coverage detected