Posted July 10, 20214 yr Hello. I'm creating an item that executes a command when you use it. Don't ask why, there's a reason why I'm going this route instead of just calling the code the command actually executes. Can someone help with this? Everything resource I've found has been for older versions. Would appreciate any help you can provide. Thank you!
July 12, 20214 yr 47 minutes ago, namarino41 said: Can anyone give me a little more detail? I'm on 1.16.5. In the package net.minecraft.command there is a class Commands.class that has the functions that execute commands. If you read the code you'll be able to see how it's done.
July 12, 20214 yr On 7/11/2021 at 5:27 AM, namarino41 said: Hello. I'm creating an item that executes a command when you use it. Don't ask why, there's a reason why I'm going this route instead of just calling the code the command actually executes. Can someone help with this? Everything resource I've found has been for older versions. Would appreciate any help you can provide. Thank you! I have the same problem too, but I still can't figure it out. Did you find anything helpful?
July 12, 20214 yr Author 10 hours ago, diesieben07 said: The answers were already given above...? Those were hardly answers. Would be nice to be given some examples. Could you provide us with some more help? Edited July 12, 20214 yr by namarino41
July 12, 20214 yr Author 11 minutes ago, diesieben07 said: You have been told exactly which method you need to call. If you don't know how to call methods you need to go and learn Java before modding. I know how to call methods, thanks. There are other things you need to pass into those methods that I can't get, like the commandsource.
July 12, 20214 yr Author 6 minutes ago, diesieben07 said: Look at where Minecraft calls this method and see what it does to create the CommandSource. Ok will do. I would recommend being a little more polite in the future also. I've seen a number of your posts and many of them come across as pretty rude and condescending. Don't assume that because someone is asking a question you think is stupid, he's deserving of that sort of attitude. Ignorance isn't stupidity. Edited July 12, 20214 yr by namarino41
July 12, 20214 yr Author Just now, diesieben07 said: I am perfectly polite, just direct and to the point. Yeah maybe you need to reassess.
July 13, 20214 yr 8 hours ago, namarino41 said: I know how to call methods, thanks. There are other things you need to pass into those methods that I can't get, like the commandsource. I can remember that there was a Dummy CommandSource, unfortunately I don't know whether it still exists and if so in which class, I also don't know whether you should use it. which command do you want to execute? since there is usually another possibility to execute the command code without using a command
July 13, 20214 yr Author 18 minutes ago, Luis_ST said: I can remember that there was a Dummy CommandSource, unfortunately I don't know whether it still exists and if so in which class, I also don't know whether you should use it. which command do you want to execute? since there is usually another possibility to execute the command code without using a command Yeah unfortunately there are some commands that another mod makes available and I want to call those. Sounds weird, but there's a reason for it, trust me haha. Problem I'm facing right now is I can't seem to get a server instance that isn't null...
July 13, 20214 yr are the mods you are talking about needed to use your mod? if not, there will be errors when executing the command. what exactly does the command?
July 13, 20214 yr 28 minutes ago, namarino41 said: Yeah unfortunately there are some commands that another mod makes available and I want to call those. Sounds weird, but there's a reason for it, trust me haha. Problem I'm facing right now is I can't seem to get a server instance that isn't null... Hmm. Can you make the other mod a dependency and then call the methods from the other mod directly? I'm not experienced at all in mods let alone inter-mod functionality, but if that's possible, it'd be the right way to do it, I think.
July 13, 20214 yr 1 hour ago, Luis_ST said: I can remember that there was a Dummy CommandSource ICommandSource.DUMMY The second parameter is a string where is the command inserted, e.g. "/gamemode survival". And then it will just print an error message if the command cannot be executed.
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.