Add a return; procedure block

Started by Nwago on

Topic category: Feature requests and ideas for MCreator

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Add a return; procedure block

return; is extremely useful for making procedure code more readable and run better in the blockly editor (avoid huge if nesting), and from experience works flawlessly using it in custom code format, but having it built in would save a bit of time and encourage more people to use it!

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
+1 I made a plugin partly…
Sun, 09/07/2025 - 20:11

+1 I made a plugin partly because this wasn't a block yet

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Guard clauses are bad?
Mon, 09/08/2025 - 14:04

Guard clauses are bad?

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Wdym? MCreator's own…
Mon, 09/08/2025 - 14:14

Wdym? MCreator's own generated code uses them,

How's it like goto?

It breaks the code flow. We…
Mon, 09/08/2025 - 14:18

It breaks the code flow. We try to avoid them, especially if deely nested, as one can quickly miss them. Here (your screenshot) is an early check, where it is ok.

But we could add it, however, it is very hard to validate edge cases where it could cause build errors. Even current return value blocks can cause build errors in some cases and we currently don't have reliable validation for those cases invented yet

Guard clauses are bad?

Guard clauses themselves not, but returning in e.g. nested code is bad as it is hard to read.

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, I have never used deeply…
Mon, 09/08/2025 - 14:21

Oh, I have never used deeply nested guard clauses so I didn't even think of that possibility. I always just use them like MCreator does there.

 

You could always just put the return block in the advanced tab.

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Bit of a bandaid, but you…
Mon, 09/08/2025 - 22:33

Bit of a bandaid, but you could add a little warning at the bottom of the page (similar to the nbt one) saying that MCreator isn't able to fully validate these blocks and to use them only if you know what you are doing