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

The following examples show how to use net.minecraft.world.biome.Biome#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: ItemBiomeChanger.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public List<ModuleBase> getModules(int id, EntityPlayer player) {
	List<ModuleBase> list = new LinkedList<ModuleBase>();

	SatelliteBiomeChanger sat = (SatelliteBiomeChanger) getSatellite(player.getHeldItem(EnumHand.MAIN_HAND));
	if(player.world.isRemote) {
		list.add(new ModuleImage(24, 14, zmaster587.advancedRocketry.inventory.TextureResources.earthCandyIcon));
	}

	List<ModuleBase> list2 = new LinkedList<ModuleBase>();
	int j = 0;
	for(byte biomeByte : sat.discoveredBiomes()) {
		Biome biome = Biome.getBiome(biomeByte);
		list2.add(new ModuleButton(32, 16 + 24*(j++), Biome.getIdForBiome(biome), biome.getBiomeName(), this, TextureResources.buttonBuild));
	}

	//Relying on a bug, is this safe?
	ModuleContainerPan pan = new ModuleContainerPan(32, 16, list2, new LinkedList<ModuleBase>(), null, 128, 128, 0, -64, 0, 1000);

	list.add(pan);
	list.add(new ModuleButton(120, 124, -1, LibVulpes.proxy.getLocalizedString("msg.biomechanger.scan"), this, TextureResources.buttonScan));
	list.add(new ModulePower(16, 48, (IUniversalEnergy) sat));

	return list;
}
 
Example 2
Source File: BiomeProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Returns an array of biomes for the location input.
 */
@Override
public Biome[] getBiomesForGeneration(Biome[] biomes, int x, int z, int width, int height) {
    IntCache.resetIntCache();

    if (biomes == null || biomes.length < width * height)
    {
        biomes = new Biome[width * height];
    }

    int[] aint = this.genBiomes.getInts(x, z, width, height);

    try
    {
        for (int i = 0; i < width * height; ++i)
        {
            biomes[i] = Biome.getBiome(aint[i], TofuBiomes.TOFU_RIVER);
        }

        return biomes;
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock");
        crashreportcategory.addCrashSection("biomes[] size", Integer.valueOf(biomes.length));
        crashreportcategory.addCrashSection("x", Integer.valueOf(x));
        crashreportcategory.addCrashSection("z", Integer.valueOf(z));
        crashreportcategory.addCrashSection("w", Integer.valueOf(width));
        crashreportcategory.addCrashSection("h", Integer.valueOf(height));
        throw new ReportedException(crashreport);
    }
}
 
Example 3
Source File: BiomeProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Gets a list of biomes for the specified blocks.
 */
@Override
public Biome[] getBiomes(@Nullable Biome[] listToReuse, int x, int z, int width, int length, boolean cacheFlag) {
    IntCache.resetIntCache();

    if (listToReuse == null || listToReuse.length < width * length)
    {
        listToReuse = new Biome[width * length];
    }

    if (cacheFlag && width == 16 && length == 16 && (x & 15) == 0 && (z & 15) == 0)
    {
        Biome[] abiome = this.biomeCache.getCachedBiomes(x, z);
        System.arraycopy(abiome, 0, listToReuse, 0, width * length);
        return listToReuse;
    }
    else
    {
        int[] aint = this.biomeIndexLayer.getInts(x, z, width, length);

        for (int i = 0; i < width * length; ++i)
        {
            listToReuse[i] = Biome.getBiome(aint[i], TofuBiomes.TOFU_RIVER);
        }

        return listToReuse;
    }
}
 
Example 4
Source File: BiomeProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * checks given Chunk's Biomes against List of allowed ones
 */
@Override
public boolean areBiomesViable(int x, int z, int radius, List<Biome> allowed) {
    IntCache.resetIntCache();
    int i = x - radius >> 2;
    int j = z - radius >> 2;
    int k = x + radius >> 2;
    int l = z + radius >> 2;
    int i1 = k - i + 1;
    int j1 = l - j + 1;
    int[] aint = this.genBiomes.getInts(i, j, i1, j1);

    try
    {
        for (int k1 = 0; k1 < i1 * j1; ++k1)
        {
            Biome biome = Biome.getBiome(aint[k1]);

            if (!allowed.contains(biome))
            {
                return false;
            }
        }

        return true;
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer");
        crashreportcategory.addCrashSection("Layer", this.genBiomes.toString());
        crashreportcategory.addCrashSection("x", Integer.valueOf(x));
        crashreportcategory.addCrashSection("z", Integer.valueOf(z));
        crashreportcategory.addCrashSection("radius", Integer.valueOf(radius));
        crashreportcategory.addCrashSection("allowed", allowed);
        throw new ReportedException(crashreport);
    }
}
 
Example 5
Source File: ChunkManagerPlanet.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public Biome[] getBiomesForGeneration(Biome[] biomes, int x, int z, int width, int height)
{
	GenLayerBiomePlanet.setupBiomesForUse(this.biomes);
	//return super.getBiomesForGeneration(p_76937_1_, p_76937_2_, p_76937_3_, p_76937_4_, p_76937_5_);

	IntCache.resetIntCache();

	if (biomes == null || biomes.length < width * height)
	{
		biomes = new Biome[width * height];
	}

	int[] aint = this.genBiomes.getInts(x, z, width, height);

	try
	{
		for (int i1 = 0; i1 < width * height; ++i1)
		{
			biomes[i1] = Biome.getBiome(aint[i1], Biomes.OCEAN);//AdvancedRocketryBiomes.instance.getBiomeById(aint[i1]);
		}

		return biomes;
	}
	catch (Throwable throwable)
	{
		CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
		CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock");
		crashreportcategory.addCrashSection("biomes[] size", Integer.valueOf(biomes.length));
		crashreportcategory.addCrashSection("x", Integer.valueOf(x));
		crashreportcategory.addCrashSection("z", Integer.valueOf(z));
		crashreportcategory.addCrashSection("w", Integer.valueOf(width));
		crashreportcategory.addCrashSection("h", Integer.valueOf(height));
		throw new ReportedException(crashreport);
	}
}
 
Example 6
Source File: ChunkManagerPlanet.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false,
 * don't check biomeCache to avoid infinite loop in BiomeCacheBlock)
 */
@Override
public Biome[] getBiomes(@Nullable Biome[] listToReuse, int x, int z, int width, int length, boolean cacheFlag) {

	GenLayerBiomePlanet.setupBiomesForUse(biomes);
	//return super.getBiomeGenAt(biomeGenBase, x, y, width, length, p_76931_6_);

	IntCache.resetIntCache();

	if (listToReuse == null || listToReuse.length < width * length)
	{
		listToReuse = new Biome[width * length];
	}

	if (cacheFlag && width == 16 && length == 16 && (x & 15) == 0 && (z & 15) == 0)
	{
		Biome[] abiome = this.biomeCache.getCachedBiomes(x, z);
		System.arraycopy(abiome, 0, listToReuse, 0, width * length);
		return listToReuse;
	}
	else
	{
		int[] aint = this.biomeIndexLayer.getInts(x, z, width, length);

		for (int i = 0; i < width * length; ++i)
		{
			listToReuse[i] = Biome.getBiome(aint[i], Biomes.DEFAULT);
		}

		return listToReuse;
	}
}
 
Example 7
Source File: ItemBiomeChanger.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
private void setBiomeId(ItemStack stack, int id) {
	if(Biome.getBiome(id) != null) {
		SatelliteBase sat = getSatellite(stack);
		if(sat != null && sat instanceof SatelliteBiomeChanger) {
			((SatelliteBiomeChanger)sat).setBiome(id);
		}
	}
}
 
Example 8
Source File: AdvancedRocketryBiomes.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * Gets Biomes from Advanced Rocketry's biomes registry.  If it does not exist attepts to retrieve from vanilla forge
 * @param id biome id
 * @return Biome retrieved from the biome ID
 */
public Biome getBiomeById(int id) {

	for(Biome biome : registeredBiomes) {
		if( Biome.getIdForBiome(biome) == id)
			return biome;
	}

	return Biome.getBiome(id);
}
 
Example 9
Source File: DimensionProperties.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * Adds a biome to the list of biomes allowed to spawn on this planet
 * @param biome biome to be added as viable
 * @return true if the biome was added sucessfully, false otherwise
 */
public boolean addBiome(int biomeId) {

	Biome biome =  Biome.getBiome(biomeId);
	if(biomeId == 0 || Biome.getIdForBiome(biome) != 0) {
		List<Biome> biomes = new ArrayList<Biome>();
		biomes.add(biome);
		allowedBiomes.addAll(getBiomesEntries(biomes));
		return true;
	}
	return false;
}
 
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: ShipStorage.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Biome getBiome(BlockPos pos) {
	return Biome.getBiome(0);
}
 
Example 12
Source File: StorageChunk.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public Biome getBiome(BlockPos pos) {
	//Don't care, gen ocean
	return Biome.getBiome(0);
}
 
Example 13
Source File: WorldProviderPaths.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Biome getBiomeForCoords(BlockPos pos)
{
	return Biome.getBiome(1);
}
 
Example 14
Source File: BiomeProviderTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public BiomeProviderTFC() 
{
	super(Biome.getBiome(1));
}
 
Example 15
Source File: BiomeProviderTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Biome getBiome(BlockPos pos)
{
	IslandMap map = WorldGen.getInstance().getIslandMap(pos);
	return Biome.getBiome(1);
}
 
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);
	}