So basically, I'm trying to get a Minecraft variable (unsupported version, and nobody knew how when it was anyways) and I need to change the block the variable has, to a new block. I checked this issue out and it turns out trying to set a final variable doesn't work as the code using it still returns the old value, while code using the reflected variable returns the new value. There is someone who got this working for 1.7.2, but I am using 1.7.10 and the code no longer works on that version, I tested it a while ago. I unfortunately could not find the thread where this code originates from and I no longer have it.
I want "new BlockFence("planks_oak", Material.wood)" to be changed to "new BlockNewFence("planks_oak", Material.wood)" in this line, but I'm pretty new to reflections and would have no idea how. Here's the line:
blockRegistry.addObject(85, "fence", (new BlockFence("planks_oak", Material.wood)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("fence"));
Thanks for reading, if you have. I've tried this myself but honestly got nowhere as I'm really unsure of what to do to achieve this, I really only know how to get and set a private/protected field but as I found earlier final fields don't really work the same way. Please let me know if I need to provide more information. The reason why I brought up final fields and stuff earlier is because both blockRegistry is final, as well as the variable that uses this registry entry.
Aucun commentaire:
Enregistrer un commentaire