fix wrong center chunk coordinates
This commit is contained in:
parent
8172e2ef60
commit
d7debfd34e
1 changed files with 21 additions and 42 deletions
|
@ -12,17 +12,13 @@ import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.ChunkCoordIntPair;
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
import net.minecraft.world.gen.ChunkProviderEnd;
|
|
||||||
import net.minecraft.world.gen.ChunkProviderHell;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class GT_Worldgenerator
|
public class GT_Worldgenerator implements IWorldGenerator {
|
||||||
implements IWorldGenerator {
|
|
||||||
private static int mEndAsteroidProbability = 300;
|
private static int mEndAsteroidProbability = 300;
|
||||||
private static int mGCAsteroidProbability = 50;
|
private static int mGCAsteroidProbability = 50;
|
||||||
private static int mSize = 100;
|
private static int mSize = 100;
|
||||||
|
@ -54,8 +50,7 @@ public class GT_Worldgenerator
|
||||||
new WorldGenContainer(new XSTR(aRandom.nextInt()), aX * 16, aZ * 16, tempDimensionId, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName).run();
|
new WorldGenContainer(new XSTR(aRandom.nextInt()), aX * 16, aZ * 16, tempDimensionId, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WorldGenContainer
|
public static class WorldGenContainer implements Runnable {
|
||||||
implements Runnable {
|
|
||||||
public final Random mRandom;
|
public final Random mRandom;
|
||||||
public int mX;
|
public int mX;
|
||||||
public int mZ;
|
public int mZ;
|
||||||
|
@ -76,30 +71,23 @@ public class GT_Worldgenerator
|
||||||
this.mChunkProvider = aChunkProvider;
|
this.mChunkProvider = aChunkProvider;
|
||||||
this.mBiome = aBiome;
|
this.mBiome = aBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean surroundingChunksLoaded(int aX, int aZ){
|
//returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square
|
||||||
if(!mWorld.checkChunksExist(aX-16, 100, aZ-16, aX-16, 100, aZ-16)) return false;
|
public int getVeinCenterCoordinate(int c) {
|
||||||
if(!mWorld.checkChunksExist(aX, 100, aZ-16, aX , 100, aZ-16)) return false;
|
c += c < 0 ? 1 : 3;
|
||||||
if(!mWorld.checkChunksExist(aX+16, 100, aZ-16, aX+16, 100, aZ-16)) return false;
|
return c - c % 3 - 2;
|
||||||
if(!mWorld.checkChunksExist(aX+16, 100, aZ , aX+16, 100, aZ )) return false;
|
}
|
||||||
if(!mWorld.checkChunksExist(aX+16, 100, aZ+16, aX+16, 100, aZ+16)) return false;
|
|
||||||
if(!mWorld.checkChunksExist(aX , 100, aZ+16, aX , 100, aZ+16)) return false;
|
public boolean surroundingChunksLoaded(int xCenter, int zCenter) {
|
||||||
if(!mWorld.checkChunksExist(aX-16, 100, aZ+16, aX-16, 100, aZ+16)) return false;
|
return mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16);
|
||||||
if(!mWorld.checkChunksExist(aX-16, 100, aZ , aX-16, 100, aZ )) return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
int sX = mX;
|
int xCenter = getVeinCenterCoordinate(mX >> 4) << 4;
|
||||||
int sZ = mZ;
|
int zCenter = getVeinCenterCoordinate(mZ >> 4) << 4;
|
||||||
if((this.mX / 16 - 1) % 3 == 1) sX = mX - 16;
|
ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter);
|
||||||
if((this.mX / 16 - 1) % 3 == 2) sX = mX + 16;
|
if (surroundingChunksLoaded(xCenter, zCenter) && !mGenerated.contains(centerChunk)) {
|
||||||
if((this.mZ / 16 - 1) % 3 == 1) sZ = mZ - 16;
|
mGenerated.add(centerChunk);
|
||||||
if((this.mZ / 16 - 1) % 3 == 2) sZ = mZ + 16;
|
|
||||||
if (((sX / 16 - 1) % 3 == 0) && ((sZ / 16 - 1) % 3 == 0) && surroundingChunksLoaded(sX,sZ)) {
|
|
||||||
ChunkCoordIntPair tPair = new ChunkCoordIntPair(sX, sZ);
|
|
||||||
if(!mGenerated.contains(tPair)){
|
|
||||||
mGenerated.add(tPair);
|
|
||||||
if ((GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
|
if ((GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
|
||||||
boolean temp = true;
|
boolean temp = true;
|
||||||
int tRandomWeight;
|
int tRandomWeight;
|
||||||
|
@ -109,7 +97,7 @@ public class GT_Worldgenerator
|
||||||
tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer) tWorldGen).mWeight;
|
tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer) tWorldGen).mWeight;
|
||||||
if (tRandomWeight <= 0) {
|
if (tRandomWeight <= 0) {
|
||||||
try {
|
try {
|
||||||
if (tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, sX, sZ, this.mChunkGenerator, this.mChunkProvider)) {
|
if (tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, xCenter, zCenter, this.mChunkGenerator, this.mChunkProvider)) {
|
||||||
temp = false;
|
temp = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -121,10 +109,9 @@ public class GT_Worldgenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int tX = sX - 16; i < 3; tX += 16) {
|
for (int tX = xCenter - 16; i < 3; tX += 16) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int tZ = sZ - 16; j < 3; tZ += 16) {
|
for (int tZ = zCenter - 16; j < 3; tZ += 16) {
|
||||||
String tBiome = this.mWorld.getBiomeGenForCoords(tX + 8, tZ + 8).biomeName;
|
|
||||||
try {
|
try {
|
||||||
for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) {
|
for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) {
|
||||||
tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, tX, tZ, this.mChunkGenerator, this.mChunkProvider);
|
tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, tX, tZ, this.mChunkGenerator, this.mChunkProvider);
|
||||||
|
@ -136,14 +123,13 @@ public class GT_Worldgenerator
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//Asteroid Worldgen
|
//Asteroid Worldgen
|
||||||
int tDimensionType = this.mWorld.provider.dimensionId;
|
int tDimensionType = this.mWorld.provider.dimensionId;
|
||||||
String tDimensionName = this.mWorld.provider.getDimensionName();
|
String tDimensionName = this.mWorld.provider.getDimensionName();
|
||||||
Random aRandom = new Random();
|
Random aRandom = new Random();
|
||||||
if (((tDimensionType == 1) && endAsteroids && ((mEndAsteroidProbability <= 1) || (aRandom.nextInt(mEndAsteroidProbability) == 0))) || ((tDimensionName.equals("Asteroids")) && gcAsteroids && ((mGCAsteroidProbability <= 1) || (aRandom.nextInt(mGCAsteroidProbability) == 0)))) {
|
if (((tDimensionType == 1) && endAsteroids && ((mEndAsteroidProbability <= 1) || (aRandom.nextInt(mEndAsteroidProbability) == 0))) || ((tDimensionName.equals("Asteroids")) && gcAsteroids && ((mGCAsteroidProbability <= 1) || (aRandom.nextInt(mGCAsteroidProbability) == 0)))) {
|
||||||
short primaryMeta = 0;
|
short primaryMeta = 0;
|
||||||
short secondaryMeta = 0;
|
short secondaryMeta = 0;
|
||||||
short betweenMeta = 0;
|
short betweenMeta = 0;
|
||||||
short sporadicMeta = 0;
|
short sporadicMeta = 0;
|
||||||
|
@ -171,7 +157,7 @@ public class GT_Worldgenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(GT_Values.D1)System.out.println("do asteroid gen: "+this.mX+" "+this.mZ);
|
if (GT_Values.D1) System.out.println("do asteroid gen: " + this.mX + " " + this.mZ);
|
||||||
int tX = mX + aRandom.nextInt(16);
|
int tX = mX + aRandom.nextInt(16);
|
||||||
int tY = 50 + aRandom.nextInt(200 - 50);
|
int tY = 50 + aRandom.nextInt(200 - 50);
|
||||||
int tZ = mZ + aRandom.nextInt(16);
|
int tZ = mZ + aRandom.nextInt(16);
|
||||||
|
@ -223,12 +209,7 @@ public class GT_Worldgenerator
|
||||||
if (tDimensionType == 1) {
|
if (tDimensionType == 1) {
|
||||||
mWorld.setBlock(eX, eY, eZ, Blocks.end_stone, 0, 2);
|
mWorld.setBlock(eX, eY, eZ, Blocks.end_stone, 0, 2);
|
||||||
} else if (tDimensionName.equals("Asteroids")) {
|
} else if (tDimensionName.equals("Asteroids")) {
|
||||||
//int asteroidType = aRandom.nextInt(20);
|
|
||||||
//if (asteroidType == 19) { //Rare Asteroid?
|
|
||||||
//mWorld.setBlock(eX, eY, eZ, GregTech_API.sBlockGranites, 8, 3);
|
|
||||||
//} else {
|
|
||||||
mWorld.setBlock(eX, eY, eZ, GregTech_API.sBlockGranites, 8, 3);
|
mWorld.setBlock(eX, eY, eZ, GregTech_API.sBlockGranites, 8, 3);
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,10 +220,8 @@ public class GT_Worldgenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ);
|
Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ);
|
||||||
if (tChunk != null) {
|
if (tChunk != null) {
|
||||||
tChunk.isModified = true;
|
tChunk.isModified = true;
|
||||||
|
|
Loading…
Reference in a new issue