Java Code Examples for net.minecraftforge.common.BiomeDictionary#hasType()

The following examples show how to use net.minecraftforge.common.BiomeDictionary#hasType() . 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: SoyGenerator.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;

    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
            || BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
        return;
    }

    if (random.nextFloat() < 70 / 4000.0F) {
        int posX = x + world.rand.nextInt(16) + 8;
        int posZ = z + world.rand.nextInt(16) + 8;
        BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
        if ((newPos != null) && (BlockLoader.SOYBEAN.canPlaceBlockAt(world, newPos))) {
            world.setBlockState(newPos, BlockLoader.SOYBEAN.getDefaultState().withProperty(BlockSoybean.AGE, random.nextInt(4)), 2);
        }
    }
}
 
Example 2
Source File: WorldGenBambooShot.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;
    
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
    		||BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
      return;
    }
    
       if (random.nextFloat() < SakuraConfig.bambooshot_weight / 4000.0F)
    {
      int posX = x+ world.rand.nextInt(16) + 8;
      int posZ = z+ world.rand.nextInt(16) + 8;
      BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
      if ((newPos != null) && (BlockLoader.BAMBOOSHOOT.canBlockStay(world, newPos))) {
        world.setBlockState(newPos, BlockLoader.BAMBOOSHOOT.getDefaultState(), 2);
      }
    }
}
 
Example 3
Source File: WorldGenPepper.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;
    
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
    		||BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
      return;
    }

	if (random.nextFloat() < SakuraConfig.pepper_weight / 4000.0F) {
      int posX = x  + world.rand.nextInt(16) + 8;
      int posZ = z  + world.rand.nextInt(16) + 8;
      BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
      if ((newPos != null) && (BlockLoader.PEPPER_SPLINT.canPlaceBlockAt(world, newPos))) {
        world.setBlockState(newPos, BlockLoader.PEPPERCROP.getDefaultState(), 2);
      }
    }
}
 
Example 4
Source File: WorldGenVanilla.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;
    
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
    		||BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
      return;
    }

	if (random.nextFloat() < SakuraConfig.vanilla_weight / 4000.0F)
    {
      int posX = x + world.rand.nextInt(16) + 8;
      int posZ = z + world.rand.nextInt(16) + 8;
      BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
      if ((newPos != null) && (BlockLoader.VANILLA_SPLINT.canPlaceBlockAt(world, newPos))) {
        world.setBlockState(newPos, BlockLoader.VANILLACROP.getDefaultState(), 2);
      }
    }
}
 
Example 5
Source File: AbstractBiomeFilter.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
protected boolean isExcluded(Biome candidate) {
  for (BiomeDictionary.Type exType : typeExcludes) {
    if (BiomeDictionary.hasType(candidate, exType)) {
      if (Config.spawnConfigPrintDetailedOutput) {
        System.out.print("Excluded " + candidate.getBiomeName() + ", ");
      }
      return true;

    }
  }
  for (ResourceLocation exName : nameExcludes) {
    if (exName != null && exName.equals(candidate.getRegistryName())) {
      System.out.print("Excluded " + candidate.getRegistryName() + ", ");
      return false;
    }
  }
  return false;
}
 
Example 6
Source File: BiomeFilterAll.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public boolean isMatchingBiome(Biome biome) {

  if (isExcluded(biome)) {
    return false;
  }
  if (!names.isEmpty() && !names.contains(biome.getRegistryName())) {
    return false;
  }
  for (BiomeDictionary.Type type : types) {
    if (!BiomeDictionary.hasType(biome, type)) {
      return false;
    }
  }
  return true;
}
 
Example 7
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 8
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 9
Source File: BiomeFilterAny.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public boolean isMatchingBiome(Biome biome) {
  if (isExcluded(biome)) {
    return false;
  }
  if (names.contains(biome.getRegistryName())) {
    return true;
  }
  for (BiomeDictionary.Type type : types) {
    if (BiomeDictionary.hasType(biome, type)) {
      return true;
    }
  }
  return false;
}
 
Example 10
Source File: GTEventPopulateChunk.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.NORMAL)
	public void onEvent(PopulateChunkEvent.Post event) {
		if (!event.getWorld().provider.getDimensionType().equals(DimensionType.OVERWORLD)) {
			return;
		}
		if (GTConfig.general.replaceOceanGravelWithSand) {
			Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ());
			for (int x = 0; x < 16; ++x) {
				for (int z = 0; z < 16; ++z) {
					Biome biomegenbase = event.getWorld().getBiome(new BlockPos(chunk.x * 16 + x, 128, chunk.z * 16
							+ z));
					if (BiomeDictionary.hasType(biomegenbase, Type.OCEAN)
							|| BiomeDictionary.hasType(biomegenbase, Type.BEACH)) {
						for (int y = 30; y < 60; ++y) {
							if (chunk.getBlockState(x, y, z).getBlock() == BLOCK_GRAVEL) {
								chunk.setBlockState(new BlockPos(x, y, z), BLOCK_SAND.getDefaultState());
							}
						}
					}
				}
			}
			chunk.markDirty();
		}
//		if (GTConfig.general.redSandInForestsAndPlains) {
//			Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ());
//			for (int x = 0; x < 16; ++x) {
//				for (int z = 0; z < 16; ++z) {
//					Biome biomegenbase = event.getWorld().getBiome(new BlockPos(chunk.x * 16 + x, 128, chunk.z * 16
//							+ z));
//					if (BiomeDictionary.hasType(biomegenbase, Type.FOREST)
//							|| BiomeDictionary.hasType(biomegenbase, Type.PLAINS)) {
//						for (int y = 30; y < 80; ++y) {
//							if (chunk.getBlockState(x, y, z).getBlock() == BLOCK_SAND) {
//								chunk.setBlockState(new BlockPos(x, y, z), BLOCKSTATE_RED_SAND);
//							}
//						}
//					}
//				}
//			}
//			chunk.markDirty();
//		}
	}
 
Example 11
Source File: SpawnContext.java    From minecraft-roguelike with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean biomeHasType(Type type) {
	return BiomeDictionary.hasType(info.getBiome(), type);
}