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

The following examples show how to use net.minecraft.world.biome.Biome#getTemperature() . 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: MoonSurfaceBuilder.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public void generate(Random random, Chunk chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState fluidBlock, int seaLevel, long seed, TernarySurfaceConfig ternarySurfaceConfig) {
    BlockState blockState = ternarySurfaceConfig.getTopMaterial();
    BlockState blockState2 = ternarySurfaceConfig.getUnderMaterial();
    BlockPos.Mutable mutable = new BlockPos.Mutable();
    int i = -1;
    int j = (int) (noise / 3.0D + 3.0D + random.nextDouble() * 0.25D);
    int k = x & 15;
    int l = z & 15;

    for (int m = height; m >= 0; --m) {
        mutable.set(k, m, l);
        BlockState blockState3 = chunk.getBlockState(mutable);
        if (blockState3.isAir()) {
            i = -1;
        } else if (blockState3.isOf(defaultBlock.getBlock())) {
            if (i == -1) {
                if (j <= 0) {
                    blockState = Blocks.AIR.getDefaultState();
                    blockState2 = defaultBlock;
                } else if (m >= seaLevel - 4 && m <= seaLevel + 1) {
                    blockState = ternarySurfaceConfig.getTopMaterial();
                    blockState2 = ternarySurfaceConfig.getUnderMaterial();
                }

                if (m < seaLevel && (blockState == null || blockState.isAir())) {
                    if (biome.getTemperature(mutable.set(x, m, z)) < 0.15F) {
                        blockState = Blocks.ICE.getDefaultState();
                    } else {
                        blockState = fluidBlock;
                    }

                    mutable.set(k, m, l);
                }

                i = j;
                if (m >= seaLevel - 1) {
                    chunk.setBlockState(mutable, blockState, false);
                } else if (m < seaLevel - 7 - j) {
                    blockState = Blocks.AIR.getDefaultState();
                    blockState2 = defaultBlock;
                    chunk.setBlockState(mutable, ternarySurfaceConfig.getUnderwaterMaterial(), false);
                } else {
                    chunk.setBlockState(mutable, blockState2, false);
                }
            } else if (i > 0) {
                --i;
                chunk.setBlockState(mutable, blockState2, false);
                if (i == 0 && blockState2.isOf(GalacticraftBlocks.MOON_TURF) && j > 1) {
                    i = random.nextInt(4) + Math.max(0, m - 63);
                    blockState2 = GalacticraftBlocks.MOON_ROCK.getDefaultState();
                }
            }
        }
    }
}
 
Example 3
Source File: MultiBlockSurfaceBuilder.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
protected void generate(Random random, Chunk chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState fluidBlock, MultiBlockSurfaceConfig multiBlockSurfaceConfig, int seaLevel) {
    BlockState blockState = multiBlockSurfaceConfig.getTopMaterial();
    BlockState blockState2 = multiBlockSurfaceConfig.getUnderMaterial();
    BlockPos.Mutable mutable = new BlockPos.Mutable();
    int i = -1;
    int j = (int) (noise / 3.0D + 3.0D + random.nextDouble() * 0.25D);
    int k = x & 15;
    int l = z & 15;

    for (int m = height; m >= 0; --m) {
        mutable.set(k, m, l);
        BlockState blockState3 = chunk.getBlockState(mutable);
        if (blockState3.isAir()) {
            i = -1;
        } else if (blockState3.getBlock() == defaultBlock.getBlock()) {
            if (i == -1) {
                if (j <= 0) {
                    blockState = Blocks.AIR.getDefaultState();
                    blockState2 = multiBlockSurfaceConfig.getUnderMaterial();
                } else if (m >= seaLevel - 4 && m <= seaLevel + 1) {
                    blockState = multiBlockSurfaceConfig.getTopMaterial();
                    blockState2 = multiBlockSurfaceConfig.getUnderMaterial();
                }

                if (m < seaLevel && (blockState == null || blockState.isAir())) {
                    if (biome.getTemperature(mutable.set(x, m, z)) < 0.15F) {
                        blockState = Blocks.ICE.getDefaultState();
                    } else {
                        blockState = fluidBlock;
                    }

                    mutable.set(k, m, l);
                }

                i = j;
                if (m >= seaLevel - 1) {
                    chunk.setBlockState(mutable, blockState, false);
                } else if (m < seaLevel - 7 - j) {
                    blockState = Blocks.AIR.getDefaultState();
                    blockState2 = multiBlockSurfaceConfig.getTopMaterial();
                    chunk.setBlockState(mutable, multiBlockSurfaceConfig.getUnderwaterMaterial(), false);
                } else {
                    chunk.setBlockState(mutable, blockState2, false);
                }
            } else if (i > 0) {
                --i;
                chunk.setBlockState(mutable, blockState2, false);
                if (i == 0 && blockState2.getBlock() == Blocks.SAND && j > 1) {
                    i = random.nextInt(4) + Math.max(0, m - 63);
                    blockState2 = blockState2.getBlock() == Blocks.RED_SAND ? Blocks.RED_SANDSTONE.getDefaultState() : Blocks.SANDSTONE.getDefaultState();
                }
            }
        }
    }
}
 
Example 4
Source File: BiomeDictionary.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Automatically adds appropriate types to a given {@link Biome} based on certain heuristics.
 *
 * <p>If a {@link Biome}'s types are requested and no types have been added to the {@link Biome} so far, its types
 * will be determined and added using this method.</p>
 */
public static void makeBestGuess(Biome biome) {
	Type type = Type.fromVanilla(biome.getCategory());

	if (type != null) {
		BiomeDictionary.addTypes(biome, type);
	}

	if (biome.getRainfall() > 0.85f) {
		BiomeDictionary.addTypes(biome, WET);
	}

	if (biome.getRainfall() < 0.15f) {
		BiomeDictionary.addTypes(biome, DRY);
	}

	if (biome.getTemperature() > 0.85f) {
		BiomeDictionary.addTypes(biome, HOT);
	}

	if (biome.getTemperature() < 0.15f) {
		BiomeDictionary.addTypes(biome, COLD);
	}

	if (biome.hasHighHumidity() && biome.getDepth() < 0.0F && (biome.getScale() <= 0.3F && biome.getScale() >= 0.0F)) {
		BiomeDictionary.addTypes(biome, SWAMP);
	}

	if (biome.getDepth() <= -0.5F) {
		if (biome.getScale() == 0.0F) {
			BiomeDictionary.addTypes(biome, RIVER);
		} else {
			BiomeDictionary.addTypes(biome, OCEAN);
		}
	}

	if (biome.getScale() >= 0.4F && biome.getScale() < 1.5F) {
		BiomeDictionary.addTypes(biome, HILLS);
	}

	if (biome.getScale() >= 1.5F) {
		BiomeDictionary.addTypes(biome, MOUNTAIN);
	}
}