The Meaning of Life, the Universe, and Everything.
Join Date:
4/7/2011
Posts:
233
Member Details
Hey guys,
I managed to make a crafting recipe that takes a players class into consideration, thanks to diesieben7. It works just fine in exlipse, but when I try to start my actual minecraft client, it bugs out. Eclipse and Minecraft runs the exact same forge build, so that should not be problem. My crash log contains some info about 3rd party mods, but that is not the problem either (I tried with only my mod installed, and it didn't work). I tried googling the error code to see if it gave me any clue, but no luck, so you guys are my only hope.
Here is the error code:
---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.
Time: 09.11.16 23:24
Description: There was a severe problem during mod loading that has caused the game to fail
cpw.mods.fml.common.LoaderException: java.lang.ExceptionInInitializerError
at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:559)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:480)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)
at net.minecraft.client.main.Main.main(SourceFile:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.ExceptionInInitializerError
at com.ehaugw.wom.Items.ModItems.init(ModItems.java:292)
at com.ehaugw.wom.CommonProxy.preInit(CommonProxy.java:29)
at com.ehaugw.wom.ClientProxy.preInit(ClientProxy.java:61)
at com.ehaugw.wom.Main.preInit(Main.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556)
... 10 more
Caused by: cpw.mods.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: eventHandler
at cpw.mods.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:94)
at com.ehaugw.wom.Recipes.ApplyPoisonToWeaponRecipe.<clinit>(ApplyPoisonToWeaponRecipe.java:91)
... 40 more
Caused by: java.lang.NoSuchFieldException: eventHandler
at java.lang.Class.getDeclaredField(Class.java:2062)
at cpw.mods.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:85)
... 41 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.8.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 150835160 bytes (143 MB) / 306737152 bytes (292 MB) up to 1060372480 bytes (1011 MB)
JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 12 mods loaded, 12 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCH FML{7.10.99.99} [Forge Mod Loader] (forge-1.7.10-10.13.4.1558-1.7.10.jar)
UCH Forge{10.13.4.1558} [Minecraft Forge] (forge-1.7.10-10.13.4.1558-1.7.10.jar)
UCH BiblioCraft{1.11.5} [BiblioCraft] (BiblioCraft-Mod-1.7.10.jar)
UCH CoroAI{v1.0} [CoroAI] (CoroUtil-1.0.jar)
UCH ExtendedRenderer{v1.0} [Extended Renderer] (CoroUtil-1.0.jar)
UCH ConfigMod{v1.0} [Extended Mod Config] (CoroUtil-1.0.jar)
UCH millenaire{6.0.0pb2} [Millénaire] (millenaire-6.0.0pb2.jar)
UCH ropebridge{1.3} [Rope Bridge] (RopeBridge-v1.3-mc1.7.10.jar)
UCH RTG{1.7.10-1.0-snapshot-2} [Realistic Terrain Generation] (RTG-1.7.10-1.0-snapshot-2.jar)
UCE wom{1.0.0} [World of Minecraft] (World of Minecraft-1.7.10-0.11.jar)
UCH ZAMod{v1.9.2} [Zombie Awareness] (ZombieAwareness-1.9.2.jar)
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.200.1062.1004' Renderer: 'AMD Radeon HD 6900 Series'
//CREDITS TO DIESIEBEN7 FOR THIS PART.
private static final Field eventHandlerField = ReflectionHelper.findField(InventoryCrafting.class, "eventHandler");
private static final Field containerPlayerPlayerField = ReflectionHelper.findField(ContainerPlayer.class, "thePlayer");
private static final Field slotCraftingPlayerField = ReflectionHelper.findField(SlotCrafting.class, "thePlayer");
The find method in the ReflectionHelper class can take multiple strings as the name of the type, this is used to find either the type when the games is either obfuscated or deobfuscated.
The way you're currently doing it is that you're only finding the type with its deobfuscated name, you also need to use the type's obfuscated name if running in a non-dev environment in order to find the type.
Note: the game is automatically deobfuscated to SRG names by Forge (since 1.6.4 iirc), no need to use Notch names.
Example usage:
ReflectionHelper.find***(SomeMinecraftClass.class, new String[] { "obfuscatedName", "deobfuscatedName" })
The find method in the ReflectionHelper class can take multiple strings as the name of the type, this is used to find either the type when the games is either obfuscated or deobfuscated.
The way you're currently doing it is that you're only finding the type with its deobfuscated name, you also need to use the type's obfuscated name if running in a non-dev environment in order to find the type.
Note: the game is automatically deobfuscated to SRG names by Forge (since 1.6.4 iirc), no need to use Notch names.
Example usage:
ReflectionHelper.find***(SomeMinecraftClass.class, new String[] { "obfuscatedName", "deobfuscatedName" })
That made sense. I have two questions though: What is SRG, and how do I find the obfuscated names in 1.7.10?
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
Fields can be accessed by id/index as well, as described in this tutorial.
Honestly, I think that getting types through its specific index is not a very modular nor remote solution.
Yes, I've it before, and while it does work, it's not a good solution to the method of getting types.
If some mod(s) use asm and add a type into the class (35 % chance of a mod adding types to that class), then the type table gets altered, and you're not able to get that specific type through the now invalid index.
I also wouldn't say that finding types through its name is the best solution either, but in my opinion, it is the best method.
The best method I'd say would be, is to get find the type through its name, then check its class type whether it's what you want or not.
MCPBot can tell you the SRG name of a field/method.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The Meaning of Life, the Universe, and Everything.
Join Date:
4/7/2011
Posts:
233
Member Details
Thanks guys, nice replies here. As the Ghast Hunter said, a core mod might modify the classes, which means the method choonster and dark_lizzie presents would cause incompability. Considered this code runs very rarely, I decided to say goodbye to optimization, in advantage of compability:
EntityPlayer findPlayer(InventoryCrafting inv) {
try {
Container container = null;
for (Field f: InventoryCrafting.class.getDeclaredFields()) {
if (ReflectionHelper.findField(InventoryCrafting.class, f.getName()).get(inv) instanceof Container) {
System.out.println("Container field name: " + f.getName());
container = (Container) ReflectionHelper.findField(InventoryCrafting.class, f.getName()).get(inv);
}
}
if (container != null && container instanceof ContainerPlayer) {
for (Field f: ContainerPlayer.class.getDeclaredFields()) {
if (ReflectionHelper.findField(ContainerPlayer.class, f.getName()).get(container) instanceof EntityPlayer) {
System.out.println("Player field name in player crafting: " + f.getName());
return (EntityPlayer) ReflectionHelper.findField(ContainerPlayer.class, f.getName()).get(container);
}
}
} else if (container instanceof ContainerWorkbench) {
for (Field f: SlotCrafting.class.getDeclaredFields()) {
if (ReflectionHelper.findField(SlotCrafting.class, f.getName()).get(container.getSlot(0)) instanceof EntityPlayer) {
System.out.println("Player field name in bench crafting: " + f.getName());
return (EntityPlayer) ReflectionHelper.findField(SlotCrafting.class, f.getName()).get(container.getSlot(0));
}
}
} else {
return null;
}
} catch (Exception e) {
throw Throwables.propagate(e);
}
return null;
}
What do you think about this solution? I can not see any situation a core modder would like to add another field of type EntityPlayer to a crafting table, or how a player could open two at once, which means this method should be safe. It is all a optimization issue.
Hey guys,
I managed to make a crafting recipe that takes a players class into consideration, thanks to diesieben7. It works just fine in exlipse, but when I try to start my actual minecraft client, it bugs out. Eclipse and Minecraft runs the exact same forge build, so that should not be problem. My crash log contains some info about 3rd party mods, but that is not the problem either (I tried with only my mod installed, and it didn't work). I tried googling the error code to see if it gave me any clue, but no luck, so you guys are my only hope.
Here is the error code:
---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.
Time: 09.11.16 23:24
Description: There was a severe problem during mod loading that has caused the game to fail
cpw.mods.fml.common.LoaderException: java.lang.ExceptionInInitializerError
at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:559)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:480)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)
at net.minecraft.client.main.Main.main(SourceFile:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.ExceptionInInitializerError
at com.ehaugw.wom.Items.ModItems.init(ModItems.java:292)
at com.ehaugw.wom.CommonProxy.preInit(CommonProxy.java:29)
at com.ehaugw.wom.ClientProxy.preInit(ClientProxy.java:61)
at com.ehaugw.wom.Main.preInit(Main.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556)
... 10 more
Caused by: cpw.mods.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: eventHandler
at cpw.mods.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:94)
at com.ehaugw.wom.Recipes.ApplyPoisonToWeaponRecipe.<clinit>(ApplyPoisonToWeaponRecipe.java:91)
... 40 more
Caused by: java.lang.NoSuchFieldException: eventHandler
at java.lang.Class.getDeclaredField(Class.java:2062)
at cpw.mods.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:85)
... 41 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.8.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 150835160 bytes (143 MB) / 306737152 bytes (292 MB) up to 1060372480 bytes (1011 MB)
JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 12 mods loaded, 12 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCH FML{7.10.99.99} [Forge Mod Loader] (forge-1.7.10-10.13.4.1558-1.7.10.jar)
UCH Forge{10.13.4.1558} [Minecraft Forge] (forge-1.7.10-10.13.4.1558-1.7.10.jar)
UCH BiblioCraft{1.11.5} [BiblioCraft] (BiblioCraft-Mod-1.7.10.jar)
UCH CoroAI{v1.0} [CoroAI] (CoroUtil-1.0.jar)
UCH ExtendedRenderer{v1.0} [Extended Renderer] (CoroUtil-1.0.jar)
UCH ConfigMod{v1.0} [Extended Mod Config] (CoroUtil-1.0.jar)
UCH millenaire{6.0.0pb2} [Millénaire] (millenaire-6.0.0pb2.jar)
UCH ropebridge{1.3} [Rope Bridge] (RopeBridge-v1.3-mc1.7.10.jar)
UCH RTG{1.7.10-1.0-snapshot-2} [Realistic Terrain Generation] (RTG-1.7.10-1.0-snapshot-2.jar)
UCE wom{1.0.0} [World of Minecraft] (World of Minecraft-1.7.10-0.11.jar)
UCH ZAMod{v1.9.2} [Zombie Awareness] (ZombieAwareness-1.9.2.jar)
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.200.1062.1004' Renderer: 'AMD Radeon HD 6900 Series'
Here is the recipe that bugs out:
package com.ehaugw.wom.Recipes;
import java.lang.reflect.Field;
import com.ehaugw.wom.Main;
import com.ehaugw.wom.ModUtils;
import com.ehaugw.wom.Classes.ModClasses;
import com.ehaugw.wom.Items.ItemCustomPoison;
import com.google.common.base.Throwables;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class ApplyPoisonToWeaponRecipe implements IRecipe {
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack weapon = null;
ItemCustomPoison poison = null;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack == null)
continue;
if (stack.getItem() instanceof ItemSword)
weapon = stack.copy();
if (stack.getItem() instanceof ItemCustomPoison)
poison = (ItemCustomPoison) stack.getItem();
}
NBTTagCompound tag = ModUtils.getTagCompound(weapon);
tag.setInteger(Main.MODID + "poisonAppliedUses", poison.appliedUses);
tag.setString(Main.MODID + "poisonEffect", poison.effect);
tag.setInteger(Main.MODID + "poisonAmplitude", poison.amplitude);
tag.setFloat(Main.MODID + "poisonProcRate", poison.procRate);
weapon.setTagCompound(tag);
return weapon;
}
@Override
public ItemStack getRecipeOutput() {
return null;
}
@Override
public int getRecipeSize() {
return 10;
}
@Override
public boolean matches(InventoryCrafting inv, World world) {
EntityPlayer player = findPlayer(inv);
if (player == null)
return false;
if (!ModClasses.entityIsClass(player, "rogue"))
return false;
ItemStack weapon = null;
ItemStack poison = null;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack == null)
continue;
if (stack.getItem() instanceof ItemSword) {
if (weapon == null) weapon = stack;
else return false;
} else if (stack.getItem() instanceof ItemCustomPoison) {
if (poison == null) poison = stack;
else return false;
} else return false;
}
return weapon != null && poison != null;
}
//CREDITS TO DIESIEBEN7 FOR THIS PART.
private static final Field eventHandlerField = ReflectionHelper.findField(InventoryCrafting.class, "eventHandler");
private static final Field containerPlayerPlayerField = ReflectionHelper.findField(ContainerPlayer.class, "thePlayer");
private static final Field slotCraftingPlayerField = ReflectionHelper.findField(SlotCrafting.class, "thePlayer");
EntityPlayer findPlayer(InventoryCrafting inv) {
try {
Container container = (Container) eventHandlerField.get(inv);
if (container instanceof ContainerPlayer) {
return (EntityPlayer) containerPlayerPlayerField.get(container);
} else if (container instanceof ContainerWorkbench) {
return (EntityPlayer) slotCraftingPlayerField.get(container.getSlot(0));
} else {
// don't know the player
return null;
}
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
}
Thanks for your time!
ReflectionHelper.find***(Class<?>, String...)
The find method in the ReflectionHelper class can take multiple strings as the name of the type, this is used to find either the type when the games is either obfuscated or deobfuscated.
The way you're currently doing it is that you're only finding the type with its deobfuscated name, you also need to use the type's obfuscated name if running in a non-dev environment in order to find the type.
Note: the game is automatically deobfuscated to SRG names by Forge (since 1.6.4 iirc), no need to use Notch names.
Example usage:
ReflectionHelper.find***(SomeMinecraftClass.class, new String[] { "obfuscatedName", "deobfuscatedName" })
That made sense. I have two questions though: What is SRG, and how do I find the obfuscated names in 1.7.10?
Fields can be accessed by id/index as well, as described in this tutorial.
Honestly, I think that getting types through its specific index is not a very modular nor remote solution.
Yes, I've it before, and while it does work, it's not a good solution to the method of getting types.
If some mod(s) use asm and add a type into the class (35 % chance of a mod adding types to that class), then the type table gets altered, and you're not able to get that specific type through the now invalid index.
I also wouldn't say that finding types through its name is the best solution either, but in my opinion, it is the best method.
The best method I'd say would be, is to get find the type through its name, then check its class type whether it's what you want or not.
MCPBot can tell you the SRG name of a field/method.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Thanks guys, nice replies here. As the Ghast Hunter said, a core mod might modify the classes, which means the method choonster and dark_lizzie presents would cause incompability. Considered this code runs very rarely, I decided to say goodbye to optimization, in advantage of compability:
What do you think about this solution? I can not see any situation a core modder would like to add another field of type EntityPlayer to a crafting table, or how a player could open two at once, which means this method should be safe. It is all a optimization issue.
On a side note, I was 100% sure that
would be the same as f it is not, lulwut?
Ps. Thanks a lot for helping, it is good to know I have you on my side when google fails me!