Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

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.

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?

  • 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 by namarino41

  • 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.

  • 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 by namarino41

  • Author
Just now, diesieben07 said:

I am perfectly polite, just direct and to the point.

Yeah maybe you need to reassess.

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

  • 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...

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?

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.