Topic category: Help with modding (Java Edition)
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
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
Last reply is wrong, the correct command should be
"forceload add x z x z"
Being x and z regular coordinates.