Search in sources :

Example 51 with Biome

use of net.minecraft.world.biome.Biome in project Almura by AlmuraDev.

the class FarmersAlmanacItem method onItemUse.

@SuppressWarnings("ConstantConditions")
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        final Player spongePlayer = (Player) player;
        if (!spongePlayer.hasPermission("almura.item.farmers_almanac")) {
            spongePlayer.sendMessage(Text.of("Access denied, missing permission: ", TextColors.AQUA, "almura.item.farmers_" + "almanac", TextColors.WHITE, "."));
            return EnumActionResult.FAIL;
        }
        final Block block = world.getBlockState(pos).getBlock();
        if (block instanceof BlockFarmland | block instanceof BlockCrops) {
            final Biome biome = world.getBiome(pos);
            final float biomeTemperature = biome.getTemperature(pos);
            final float biomeRainfall = biome.getRainfall();
            final int blockLight = world.getLightFor(EnumSkyBlock.BLOCK, pos);
            final int skyLight = world.getLightFor(EnumSkyBlock.SKY, pos) - world.getSkylightSubtracted();
            player.swingArm(hand);
            network.sendTo(spongePlayer, new ClientboundWorldPositionInformationPacket(pos.getX(), pos.getY(), pos.getZ(), hitX, hitY, hitZ, biome.getRegistryName().toString(), biomeTemperature, biomeRainfall, blockLight, skyLight));
        } else {
            spongePlayer.sendMessage(Text.of("The ", TextColors.AQUA, "Farmer's Almanac", TextColors.WHITE, " can only be " + "used on crops or farmland."));
        }
    }
    return EnumActionResult.PASS;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) Player(org.spongepowered.api.entity.living.player.Player) ClientboundWorldPositionInformationPacket(com.almuradev.almura.feature.complex.item.almanac.network.ClientboundWorldPositionInformationPacket) BlockFarmland(net.minecraft.block.BlockFarmland) BlockCrops(net.minecraft.block.BlockCrops) Biome(net.minecraft.world.biome.Biome) Block(net.minecraft.block.Block) EnumSkyBlock(net.minecraft.world.EnumSkyBlock)

Example 52 with Biome

use of net.minecraft.world.biome.Biome in project MinecraftForge by MinecraftForge.

the class ForgeHooksClient method getSkyBlendColour.

public static int getSkyBlendColour(World world, BlockPos center) {
    if (center.getX() == skyX && center.getZ() == skyZ && skyInit) {
        return skyRGBMultiplier;
    }
    skyInit = true;
    GameSettings settings = Minecraft.getMinecraft().gameSettings;
    int[] ranges = ForgeModContainer.blendRanges;
    int distance = 0;
    if (settings.fancyGraphics && ranges.length > 0) {
        distance = ranges[MathHelper.clamp(settings.renderDistanceChunks, 0, ranges.length - 1)];
    }
    int r = 0;
    int g = 0;
    int b = 0;
    int divider = 0;
    for (int x = -distance; x <= distance; ++x) {
        for (int z = -distance; z <= distance; ++z) {
            BlockPos pos = center.add(x, 0, z);
            Biome biome = world.getBiome(pos);
            int colour = biome.getSkyColorByTemp(biome.getFloatTemperature(pos));
            r += (colour & 0xFF0000) >> 16;
            g += (colour & 0x00FF00) >> 8;
            b += colour & 0x0000FF;
            divider++;
        }
    }
    int multiplier = (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255;
    skyX = center.getX();
    skyZ = center.getZ();
    skyRGBMultiplier = multiplier;
    return skyRGBMultiplier;
}
Also used : Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos) GameSettings(net.minecraft.client.settings.GameSettings)

Example 53 with Biome

use of net.minecraft.world.biome.Biome in project MinecraftForge by MinecraftForge.

the class ForgeModContainer method registerAllBiomesAndGenerateEvents.

private static void registerAllBiomesAndGenerateEvents() {
    for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
        if (biome.theBiomeDecorator instanceof DeferredBiomeDecorator) {
            DeferredBiomeDecorator decorator = (DeferredBiomeDecorator) biome.theBiomeDecorator;
            decorator.fireCreateEventAndReplace(biome);
        }
        BiomeDictionary.ensureHasTypes(biome);
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) DeferredBiomeDecorator(net.minecraftforge.event.terraingen.DeferredBiomeDecorator)

Example 54 with Biome

use of net.minecraft.world.biome.Biome in project MinecraftForge by MinecraftForge.

the class BiomeSpawnableListTest method testAddAndRemoveSpawn.

@Test
public void testAddAndRemoveSpawn() throws Exception {
    final Class<EntityHorse> entityClass = EntityHorse.class;
    final int weightedProb = 1;
    final int minGroupCount = 1;
    final int maxGroupCount = 20;
    final Biome biome = Biomes.PLAINS;
    // Test 1: We can add a spawn for the non-vanilla EnumCreatureType
    EntityRegistry.addSpawn(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome);
    final boolean containsEntryAfterAdd = spawnableListContainsEntry(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome);
    assertTrue("The SpawnListEntry wasn't added", containsEntryAfterAdd);
    // Test 2: We can remove a spawn for the non-vanilla EnumCreatureType
    EntityRegistry.removeSpawn(entityClass, creatureTypeHorse, biome);
    final boolean containsEntryAfterRemove = spawnableListContainsEntry(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome);
    assertFalse("The SpawnListEntry wasn't removed", containsEntryAfterRemove);
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) Biome(net.minecraft.world.biome.Biome) Test(org.junit.Test)

Example 55 with Biome

use of net.minecraft.world.biome.Biome in project NetherEx by LogicTechCorp.

the class ChunkProviderNether method buildSurfaces.

@Override
public void buildSurfaces(int chunkX, int chunkZ, ChunkPrimer primer) {
    if (!ForgeEventFactory.onReplaceBiomeBlocks(this, chunkX, chunkZ, primer, world)) {
        return;
    }
    soulSandNoise = noiseGenSoulSandGravel.generateNoiseOctaves(soulSandNoise, chunkX * 16, chunkZ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D);
    gravelNoise = noiseGenSoulSandGravel.generateNoiseOctaves(gravelNoise, chunkX * 16, 109, chunkZ * 16, 16, 1, 16, 0.03125D, 1.0D, 0.03125D);
    depthBuffer = noiseGenNetherrack.generateNoiseOctaves(depthBuffer, chunkX * 16, chunkZ * 16, 0, 16, 16, 1, 0.0625D, 0.0625D, 0.0625D);
    for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
            int l = (int) (depthBuffer[x + z * 16] / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
            int i1 = -1;
            boolean genSoulSand = soulSandNoise[x + z * 16] + rand.nextDouble() * 0.2D > 0.0D;
            boolean genGravel = gravelNoise[x + z * 16] + rand.nextDouble() * 0.2D > 0.0D;
            Biome biome = biomesForGen[x + z * 16];
            IBlockState topState = biome.topBlock;
            IBlockState fillerState = biome.fillerBlock;
            NetherExBiomeType type = NetherExBiomeType.getTypeFromBiome(biome);
            IBlockState oceanState = type.getBiomeOceanBlock(biome);
            for (int y = 127; y >= 0; y--) {
                if (y < 127 && y > 0) {
                    IBlockState checkState = primer.getBlockState(x, y, z);
                    if (checkState.getMaterial() != Material.AIR) {
                        if (checkState == biome.fillerBlock) {
                            if (i1 == -1) {
                                if (l <= 0) {
                                    topState = Blocks.AIR.getDefaultState();
                                    fillerState = biome.topBlock;
                                } else if (y >= 62 && y <= 66) {
                                    topState = biome.topBlock;
                                    fillerState = biome.fillerBlock;
                                    if (ConfigHandler.dimension.nether.generateGravel && genGravel) {
                                        topState = Blocks.GRAVEL.getDefaultState();
                                    }
                                    if (ConfigHandler.dimension.nether.generateSoulSand && genSoulSand) {
                                        topState = Blocks.SOUL_SAND.getDefaultState();
                                        fillerState = Blocks.SOUL_SAND.getDefaultState();
                                    }
                                }
                                if (y <= 32 && (topState == null || topState.getMaterial() == Material.AIR)) {
                                    topState = oceanState;
                                }
                                i1 = l;
                                if (topState == biome.topBlock && fillerState == biome.fillerBlock) {
                                    primer.setBlockState(x, y, z, topState);
                                } else {
                                    if (y > 64) {
                                        primer.setBlockState(x, y, z, topState);
                                    } else {
                                        primer.setBlockState(x, y, z, fillerState);
                                    }
                                }
                            } else if (i1 > 0) {
                                i1--;
                                primer.setBlockState(x, y, z, fillerState);
                            }
                        }
                    } else {
                        i1 = -1;
                    }
                } else {
                    primer.setBlockState(x, y, z, Blocks.BEDROCK.getDefaultState());
                }
            }
        }
    }
}
Also used : NetherExBiomeType(nex.world.biome.NetherExBiomeType) Biome(net.minecraft.world.biome.Biome) IBlockState(net.minecraft.block.state.IBlockState)

Aggregations

Biome (net.minecraft.world.biome.Biome)110 BlockPos (net.minecraft.util.math.BlockPos)39 IBlockState (net.minecraft.block.state.IBlockState)16 ResourceLocation (net.minecraft.util.ResourceLocation)9 World (net.minecraft.world.World)9 Nullable (javax.annotation.Nullable)8 Random (java.util.Random)7 ChunkPos (net.minecraft.util.math.ChunkPos)7 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)6 HashMap (java.util.HashMap)6 FunctionPredicate (com.almuradev.content.component.predicate.FunctionPredicate)5 Map (java.util.Map)5 Block (net.minecraft.block.Block)5 WorldServer (net.minecraft.world.WorldServer)5 BiomeChunk (com.almuradev.almura.feature.biome.BiomeChunk)4 Overwrite (org.spongepowered.asm.mixin.Overwrite)4 Entity (net.minecraft.entity.Entity)3 IntRange (com.almuradev.toolbox.util.math.IntRange)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2