use of net.minecraft.world.biome.BiomeGenBase in project ct.js by ChatTriggers.
the class Player method getBiome.
/**
* Gets the biome the player is currently in.
*
* @return the biome name
*/
public static String getBiome() {
if (getPlayer() == null)
return "";
Chunk chunk = World.getWorld().getChunkFromBlockCoords(getPlayer().getPosition());
BiomeGenBase biome = chunk.getBiome(getPlayer().getPosition(), World.getWorld().getWorldChunkManager());
return biome.biomeName;
}
use of net.minecraft.world.biome.BiomeGenBase in project ArsMagica2 by Mithion.
the class BossSpawnHelper method onIceEffigyBuilt.
public void onIceEffigyBuilt(World world, int x, int y, int z) {
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
Type[] types = BiomeDictionary.getTypesForBiome(biome);
boolean containsIceType = false;
for (Type type : types) {
if (type == Type.COLD) {
containsIceType = true;
break;
}
}
if (!containsIceType)
return;
for (int i = -1; i <= 1; ++i) for (int j = -1; j <= 1; ++j) if (i == 0 && j == 0)
continue;
else if (!world.canBlockSeeTheSky(x + i, y + 1, z + j))
return;
world.setBlockToAir(x, y, z);
world.setBlockToAir(x, y + 1, z);
world.setBlockToAir(x, y + 2, z);
EntityWinterGuardian guardian = new EntityWinterGuardian(world);
guardian.setPosition(x + 0.5, y + 1, z + 0.5);
world.spawnEntityInWorld(guardian);
}
use of net.minecraft.world.biome.BiomeGenBase in project ArsMagica2 by Mithion.
the class EntityFlicker method getCanSpawnHere.
@Override
public boolean getCanSpawnHere() {
if (AMCore.proxy.getTotalFlickerCount() > 8 * worldObj.playerEntities.size() || worldObj.rand.nextDouble() > 0.2f) {
return false;
}
// get the biome we're trying to spawn in
BiomeGenBase biome = worldObj.getBiomeGenForCoords((int) Math.floor(this.posX), (int) Math.floor(this.posZ));
if (biome != null) {
// get the tags on this biome
Type[] biomeTags = BiomeDictionary.getTypesForBiome(biome);
// pick a random tag to focus on
Type tagType = biomeTags[worldObj.rand.nextInt(biomeTags.length)];
// create a list of valid types based on that tag
ArrayList<Affinity> validAffinities = new ArrayList<Affinity>();
// DO NOT USE THIS LIST FOR AIR/EARTH/LIFE - they are handled by special cases.
switch(tagType) {
case END:
validAffinities.add(Affinity.ENDER);
break;
case FOREST:
case CONIFEROUS:
case JUNGLE:
validAffinities.add(Affinity.NATURE);
break;
case COLD:
case SNOWY:
validAffinities.add(Affinity.ICE);
break;
case MAGICAL:
validAffinities.add(Affinity.ARCANE);
break;
case NETHER:
validAffinities.add(Affinity.FIRE);
break;
case OCEAN:
validAffinities.add(Affinity.LIGHTNING);
case SWAMP:
case WATER:
case RIVER:
case WET:
case BEACH:
validAffinities.add(Affinity.WATER);
break;
case DEAD:
case DENSE:
case DRY:
case HOT:
case LUSH:
case MESA:
case SANDY:
case SAVANNA:
case SPARSE:
case SPOOKY:
case WASTELAND:
case PLAINS:
case HILLS:
case MOUNTAIN:
case MUSHROOM:
default:
break;
}
// special conditions for air/earth flickers based on y coordinate
if (posY < 55) {
validAffinities.add(Affinity.EARTH);
}
if (worldObj.canBlockSeeTheSky((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)))
validAffinities.add(Affinity.AIR);
if (worldObj.isRaining() && worldObj.rand.nextBoolean()) {
validAffinities.clear();
validAffinities.add(Affinity.LIGHTNING);
}
if (validAffinities.size() <= 0)
return false;
// life flickers always have a chance to spawn?
if (worldObj.rand.nextDouble() < 0.1f) {
this.setFlickerType(Affinity.LIFE);
} else {
this.setFlickerType(validAffinities.get(worldObj.rand.nextInt(validAffinities.size())));
}
if (this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) {
AMCore.proxy.incrementFlickerCount();
return true;
}
}
return false;
}
use of net.minecraft.world.biome.BiomeGenBase in project ArsMagica2 by Mithion.
the class AM2WorldDecorator method generateOverworld.
public void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
generateOre(vinteum, vinteumFrequency, world, random, vinteumMin, vinteumMax, chunkX, chunkZ);
generateOre(chimerite, chimeriteFrequency, world, random, chimeriteMin, chimeriteMax, chunkX, chunkZ);
generateOre(blueTopaz, topazFrequency, world, random, topazMin, topazMax, chunkX, chunkZ);
generateOre(sunstone, sunstoneFrequency, world, random, sunstoneMin, sunstoneMax, chunkX, chunkZ);
generateFlowers(blueOrchid, world, random, chunkX, chunkZ);
generateFlowers(desertNova, world, random, chunkX, chunkZ);
generateFlowers(tarmaRoot, world, random, chunkX, chunkZ);
BiomeGenBase biome = world.getBiomeGenForCoords(chunkX << 4, chunkZ << 4);
Type[] biomeTypes = BiomeDictionary.getTypesForBiome(biome);
boolean typeValid = false;
for (Type type : biomeTypes) {
if (type == Type.BEACH || type == Type.SWAMP || type == Type.JUNGLE || type == Type.PLAINS || type == Type.WATER) {
typeValid = true;
} else if (type == Type.FROZEN) {
typeValid = false;
break;
}
}
if (biome != BiomeGenBase.ocean && typeValid && random.nextInt(wakeChance) < 7) {
generateFlowers(wakebloom, world, random, chunkX, chunkZ);
}
if (random.nextInt(witchChance) == 0) {
generateTree(witchwoodTree, world, random, chunkX, chunkZ);
}
if (random.nextInt(poolChance) == 0) {
generatePools(world, random, chunkX, chunkZ);
}
if ((BiomeDictionary.isBiomeOfType(biome, Type.MAGICAL) || BiomeDictionary.isBiomeOfType(biome, Type.FOREST)) && random.nextInt(4) == 0 && TerrainGen.populate(chunkProvider, world, random, chunkX, chunkZ, true, LAKE)) {
int lakeGenX = (chunkX * 16) + random.nextInt(16) + 8;
int lakeGenY = random.nextInt(128);
int lakeGenZ = (chunkZ * 16) + random.nextInt(16) + 8;
(new WorldGenEssenceLakes(BlocksCommonProxy.liquidEssence)).generate(world, random, lakeGenX, lakeGenY, lakeGenZ);
}
}
use of net.minecraft.world.biome.BiomeGenBase in project BetterRain by OreCruncher.
the class PlayerSoundEffectHandler method getBiomeSounds.
private static List<SoundEffect> getBiomeSounds(final String conditions) {
// Need to collect sounds from all the applicable biomes
// along with their weights.
final TObjectIntHashMap<SoundEffect> sounds = new TObjectIntHashMap<SoundEffect>();
final TObjectIntHashMap<BiomeGenBase> weights = BiomeSurveyHandler.getBiomes();
for (final BiomeGenBase biome : weights.keySet()) {
final List<SoundEffect> bs = BiomeRegistry.getSounds(biome, conditions);
for (final SoundEffect sound : bs) sounds.put(sound, sounds.get(sound) + weights.get(biome));
}
// Scale the volumes in the resulting list based on the weights
final List<SoundEffect> result = new ArrayList<SoundEffect>();
final int area = BiomeSurveyHandler.getArea();
for (final SoundEffect sound : sounds.keySet()) {
final float scale = 0.3F + 0.7F * ((float) sounds.get(sound) / (float) area);
result.add(SoundEffect.scaleVolume(sound, scale));
}
return result;
}
Aggregations