Getting world heights from chunks on structure gen bug

Started by Applecake246 on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 21:04, 29. Nov 2022
Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Getting world heights from chunks on structure gen bug
Sat, 03/19/2022 - 13:56 (edited)

Hi, since the newer updates of mcreator I can't make a function where I pull world heights to verify if a structure can spawn or not.

The error log comes down to this:

22:08.47 [Worker-Main-4/ERROR]: Requested chunk : -8 -8 
22:08.47 [Worker-Main-4/ERROR]: Region bounds : -17 -6 | -1 10 
22:08.47 [Server thread/ERROR]: Encountered an unexpected exception 
net.minecraft.ReportedException: Feature placement

I've tried several work arounds like having the server wait with spawning those structures for x time after joining the dimension, but nothing helps.

-Apple

 

Edit: it is not since the new updates but rather since me increasing structures size detection

Edited by Applecake246 on Sat, 03/19/2022 - 13:56
Last seen on 13:58, 21. Jan 2023
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you present your code…
Thu, 03/17/2022 - 04:10

Can you present your code for this and an explanation for what your program is intended to do.

Last seen on 21:04, 29. Nov 2022
Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Explanation: The code…
Sat, 03/19/2022 - 13:54

Explanation:

The code returns if the corners of a structure are the same height as where it would originate from, thus verifying that the surface is flat. It also confirms is the corner furthest away is grass, so it will not spawn towards water blocks

This is a working example of the code: 

public class SwampPool1ConditionProcedure {
	public static boolean execute(LevelAccessor world, double x, double y, double z) {
		SnorsZomboidMod.LOGGER.info(world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int(x + 15), (int) z));
		SnorsZomboidMod.LOGGER.info(world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) (x + 15), (int) (z + 15)));
		SnorsZomboidMod.LOGGER.info(world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) (z + 15)));
		SnorsZomboidMod.LOGGER.info(world.getBlockState(new BlockPos((int) (x + 15), (int) y, (int) (z + 15))));
		return world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) (x + 15), (int) z) == world
				.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z)
				&& world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) (x + 15), (int) (z + 15)) == world
						.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z)
				&& (world.getBlockState(new BlockPos((int) (x + 15), (int) y, (int) (z + 15)))).getBlock() == Blocks.GRASS_BLOCK
				&& world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) (z + 15)) == world
						.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z);
	}
}

Now for the not working part it'd ask x + 16 or z + 16 since those are outside of the chunk.

So for now I can spawn 16 x 16 structures in 'safe' locations but if I where to use larger structures I wouldn't be able to detect world heights outside of a 16 block radius.

Atleast if no one else has a workaround :/