Use forceload command in procedure block

Started by Sancho on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use forceload command in procedure block

I'm making a mod that generated structures that will be regenerated each X minutes, using a block as an anchor for the regeneration.

The regeneration procedure and it's cooldown is located inside the OnTickUpdate of the anchor block.

The thing is I cannot ensure the tick update of the block if there are no players nearby unless I forceload the chunk.

When I try to execute "forceload add ~ ~" in the structure generation procedure I get the following crash when structure is going to be generated:

 

java.lang.ClassCastException: net.minecraft.world.gen.WorldGenRegion cannot be cast to net.minecraft.world.server.ServerWorld

 

Am I doing something wrong?

Is there any other known way to achieve the chunk loading in Mcreator?

 

Thanks in advance

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I realized how to achieve…
Sun, 08/16/2020 - 06:06

I realized how to achieve this:

You need to calculate the chunk coordinates and execute a command that would be the following string with replacements

"forceload add x_chunk_coord z_chunk_coord"

x_chunk_coord is the x coordinate divided by 16 rounded down

z_chunk_coord is the z coordinate divided by 16 rounded down

 

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Last reply is wrong, the…
Sun, 08/16/2020 - 06:15

Last reply is wrong, the correct command should be

"forceload add x z x z"

Being x and z regular coordinates.