Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A non-null return value causes custom NBT change script to fail to run #506

Open
Cynthia7979 opened this issue Oct 28, 2024 · 2 comments
Open

Comments

@Cynthia7979
Copy link

Describe the bug
It seems that apply(ChunkData data), before(), and after() will not be run at all if anything is returned by one of them.

To Reproduce

  1. Open any valid Minecraft save
  2. Select any chunk
  3. Go to 'Tools > Change fields'
  4. Click on 'Script'
  5. Edit the script so any of the three functions returns something other than null. For example: return 1;
  6. Click 'OK'
  7. No confirmation dialog appears, nor is any log written to the log file (even with debug messages enabled). No chunk data is changed.

Expected behavior
Depending on the nature of what caused the bug, I would expect either of these behaviors:

  1. The program executes all of the methods regularly even if a non-null value was returned by any of the methods. Or,
  2. If any return statement is entered into any of the functions, then after clicking on 'OK' while having the "Script" tab open, an error should be shown in a message dialog and be printed to the log file. The error message should indicate that the code was not executed because it contained a return statement.

Screenshots and other files
Screenshots and log will probably not tell much since the bug is the absence of log or error message. Here's them anyway:

mcaselector.log
image
image
image
image
mcaselector.log

Environment (please complete the following information):

  • OS: Windows 10
  • Java version: 21.0.2
  • Version of MCA Selector: 2.4.2

Additional context
Would greatly appreciate it if there can be some sort of documentation for modifying chunk NBT via custom script. The Custom field is helpful but does not allow importing libraries, and I still haven't figured out how you're supposed to use the Script field yet 😅

@arvitus
Copy link
Contributor

arvitus commented Nov 12, 2024

First of all, this is a user error :)
If a function, that is supposed to return nothing, returns something nevertheless, the code won't compile and therefore cannot be executed. I don't really think a warning is needed here as this is just based on wrong syntax assumptions, but maybe it would help some people.

Sadly there is not much documentation about the custom filter scripts yet. Apart from the custom filter tutorial I wrote a while back there is barely any, if not none. But I created a repo with some useful examples and am planning to add more filters over time and make it a place for everyone to share their examples. Currently there are a few examples for filters and modifiers. You can check them out here. And if you still need help, you can check out the Discord Server and ask for help there.

Hope that helps :)

@Cynthia7979
Copy link
Author

Thanks! The custom filter tutorial was of some help, though it does not fully apply to NBT change use cases. I will check out the examples you linked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants