19 mars 2014, 13:51
Le problème est finalement résolu!
private ChunkCoordinates findClosestBlockOfBiome(Entity e, BiomeGenBase b, double radius)
{
World w = e.worldObj;
double min = Double.POSITIVE_INFINITY;
ChunkCoordinates current = null;
for(double x = -radius;x<=radius;x+=0.5)
{
for(double z = -radius;z<=radius;z+=0.5)
{
double dist = Math.sqrt(Math.pow((e.posX-(int)Math.floor(x+e.posX)),2)+Math.pow((e.posZ-(int)Math.floor(z+e.posZ)),2));
if(w.getBiomeGenForCoords((int)Math.floor(x+e.posX), (int)Math.floor(z+e.posZ)) == b && dist <= radius && min > dist)
{
min = dist;
current = new ChunkCoordinates((int)Math.floor(x+e.posX), 0, (int)Math.floor(z+e.posZ));
}
}
}
return current;
}