Posted September 27, 20223 yr Hey I started modding recently And i cant find a way to run code on a certain player by his name Example: username.setGlowing(true);
September 27, 20223 yr Why do you need to use the name? Typically, you only need to do that with commands, e.g. see the GiveCommand and how it uses "targets". For adding effects to entities see WitherSkeleton.doHurtTarget() If you were going to do this outside of the context of commands, it would be something like this untested code: public static void setGlowing(ServerLevel level, String name) { var player = level.getServer().getPlayerList().getPlayerByName(name); if (player != null) { player.addEffect(new MobEffectInstance(MobEffects.GLOWING)); } } Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
September 27, 20223 yr This command already exists: https://minecraft.fandom.com/wiki/Commands/effect Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.