Search in sources :

Example 1 with NetherExBiomeType

use of nex.world.biome.NetherExBiomeType in project NetherEx by LogicTechCorp.

the class AdditionalBiomeManager method init.

public static void init(File directory) {
    try {
        if (!directory.exists()) {
            directory.mkdir();
        }
        LOGGER.info("Copying the Biome List Directory to the config folder.");
        if (NetherEx.IS_DEV_ENV) {
            FileUtils.copyDirectory(new File(NetherEx.class.getResource("/assets/nex/biome_lists").getFile()), directory);
        } else {
            FileUtil.extractFromJar("/assets/nex/biome_lists", directory.getPath());
        }
    } catch (IOException e) {
        LOGGER.fatal("The attempt to copy the Biome List Directory to the config folder was unsuccessful.");
        LOGGER.fatal(e);
    }
    Gson gson = new Gson();
    List<File> additionalBiomeFiles = Lists.newArrayList(directory.listFiles());
    try {
        for (File additionalBiomeFile : additionalBiomeFiles) {
            String jsonText = Files.toString(additionalBiomeFile, Charsets.UTF_8);
            AdditionalBiomeList biomeList = gson.fromJson(jsonText, AdditionalBiomeList.class);
            LOGGER.info("Adding biomes from the " + biomeList.getName() + ".");
            for (AdditionalBiomeMod biomeMod : biomeList.getMods()) {
                for (AdditionalBiome additionalBiome : biomeMod.getBiomes()) {
                    ResourceLocation biomeRegistryName = new ResourceLocation(biomeMod.getName() + ":" + additionalBiome.getName());
                    Biome biome = Biome.REGISTRY.getObject(biomeRegistryName);
                    if (biome == null) {
                        continue;
                    }
                    int weight = additionalBiome.getWeight();
                    AdditionalBiome.OceanBlock oceanBlock = additionalBiome.getOceanBlock();
                    if (oceanBlock == null) {
                        oceanBlock = new AdditionalBiome.OceanBlock("minecraft:air", 0);
                    }
                    Block block = Block.getBlockFromName(oceanBlock.getName().isEmpty() ? "minecraft:air" : oceanBlock.getName());
                    int meta = oceanBlock.getMeta();
                    IBlockState state = block.getStateFromMeta(meta);
                    NetherExBiomeType type = NetherExBiomeType.getFromString(additionalBiome.getType());
                    NetherExBiomes.addBiome(biome, weight, state, type);
                    LOGGER.info("The " + biome.getBiomeName() + " biome from the " + biomeList.getName() + " was added to the Nether.");
                }
            }
        }
    } catch (IOException e) {
        LOGGER.fatal("NetherEx was unable to read the Biome lists.");
        LOGGER.fatal(e);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) NetherEx(nex.NetherEx) Gson(com.google.gson.Gson) IOException(java.io.IOException) NetherExBiomeType(nex.world.biome.NetherExBiomeType) Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) File(java.io.File)

Example 2 with NetherExBiomeType

use of nex.world.biome.NetherExBiomeType 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)

Example 3 with NetherExBiomeType

use of nex.world.biome.NetherExBiomeType in project NetherEx by LogicTechCorp.

the class ChunkProviderNether method prepareHeights.

@Override
public void prepareHeights(int chunkX, int chunkZ, ChunkPrimer primer) {
    buffer = generateHeightMap(buffer, chunkX * 4, 0, chunkZ * 4, 5, 17, 5);
    for (int x = 0; x < 4; x++) {
        for (int z = 0; z < 4; z++) {
            for (int y = 0; y < 16; y++) {
                double d1 = buffer[(x * 5 + z) * 17 + y];
                double d2 = buffer[(((x * 5) + z + 1) * 17) + y];
                double d3 = buffer[((((x + 1) * 5) + z) * 17) + y];
                double d4 = buffer[((x + 1) * 5 + z + 1) * 17 + y];
                double d5 = (buffer[(x * 5 + z) * 17 + y + 1] - d1) * 0.125D;
                double d6 = (buffer[(x * 5 + z + 1) * 17 + y + 1] - d2) * 0.125D;
                double d7 = (buffer[((x + 1) * 5 + z) * 17 + y + 1] - d3) * 0.125D;
                double d8 = (buffer[((x + 1) * 5 + z + 1) * 17 + y + 1] - d4) * 0.125D;
                for (int y2 = 0; y2 < 8; y2++) {
                    double d10 = d1;
                    double d11 = d2;
                    double d12 = (d3 - d1) * 0.25D;
                    double d13 = (d4 - d2) * 0.25D;
                    for (int x2 = 0; x2 < 4; x2++) {
                        double d15 = d10;
                        double d16 = (d11 - d10) * 0.25D;
                        for (int z2 = 0; z2 < 4; z2++) {
                            int posX = x2 + x * 4;
                            int posY = y2 + y * 8;
                            int posZ = z2 + z * 4;
                            Biome biome = biomesForGen[posX + posZ * 16];
                            IBlockState state = null;
                            NetherExBiomeType type = NetherExBiomeType.getTypeFromBiome(biome);
                            IBlockState oceanState = type.getBiomeOceanBlock(biome);
                            if (posY < 32) {
                                state = oceanState;
                            }
                            if (d15 > 0.0D) {
                                state = biome.fillerBlock;
                            }
                            primer.setBlockState(posX, posY, posZ, state);
                            d15 += d16;
                        }
                        d10 += d12;
                        d11 += d13;
                    }
                    d1 += d5;
                    d2 += d6;
                    d3 += d7;
                    d4 += d8;
                }
            }
        }
    }
}
Also used : NetherExBiomeType(nex.world.biome.NetherExBiomeType) Biome(net.minecraft.world.biome.Biome) IBlockState(net.minecraft.block.state.IBlockState)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)3 Biome (net.minecraft.world.biome.Biome)3 NetherExBiomeType (nex.world.biome.NetherExBiomeType)3 Gson (com.google.gson.Gson)1 File (java.io.File)1 IOException (java.io.IOException)1 Block (net.minecraft.block.Block)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 NetherEx (nex.NetherEx)1