#String "Arrow" to Arrow.class ?
1 messages · Page 1 of 1 (latest)
If I remember correctly Class has some static methods for doing stuff like that. But you will probably have to then get the determined constructor and initiate a new instance, if you want to work with the obj.
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html
Ok, I'll check these links and what I can do, thank you for the links 🙂
Do you need the class itself or an instance of the class?
the class itself
kk
I have a global class, and basicaly what I want to do is change the projectile fired by a bow when entrering a command
Ah, but you only want to change newly fired projectiles and not the already existing ones, right?
Exactly
Even then, I'd rather suggest you just use if-statements, instead of doing it via Class.forName() as it would be less of a hassle and not as prone to unforseen issues
global file
public static Class current_projectile=Arrow.class;
The target file
Projectile projectile=player.launchProjectile(global.current_projectile);
Ah, btw, the Class.forName() needs the entire class path, as in: "net.minecraft_1_12_2.Entities.Arrow" or smth like that
ok, i'll try that, ty for the help 😄