Made the biome check relative to the player's position and choose the closest biome that it can find
This commit is contained in:
parent
1d3730c93b
commit
b9d7f223f4
2 changed files with 50 additions and 7 deletions
|
@ -47,7 +47,7 @@ public class TextureBiomeFinder extends TextureAtlasSprite
|
|||
|
||||
if (par1World != null && !par8)
|
||||
{
|
||||
System.out.println(biomePosX + " " + biomePosZ);
|
||||
//System.out.println(biomePosX + " " + biomePosZ);
|
||||
|
||||
double d4 = (double)biomePosX - playerPosX;
|
||||
double d5 = (double)biomePosZ - playerPosZ;
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
@ -39,23 +40,65 @@ public class ItemBiomeFinder extends Item
|
|||
|
||||
WorldChunkManager chunkManager = world.getWorldChunkManager();
|
||||
|
||||
//TODO: findBiome()?
|
||||
ChunkPosition biomePosition = null;
|
||||
ChunkPosition finalFoundPosition1 = null;
|
||||
|
||||
for (int x = -10; x <= 10; x++)
|
||||
int playerX = MathHelper.floor_double(player.posX);
|
||||
int playerZ = MathHelper.floor_double(player.posZ);
|
||||
|
||||
for (int x = 10; x <= 10; x++)
|
||||
{
|
||||
for (int z = -10; z <= 10; z++)
|
||||
{
|
||||
ChunkPosition foundPosition = chunkManager.func_150795_a(x * 1024, z * 1024, radius, Arrays.asList(biomeToFind), world.rand);
|
||||
ChunkPosition foundPosition = chunkManager.func_150795_a(playerX + (x * 1024), playerZ + (z * 1024), radius, Arrays.asList(biomeToFind), world.rand);
|
||||
|
||||
if (foundPosition != null && world.getBiomeGenForCoords(foundPosition.field_151329_a, foundPosition.field_151328_c) == biomeToFind)
|
||||
{
|
||||
biomePosition = foundPosition;
|
||||
finalFoundPosition1 = foundPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChunkPosition finalFoundPosition2 = null;
|
||||
|
||||
for (int x = -10; x <= 10; x++)
|
||||
{
|
||||
for (int z = 10; z >= -10; z--)
|
||||
{
|
||||
ChunkPosition foundPosition = chunkManager.func_150795_a(playerX + (x * 1024), playerZ + (z * 1024), radius, Arrays.asList(biomeToFind), world.rand);
|
||||
|
||||
if (foundPosition != null && world.getBiomeGenForCoords(foundPosition.field_151329_a, foundPosition.field_151328_c) == biomeToFind)
|
||||
{
|
||||
finalFoundPosition2 = foundPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChunkPosition biomePosition = null;
|
||||
|
||||
System.out.println((finalFoundPosition1 == null) + " " + (finalFoundPosition2 == null));
|
||||
|
||||
if (finalFoundPosition1 != null && finalFoundPosition2 != null)
|
||||
{
|
||||
int f1X = finalFoundPosition1.field_151329_a;
|
||||
int f1Z = finalFoundPosition1.field_151328_c;
|
||||
|
||||
int f2X = finalFoundPosition2.field_151329_a;
|
||||
int f2Z = finalFoundPosition2.field_151328_c;
|
||||
|
||||
System.out.println(f1X + " " + f1Z);
|
||||
System.out.println(f2X + " " + f2Z);
|
||||
|
||||
if (Math.sqrt((f1X * f1X) + (f1Z * f1Z)) > Math.sqrt((f2X * f2X) + (f2Z * f2Z))) biomePosition = finalFoundPosition2;
|
||||
else biomePosition = finalFoundPosition1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (finalFoundPosition1 == null) biomePosition = finalFoundPosition2;
|
||||
else if (finalFoundPosition2 == null) biomePosition = finalFoundPosition1;
|
||||
}
|
||||
|
||||
if (biomePosition != null)
|
||||
{
|
||||
System.out.println(biomePosition.field_151329_a + " " + biomePosition.field_151328_c);
|
||||
|
|
Loading…
Reference in a new issue