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

The following examples show how to use net.minecraft.world.World#getBiome() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockSaltPan.java    From TofuCraftReload with MIT License 6 votes vote down vote up
private float calcAdaptation(World world, BlockPos pos)
{
    Biome biome = world.getBiome(pos);
    boolean isUnderTheSun = world.canBlockSeeSky(pos);
    boolean isRaining = world.isRaining();
    boolean isDaytime = world.getWorldTime() % 24000 < 12000;
    float humidity = biome.getRainfall();
    float temperature = biome.getTemperature(pos);
    float rate;

    if (!isUnderTheSun || isRaining)
    {
        rate = 0.0F;
    }
    else
    {
        rate = isDaytime ? 2.0F : 1.0F;
        rate *= humidity < 0.2D ? 4.0D : humidity < 0.7D ? 2.0D : humidity < 0.9 ? 1.0D : 0.5D;
        rate *= temperature < 0.0D ? 1.0D : temperature < 0.6D ? 1.5D : temperature < 1.0D ? 2.0D : 4.0D;
    }
    return rate;
}
 
Example 2
Source File: OreGenerator.java    From EmergingTechnology with MIT License 6 votes vote down vote up
public void addOreSpawn(Block block, byte blockMeta, Block targetBlock, World world, Random random, int blockXPos,
        int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY, boolean restrictBiome) {
    WorldGenMinable minable = new WorldGenMinable(block.getStateFromMeta(blockMeta),
            (minVeinSize + random.nextInt(maxVeinSize - minVeinSize + 1)), BlockStateMatcher.forBlock(targetBlock));
    for (int i = 0; i < chancesToSpawn; i++) {
        int posX = blockXPos + random.nextInt(16);
        int posY = minY + random.nextInt(maxY - minY);
        int posZ = blockZPos + random.nextInt(16);

        BlockPos plannedPosition = new BlockPos(posX, posY, posZ);

        Biome blockBiome = world.getBiome(plannedPosition);

        for (Biome biome : validBiomes) {
            if (biome == blockBiome || !restrictBiome) {
                minable.generate(world, random, new BlockPos(posX, posY, posZ));
                break;
            }
        }
    }
}
 
Example 3
Source File: WorldGenIronSand.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
	public void generate(Random rand, int chunkX, int chunkZ, World worldIn, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
		  for (int i = 0; i < block_count; i++) {
	            int rX = (chunkX  * 16) + rand.nextInt(16) + 8;
	            int rY = 48 + rand.nextInt(19);
	            int rZ = (chunkZ  * 16) + rand.nextInt(16) + 8;
	            BlockPos pos = new BlockPos(rX, rY, rZ);
	            IBlockState stateAt = worldIn.getBlockState(pos);
	            if(!stateAt.getBlock().equals(Blocks.SAND)) {
	                continue;
	            }

	            boolean canSpawn = false;
	            for (int yy = 0; yy < 2; yy++) {
	                BlockPos check = pos.offset(EnumFacing.UP, yy);
	                IBlockState bs = worldIn.getBlockState(check);
	                Block block = bs.getBlock();
	                if(worldIn.getBiome(pos) instanceof BiomeBeach|| worldIn.getBiome(pos) instanceof BiomeRiver)
	                if((worldIn.isAirBlock(pos.up())||block instanceof BlockLiquid && bs.getMaterial() == Material.WATER)) {
	                    canSpawn = true;
	                    break;
	                }
	            }
	            if(!canSpawn)
	                continue;
	            worldIn.setBlockState(pos, BlockLoader.IRON_SAND.getDefaultState());
//	            SakuraMain.logger.info(String.format("Iron Sand in: %d %d %d", pos.getX(),pos.getY(),pos.getZ()));
	        }
	}
 
Example 4
Source File: WorldGenLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onOreGen(OreGenEvent.Post event) {
	World worldIn = event.getWorld();
       int genY = 10 + event.getRand().nextInt(24);
	if (SakuraConfig.every_where_sakura_diamond||(worldIn.getBiome(new BlockPos(event.getPos().getX(), 0, event.getPos().getZ())) == SakuraBiomes.BAMBOOFOREST ||
		worldIn.getBiome(new BlockPos(event.getPos().getX(), 0, event.getPos().getZ())) == SakuraBiomes.MAPLEFOREST)) {
		BlockPos pos=new BlockPos(event.getPos().getX(),genY, event.getPos().getZ());
               for (int i = 0; i < 2; i++) {
                   new WorldGenMinable(BlockLoader.SAKURA_DIAMOND_ORE.getDefaultState(),3 + event.getRand().nextInt(5)).generate(worldIn, event.getRand(), pos);
               }
       }
}
 
Example 5
Source File: CoverSolarPanel.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean canSeeSunClearly(World world, BlockPos blockPos) {
    if (!world.canSeeSky(blockPos)) {
        return false;
    }
    if (world.isRaining()) {
        Biome biome = world.getBiome(blockPos);
        if (biome.canRain() || biome.getEnableSnow()) {
            return false;
        }
    }
    return world.isDaytime();
}
 
Example 6
Source File: WorldGenRubberTree.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (world.getWorldType() == WorldType.FLAT ||
        !world.provider.isSurfaceWorld()) {
        return; //do not generate in flat worlds, or in non-surface worlds
    }
    BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8);
    Biome biome = world.getBiome(randomPos);

    if (BiomeDictionary.hasType(biome, Type.COLD) ||
        BiomeDictionary.hasType(biome, Type.HOT) ||
        BiomeDictionary.hasType(biome, Type.DRY) ||
        BiomeDictionary.hasType(biome, Type.DEAD) ||
        BiomeDictionary.hasType(biome, Type.SPOOKY))
        return; //do not generate in inappropriate biomes

    int rubberTreeChance = 6;
    if (BiomeDictionary.hasType(biome, Type.SWAMP) ||
        BiomeDictionary.hasType(biome, Type.WET))
        rubberTreeChance /= 2; //double chance of spawning in swamp or wet biomes

    if (random.nextInt(rubberTreeChance) == 0) {
        randomPos = world.getTopSolidOrLiquidBlock(randomPos).down();
        IBlockState solidBlockState = world.getBlockState(randomPos);
        BlockGregSapling sapling = MetaBlocks.SAPLING;
        if (solidBlockState.getBlock().canSustainPlant(solidBlockState, world, randomPos, EnumFacing.UP, sapling)) {
            BlockPos abovePos = randomPos.up();
            IBlockState saplingState = sapling.getDefaultState()
                .withProperty(BlockGregSapling.VARIANT, LogVariant.RUBBER_WOOD);
            world.setBlockState(abovePos, saplingState);
            sapling.generateTree(world, abovePos, saplingState, random);
        }
    }
}
 
Example 7
Source File: GTWorldGen.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
		IChunkProvider chunkProvider) {
	Biome biomegenbase = world.getBiome(new BlockPos(chunkX * 16 + 16, 128, chunkZ * 16 + 16));
	// Any Biome
	GTOreGenerator.generateBasicVein(GTBlocks.oreIridium, GTConfig.generation.iridiumGenerate, GTConfig.generation.iridiumSize, GTConfig.generation.iridiumWeight, 0, 128, Blocks.STONE, world, random, chunkX, chunkZ);
	// Jungle Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.JUNGLE)) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreSheldonite, GTConfig.generation.sheldoniteGenerate, GTConfig.generation.sheldoniteSize, GTConfig.generation.sheldoniteWeight, 10, 30, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	// Hot Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.HOT)) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreRuby, GTConfig.generation.rubyGenerate, GTConfig.generation.rubySize, GTConfig.generation.rubyWeight, 0, 48, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	// Ocean Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.OCEAN) || BiomeDictionary.hasType(biomegenbase, Type.BEACH)) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreSapphire, GTConfig.generation.sapphireGenerate, GTConfig.generation.sapphireSize, GTConfig.generation.sapphireWeight, 0, 48, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	// Forest or Plains Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.FOREST)
			|| (BiomeDictionary.hasType(biomegenbase, Type.PLAINS))) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreBauxite, GTConfig.generation.bauxiteGenerate, GTConfig.generation.bauxiteSize, GTConfig.generation.bauxiteWeight, 50, 120, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	if (world.provider.getDimensionType().equals(DimensionType.OVERWORLD)) {
		for (Block block : GTBedrockOreHandler.getBedrockOreMap().keySet()) {
			if (GTBedrockOreHandler.shouldGTCHandleGeneration(block)) {
				GTOreGenerator.generateBedrockVein(block, world, random, chunkX, chunkZ);
			}
		}
	}
}
 
Example 8
Source File: BlockElectricMushroom.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void updateTick(World world, BlockPos pos, IBlockState state,
		Random rand) {
	if(!world.isRemote && Configuration.electricPlantsSpawnLightning && world.isRaining() && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) {
		int lightningX = pos.getX() + rand.nextInt(24) - 12;
		int lightningZ = pos.getZ() + rand.nextInt(24) - 12;
		BlockPos lightning = new BlockPos(lightningX, 0, lightningZ );
		lightning = world.getTopSolidOrLiquidBlock(lightning);
		
		world.addWeatherEffect(new EntityLightningBolt(world, lightning.getX(), lightning.getY(), lightning.getZ(), true));
	}
}
 
Example 9
Source File: BlockElectricMushroom.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World world,
		BlockPos pos, Random rand) {
	
	super.randomDisplayTick(stateIn, world, pos, rand);
	if(world.getTotalWorldTime() % 100 == 0 && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) {
		FxSystemElectricArc.spawnArc(world, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, .3, 7);
		world.playSound(Minecraft.getMinecraft().player, pos, AudioRegistry.electricShockSmall, SoundCategory.BLOCKS, .7f,  0.975f + world.rand.nextFloat()*0.05f);
	}
}
 
Example 10
Source File: BiomeHandler.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public static void changeBiome(World world, int biomeId, BlockPos pos) {
	Chunk chunk = world.getChunkFromBlockCoords(pos);

	Biome biome = world.getBiome(pos);
	Biome biomeTo = Biome.getBiome(biomeId);
	
	if(biome == biomeTo)
		return;
	
	int y = 60;
	if(biome.topBlock != biomeTo.topBlock) {
		BlockPos yy = world.getHeight(pos);
		
		while(!world.getBlockState(yy.down()).isOpaqueCube() && yy.getY() > 0)
			yy = yy.down();
		
		if(world.getBlockState(yy.down()) == biome.topBlock)
			world.setBlockState(yy.down(), biomeTo.topBlock);
	}

	byte[] biomeArr = chunk.getBiomeArray();
	try {
		biomeArr[(pos.getX() & 15) + (pos.getZ() & 15)*16] = (byte)biomeId;
	} catch (IndexOutOfBoundsException e) {
		e.printStackTrace();
	}

	PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new HashedBlockPosition(pos)), world.provider.getDimension(), pos, 256);
}
 
Example 11
Source File: WorldGenHotSpring.java    From Sakura_mod with MIT License 4 votes vote down vote up
public boolean generate(World worldIn, Random rand, BlockPos position) {
      for (position = position.add(-8, 0, -8); position.getY() > 5 && worldIn.isAirBlock(position); position = position.down()) {
          ;
      }
position = position.down(4);
boolean[] aboolean = new boolean[2048];
int i = rand.nextInt(4) + 4;

for (int j = 0; j < i; ++j) {
    double d0 = rand.nextDouble() * 6.0D + 3.0D;
    double d1 = rand.nextDouble() * 4.0D + 2.0D;
    double d2 = rand.nextDouble() * 6.0D + 3.0D;
    double d3 = rand.nextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
    double d4 = rand.nextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
    double d5 = rand.nextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;

    for (int l = 1; l < 15; ++l) {
        for (int i1 = 1; i1 < 15; ++i1) {
            for (int j1 = 1; j1 < 7; ++j1) {
                double d6 = (l - d3) / (d0 / 2.0D);
                double d7 = (j1 - d4) / (d1 / 2.0D);
                double d8 = (i1 - d5) / (d2 / 2.0D);
                double d9 = d6 * d6 + d7 * d7 + d8 * d8;

                if (d9 < 1.0D)
                    aboolean[(l * 16 + i1) * 8 + j1] = true;
            }
        }
    }
}

for (int k1 = 0; k1 < 16; ++k1){
    for (int l2 = 0; l2 < 16; ++l2) {
        for (int k = 0; k < 8; ++k) {
            boolean flag = !aboolean[(k1 * 16 + l2) * 8 + k] && (k1 < 15 && aboolean[((k1 + 1) * 16 + l2) * 8 + k] || k1 > 0 && aboolean[((k1 - 1) * 16 + l2) * 8 + k] || l2 < 15 && aboolean[(k1 * 16 + l2 + 1) * 8 + k] || l2 > 0 && aboolean[(k1 * 16 + (l2 - 1)) * 8 + k] || k < 7 && aboolean[(k1 * 16 + l2) * 8 + k + 1] || k > 0 && aboolean[(k1 * 16 + l2) * 8 + (k - 1)]);

            if (flag) {
                Material material = worldIn.getBlockState(position.add(k1, k, l2)).getMaterial();

                if (k >= 4 && material.isLiquid())  {
                    return false;
                }

                if (k < 4 && !material.isSolid() && worldIn.getBlockState(position.add(k1, k, l2)).getBlock() != BlockLoader.HOT_SPRING_WATER)  {
                    return false;
                }
            }
        }
    }
}

for (int l1 = 0; l1 < 16; ++l1) {
    for (int i3 = 0; i3 < 16; ++i3) {
        for (int i4 = 0; i4 < 8; ++i4) {
            if (aboolean[(l1 * 16 + i3) * 8 + i4]) {
                worldIn.setBlockState(position.add(l1, i4, i3), i4 >= 4 ? Blocks.AIR.getDefaultState() : BlockLoader.HOT_SPRING_WATER.getDefaultState(), 2);
            }
        }
    }
}

for (int i2 = 0; i2 < 16; ++i2){
    for (int j3 = 0; j3 < 16; ++j3) {
        for (int j4 = 4; j4 < 8; ++j4) {
            if (aboolean[(i2 * 16 + j3) * 8 + j4]) {
                BlockPos blockpos = position.add(i2, j4 - 1, j3);

                if (worldIn.getBlockState(blockpos).getBlock() == Blocks.DIRT && worldIn.getLightFor(EnumSkyBlock.SKY, position.add(i2, j4, j3)) > 0) {
                    Biome biome = worldIn.getBiome(blockpos);

                    if (biome.topBlock.getBlock() == Blocks.MYCELIUM) {
                        worldIn.setBlockState(blockpos, Blocks.MYCELIUM.getDefaultState(), 2);
                    }
                    else {
                        worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState(), 2);
                    }
                }
            }
        }
    }
}
   for (int j2 = 0; j2 < 16; ++j2) {
       for (int k3 = 0; k3 < 16; ++k3) {
           for (int k4 = 0; k4 < 8; ++k4) {
               boolean flag1 = !aboolean[(j2 * 16 + k3) * 8 + k4] && (j2 < 15 && aboolean[((j2 + 1) * 16 + k3) * 8 + k4] || j2 > 0 && aboolean[((j2 - 1) * 16 + k3) * 8 + k4] || k3 < 15 && aboolean[(j2 * 16 + k3 + 1) * 8 + k4] || k3 > 0 && aboolean[(j2 * 16 + (k3 - 1)) * 8 + k4] || k4 < 7 && aboolean[(j2 * 16 + k3) * 8 + k4 + 1] || k4 > 0 && aboolean[(j2 * 16 + k3) * 8 + (k4 - 1)]);
               if (flag1 && (k4 < 4 || rand.nextInt(2) != 0) && worldIn.getBlockState(position.add(j2, k4, k3)).getMaterial().isSolid()){
                   worldIn.setBlockState(position.add(j2, k4, k3), Blocks.STONE.getDefaultState(), 2);
               }
           }
       }
   }

return true;
  }
 
Example 12
Source File: BlockFuton.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	if (worldIn.isRemote) {
		return true;
	}
	if (state.getValue(PART) != EnumPartType.HEAD) {
		pos = pos.offset(state.getValue(FACING));
		state = worldIn.getBlockState(pos);

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

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

			if (entityplayer != null) {
				playerIn.sendMessage(new TextComponentTranslation("tile.bed.occupied"));
				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;
		}
		if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_POSSIBLE_NOW) {
			playerIn.sendMessage(new TextComponentTranslation("tile.bed.noSleep"));
		} else if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_SAFE) {
			playerIn.sendMessage(new TextComponentTranslation("tile.bed.notSafe"));
		}

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

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

	worldIn.newExplosion(null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 5.0F, true, true);
	return true;
}
 
Example 13
Source File: WorldGenManaLake.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void generate(World world, Random rand, BlockPos position) {
	int chance = rand.nextInt(ConfigValues.manaPoolRarity);
	if (chance == 0) {
		if (position.getY() > 4) {
			position = position.down(4);
			boolean[] aboolean = new boolean[2048];
			int i = rand.nextInt(4) + 4;

			for (int j = 0; j < i; ++j) {
				double d0 = rand.nextDouble() * 6.0D + 3.0D;
				double d1 = rand.nextDouble() * 4.0D + 2.0D;
				double d2 = rand.nextDouble() * 6.0D + 3.0D;
				double d3 = rand.nextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
				double d4 = rand.nextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
				double d5 = rand.nextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;

				for (int l = 1; l < 15; ++l) {
					for (int i1 = 1; i1 < 15; ++i1) {
						for (int j1 = 1; j1 < 7; ++j1) {
							double d6 = ((double) l - d3) / (d0 / 2.0D);
							double d7 = ((double) j1 - d4) / (d1 / 2.0D);
							double d8 = ((double) i1 - d5) / (d2 / 2.0D);
							double d9 = d6 * d6 + d7 * d7 + d8 * d8;

							if (d9 < 1.0D) {
								aboolean[(l * 16 + i1) * 8 + j1] = true;
							}
						}
					}
				}
			}

			for (int k1 = 0; k1 < 16; ++k1) {
				for (int l2 = 0; l2 < 16; ++l2) {
					for (int k = 0; k < 8; ++k) {
						boolean flag = !aboolean[(k1 * 16 + l2) * 8 + k] && (k1 < 15 && aboolean[((k1 + 1) * 16 + l2) * 8 + k] || k1 > 0 && aboolean[((k1 - 1) * 16 + l2) * 8 + k] || l2 < 15 && aboolean[(k1 * 16 + l2 + 1) * 8 + k] || l2 > 0 && aboolean[(k1 * 16 + (l2 - 1)) * 8 + k] || k < 7 && aboolean[(k1 * 16 + l2) * 8 + k + 1] || k > 0 && aboolean[(k1 * 16 + l2) * 8 + (k - 1)]);

						if (flag) {
							Material material = world.getBlockState(position.add(k1, k, l2)).getMaterial();

							if (k >= 4 && material.isLiquid()) {
								return;
							}

							if (k < 4 && !material.isSolid() && world.getBlockState(position.add(k1, k, l2)).getBlock() != this.block) {
								return;
							}
						}
					}
				}
			}

			for (int l1 = 0; l1 < 16; ++l1) {
				for (int i3 = 0; i3 < 16; ++i3) {
					for (int i4 = 0; i4 < 8; ++i4) {
						if (aboolean[(l1 * 16 + i3) * 8 + i4]) {
							world.setBlockState(position.add(l1, i4, i3), i4 >= 4 ? Blocks.AIR.getDefaultState() : this.block.getDefaultState(), 2);
						}
					}
				}
			}

			for (int i2 = 0; i2 < 16; ++i2) {
				for (int j3 = 0; j3 < 16; ++j3) {
					for (int j4 = 4; j4 < 8; ++j4) {
						if (aboolean[(i2 * 16 + j3) * 8 + j4]) {
							BlockPos blockpos = position.add(i2, j4 - 1, j3);

							if (world.getBlockState(blockpos).getBlock() == Blocks.DIRT && world.getLightFor(EnumSkyBlock.SKY, position.add(i2, j4, j3)) > 0) {
								Biome biome = world.getBiome(blockpos);

								if (biome.topBlock.getBlock() == Blocks.MYCELIUM) {
									world.setBlockState(blockpos, Blocks.MYCELIUM.getDefaultState(), 2);
								} else {
									world.setBlockState(blockpos, Blocks.GRASS.getDefaultState(), 2);

									if (rand.nextInt(3) == 0) {
										WorldGeneratorWisdomTree tree = new WorldGeneratorWisdomTree(false);
										tree.generate(world, rand, blockpos);
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
 
Example 14
Source File: WorldOverlayRenderer.java    From NotEnoughItems with MIT License 4 votes vote down vote up
private static void renderMobSpawnOverlay(Entity entity) {
    if (mobOverlay == 0) {
        return;
    }

    boolean cms = Loader.instance().isModLoaded("customspawner");

    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    glLineWidth(1.5F);
    glBegin(GL_LINES);

    GlStateManager.color(1, 0, 0);

    World world = entity.world;
    int x1 = (int) entity.posX;
    int z1 = (int) entity.posZ;
    int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16);

    for (int x = x1 - 16; x <= x1 + 16; x++) {
        for (int z = z1 - 16; z <= z1 + 16; z++) {
            BlockPos pos = new BlockPos(x, y1, z);
            Chunk chunk = world.getChunkFromBlockCoords(pos);
            Biome biome = world.getBiome(pos);
            if ((!cms && biome.getSpawnableList(EnumCreatureType.MONSTER).isEmpty()) || biome.getSpawningChance() <= 0) {
                continue;
            }

            for (int y = y1 - 16; y < y1 + 16; y++) {
                int spawnMode = getSpawnMode(chunk, x, y, z);
                if (spawnMode == 0) {
                    continue;
                }

                if (spawnMode == 1) {
                    GlStateManager.color(1, 1, 0);
                } else {
                    GlStateManager.color(1, 0, 0);
                }

                glVertex3d(x, y + 0.004, z);
                glVertex3d(x + 1, y + 0.004, z + 1);
                glVertex3d(x + 1, y + 0.004, z);
                glVertex3d(x, y + 0.004, z + 1);
            }
        }
    }

    glEnd();
    GlStateManager.enableLighting();
    GlStateManager.enableTexture2D();
}
 
Example 15
Source File: SpawnableBlocksHelper.java    From BoundingBoxOutlineReloaded with MIT License 4 votes vote down vote up
static boolean isBiomeHostileSpawnProof(World world, BlockPos pos) {
    Biome biome = world.getBiome(pos);
    return biome.getSpawningChance() == 0 ||
            biome.getSpawns(EntityClassification.MONSTER).isEmpty();
}
 
Example 16
Source File: BiomeHandler.java    From AdvancedRocketry with MIT License 3 votes vote down vote up
public static void changeBiome(World world, int biomeId, Chunk chunk, BlockPos pos) {

		Biome biome = world.getBiome(pos);
		Biome biomeTo = Biome.getBiome(biomeId);
		
		int x = pos.getX();
		int z = pos.getZ();
		if(biome == biomeTo)
			return;
		
		int y = 60;
		if(biome.topBlock != biomeTo.topBlock) {
			int yy = chunk.getHeightValue(x & 15, z & 15);
			
			while(!world.getBlockState(new BlockPos(x, yy - 1, z)).isOpaqueCube() && yy > 0)
				yy--;
			
			if(yy == 0)
				return;
			
			
			
			if(chunk.getBlockState(x & 15, yy - 1, z & 15) == biome.topBlock)
				chunk.setBlockState(new BlockPos(x & 15, yy - 1, z & 15), biomeTo.topBlock);

			y = (short)yy;
		}

		byte[] biomeArr = chunk.getBiomeArray();
		biomeArr[(x & 15) + (z & 15)*16] = (byte)biomeId;

		//PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new BlockPosition(x, y, z)), world.provider.dimensionId, x, y, z, 256);
	}