Java Code Examples for net.minecraft.world.World.getBiome()

The following are Jave code examples for showing how to use getBiome() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: genera   File: BlockNightshadeCrop.java   Source Code and License Vote up 6 votes
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    super.updateTick(worldIn, pos, state, rand);
    if (!worldIn.isRemote) {
        if (state.getValue(AGE) == 2) {
            EntityFaerie faerie = new EntityFaerie(worldIn, 4.0D, 0, 0.1F, 1);
            faerie.setPosition((double) pos.getX(), (double) pos.up().getY(), (double) pos.getZ());
            worldIn.spawnEntity(faerie);
        }
        if (!(worldIn.getBiome(pos) == Biomes.FOREST ||
                worldIn.getBiome(pos) == Biomes.FOREST_HILLS ||
                worldIn.getBiome(pos) == Biomes.TAIGA ||
                worldIn.getBiome(pos) == Biomes.TAIGA_HILLS) && state.getValue(AGE) >= 1) {
            worldIn.setBlockState(pos, state.withProperty(AGE, 0));
        }
    }

}
 
Example 2
Project: SimplyTea   File: SimplyTea.java   Source Code and License Vote up 6 votes
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
		IChunkProvider chunkProvider) {
	if (random.nextInt(20) == 0){
		int x = chunkX * 16 + 2 + random.nextInt(12);
		int z = chunkZ * 16 + 2 + random.nextInt(12);
		BlockPos p = new BlockPos(x,0,z);
		p = world.getHeight(p);
		Biome b = world.getBiome(p);
		if (BiomeDictionary.hasType(b, BiomeDictionary.Type.FOREST) || b == Biomes.FOREST || b == Biomes.FOREST_HILLS){
			if (world.getBlockState(p.down()).getBlock() instanceof BlockGrass && world.isAirBlock(p)){
				BlockTeaSapling.generateTree(world, p, Blocks.AIR.getDefaultState(), random);
			}
		}
	}
}
 
Example 3
Project: GardenStuff   File: WorldGenCandelilla.java   Source Code and License Vote up 6 votes
@Override
public void generate (Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    int x = chunkX * 16 + 8;
    int z = chunkZ * 16 + 8;

    Biome biome = world.getBiome(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.COLD ))
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.COLD)
        || BiomeDictionary.hasType(biome, BiomeDictionary.Type.NETHER)
        || BiomeDictionary.hasType(biome, BiomeDictionary.Type.WET)
        || BiomeDictionary.hasType(biome, BiomeDictionary.Type.WASTELAND)
        || BiomeDictionary.hasType(biome, BiomeDictionary.Type.SNOWY))
        return;

    if (!BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY))
        return;

    if (random.nextInt(15) > 0)
        return;

    generate(world, random, new BlockPos(x, world.getSeaLevel(), z));
}
 
Example 4
Project: modName   File: GrassColours.java   Source Code and License Vote up 6 votes
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.equals(this.abstractGetColorAtPos)) {
        Biome biome = (Biome)args[0];
        BlockPos pos = (BlockPos)args[1];

        World world = Minecraft.getMinecraft().world;

        if (world != null && GeneralUtil.isWorldATG(world)) {
            // probe the current world biomes to eliminate most cases of it being the wrong one (I hope)
            Biome probe = world.getBiome(pos);
            if (probe == biome) {
                return getGrassColour(world, biome, pos);
            }
        }

        if (wrappedResolver != null) {
            return wrappedGetColorAtPos.invoke(this.wrappedResolver, biome, pos);
        }

        return 0xFF00FF;
    }
    return method.invoke(this.wrappedResolver, args);
}
 
Example 5
Project: rezolve   File: CityGenerator.java   Source Code and License Vote up 5 votes
public Chunk[] getNeighborCities(World world, int chunkX, int chunkZ) {
	ArrayList<Chunk> neighborCities = new ArrayList<Chunk>();
	Chunk[] neighbors = new Chunk[] {
		world.getChunkProvider().getLoadedChunk(chunkX + 1, chunkZ),
		world.getChunkProvider().getLoadedChunk(chunkX + 2, chunkZ),
		world.getChunkProvider().getLoadedChunk(chunkX - 1, chunkZ),
		world.getChunkProvider().getLoadedChunk(chunkX - 2, chunkZ),
		world.getChunkProvider().getLoadedChunk(chunkX, chunkZ + 1),
		world.getChunkProvider().getLoadedChunk(chunkX, chunkZ + 2),
		world.getChunkProvider().getLoadedChunk(chunkX, chunkZ - 1),
		world.getChunkProvider().getLoadedChunk(chunkX, chunkZ - 2),
		world.getChunkProvider().getLoadedChunk(chunkX + 1, chunkZ + 1),
		world.getChunkProvider().getLoadedChunk(chunkX + 2, chunkZ + 2),
		world.getChunkProvider().getLoadedChunk(chunkX - 1, chunkZ - 1),
		world.getChunkProvider().getLoadedChunk(chunkX - 2, chunkZ - 2),
		world.getChunkProvider().getLoadedChunk(chunkX + 1, chunkZ - 1),
		world.getChunkProvider().getLoadedChunk(chunkX + 2, chunkZ - 2),
		world.getChunkProvider().getLoadedChunk(chunkX - 1, chunkZ + 1),
		world.getChunkProvider().getLoadedChunk(chunkX - 2, chunkZ + 2),
	};
	
	for (Chunk neighbor : neighbors) {
		if (neighbor == null)
			continue;
		
		Biome biome = world.getBiome(new BlockPos(neighbor.xPosition * 16 + 8, 128, neighbor.zPosition * 16 + 8));
		if (biome == RezolveMod.CITY_BIOME)
			neighborCities.add(neighbor);
	}
	
	return neighborCities.toArray(new Chunk[neighborCities.size()]);
}
 
Example 6
Project: harshencastle   File: HarshenUtils.java   Source Code and License Vote up 5 votes
public static boolean isLevelAcceptable(World world, BlockPos pos, EntityPlayer player)
{
	return !(world.getBiome(pos) instanceof BasePontusResourceBiome) || 
			((BasePontusResourceBiome) world.getBiome(pos)).getLevel() <= 0 ||
			((BasePontusResourceBiome)world.getBiome(pos)).getLevel() <= HandlerPontusAllowed.getAllowed(player);
	
}
 
Example 7
Project: modName   File: ChunkProviderBasic.java   Source Code and License Vote up 5 votes
public boolean canSnowAt(World world, BlockPos pos, boolean checkLight) {
    Biome biome = world.getBiome(pos);
    float f = this.getFloatTemperature(biome, pos);

    if (f > 0.15F)
    {
        return false;
    }
    else if (!checkLight)
    {
        return true;
    }
    else
    {
        if (pos.getY() >= 0 && pos.getY() < 256 && world.getLightFor(EnumSkyBlock.BLOCK, pos) < 10)
        {
            IBlockState iblockstate = world.getBlockState(pos);

            if (iblockstate.getBlock().isAir(iblockstate, world, pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos))
            {
                return true;
            }
        }

        return false;
    }
}
 
Example 8
Project: Backmemed   File: RandomMobs.java   Source Code and License Vote up 5 votes
public static void entityLoaded(Entity p_entityLoaded_0_, World p_entityLoaded_1_)
{
    if (p_entityLoaded_0_ instanceof EntityLiving)
    {
        if (p_entityLoaded_1_ != null)
        {
            EntityLiving entityliving = (EntityLiving)p_entityLoaded_0_;
            entityliving.spawnPosition = entityliving.getPosition();
            entityliving.spawnBiome = p_entityLoaded_1_.getBiome(entityliving.spawnPosition);
            WorldServer worldserver = Config.getWorldServer();

            if (worldserver != null)
            {
                Entity entity = worldserver.getEntityByID(p_entityLoaded_0_.getEntityId());

                if (entity instanceof EntityLiving)
                {
                    EntityLiving entityliving1 = (EntityLiving)entity;
                    UUID uuid = entityliving1.getUniqueID();
                    long i = uuid.getLeastSignificantBits();
                    int j = (int)(i & 2147483647L);
                    entityliving.randomMobsId = j;
                }
            }
        }
    }
}
 
Example 9
Project: ExPetrum   File: Helpers.java   Source Code and License Vote up 5 votes
public static float getTemperatureAt(World w, BlockPos pos)
{
	float tempBase = IExPWorld.of(w).getOverhaulTemperature();
	Biome b = w.getBiome(pos);
	if (b instanceof IBiome)
	{
		tempBase *= ((IBiome)b).getTemperatureMultiplier();
		tempBase += ((IBiome)b).getTemperatureBaseModifier();
	}
	return tempBase;
}
 
Example 10
Project: Got-Wood   File: WorldGenerator.java   Source Code and License Vote up 4 votes
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	if (world.provider.getDimension() == 0) {

		WorldGenAbstractTree apple = new WorldGenApple(false);
		WorldGenAbstractTree maple = new WorldGenMaple(false);
		WorldGenAbstractTree ebony = new WorldGenEbony(false);
		WorldGenAbstractTree fir = new WorldGenFir(false);
		WorldGenAbstractTree pine = new WorldGenPine(false);
		WorldGenAbstractTree willow = new WorldGenWillow();
		WorldGenAbstractTree yew = new WorldGenYew();

		// get the biome
		Biome biome = world.getBiome(new BlockPos(chunkX * 16, 64, chunkZ * 16));

		if (biome instanceof BiomeDesert) {
			makeTree(ebony, chunkX, chunkZ, random, world, 0, 1);
		}

		if (biome instanceof BiomeForest || biome instanceof BiomeForestMutated) {
			if (random.nextInt(4) == 0) {
				makeTree(maple, chunkX, chunkZ, random, world, 0, 3);
			}

			if (random.nextInt(12) == 0) {
				makeTree(apple, chunkX, chunkZ, random, world, 1, 2);
			}

			makeTree(pine, chunkX, chunkZ, random, world, 0, 3);
		}

		if (biome instanceof BiomeHills) {
			makeTree(maple, chunkX, chunkZ, random, world, 0, 3);
			makeTree(fir, chunkX, chunkZ, random, world, 0, 3);
		}

		if (biome instanceof BiomeMesa && random.nextBoolean()) {
			makeTree(ebony, chunkX, chunkZ, random, world, 1, 3);
		}

		if (biome instanceof BiomePlains) {
			makeTree(apple, chunkX, chunkZ, random, world, 0, 1);
		}

		if (biome instanceof BiomeRiver && random.nextInt(3) == 0) {
			makeTree(yew, chunkX, chunkZ, random, world, 0, 3);
		}

		if (biome instanceof BiomeSavanna) {
			makeTree(ebony, chunkX, chunkZ, random, world, 0, 3);
		}

		if (biome instanceof BiomeSwamp) {
			if (random.nextInt(2) == 0) {
				makeTree(willow, chunkX, chunkZ, random, world, 0, 3);
			}
			if (random.nextInt(1) == 0) {
				makeTree(yew, chunkX, chunkZ, random, world, 0, 3);
			}
		}

		if (biome instanceof BiomeTaiga) {
			makeTree(pine, chunkX, chunkZ, random, world, 0, 3);
			makeTree(fir, chunkX, chunkZ, random, world, 1, 4);
		}
		if (biome instanceof BiomeJungle) {
			makeTree(rubber, chunkX, chunkZ, random, world, 0, 3);
		}
	}
}
 
Example 11
Project: Backmemed   File: MapGenScatteredFeature.java   Source Code and License Vote up 4 votes
public Start(World worldIn, Random random, int chunkX, int chunkZ)
{
    this(worldIn, random, chunkX, chunkZ, worldIn.getBiome(new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8)));
}
 
Example 12
Project: Backmemed   File: BlockBed.java   Source Code and License Vote up 4 votes
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
        {
            pos = pos.offset((EnumFacing)state.getValue(FACING));
            state = worldIn.getBlockState(pos);

            if (state.getBlock() != this)
            {
                return true;
            }
        }

        if (worldIn.provider.canRespawnHere() && worldIn.getBiome(pos) != Biomes.HELL)
        {
            if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
            {
                EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);

                if (entityplayer != null)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.occupied", new Object[0]), true);
                    return true;
                }

                state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
                worldIn.setBlockState(pos, state, 4);
            }

            EntityPlayer.SleepResult entityplayer$sleepresult = playerIn.trySleep(pos);

            if (entityplayer$sleepresult == EntityPlayer.SleepResult.OK)
            {
                state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
                worldIn.setBlockState(pos, state, 4);
                return true;
            }
            else
            {
                if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_POSSIBLE_NOW)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.noSleep", new Object[0]), true);
                }
                else if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_SAFE)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.notSafe", new Object[0]), true);
                }
                else if (entityplayer$sleepresult == EntityPlayer.SleepResult.TOO_FAR_AWAY)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.tooFarAway", new Object[0]), true);
                }

                return true;
            }
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());

            if (worldIn.getBlockState(blockpos).getBlock() == this)
            {
                worldIn.setBlockToAir(blockpos);
            }

            worldIn.newExplosion((Entity)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 5.0F, true, true);
            return true;
        }
    }
}
 
Example 13
Project: CustomWorldGen   File: ForgeHooksClient.java   Source Code and License Vote up 4 votes
public static int getSkyBlendColour(World world, BlockPos center)
{
    if (center.getX() == skyX && center.getZ() == skyZ && skyInit)
    {
        return skyRGBMultiplier;
    }
    skyInit = true;

    GameSettings settings = Minecraft.getMinecraft().gameSettings;
    int[] ranges = ForgeModContainer.blendRanges;
    int distance = 0;
    if (settings.fancyGraphics && settings.renderDistanceChunks >= 0 && settings.renderDistanceChunks < ranges.length)
    {
        distance = ranges[settings.renderDistanceChunks];
    }

    int r = 0;
    int g = 0;
    int b = 0;

    int divider = 0;
    for (int x = -distance; x <= distance; ++x)
    {
        for (int z = -distance; z <= distance; ++z)
        {
            BlockPos pos = center.add(x, 0, z);
            Biome biome = world.getBiome(pos);
            int colour = biome.getSkyColorByTemp(biome.getFloatTemperature(pos));
            r += (colour & 0xFF0000) >> 16;
            g += (colour & 0x00FF00) >> 8;
            b += colour & 0x0000FF;
            divider++;
        }
    }

    int multiplier = (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255;

    skyX = center.getX();
    skyZ = center.getZ();
    skyRGBMultiplier = multiplier;
    return skyRGBMultiplier;
}
 
Example 14
Project: CustomWorldGen   File: MapGenScatteredFeature.java   Source Code and License Vote up 4 votes
public Start(World worldIn, Random random, int chunkX, int chunkZ)
{
    this(worldIn, random, chunkX, chunkZ, worldIn.getBiome(new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8)));
}
 
Example 15
Project: CustomWorldGen   File: BlockBed.java   Source Code and License Vote up 4 votes
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
        {
            pos = pos.offset((EnumFacing)state.getValue(FACING));
            state = worldIn.getBlockState(pos);

            if (state.getBlock() != this)
            {
                return true;
            }
        }

        if (worldIn.provider.canRespawnHere() && worldIn.getBiome(pos) != Biomes.HELL)
        {
            if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
            {
                EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);

                if (entityplayer != null)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.occupied", new Object[0]));
                    return true;
                }

                state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
                worldIn.setBlockState(pos, state, 4);
            }

            EntityPlayer.SleepResult entityplayer$sleepresult = playerIn.trySleep(pos);

            if (entityplayer$sleepresult == EntityPlayer.SleepResult.OK)
            {
                state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
                worldIn.setBlockState(pos, state, 4);
                return true;
            }
            else
            {
                if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_POSSIBLE_NOW)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.noSleep", new Object[0]));
                }
                else if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_SAFE)
                {
                    playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.notSafe", new Object[0]));
                }

                return true;
            }
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());

            if (worldIn.getBlockState(blockpos).getBlock() == this)
            {
                worldIn.setBlockToAir(blockpos);
            }

            worldIn.newExplosion((Entity)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 5.0F, true, true);
            return true;
        }
    }
}