Gently encourage people to disable structures the intended way, and stop it crashing if they try and do it the wrong way.
What's wrong with my structures anyway? :'(
This commit is contained in:
@@ -27,7 +27,6 @@ import net.minecraft.world.gen.structure.MapGenStructureData;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -120,6 +119,7 @@ public abstract class WorldGenSurfaceStructure implements IWorldGenerator {
|
||||
* @param world The world in which to spawn the structure
|
||||
* @param chunkX The x-coordinate of the chunk being populated
|
||||
* @param chunkZ The z-coordinate of the chunk being populated
|
||||
* @param structureFile The name of the structure file, used for error messages.
|
||||
* @return The coordinates of the position found, or null if no suitable position was found. The returned
|
||||
* {@code BlockPos} is <b>always</b> the northwest corner of the structure, and the y-coordinate is that of the
|
||||
* uppermost block at those (x, z) coordinates. If the structure is being rotated this needs to be altered using
|
||||
@@ -128,7 +128,7 @@ public abstract class WorldGenSurfaceStructure implements IWorldGenerator {
|
||||
*/
|
||||
@Nullable
|
||||
protected BlockPos findValidPosition(Template template, PlacementSettings settings, Random random, World world,
|
||||
int chunkX, int chunkZ){
|
||||
int chunkX, int chunkZ, String structureFile){
|
||||
|
||||
// Offset by (8, 8) to minimise cascading worldgen lag
|
||||
// See https://www.reddit.com/r/feedthebeast/cowmments/5x0twz/investigating_extreme_worldgen_lag/?ref=share&ref_source=embed&utm_content=title&utm_medium=post_embed&utm_name=c07cbb545f74487793783012794733d8&utm_source=embedly&utm_term=5x0twz
|
||||
@@ -136,6 +136,11 @@ public abstract class WorldGenSurfaceStructure implements IWorldGenerator {
|
||||
BlockPos origin = new BlockPos(8 + (chunkX << 4) + random.nextInt(16), 0, 8 + (chunkZ << 4) + random.nextInt(16));
|
||||
|
||||
BlockPos size = template.transformedSize(settings.getRotation());
|
||||
|
||||
if(size.getX() == 0 || size.getY() == 0 || size.getZ() == 0){
|
||||
Wizardry.logger.warn("Structure template file {} is missing or empty! If you're trying to disable structure spawning, pointing to a non-existent location is NOT the correct way to do so; use the structure dimension lists instead.", structureFile);
|
||||
}
|
||||
|
||||
// Estimate a starting height for searching for the floor
|
||||
BlockPos centre = world.getTopSolidOrLiquidBlock(new BlockPos(origin.add(size.getX()/2, 0, size.getZ()/2)));
|
||||
Integer startingHeight = WizardryUtilities.getNearestSurface(world, centre, EnumFacing.UP, 32, true,
|
||||
@@ -212,7 +217,7 @@ public abstract class WorldGenSurfaceStructure implements IWorldGenerator {
|
||||
BlockPos origin;
|
||||
|
||||
do {
|
||||
origin = findValidPosition(template, settings, random, world, chunkX, chunkZ);
|
||||
origin = findValidPosition(template, settings, random, world, chunkX, chunkZ, structureFile.toString());
|
||||
triesLeft--;
|
||||
}while(triesLeft > 0 && origin != null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user