Jump to content

Serverside chat function


Loratia

Recommended Posts

Hi guys

I'm new at this, so take everything I say with a grain of salt.

So I'm trying to update an small, old 1.8 mod to 1.12.2 by request from a friend.
The original creator is unavailable and so I did a decompile on his classes and got the source code.
I figured out what the mod was doing and rewrote the classes.
I can run the mod on a dedicated server on my own machine (I *think* it's a dedicated server - console pop-up server?) and I can connect to it as a multiplayer lan server from my client.

 

So here's my problems:

I'm trying to hook into the chat message system and "redo" the send message function with some added functionality.
The hook seems to work, as I can stop the message or let it pass through.
In the hook I want to compare the distance between the sender and all other players. (for stuff like /talk, /shout, /yell)

My IDE is horrible to say the least and I have no experience with minecraft or modding and for this small task, this IDE was the best way to quickly edit and compile the code and see if it worked.
I haven't found any way of telling whether a function is a serverside function or a clientside function and using my google-fu skills to find some functions to help me, got me to try to do something like this FMLCommonHandler.instance().getMinecraftServerInstance();
And while that function works, if I do anything with the minecraft-server-instance, such as getPlayerList(), I get a java.lang.nosuchmethoderror.
 

I have looked at the proxy-client-server-thing, but I dont understand it and do I need it? Am I trying to call a client-only function? (the intend is to have a serverside only mod with no need for client installation)

 

Is there a quick way to tell, whether I'm doing something totally wrong?
If I'm just not using the correct functions, could someone tell me the functions I need use to get all players/playerlist and a player positions?

 

 

Thx in advance for any help.

Link to comment
Share on other sites

You should read https://mcforge.readthedocs.io/en/latest/concepts/sides/. After that you should be able to understand your problem better. Have you checked if there is a Forge event for what you’re trying to do? This will mean you don’t need a proxy, to can just specify the side in the event subscriber annotation.

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Hi Cadiboo

 

Thx for your incredibly fast response!

 

I already read the page you are referencing and I honestly don't *really* get it. Maybe because I don't really think I need it for this mod, as you are kinda suggesting as well.

 

As I said, I think I am hooking the event just fine and I'm able to respond by printout console lines just fine when a user 'says something'. I'm also able to show the message in chat or ignore it and thus not show it.

 

My main problem is that I don't know how to get a list of players and positions and when I try to use any functions I've found through Google or here, I get a server error with a method-not-found, which I'm unable to determine is because I'm using client-side functions or doing something else completely wrong?

Link to comment
Share on other sites

Hi Diesieben07

 

Thx for your reply.

 

I'm using something called MCreator. It does give compilation errors, if I'm trying to use a function, that does not exist, but it does not seem to check if something is serverside or clientside only. I'm also not running the code from MCreator, but rather moving the compiled classes into a jar file and running it on the server to test whether it works.

 

If I use:
System.out.println(FMLCommonHandler.instance().getSide()); I get a "SERVER" printout.

If I use:
System.out.println(DedicatedServer.getCurrentTimeMillis()); I can compile, but I get a no-method-found error, when running it.
System.out.println(FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList()); gives the same.

So I'm looking for the way to find all players and determine distance between them serverside or as a lesser solution a way to determine if I'm actually able to use serversided function and what serversided functions I have available.

Link to comment
Share on other sites

MCreator is poorly written, it creates mods that are broken and poorly written, and the license for it means anything you make with it is owned by THEM, not you.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

34 minutes ago, Loratia said:

for "2 lines of code" it seems to do the trick

MCreator is known for creating broken mods. The "2 lines of code" might cause major issues later on (like crash in multiplayer, etc).

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Well, Im not using any of the MCreator files, Im just using it to compile my own classes, instead of using the java console. Again, it was easy to setup up, as the installer was small and did all the work and it didnt require any setup.
But thanks for the heads up on the bad IDE.


But assuming that MCreator is not the problem, how am I gonna get my problem solved :-?

 

 

Link to comment
Share on other sites

If you continue to insist on using MCreator in any shape or form you may find that you stop receiving help.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

I really don't mean to step on anyone's toes here. 

I have not said, that I think MCreator is good, suggested that anyone else use it or said I wouldn't use something else. I have been honest in that it was the actual IDE and that because of it, I don't seem to get a lot of features, but I do have some sort of autocomplete and I can see the source code. I was also just honest about why I choose it to begin with. 

 

But DaemonUmbra giving a suggestion to help me instead bashing a IDE seems like a way more productive way of going forward. 

And while I do read the suggestion on IDE change, it is actually a lot more work than clicking an exe installer (from the description). 

And again not saying that I wouldn't do it! 

 

But for what seems to be two lines of code (minecraftserver.getplayerlist + player.position), I'd rather just start with those and maybe avoid the whole reinstalls and roaming through source codes, if someone knew the "two lines of code". 

 

Again, I don't mean to dismiss any suggestions or good advice, I really would like to know, how can I get a list of the current online players server-side and check their position?

Am I using wrong lines of code or should it be working already? 

(I apologize if this was answered already, if so I missed it and it wasn't clear to me) 

 

Again, thx for all your input

Link to comment
Share on other sites

MCreator is not an IDE, it is a cookie-cutter-mod-maker that does not do the job very well.

Install an actual IDE if you want to mod, otherwise you’re being apathetic which is likely to cause problems for you down the road.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

DaemonUmbra, I totally get what you are saying! 

 

I usually use Unity3D for work. It uses C# or Unity script for coding. In that framework, I could do all the coding in less than 3 hours. 

I don't intend to create or publish any mods, since this is a quick, small one-time thing with 50-100 lines of code with no updates or nothing in the future. 

Unity has a decent API, which I know somewhat well, having spent years coding in that framework, which is also why I know where I would look for info, when I need to code something there. 

 

But I was trying to avoid spending time learning a new system/api and installing and setting up a lot of stuff. Even if I set up the suggested IDE, it would still save me hours of running through code, installations, testing, etc, if someone could say 'ohh, server-side getting a list of players, you just write mcserver.getplayer() and positions on those are player.position.x'

 

With that information, I know the right lines of code and could check if that worked and if not, debug what I (or the IDE, or the minecraft installation) was doing wrong. 

 

I was trying to provide as much information as possible, maybe that was a mistake, but the question I'm asking is really just 'what line(s) of code do I need to use server-side to get a list of players and extract their positions' 

 

Thx for any and all input. 

Link to comment
Share on other sites

Ok does this sound correct?

You are trying to update a mod without:

  • Learning Java
  • Learning the Forge API
  • Installing an IDE
  • Testing your code

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

I agree with what diesieben said, I think you should install IntelliJ (Community Edition). The install is dead simple, just run the installer. And it’s easier to set up a Modding workspace with IntelliJ than with eclipse (IMO).

For your original problem I think that you should

- post your code

- make sure your handler is running on the logical server only

- find out the methods that exist for getting a list of players that aren’t exclusively in 1 distribution

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

DaemonUmbra, I'll answer your questions, but why not just answer mine?
It's a pretty simple question (at least from other coding language perspectives) and either you know it and could answer it rather quickly, or you dont and I must say, I wonder where you're going with all this?

 

- I learned Java as my first major programming language at the University and used it for ~5 years while studying. That's ~20 years ago. In the meanwhile I learned a bunch of other languages as well, but havent kept my java skills up to date, but syntax-wise, it's not really that different from a lot of the other major ones. So I would say untrue.

- Totally dont want to learn a whole API, when it's a 50-100 line program and where I don't ever plan to use it again, so true. Also, I havent found a real API, just the source code, where I can spend hours and hours getting nowhere.

 

- I had to look up IDE to answer correctly: From Wiki "An IDE normally consists of at least a source code editor, build automation tools, and a debugger.". Since MCreator actually has the ability to edit source code, has a build tool and a debugger, I have to say I already installed one. And as I said, I'm not against installing another one. I just installed the first, easiest program I found that seemed to be able to do the job. Whether it can or not is not one of the questions I asked. So I would believe the answer is untrue.

- I'm testing my code a lot already and hence the questions I asked. I tested it on a server and gave details on how and what I tested, what results I got and my ideas on why. So this would be untrue as well.

Heck, I'd ask you to code the thing, if you want, but I honestly just wanted to know:
A. How do I get a list of current online players server-side?
B. How do I get the position of said players server-side?

(just working lines of code that is known to compile and run correctly. I'm not asking you to debug my code, my IDE or my installation, I'm just unsure as to which function would actually do, what I want and should run on the correct side)
 

If you want to code it instead, I'm sure up for letting you. I'm sure you'd be faster than me, since, again, I dont know what functions I'm looking for that should work on server-side.
(heck, even if unable to help me with the actual questioned functionality, another garantied working server-side function would be a small step in the right direction)


In pseudo-code the program did previously and should still do the following:
1. Hook the SendMessage-function <- already works.
2. Lookup range between sender and all receives <- thus the questions.
3. String-functions to check chat message for "/say" or "/shout" etc and manipulate strings. <- already works.
4. Format message and send new format to players within range. <- needs a little work, cause I haven't tested it, but should be done quickly.

 

So you see, it's really not a big program. As I said, it's like 50-100 lines. Most of it was already working, but just needed an update, because functions changed from 1.8 to 1.12.

Here's the two lines of code in C# using Unity (just to show how simple my question is):


GameObject playerlist[] = GameObject.FindGameObjectsWithTag("Player");
Vector3 distance = playerlist[0].transform.position - playerlist[1].transform.position;


I'm sure it's readable even if it's C# and not Java. It took me less than 2 min to write and make sure the syntax was correct from the API. It could take a person with no prior Unity knowledge hours to figure out that it was those two lines he/she needed to use.
I'm just trying to avoid spending many more hours and instead just asking the pro's with the knowledge.

If you don't know the answer, that's totally cool and I support all your opinions on MCreator, but maybe you could help a fellow out and throw me a line of code you know for sure works server-side only. (or even let me know if my lines of code that I posted as already tried examples should work correctly server-side)

And Cadiboo, "- find out the methods that exist for getting a list of players that aren’t exclusively in 1 distribution" - I think this is what I'm asking, no?

So, again, no need to bash me or my attempt, I wholeheartedly agree with your opinions, just throw me a bone, help me out, answer my question(s) if you can or anything that will speed up the process is much appreciated!

Link to comment
Share on other sites

2 hours ago, Cadiboo said:

find out the methods that exist for getting a list of players that aren’t exclusively in 1 distribution

This should be done by looking at the source in your IDE. If you have the entity that sent the message, you can get the entities world and get the list of players from that.

Right now it seems like you’re trying to make a mod without being willing to learn how to make a mod or even download the tools needed to make a proper mod. Most people don’t know the answer to your question off the top of their head, but they can (and do) find the answer in 3 clicks with a proper IDE. You also haven’t posted your code or the original code that you’re trying to port. 

 

Setting up the tools is as simple as

- download IDE

- download MDK

- import MDK project into IDE

- run task to generate run configs

- refresh project

This takes about 5 minutes of user interaction (Not including downloading the files or the decompiling/deobfing MC process)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I'm still confused about the essence of your two answers there.
Are your answers (paraphrased) :
1. We dont know the answer. (look it up)
2. We wouldn't tell you the answer. (look it up)
3. Having a better IDE will automatically tell you the answer. (no look up is needed at all)

 

I'm especially confused about the "this can be done in 3 clicks", when that's all I'm really asking for someone to verify for me.

It's also not true, that I didn't post code. I posted "FMLCommonHandler.instance().getMinecraftServerInstance();" as I line I used and tested.
Is "FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();" a valid server-side only code that should compile correctly and give me a list of players currently online on the server, possibly in a format, where I can then extract the player position afterwards?
I'm asking to save time and because I got an actual error trying to call that function on the actual server, but had no compile errors, so I'm unsure whether I have an error with the MC installation, the function, the software used or my code. A simple "yes, that function works server-side and would be a way to get a list of players" would answer that question in full, or a "No, that is a client-side only function" would also be half the answer.

Installing a different IDE and getting the same error would not bring me closer to my goal.
Asking the quick question "what function works for A" and getting the quick answer "function B" would instantly get me over the finish line.
Even getting the answer of "function C works server-side, you can test it" would save me hours and hours of testing, reading, error-checking etc. Especially if I have misunderstood a key part of something somewhere - I see no reason for any potentiel condescension, when I'm asking for help in a supporting forum in a hopefully tactful manner, taking the time to write out extra details on my problems and trying to be forthcoming with my lack of knowledge, my already tried efforts, my actual goals and my hoped answers.

Link to comment
Share on other sites

24 minutes ago, Loratia said:

Are your answers (paraphrased) :
1. We dont know the answer. (look it up)
2. We wouldn't tell you the answer. (look it up)
3. Having a better IDE will automatically tell you the answer. (no look up is needed at all)

8 hours ago, DaemonUmbra said:

If you continue to insist on using MCreator in any shape or form you may find that you stop receiving help.

No one really knows what kind of code MCreator will generate, therefore it is hard to help you.

 

2 hours ago, Loratia said:

From Wiki "An IDE normally consists of at least a source code editor, build automation tools, and a debugger."

However, a good IDE also:

  • Has ways to view the source code
  • Has good warning/error displaying
  • Has easy navigations and links through files
  • Has good javadoc support
  • etc

I am doubtful that MCreator has those features.

Using a bad IDE will no doubt slow down your development.

 

24 minutes ago, Loratia said:

I'm especially confused about the "this can be done in 3 clicks"

Cmd + left click in my case.

Viewing the source code can be very helpful when developing with a new API.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

36 minutes ago, Loratia said:

A simple "yes, that function works server-side and would be a way to get a list of players" would answer that question in full, or a "No, that is a client-side only function" would also be half the answer.

You can answer those questions for yourself in 1 click. You’re trying to port some code (which you haven’t posted) and you’ve given us only a small snippet of your new code. We don’t know any of the context. 

 

1 hour ago, Cadiboo said:

If you have the entity that sent the message, you can get the entities world and get the list of players from that.

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Thanks for your input, DavidM.

But you dont really have to doubt whether a particular IDE is good, bad or has certain features or if said IDE generates good or bad code for know whether any particular one line of code *should* work in a particular way, right?


I mean the "World.isRemote" boolean either works or it doesn't, right? It shouldn't turn all blocks into nether-blocks when compiled with Eclipse and then turn all blocks into lava if compiled with MCreator, right? It might give two different results based on whether you are on client-side and server-side, I get that. I also get that MCreator might be a piece of #%¤& and might cause problems, but that doesn't change the statement or my questions.

If I look up World.isRemote in the source code, I get the comment "server worlds have this set to false, client worlds have this set to true." - alright, I get the explaination there.
But for instance World.calendar does not contain any comments. What is it, how does it work, what does it do, does it work server-side and/or client-side, does it give the same answer on both. (but that's not my question either, nor important)

 


But I'm not asking anyone to go through the entire source code and tell me what functions do. I haven't posted more than perhaps a line or two of code, and even then I'm not asking what the functions do.
Instead, I'm asking for "two" specific functions (if anyone knows them), that I can definately use server-side.
And as a side-question, if noone was able to answer the main question, I'm asking for a single line of server-side code, that will definately run server-side, so I can test that everything works as it should, because I thought/think I have some issues with that (That could definately be System.out.println(World.isRemote), if that's a valid line of code I can call, but given the fact that it also works on client-side, I would prefer another)

This "If you have the entity that sent the message, you can get the entities world and get the list of players from that." is also half helpful, but why not just post the code instead of letting me guess the rest.
Is it <entityname>.getWorld().getPlayerList()? Is this a valid server-side line of code that will work? Or is it <entityname>.getWorld().instance.getOnlinePlayerNames()?
I totally get the "I can look it up through the source code docs"-answer, but it honestly seems a little halfway done answer.

I also see no point in posting the entire source code of my project, when I'm asking for something so specific. I guess I could decompile the old class files again for you, Cadiboo, but would you get a lot from a call to something like function_0981f()? Especially if said function doesn't exist in 1.12 anymore? I mean I already read through the files and functions, figured out what it did, rewrote all the "generic parts" and basically just needed answers to the functionality I have outlined a few times, since I couldn't find anything elsewhere and this place seemed to be a very good to get some help. (and again cut a lot of time out of the process)

Link to comment
Share on other sites

Stop using MCreator, you say I'm doing nothing but bashing it but I'm just trying to get you past step one!

 

A real IDE will help you more than us just saying "Yes this code will work" or "Use this code instead", we try to avoid outright giving code like that, we prefer teaching people how to help themselves.

 

If you are trying to do things with as little effort and investment as possible you're going to have a bad time.

 

Before all of this, do you have permission from the original author to continue/update their work? Have you attempted to contact them?

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

I'm totally on board with the whole "give a man a fish, teach a man to fish"-thing.
I also get that MCreator is bad and that noone knows what it does or will take responsibility for what it does.

 

But I've looked through the internet, I've looked through the source-code, I haven't found what I'm looking for and I'm not trying to build an MMORPG and looking for someone to "just code it for free for me, cause Blizzard did it in 1 year".

I have no intention of learning a whole API to do a simple thing and I dont intend on doing any other projects. I'm not unexperienced in programming, I'm not asking for someone to hold my hand or program anything for me.
I'm trying to find a "needle in a haystack" for me right now without using 10 times as much time as it should take me (would take me in a language I knew) and as a side note I'm having a technical error/problem, where I'm asking for some help to verify where the problem is. I'm not even asking anyone to guess where the problem is, I just ask for a single piece of information, so I can determine where the error is myself (and fix it myself).

The whole continued "get a real IDE" is like answering my question with a "did you remember to turn on your screen?".
I know how to fish, I've caught many fish, I just dont know what bait works with a cod. Now you can tell me that I should get an Abu fishing wheel, but I still wouldn't know what bait to use with a cod. (I hope you see the comparison)

 


As for the original author. The mod is "discontinued" and the author has been attempted contacted without any response for a long period of time. (I dont know the specifics of this, but from what I've been told, it sounded like it has been so for a few years).
Doing the mod from scratch would also not have been a big deal and I'm pretty sure there's no patent on "/say" and "/tell".

Edited by Loratia
Link to comment
Share on other sites

After I figured out that it was a technical issue, what it was and fixing it, it took roughly an hour of coding, testing and finishing up and I was done.

I did not learn the API, since I only really needed two lines of code. I did not install a different IDE, since MCreator did the job needed. I did not learn more about sides (which I totally do/did not get anyway), as I did not have to use any proxies or @SideOnly.

 

For anyone interested, the two lines of code I needed/used:
(EntityPlayerMP sender)

for (EntityPlayer receiver : sender.getServer().getPlayerList().getPlayers()){} // runs through a list of players.
sender.getDistance(receiver) // Gets the distance between players.

 

Had someone just said "Hey, try to run 'System.out.println(World.isRemote)' and that should give you a clear response serverside" or "FMLCommonHandler.GetPlayer(0).MoveY(10); will make your player move 10 feet up in the air on the server, test that one", I would have said "Thank you" and been straight into the technical/installation area looking for the problem and saved a lot of time.

 

I spent more time trying to figure out what all the obscure, weird responses meant and why I felt like you guys repeatly weren't responding in any useful manner to my seemingly simple question, than I did in finishing the mod, which is really a shame.
I would think a community would want to be forthcoming and open, if it wants a chance to evolve, develop and expand its member base.

 

 

Link to comment
Share on other sites

Congratulations on ignoring any and all advice given to you.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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