Jump to content

[1.7.10] Game lags a ton when generating blocks in the sky


Eternaldoom

Recommended Posts

Hi,

 

A dimension for a mod I'm working on requires worldgen in the sky. XolovA (the creator of the mod) apparently had to remove two dimensions from his new mod for this reason. He said that Forge changed how chunks are generated and split it into four vertical sections. The chunks are generating fine, but the worldgen is making the game completely unplayable. Do you know of a way to fix this?

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

The ChunkProvider:

public class ChunkProviderVethea implements IChunkProvider {

private Random rand;
private NoiseGeneratorOctaves noiseGen1;
private NoiseGeneratorOctaves noiseGen2;
private NoiseGeneratorOctaves noiseGen3;
private NoiseGeneratorPerlin noiseGen4;
public NoiseGeneratorOctaves noiseGen5;
public NoiseGeneratorOctaves noiseGen6;
public NoiseGeneratorOctaves mobSpawnerNoise;
private World worldObj;
private double[] noiseArray;
private double[] stoneNoise = new double[256];
private MapGenBase caveGenerator = new MapGenFloorCrystals();
private BiomeGenBase[] biomesForGeneration;
private final ArrayList<WorldGenerator> items;
private final ArrayList<WorldGenerator> lamps;
private final ArrayList<WorldGenerator> floatingTrees;
private final ArrayList<WorldGenerator> crypts;
private final ArrayList<WorldGenerator> l1Trees;
private final ArrayList<WorldGenerator> pyramids;
private final ArrayList<WorldGenerator> l2Trees;
private final ArrayList<WorldGenerator> l3Trees;
private final ArrayList<WorldGenerator> l4Trees;
private final ArrayList<WorldGenerator> l3Altars;
private final ArrayList<WorldGenerator> l4Altars;
//private final WorldGenerator layer3TreeBig;
private final WorldGenConeUp ceilingTexture;
private final WorldGenerator pillar;
private final WorldGenerator cracklespikes;
private final WorldGenerator fernites;
private final WorldGenerator bulatobes;
private final WorldGenerator shinegrass;
//private final WorldGenerator shimmers;
//private final WorldGenerator dreamglows;
private final WorldGenerator greenGemTops;
//private final WorldGenerator purpleGemTops;
private final WorldGenerator yellowDulahs;
private final WorldGenerator greenDulahs;
private final WorldGenerator infusion;

double[] noise3;
double[] noise1;
double[] noise2;
double[] noise5;
double[] noise6;

float[] parabolicField;
int[][] field_73219_j = new int[32][32];

public ChunkProviderVethea(World par1World, long par2) {
	this.worldObj = par1World;
	this.rand = new Random(par2);
	this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16);
	this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16);
	this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, ;
	this.noiseGen4 = new NoiseGeneratorPerlin(this.rand, 4);
	this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
	this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
	this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, ;

	NoiseGenerator[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise};
	this.noiseGen4 = (NoiseGeneratorPerlin)noiseGens[3];
	this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6];

	this.items = new ArrayList(;
	items.add(new Bow());
	items.add(new Hook());
	items.add(new Mushroom());
	items.add(new Pickaxe());
	items.add(new Pointedsquare());
	items.add(new Ring());
	items.add(new Sword());
	items.add(new Trident());

	this.lamps = new ArrayList(2);
	lamps.add(new Lamp1());
	lamps.add(new Lamp2());

	this.floatingTrees = new ArrayList(7);
	floatingTrees.add(new TreeFloating1());
	floatingTrees.add(new TreeFloating2());
	floatingTrees.add(new TreeFloating3());
	floatingTrees.add(new FloatingTree4());
	floatingTrees.add(new FloatingTree5());
	floatingTrees.add(new FloatingTree6());
	floatingTrees.add(new FloatingTree7());

	this.l1Trees = new ArrayList(3);
	l1Trees.add(new Tree4());
	l1Trees.add(new Tree5());
	l1Trees.add(new Tree6());

	this.l2Trees = new ArrayList(2);
	l1Trees.add(new Tree3());
	l1Trees.add(new Tree6());

	this.crypts = new ArrayList(2);
	crypts.add(new Crypt1());
	crypts.add(new Crypt2());     

	ceilingTexture = new WorldGenConeUp();
	pillar = new WorldGenVetheanPillar();
	infusion = new InfusionOutpost();

	this.pyramids = new ArrayList(3);
	pyramids.add(new Pyramid1());
	pyramids.add(new Pyramid2());
	pyramids.add(new HiveNest());

	this.l3Trees = new ArrayList(3);
	l3Trees.add(new Tree7());
	l3Trees.add(new Tree8());
	l3Trees.add(new WorldGenLayer3SmallTree(false));

	this.l3Altars = new ArrayList(2);
	l3Altars.add(new QuadroticPost());
	l3Altars.add(new KarosMadhouse());

	this.l4Altars = new ArrayList(3);
	l4Altars.add(new Evergarden());
	l4Altars.add(new RaglokChamber());
	l4Altars.add(new WreckHall());

	this.l4Trees = new ArrayList(2);
	l4Trees.add(new Tree1());
	l4Trees.add(new Tree2());


	//layer3TreeBig = new WorldGenLayer3BigTree(false);

	cracklespikes = new WorldGenVetheanFlower(VetheaBlocks.cracklespike);
	fernites = new WorldGenVetheanFlower(VetheaBlocks.fernite);
	bulatobes = new WorldGenVetheanFlower(VetheaBlocks.bulatobe);
	shinegrass = new WorldGenVetheanFlower(VetheaBlocks.shineGrass);
	//shimmers = new WorldGenVetheanFlower(VetheaBlocks.shimmer);
	//dreamglows = new WorldGenVetheanFlower(VetheaBlocks.dreamglow);
	greenGemTops = new WorldGenVetheanFlower(VetheaBlocks.gemtopGreen);
	//purpleGemTops = new WorldGenVetheanFlower(VetheaBlocks.gemtopPurple);
	yellowDulahs = new WorldGenVetheanFlower(VetheaBlocks.yellowDulah);
	greenDulahs = new WorldGenVetheanFlower(VetheaBlocks.greenDulah);

}

public void generateTerrain(int i, int j, Block[] b) {
	for(int column = 0; column < 256; column++){
		for(int vert = 0; vert < 256; vert++){
			if((vert>0 && vert<16) || (vert>48 && vert < 64) || (vert>96 && vert<112) || (vert>144 && vert<160))b[vert+(column*256)] = VetheaBlocks.dreamStone;
		}
	}
}

private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7) {
	ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7);
	MinecraftForge.EVENT_BUS.post(event);
	if (event.getResult() == Result.DENY)
		return event.noisefield;

	if (par1ArrayOfDouble == null) {
		par1ArrayOfDouble = new double[par5 * par6 * par7];
	}

	if (this.parabolicField == null) {
		this.parabolicField = new float[25];

		for (int var8 = -2; var8 <= 2; ++var8) {
			for (int var9 = -2; var9 <= 2; ++var9) {
				float var10 = 10.0F / MathHelper.sqrt_float((float)(var8 * var8 + var9 * var9) + 0.2F);
				this.parabolicField[var8 + 2 + (var9 + 2) * 5] = var10;
			}
		}
	}

	double var44 = 684.412D;
	double var45 = 684.412D;
	this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par3, par4, par5, par6, par7, var44, var45, var44);
	this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par3, par4, par5, par6, par7, var44, var45, var44);
	this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44, var45, var44);
	this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44);
	this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44);
	boolean var43 = false;
	boolean var42 = false;
	int var12 = 0;
	int var13 = 0;

	for (int var14 = 0; var14 < par5; ++var14) {
		for (int var15 = 0; var15 < par7; ++var15) {
			float var16 = 0.0F;
			float var17 = 0.0F;
			float var18 = 0.0F;
			byte var19 = 2;
			BiomeGenBase var20 = this.biomesForGeneration[var14 + 2 + (var15 + 2) * (par5 + 5)];

			for (int var21 = -var19; var21 <= var19; ++var21) {
				for (int var22 = -var19; var22 <= var19; ++var22) {
					BiomeGenBase var23 = this.biomesForGeneration[var14 + var21 + 2 + (var15 + var22 + 2) * (par5 + 5)];
					float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (var23.rootHeight + 2.0F);

					if (var23.rootHeight > var20.heightVariation) {
						var24 /= 3.0F;
					}

					var16 += var23.rootHeight * var24;
					var17 += var23.rootHeight * var24;
					var18 += var24;
				}
			}

			var16 /= var18;
			var17 /= var18;
			var16 = var16 * 0.9F + 0.1F;
			var17 = (var17 * 4.0F - 1.0F) / 8.0F;
			double var47 = this.noise6[var13] / 8000.0D;

			if (var47 < 0.0D) {
				var47 = -var47 * 0.3D;
			}

			var47 = var47 * 3.0D - 2.0D;

			if (var47 < 0.0D) {
				var47 /= 2.0D;

				if (var47 < -1.0D) {
					var47 = -1.0D;
				}

				var47 /= 1.4D;
				var47 /= 2.0D;
			} else {
				if (var47 > 1.0D) {
					var47 = 1.0D;
				}

				var47 /= 8.0D;
			}

			++var13;

			for (int var46 = 0; var46 < par6; ++var46) {
				double var48 = (double)var17;
				double var26 = (double)var16;
				var48 += var47 * 0.2D;
				var48 = var48 * (double)par6 / 16.0D;
				double var28 = (double)par6 / 2.0D + var48 * 4.0D;
				double var30 = 0.0D;
				double var32 = ((double)var46 - var28) * 12.0D * 128.0D / 128.0D / var26;

				if (var32 < 0.0D) {
					var32 *= 4.0D;
				}

				double var34 = this.noise1[var12] / 512.0D;
				double var36 = this.noise2[var12] / 512.0D;
				double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D;

				if (var38 < 0.0D) {
					var30 = var34;
				}
				else if (var38 > 1.0D) {
					var30 = var36;
				} else {
					var30 = var34 + (var36 - var34) * var38;
				}

				var30 -= var32;

				if (var46 > par6 - 4) {
					double var40 = (double)((float)(var46 - (par6 - 4)) / 3.0F);
					var30 = var30 * (1.0D - var40) + -10.0D * var40;
				}

				par1ArrayOfDouble[var12] = var30;
				++var12;
			}
		}
	}

	return par1ArrayOfDouble;
}

public void replaceBlocksForBiome(int i, int j, Block[] ba, byte[] by, BiomeGenBase[] b) {
	double d0 = 0.03125D;
	this.stoneNoise = this.noiseGen4.func_151599_a(this.stoneNoise, (double)(i * 16), (double)(j * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);

	for(int k = 0; k < 16; ++k) {
		for(int l = 0; l < 16; ++l) {
			BiomeGenBase biomegenbase = b[l + k * 16];
			genBiomeTerrain(this.worldObj, this.rand, ba, by, i * 16 + k, j * 16 + l, this.stoneNoise[l + k * 16], biomegenbase);
		}
	}
}

public final void genBiomeTerrain(World p_150560_1_, Random p_150560_2_, Block[] p_150560_3_, byte[] p_150560_4_, int p_150560_5_, int p_150560_6_, double p_150560_7_, BiomeGenBase b) {
	boolean flag = true;
	Block block = b.topBlock;
	byte b0 = (byte)(b.field_150604_aj & 255);
	Block block1 = b.fillerBlock;
	int k = -1;
	int l = (int)(p_150560_7_ / 3.0D + 3.0D + p_150560_2_.nextDouble() * 0.25D);
	int i1 = p_150560_5_ & 15;
	int j1 = p_150560_6_ & 15;
	int k1 = p_150560_3_.length / 256;

	for (int l1 = 255; l1 >= 0; --l1) {
		int i2 = (j1 * 16 + i1) * k1 + l1;

		if (l1 <= 0 + p_150560_2_.nextInt(5)) {
			p_150560_3_[i2] = VetheaBlocks.dreamStone;
		} else {
			Block block2 = p_150560_3_[i2];

			if (block2 != null && block2.getMaterial() != Material.air) {
				if (block2 == VetheaBlocks.dreamStone) {
					if (k == -1) {
						if (l <= 0) {
							block = null;
							b0 = 0;
							block1 = VetheaBlocks.dreamStone;
						}
						else if (l1 >= 59 && l1 <= 64) {
							block = b.topBlock;
							b0 = (byte)(b.field_150604_aj & 255);
							block1 = b.topBlock;
						}

						if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) {
							if (b.getFloatTemperature(p_150560_5_, l1, p_150560_6_) < 0.15F) {
								block = b.topBlock;
								b0 = 0;
							}
						}

						k = l;

						if (l1 >= 62) {
							p_150560_3_[i2] = block;
							p_150560_4_[i2] = b0;
						}
						else if (l1 < 56 - l) {
							block = null;
							block1 = b.topBlock;
							p_150560_3_[i2] = b.topBlock;
						} else {
							p_150560_3_[i2] = block1;
						}
					}
					else if (k > 0) {
						--k;
						p_150560_3_[i2] = block1;

						if (k == 0 && block1 == VetheaBlocks.dreamStone) {
							k = p_150560_2_.nextInt(4) + Math.max(0, l1 - 63);
							block1 = VetheaBlocks.dreamStone;
						}
					}
				}
			} else {
				k = -1;
			}
		}
	}
}

@Override
public Chunk loadChunk(int par1, int par2) {
	return this.provideChunk(par1, par2);
}

@Override
public Chunk provideChunk(int par1, int par2) {
	this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L);
	Block[] block = new Block[65536];
	byte[] by = new byte[65536];
	this.generateTerrain(par1, par2, block);
	this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
	this.replaceBlocksForBiome(par1, par2, block, by, this.biomesForGeneration);
	Chunk var4 = new Chunk(this.worldObj, block, by, par1, par2);
	byte[] var5 = var4.getBiomeArray();
	for (int var6 = 0; var6 < var5.length; ++var6) {
		var5[var6] = (byte)this.biomesForGeneration[var6].biomeID;
	}

	var4.generateSkylightMap();
	return var4;
}

public boolean chunkExists(int par1, int par2) {
	return true;
}

@Override
public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {

	int var4 = par2 * 16;
	int var5 = par3 * 16;
	BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
	this.rand.setSeed(this.worldObj.getSeed());
	long var7 = this.rand.nextLong() / 2L * 2L + 1L;
	long var9 = this.rand.nextLong() / 2L * 2L + 1L;
	this.rand.setSeed((long)par2 * var7 + (long)par3 * var9 ^ this.worldObj.getSeed());
	boolean var11 = false;
	int var12;
	int var13;
	int var14;


	for (int i = 0; i < 3; i++) {
		var12 = var4 + this.rand.nextInt(16) + 8;
		var13 = 64;

		var14 = var5 + this.rand.nextInt(16) + 8;
		(new WorldGenConeUp()).generate(this.worldObj, this.rand, var12, var13, var14, this.rand.nextInt(3)+1);
	}

	//greenGemTops.generate(worldObj, rand, var4, 0, var5);
			//purpleGemTops.generate(worldObj, rand, var4, 0, var5);
			//yellowDulahs.generate(worldObj, rand, var4, 0, var5);
			//greenDulahs.generate(worldObj, rand, var4, 0, var5);

			if (this.rand.nextInt(16) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 - this.rand.nextInt(2);
				var14 = var5 + this.rand.nextInt(16) + 8;
				(new WorldGenVetheanPillar()).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			for(int i = 0; i < 2; i++) {
				var12 = 16;
				var13 = 20;
				var14 = 16;
				(new WorldGenMinable(VetheaBlocks.dreamGrass, 16, VetheaBlocks.dreamStone)).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			for(int i = 0; i < 1; i++) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = rand.nextInt(256);
				var14 = var5 + this.rand.nextInt(16) + 8;
				(new WorldGenMinable(VetheaBlocks.fireCrystal, 90, VetheaBlocks.dreamGrass)).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(32) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(this.worldObj.isAirBlock(var12, var13, var14))
					var13--;
				infusion.generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(32) == 0) {
	            var12 = var4 + this.rand.nextInt(16);
	            var13 = 20 - this.rand.nextInt(2);
	            var14 = var5 + this.rand.nextInt(16);
	            (this.items.get(this.rand.nextInt(7))).generate(this.worldObj, this.rand, var12, var13, var14);
	        }

			for (int i = 0; i < 1; ++i) {
	            var12 = var4 + this.rand.nextInt(16) + 8;
	            var13 = 30;
	            var14 = var5 + this.rand.nextInt(16) + 8;
	            (this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, this.rand, var12, var13, var14);
	        }

	        if (this.rand.nextInt(2) == 0) {
	            var12 = var4 + this.rand.nextInt(16) + 8;
	            var13 = 20;
	            var14 = var5 + this.rand.nextInt(16) + 8;
	            (this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);
	        }
	        
	        if (this.rand.nextInt(500) == 0) {
	            var12 = var4 + this.rand.nextInt(16) + 8;
	            var13 = 40;
	            var14 = var5 + this.rand.nextInt(16) + 8;
	            (new WorldGenVillageIsland()).generate(this.worldObj, this.rand, var12, var13, var14);//TODO add hunger
	        }

	        for (int i = 0; i < 1; i++) {
	            var12 = var4 + this.rand.nextInt(16) + 8;
	            var13 = 20;
	            var14 = var5 + this.rand.nextInt(16) + 8;
	            (new WorldGenLayer1Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);
	        }
	        
	        if (this.rand.nextInt(250) == 0) {
	            var12 = var4 + this.rand.nextInt(16) + 8;
	            var13 = 15;
	            var14 = var5 + this.rand.nextInt(16) + 8;
	            (crypts.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13, var14);//TODO add crypt keeper
	        }
	        
	        if (this.rand.nextInt(250) == 0) {
	            var12 = var4 + this.rand.nextInt(16) + 8;
	            var13 = 15;
	            var14 = var5 + this.rand.nextInt(16) + 8;
	            (l1Trees.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13, var14);
	        }
	        
			/*
			 * Layer 2
			 */
			for (int i = 0; i < 3; i++) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 128;
				var14 = var5 + this.rand.nextInt(16) + 8;
				 (ceilingTexture).generate(this.worldObj, this.rand, var12, var13, var14, this.rand.nextInt(3)+1);
			}

			if (this.rand.nextInt(16) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 84 - this.rand.nextInt(2);
				var14 = var5 + this.rand.nextInt(16) + 8;
				pillar.generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if(this.rand.nextInt(32) == 0) {
				var12 = var4 + rand.nextInt(16);
				var13 = 84;
				var14 = var5 + rand.nextInt(16);
				(this.items.get(this.rand.nextInt(6))).generate(this.worldObj, rand, var12, var13, var14);
			}

			if (this.rand.nextInt(32) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 85;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(this.worldObj.isAirBlock(var12, var13, var14)) {
					var13--;
				}
				infusion.generate(this.worldObj, this.rand, var12, var13, var14);
			}

			for (int i = 0; i < 3; ++i) {
				var12 = var4 + this.rand.nextInt(16);
				var13 = 90;
				var14 = var5 + this.rand.nextInt(16);
				(this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, rand, var12, var13, var14);
			}

			if (this.rand.nextInt(2) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 80;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				 (this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);
			}

			if (this.rand.nextInt(250) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 80;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				(pyramids.get(this.rand.nextInt(3))).generate(this.worldObj, this.rand, var12, var13, var14);//Add the mobs
			}

			for (int i = 0; i < 3; i++) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 84;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(new WorldGenLayer2Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 + 64;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(fernites).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 + 64;
				var14 = var5 + this.rand.nextInt(16) + 8;
				//(dreamglows).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 + 64;
				var14 = var5 + this.rand.nextInt(16) + 8;
				//(shimmers).generate(this.worldObj, this.rand, var12, var13, var14);
			}


			/*
			  * layer 3
			  */
			for (int i = 0; i < 3; i++) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 192;
				var14 = var5 + this.rand.nextInt(16) + 8;
				//(ceilingTexture).generate(this.worldObj, this.rand, var12, var13, var14, this.rand.nextInt(3)+1);
			}

			if (this.rand.nextInt(16) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 148;
				var14 = var5 + this.rand.nextInt(16) + 8;
				pillar.generate(this.worldObj, this.rand, var12, var13, var14);
			}

			for (int i = 0; i < 3; i++) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 148;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(new WorldGenLayer1Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(32) == 0) {
				var12 = var4 + rand.nextInt(16);
				var13 = 148;
				var14 = var5 + rand.nextInt(16);
				(this.items.get(this.rand.nextInt(7))).generate(this.worldObj, rand, var12, var13, var14);
			}


			if (this.rand.nextInt(32) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 148;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(this.worldObj.isAirBlock(var12, var13, var14)) {
					var13--;
				}
				infusion.generate(this.worldObj, this.rand, var12, var13, var14);
			}

			for (int i = 0; i < 3; ++i) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 158;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(2) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 19 + 128;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				(this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);
			}

			if (this.rand.nextInt(250) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 144 ;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				(l3Altars.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 + 128;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(shinegrass).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 + 128;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(cracklespikes).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 20 + 128;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(bulatobes).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			/*
			   * Layer 4
			   */
			if (this.rand.nextInt(32) == 0) {
				var12 = var4 + rand.nextInt(16);
				var13 = 212;
				var14 = var5 + rand.nextInt(16);
				(this.items.get(this.rand.nextInt(7))).generate(this.worldObj, rand, var12, var13, var14);
			}

			if (this.rand.nextInt(32) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 212;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(this.worldObj.isAirBlock(var12, var13, var14)) {
					var13--;
				}
				infusion.generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(2) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 210;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				(this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);
			}

			for (int i = 0; i < 5; i++) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 212;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(new WorldGenLayer2Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			for (int i = 0; i < 3; ++i) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 222 + this.rand.nextInt(23);
				var14 = var5 + this.rand.nextInt(16) + 8;
				(this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(150) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 210 ;
				var14 = var5 + this.rand.nextInt(16) + 8;
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				(l4Altars.get(this.rand.nextInt(3))).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			/*if (this.rand.nextInt(150) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 19 + 196;
				var14 = var5 + this.rand.nextInt(16) + 8;  
				while(!this.worldObj.isAirBlock(var12, var13, var14)) {
					var13++;
				}
				(new Layer4MassiveTree(false)).generate(this.worldObj, this.rand, var12, var13, var14);
			}*/

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 212;
				var14 = var5 + this.rand.nextInt(16) + 8;
				//(shimmers).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 212;
				var14 = var5 + this.rand.nextInt(16) + 8;
				(shinegrass).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			if (this.rand.nextInt(10) == 0) {
				var12 = var4 + this.rand.nextInt(16) + 8;
				var13 = 212;
				var14 = var5 + this.rand.nextInt(16) + 8;
				//(dreamglows).generate(this.worldObj, this.rand, var12, var13, var14);
			}

			MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, var11));
			BlockSand.fallInstantly = false;
}

public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) {
	return true;
}

public boolean canSave() {
	return true;
}

public String makeString() {
	return "Vethea";
}

@Override
public List getPossibleCreatures(EnumCreatureType enumcreaturetype, int i, int j, int k) {
	BiomeGenBase var5 = this.worldObj.getBiomeGenForCoords(i, k);
	return var5 == null ? null : var5.getSpawnableList(enumcreaturetype);
}

public int getLoadedChunkCount() {
	return 0;
}

public void recreateStructures(int par1, int par2) { }

@Override
public boolean unloadQueuedChunks() {
	return false;
}

@Override
public void saveExtraData() { }

@Override
public ChunkPosition func_147416_a(World var1, String var2, int var3, int var4, int var5) {
	return null;
}
}

 

The dimension consists of 4 layers. Each of them have a few different structures and different mobs, but overall they are pretty much the same. Yes, I realize that generating that many structures does create lag, and the dimension has never been particularly smooth, but it has been playable without making the game completely lag out. When I comment out the code for the 3rd and 4th layer, it runs quite smoothly.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

Well I can tell you one thing that's causing issues, it's a segment like this:

 

for(int i = 0; i < 2; i++) {
var12 = 16;
var13 = 20;
var14 = 16;
(new WorldGenMinable(VetheaBlocks.dreamGrass, 16, VetheaBlocks.dreamStone)).generate(this.worldObj, this.rand, var12, var13, var14);
}

 

WorldGenMinable is itself a generator, you can reuse it instead of creating a new one every time you need an ore cluster generated.

 

Otherwise, you will be creating new WorldGenMinable objects like crazy, which I would guess is a huge source of your observed lag. Instead, create a single static WorldGenMinable object for a particular type of worldgen and call it at all the appropriate points. This will avoid the massive amount of object allocation-deallocation you would have going on with the above.

Link to comment
Share on other sites

Huh! I did not know the JIT was clever enough to deal with stuff like that. I just assumed that it would unthinkingly make a new object when explicitly told to in the source, not knowing whether the programmer had special handling in the constructor and would therefore truly want a new object. Never mind then, and thanks for the info, diesieben!

Link to comment
Share on other sites

Would you mind terribly pointing me towards some literature to that effect, then? I know that this is not "java school" but I have always thought that the "new" keyword will always allocate a new object, and looking it up now I can't find anything that contradicts that.

 

I also just wrote a little for-loop that does nothing but instantiate a new object and print its identity hashcode, and it is most certainly making new allocations when I use the new keyword. Under what conditions does the compiler optimize that away?

Link to comment
Share on other sites

Yes, it is the populate method, I know that it is causing the problem.

 

 

@Override

public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {

 

int var4 = par2 * 16;

int var5 = par3 * 16;

BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);

this.rand.setSeed(this.worldObj.getSeed());

long var7 = this.rand.nextLong() / 2L * 2L + 1L;

long var9 = this.rand.nextLong() / 2L * 2L + 1L;

this.rand.setSeed((long)par2 * var7 + (long)par3 * var9 ^ this.worldObj.getSeed());

boolean var11 = false;

int var12;

int var13;

int var14;

 

 

for (int i = 0; i < 3; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

 

var14 = var5 + this.rand.nextInt(16) + 8;

(ceilingTexture).generate(this.worldObj, this.rand, var12, var13, var14, this.rand.nextInt(3)+1);

}

 

//greenGemTops.generate(worldObj, rand, var4, 0, var5);

//purpleGemTops.generate(worldObj, rand, var4, 0, var5);

//yellowDulahs.generate(worldObj, rand, var4, 0, var5);

//greenDulahs.generate(worldObj, rand, var4, 0, var5);

 

if (this.rand.nextInt(16) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 16 - this.rand.nextInt(2);

var14 = var5 + this.rand.nextInt(16) + 8;

(pillar).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

for(int i = 0; i < 2; i++) {

var12 = 16;

var13 = 16;

var14 = 16;

(grassClusters).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

for(int i = 0; i < 1; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = rand.nextInt(256);

var14 = var5 + this.rand.nextInt(16) + 8;

(firecrystals).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(32) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 16;

var14 = var5 + this.rand.nextInt(16) + 8;

while(this.worldObj.isAirBlock(var12, var13, var14))

var13--;

infusion.generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(32) == 0) {

            var12 = var4 + this.rand.nextInt(16);

            var13 = 16 - this.rand.nextInt(2);

            var14 = var5 + this.rand.nextInt(16);

            (this.items.get(this.rand.nextInt(7))).generate(this.worldObj, this.rand, var12, var13, var14);

        }

 

for (int i = 0; i < 1; ++i) {

            var12 = var4 + this.rand.nextInt(16) + 8;

            var13 = 30;

            var14 = var5 + this.rand.nextInt(16) + 8;

            (this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, this.rand, var12, var13, var14);

        }

 

        if (this.rand.nextInt(2) == 0) {

            var12 = var4 + this.rand.nextInt(16) + 8;

            var13 = 16;

            var14 = var5 + this.rand.nextInt(16) + 8;

            (this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);

        }

       

        if (this.rand.nextInt(500) == 0) {

            var12 = var4 + this.rand.nextInt(16) + 8;

            var13 = 40;

            var14 = var5 + this.rand.nextInt(16) + 8;

            (hungerVillages).generate(this.worldObj, this.rand, var12, var13, var14);//TODO add hunger

        }

 

        for (int i = 0; i < 1; i++) {

            var12 = var4 + this.rand.nextInt(16) + 8;

            var13 = 16;

            var14 = var5 + this.rand.nextInt(16) + 8;

            (new WorldGenLayer1Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);

        }

       

        if (this.rand.nextInt(250) == 0) {

            var12 = var4 + this.rand.nextInt(16) + 8;

            var13 = 15;

            var14 = var5 + this.rand.nextInt(16) + 8;

            (crypts.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13, var14);//TODO add crypt keeper

        }

       

        if (this.rand.nextInt(250) == 0) {

            var12 = var4 + this.rand.nextInt(16) + 8;

            var13 = 15;

            var14 = var5 + this.rand.nextInt(16) + 8;

            (l1Trees.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13, var14);

        }

       

// Layer 2

 

for (int i = 0; i < 3; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 96;

var14 = var5 + this.rand.nextInt(16) + 8;

(ceilingTexture).generate(this.worldObj, this.rand, var12, var13, var14, this.rand.nextInt(3)+1);

}

 

if (this.rand.nextInt(16) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64 - this.rand.nextInt(2);

var14 = var5 + this.rand.nextInt(16) + 8;

pillar.generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if(this.rand.nextInt(32) == 0) {

var12 = var4 + rand.nextInt(16);

var13 = 64;

var14 = var5 + rand.nextInt(16);

(this.items.get(this.rand.nextInt(6))).generate(this.worldObj, rand, var12, var13, var14);

}

 

if (this.rand.nextInt(32) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

while(this.worldObj.isAirBlock(var12, var13, var14)) {

var13--;

}

infusion.generate(this.worldObj, this.rand, var12, var13, var14);

}

 

for (int i = 0; i < 3; ++i) {

var12 = var4 + this.rand.nextInt(16);

var13 = 75;

var14 = var5 + this.rand.nextInt(16);

(this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, rand, var12, var13, var14);

}

 

if (this.rand.nextInt(2) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);

}

 

if (this.rand.nextInt(250) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(pyramids.get(this.rand.nextInt(3))).generate(this.worldObj, this.rand, var12, var13, var14);//Add the mobs

}

 

for (int i = 0; i < 3; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

(new WorldGenLayer2Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

(fernites).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

//(dreamglows).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 64;

var14 = var5 + this.rand.nextInt(16) + 8;

//(shimmers).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

 

/*

  * layer 3

  */

/*for (int i = 0; i < 3; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 192;

var14 = var5 + this.rand.nextInt(16) + 8;

//(ceilingTexture).generate(this.worldObj, this.rand, var12, var13, var14, this.rand.nextInt(3)+1);

}

 

if (this.rand.nextInt(16) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 148;

var14 = var5 + this.rand.nextInt(16) + 8;

pillar.generate(this.worldObj, this.rand, var12, var13, var14);

}

 

for (int i = 0; i < 3; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 148;

var14 = var5 + this.rand.nextInt(16) + 8;

(new WorldGenLayer1Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(32) == 0) {

var12 = var4 + rand.nextInt(16);

var13 = 148;

var14 = var5 + rand.nextInt(16);

(this.items.get(this.rand.nextInt(7))).generate(this.worldObj, rand, var12, var13, var14);

}

 

 

if (this.rand.nextInt(32) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 148;

var14 = var5 + this.rand.nextInt(16) + 8;

while(this.worldObj.isAirBlock(var12, var13, var14)) {

var13--;

}

infusion.generate(this.worldObj, this.rand, var12, var13, var14);

}

 

for (int i = 0; i < 3; ++i) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 158;

var14 = var5 + this.rand.nextInt(16) + 8;

(this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(2) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 19 + 128;

var14 = var5 + this.rand.nextInt(16) + 8;

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);

}

 

if (this.rand.nextInt(250) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 144 ;

var14 = var5 + this.rand.nextInt(16) + 8;

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(l3Altars.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 20 + 128;

var14 = var5 + this.rand.nextInt(16) + 8;

(shinegrass).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 20 + 128;

var14 = var5 + this.rand.nextInt(16) + 8;

(cracklespikes).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 20 + 128;

var14 = var5 + this.rand.nextInt(16) + 8;

(bulatobes).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

  //Layer 4

 

if (this.rand.nextInt(32) == 0) {

var12 = var4 + rand.nextInt(16);

var13 = 212;

var14 = var5 + rand.nextInt(16);

(this.items.get(this.rand.nextInt(7))).generate(this.worldObj, rand, var12, var13, var14);

}

 

if (this.rand.nextInt(32) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 212;

var14 = var5 + this.rand.nextInt(16) + 8;

while(this.worldObj.isAirBlock(var12, var13, var14)) {

var13--;

}

infusion.generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(2) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 210;

var14 = var5 + this.rand.nextInt(16) + 8;

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(this.lamps.get(this.rand.nextInt(2))).generate(this.worldObj, this.rand, var12, var13 - 2, var14);

}

 

for (int i = 0; i < 5; i++) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 212;

var14 = var5 + this.rand.nextInt(16) + 8;

(new WorldGenLayer2Forest(false)).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

for (int i = 0; i < 3; ++i) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 222 + this.rand.nextInt(23);

var14 = var5 + this.rand.nextInt(16) + 8;

(this.floatingTrees.get(this.rand.nextInt(6))).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(150) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 210 ;

var14 = var5 + this.rand.nextInt(16) + 8;

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(l4Altars.get(this.rand.nextInt(3))).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

/*if (this.rand.nextInt(150) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 19 + 196;

var14 = var5 + this.rand.nextInt(16) + 8; 

while(!this.worldObj.isAirBlock(var12, var13, var14)) {

var13++;

}

(new Layer4MassiveTree(false)).generate(this.worldObj, this.rand, var12, var13, var14);

}*/

 

/*if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 212;

var14 = var5 + this.rand.nextInt(16) + 8;

//(shimmers).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 212;

var14 = var5 + this.rand.nextInt(16) + 8;

(shinegrass).generate(this.worldObj, this.rand, var12, var13, var14);

}

 

if (this.rand.nextInt(10) == 0) {

var12 = var4 + this.rand.nextInt(16) + 8;

var13 = 212;

var14 = var5 + this.rand.nextInt(16) + 8;

//(dreamglows).generate(this.worldObj, this.rand, var12, var13, var14);

}*/

 

MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, var11));

BlockSand.fallInstantly = false;

}

 

 

 

I'm just not sure why the higher layers are being especially slow.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

Hi

 

A couple of thoughts

1) I helped to optimise another mod once which was generating blocks (spheres) in the sky.  The lag was awful.  The reason turned out to be the lighting calculations. Adding blocks in the sky caused a cascading series of updates to the skylight map- each update of a block's lighting value affects all its neighbours, which affects all their neighbours, and so on.  The solution was to provide a better initialisation of the lighting map instead of just having them all set to 15.

2) You can enable profiling by typing /debug start in the chat:

On success, starts or stops the debug session. While active, includes notifications about potential performance bottlenecks in the console. When stopped, creates a profiler results file in the folder "debug".  You can even add your own sections similar to the vanilla ones.

Minecraft.getMinecraft().mcProfiler.endStartSection("startOfMyCode");

 

 

3) You could also add your own profiling code to narrow down where the time is being spent eg

startTime  = System.nanoTime();

// do stuff

timeSpent = System.nanoTime() - startTime;

System.out.println("Time spent in xxx (ms)" + timeSpent / 1000000);

 

-TGG

Link to comment
Share on other sites

I tried the debug feature, and only about 20-30% of it was lighting. 3/4 of the gen is not exposed to the sky. It might be the sheer volume of the structures. Here's a screenshot:

c64fde50-6c22-11e4-9e58-b7a71f77f127.png

If so, is there any way I could make this less laggy (aside from writing a system that creates them in generateTerrain)?

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

If a majority of those are leaf blocks, which it looks like they may be, then that would be a HUGE source of lag - consider how bad dense jungles lag, and then look at what you are doing there.

 

Of course if those aren't leaf blocks, then my guess is simply that your generation code is not very optimized. It's very easy to write poorly optimized generation code, given the penchant for many recursive and looping calls.

Link to comment
Share on other sites

Relatively few of the blocks are transparent, and the little generation code that does use loops never creates objects in them. And it's not that the game just lags a lot, all of the mobs freeze and the integrated server completely freezes up. Are you sure Forge didn't change any chunk loading code? This worked fine in earlier Forge versions.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello. I've been having a problem when launching minecraft forge. It just doesn't open the game, and leaves me with this "(exit code 1)" error. Both regular and optifine versions of minecraft launch just fine, tried both with 1.18.2 and 1.20.1. I can assure that my drivers are updated so that can't be it, and i've tried using Java 17, 18 and 21 to no avail. Even with no mods installed, the thing won't launch. I'll leave the log here, although it's in spanish: https://jmp.sh/s/FPqGBSi30fzKJDt2M1gc My specs are this: Ryzen 3 4100 || Radeon R9 280x || 16gb ram || Windows 10 I'd appreciate any help, thank you in advance.
    • Hey, Me and my friends decided to start up a Server with "a few" mods, the last few days everything went well we used all the items we wanted. Now our Game crashes the moment we touch a Lava Bucket inside our Inventory. It just instantly closes and gives me an "Alc Cleanup"  Crash screen (Using GDLauncher). I honestly dont have a clue how to resolve this error. If anyone could help id really appreciate it, I speak German and Englisch so you can choose whatever you speak more fluently. Thanks in Advance. Plus I dont know how to link my Crash Report help for that would be nice too whoops
    • I hosted a minecraft server and I modded it, and there is always an error on the console which closes the server. If someone knows how to repair it, it would be amazing. Thank you. I paste the crash report down here: ---- Minecraft Crash Report ---- WARNING: coremods are present:   llibrary (llibrary-core-1.0.11-1.12.2.jar)   WolfArmorCore (WolfArmorAndStorage-1.12.2-3.8.0-universal-signed.jar)   AstralCore (astralsorcery-1.12.2-1.10.27.jar)   CreativePatchingLoader (CreativeCore_v1.10.71_mc1.12.2.jar)   SecurityCraftLoadingPlugin ([1.12.2] SecurityCraft v1.9.8.jar)   ForgelinPlugin (Forgelin-1.8.4.jar)   midnight (themidnight-0.3.5.jar)   FutureMC (Future-MC-0.2.19.jar)   SpartanWeaponry-MixinLoader (SpartanWeaponry-1.12.2-1.5.3.jar)   Backpacked (backpacked-1.4.3-1.12.2.jar)   LoadingPlugin (Reskillable-1.12.2-1.13.0.jar)   LoadingPlugin (Bloodmoon-MC1.12.2-1.5.3.jar) Contact their authors BEFORE contacting forge // There are four lights! Time: 3/28/24 12:17 PM Description: Exception in server tick loop net.minecraftforge.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient     at net.minecraftforge.fml.common.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:89)     at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:612)     at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:498)     at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)     at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)     at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)     at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)     at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)     at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)     at com.google.common.eventbus.EventBus.post(EventBus.java:217)     at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)     at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:498)     at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)     at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)     at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)     at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)     at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)     at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)     at com.google.common.eventbus.EventBus.post(EventBus.java:217)     at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)     at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:595)     at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98)     at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:333)     at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:125)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486)     at java.lang.Thread.run(Thread.java:750) Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient     at java.lang.Class.getDeclaredMethods0(Native Method)     at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)     at java.lang.Class.privateGetPublicMethods(Class.java:2902)     at java.lang.Class.getMethods(Class.java:1615)     at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:82)     at net.minecraftforge.fml.common.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:82)     ... 31 more Caused by: java.lang.ClassNotFoundException: net.minecraft.client.multiplayer.WorldClient     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)     ... 37 more Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@4e558728 from coremod FMLCorePlugin     at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:260)     at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279)     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176)     ... 39 more Caused by: java.lang.RuntimeException: Attempted to load class bsb for invalid side SERVER     at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:62)     at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:256)     ... 41 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Linux (amd64) version 5.10.0-28-cloud-amd64     Java Version: 1.8.0_382, Temurin     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Temurin     Memory: 948745536 bytes (904 MB) / 1564999680 bytes (1492 MB) up to 7635730432 bytes (7282 MB)     JVM Flags: 2 total; -Xmx8192M -Xms256M     IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0     FML: MCP 9.42 Powered by Forge 14.23.5.2860 63 mods loaded, 63 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     | State | ID                 | Version                 | Source                                                | Signature                                |     |:----- |:------------------ |:----------------------- |:----------------------------------------------------- |:---------------------------------------- |     | LC    | minecraft          | 1.12.2                  | minecraft.jar                                         | None                                     |     | LC    | mcp                | 9.42                    | minecraft.jar                                         | None                                     |     | LC    | FML                | 8.0.99.99               | forge-1.12.2-14.23.5.2860.jar                         | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LC    | forge              | 14.23.5.2860            | forge-1.12.2-14.23.5.2860.jar                         | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LC    | creativecoredummy  | 1.0.0                   | minecraft.jar                                         | None                                     |     | LC    | backpacked         | 1.4.2                   | backpacked-1.4.3-1.12.2.jar                           | None                                     |     | LC    | itemblacklist      | 1.4.3                   | ItemBlacklist-1.4.3.jar                               | None                                     |     | LC    | securitycraft      | v1.9.8                  | [1.12.2] SecurityCraft v1.9.8.jar                     | None                                     |     | LC    | aiimprovements     | 0.0.1.3                 | AIImprovements-1.12-0.0.1b3.jar                       | None                                     |     | LC    | jei                | 4.16.1.301              | jei_1.12.2-4.16.1.301.jar                             | None                                     |     | LC    | appleskin          | 1.0.14                  | AppleSkin-mc1.12-1.0.14.jar                           | None                                     |     | LC    | baubles            | 1.5.2                   | Baubles-1.12-1.5.2.jar                                | None                                     |     | LC    | astralsorcery      | 1.10.27                 | astralsorcery-1.12.2-1.10.27.jar                      | a0f0b759d895c15ceb3e3bcb5f3c2db7c582edf0 |     | LC    | attributefix       | 1.0.12                  | AttributeFix-Forge-1.12.2-1.0.12.jar                  | None                                     |     | LC    | atum               | 2.0.20                  | Atum-1.12.2-2.0.20.jar                                | None                                     |     | LC    | bloodmoon          | 1.5.3                   | Bloodmoon-MC1.12.2-1.5.3.jar                          | d72e0dd57935b3e9476212aea0c0df352dd76291 |     | LC    | forgelin           | 1.8.4                   | Forgelin-1.8.4.jar                                    | None                                     |     | LC    | bountiful          | 2.2.2                   | Bountiful-2.2.2.jar                                   | None                                     |     | LC    | camera             | 1.0.10                  | camera-1.0.10.jar                                     | None                                     |     | LC    | chisel             | MC1.12.2-1.0.2.45       | Chisel-MC1.12.2-1.0.2.45.jar                          | None                                     |     | LC    | collective         | 3.0                     | collective-1.12.2-3.0.jar                             | None                                     |     | LC    | reskillable        | 1.12.2-1.13.0           | Reskillable-1.12.2-1.13.0.jar                         | None                                     |     | LC    | compatskills       | 1.12.2-1.17.0           | CompatSkills-1.12.2-1.17.0.jar                        | None                                     |     | LC    | creativecore       | 1.10.0                  | CreativeCore_v1.10.71_mc1.12.2.jar                    | None                                     |     | LC    | customnpcs         | 1.12                    | CustomNPCs_1.12.2-(05Jul20).jar                       | None                                     |     | LC    | darknesslib        | 1.1.2                   | DarknessLib-1.12.2-1.1.2.jar                          | 220f10d3a93b3ff5fbaa7434cc629d863d6751b9 |     | LC    | dungeonsmod        | @VERSION@               | DungeonsMod-1.12.2-1.0.8.jar                          | None                                     |     | LC    | enhancedvisuals    | 1.3.0                   | EnhancedVisuals_v1.4.4_mc1.12.2.jar                   | None                                     |     | LC    | extrautils2        | 1.0                     | extrautils2-1.12-1.9.9.jar                            | None                                     |     | LC    | futuremc           | 0.2.6                   | Future-MC-0.2.19.jar                                  | None                                     |     | LC    | geckolib3          | 3.0.30                  | geckolib-forge-1.12.2-3.0.31.jar                      | None                                     |     | LC    | gottschcore        | 1.15.1                  | GottschCore-mc1.12.2-f14.23.5.2859-v1.15.1.jar        | None                                     |     | LC    | hardcorerevival    | 1.2.0                   | HardcoreRevival_1.12.2-1.2.0.jar                      | None                                     |     | LC    | waila              | 1.8.26                  | Hwyla-1.8.26-B41_1.12.2.jar                           | None                                     |     | LE    | imsm               | 1.12                    | Instant Massive Structures Mod 1.12.2.jar             | None                                     |     | L     | journeymap         | 1.12.2-5.7.1p2          | journeymap-1.12.2-5.7.1p2.jar                         | None                                     |     | L     | mobsunscreen       | @version@               | mobsunscreen-1.12.2-3.1.5.jar                         | None                                     |     | L     | morpheus           | 1.12.2-3.5.106          | Morpheus-1.12.2-3.5.106.jar                           | None                                     |     | L     | llibrary           | 1.7.20                  | llibrary-1.7.20-1.12.2.jar                            | None                                     |     | L     | mowziesmobs        | 1.5.8                   | mowziesmobs-1.5.8.jar                                 | None                                     |     | L     | nocubessrparmory   | 3.0.0                   | NoCubes_SRP_Combat_Addon_3.0.0.jar                    | None                                     |     | L     | nocubessrpnests    | 3.0.0                   | NoCubes_SRP_Nests_Addon_3.0.0.jar                     | None                                     |     | L     | nocubessrpsurvival | 3.0.0                   | NoCubes_SRP_Survival_Addon_3.0.0.jar                  | None                                     |     | L     | nocubesrptweaks    | V4.1                    | nocubesrptweaks-V4.1.jar                              | None                                     |     | L     | patchouli          | 1.0-23.6                | Patchouli-1.0-23.6.jar                                | None                                     |     | L     | artifacts          | 1.1.2                   | RLArtifacts-1.1.2.jar                                 | None                                     |     | L     | rsgauges           | 1.2.8                   | rsgauges-1.12.2-1.2.8.jar                             | None                                     |     | L     | rustic             | 1.1.7                   | rustic-1.1.7.jar                                      | None                                     |     | L     | silentlib          | 3.0.13                  | SilentLib-1.12.2-3.0.14+168.jar                       | None                                     |     | L     | scalinghealth      | 1.3.37                  | ScalingHealth-1.12.2-1.3.42+147.jar                   | None                                     |     | L     | lteleporters       | 1.12.2-3.0.2            | simpleteleporters-1.12.2-3.0.2.jar                    | None                                     |     | L     | spartanshields     | 1.5.5                   | SpartanShields-1.12.2-1.5.5.jar                       | None                                     |     | L     | spartanweaponry    | 1.5.3                   | SpartanWeaponry-1.12.2-1.5.3.jar                      | None                                     |     | L     | srparasites        | 1.9.18                  | SRParasites-1.12.2v1.9.18.jar                         | None                                     |     | L     | treasure2          | 2.2.0                   | Treasure2-mc1.12.2-f14.23.5.2859-v2.2.1.jar           | None                                     |     | L     | treeharvester      | 4.0                     | treeharvester_1.12.2-4.0.jar                          | None                                     |     | L     | twilightforest     | 3.11.1021               | twilightforest-1.12.2-3.11.1021-universal.jar         | None                                     |     | L     | variedcommodities  | 1.12.2                  | VariedCommodities_1.12.2-(31Mar23).jar                | None                                     |     | L     | voicechat          | 1.12.2-2.4.32           | voicechat-forge-1.12.2-2.4.32.jar                     | None                                     |     | L     | wolfarmor          | 3.8.0                   | WolfArmorAndStorage-1.12.2-3.8.0-universal-signed.jar | None                                     |     | L     | worldborder        | 2.3                     | worldborder_1.12.2-2.3.jar                            | None                                     |     | L     | midnight           | 0.3.5                   | themidnight-0.3.5.jar                                 | None                                     |     | L     | structurize        | 1.12.2-0.10.277-RELEASE | structurize-1.12.2-0.10.277-RELEASE.jar               | None                                     |     Loaded coremods (and transformers):  llibrary (llibrary-core-1.0.11-1.12.2.jar)   net.ilexiconn.llibrary.server.core.plugin.LLibraryTransformer   net.ilexiconn.llibrary.server.core.patcher.LLibraryRuntimePatcher WolfArmorCore (WolfArmorAndStorage-1.12.2-3.8.0-universal-signed.jar)    AstralCore (astralsorcery-1.12.2-1.10.27.jar)    CreativePatchingLoader (CreativeCore_v1.10.71_mc1.12.2.jar)    SecurityCraftLoadingPlugin ([1.12.2] SecurityCraft v1.9.8.jar)    ForgelinPlugin (Forgelin-1.8.4.jar)    midnight (themidnight-0.3.5.jar)   com.mushroom.midnight.core.transformer.MidnightClassTransformer FutureMC (Future-MC-0.2.19.jar)   thedarkcolour.futuremc.asm.CoreTransformer SpartanWeaponry-MixinLoader (SpartanWeaponry-1.12.2-1.5.3.jar)    Backpacked (backpacked-1.4.3-1.12.2.jar)   com.mrcrayfish.backpacked.asm.BackpackedTransformer LoadingPlugin (Reskillable-1.12.2-1.13.0.jar)   codersafterdark.reskillable.base.asm.ClassTransformer LoadingPlugin (Bloodmoon-MC1.12.2-1.5.3.jar)   lumien.bloodmoon.asm.ClassTransformer     Profiler Position: N/A (disabled)     Is Modded: Definitely; Server brand changed to 'fml,forge'     Type: Dedicated Server (map_server.txt)
    • When i add mods like falling leaves, visuality and kappas shaders, even if i restart Minecraft they dont show up in the mods menu and they dont work
    • Delete the forge-client.toml file in your config folder  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.