Search in sources :

Example 1 with FluidSpringPopulator

use of gregtech.api.worldgen.populator.FluidSpringPopulator in project GregTech by GregTechCE.

the class WorldGenRegistry method initializeRegistry.

public void initializeRegistry() {
    GTLog.logger.info("Initializing ore generation registry...");
    registerShapeGenerator("ellipsoid", EllipsoidGenerator::new);
    registerShapeGenerator("sphere", SphereGenerator::new);
    registerShapeGenerator("plate", PlateGenerator::new);
    registerShapeGenerator("single", SingleBlockGenerator::new);
    registerBlockFiller("simple", SimpleBlockFiller::new);
    registerBlockFiller("ignore_bedrock", () -> new BlacklistedBlockFiller(Lists.newArrayList(Blocks.BEDROCK.getDefaultState())));
    registerVeinPopulator("surface_rock", SurfaceRockPopulator::new);
    registerVeinPopulator("fluid_spring", FluidSpringPopulator::new);
    registerVeinPopulator("surface_block", SurfaceBlockPopulator::new);
    WorldGeneratorImpl worldGenerator = new WorldGeneratorImpl();
    GameRegistry.registerWorldGenerator(worldGenerator, 1);
    MinecraftForge.ORE_GEN_BUS.register(worldGenerator);
    try {
        reinitializeRegisteredVeins();
    } catch (IOException | RuntimeException exception) {
        GTLog.logger.fatal("Failed to initialize worldgen registry.", exception);
    }
}
Also used : WorldGeneratorImpl(gregtech.api.worldgen.generator.WorldGeneratorImpl) SurfaceRockPopulator(gregtech.api.worldgen.populator.SurfaceRockPopulator) FluidSpringPopulator(gregtech.api.worldgen.populator.FluidSpringPopulator) IOException(java.io.IOException) BlacklistedBlockFiller(gregtech.api.worldgen.filler.BlacklistedBlockFiller) SurfaceBlockPopulator(gregtech.api.worldgen.populator.SurfaceBlockPopulator) SimpleBlockFiller(gregtech.api.worldgen.filler.SimpleBlockFiller)

Example 2 with FluidSpringPopulator

use of gregtech.api.worldgen.populator.FluidSpringPopulator in project GregTech by GregTechCE.

the class GTOreInfo method findComponentBlocksAsItemStacks.

// Finds the possible blocks from the Filler definition, and returns them as ItemStacks
public List<ItemStack> findComponentBlocksAsItemStacks() {
    Collection<IBlockState> containedStates = new ArrayList<>();
    List<ItemStack> containedBlocksAsItemStacks = new ArrayList<>();
    // Find all possible states in the Filler
    // Needed because one generation option returns all possible blockStates
    List<FillerEntry> possibleStates = blockFiller.getAllPossibleStates();
    for (FillerEntry entry : possibleStates) {
        containedStates.addAll(entry.getPossibleResults());
    }
    // Check to see if we are dealing with a fluid generation case, before transforming states
    if (veinPopulator instanceof FluidSpringPopulator) {
        for (IBlockState state : containedStates) {
            Block temp = state.getBlock();
            if (temp instanceof IFluidBlock) {
                Fluid fluid = ((IFluidBlock) temp).getFluid();
                FluidStack fStack = new FluidStack(fluid, 1000);
                ItemStack stack = FluidUtil.getFilledBucket(fStack);
                containedBlocksAsItemStacks.add(stack);
            }
        }
    } else {
        // Transform the list of BlockStates to a list of ItemStacks
        for (IBlockState state : containedStates) {
            containedBlocksAsItemStacks.add(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
        }
    }
    return containedBlocksAsItemStacks;
}
Also used : FillerEntry(gregtech.api.worldgen.filler.FillerEntry) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) FluidSpringPopulator(gregtech.api.worldgen.populator.FluidSpringPopulator) ItemStack(net.minecraft.item.ItemStack)

Example 3 with FluidSpringPopulator

use of gregtech.api.worldgen.populator.FluidSpringPopulator in project GregTech by GregTechCE.

the class GTOreInfo method findUniqueBlocksAsItemStack.

// Condenses the List of ores down to group together ores that share the same material but only vary in stone type
public List<List<ItemStack>> findUniqueBlocksAsItemStack(List<ItemStack> itemList) {
    List<List<ItemStack>> groupedItems = new ArrayList<>();
    int entries = itemList.size();
    // return early for Fluid Generation
    if (veinPopulator instanceof FluidSpringPopulator) {
        groupedItems.add(new ArrayList<>(itemList));
        return groupedItems;
    }
    ItemStack firstItem = itemList.get(0);
    List<ItemStack> oreList = new ArrayList<>();
    oreList.add(firstItem);
    // Separate the ores ignoring their Stone Variants
    for (int counter = 1; counter < entries; counter++) {
        ItemStack item = itemList.get(counter);
        if (firstItem.getItem() != item.getItem()) {
            groupedItems.add(new ArrayList<>(oreList));
            oreList.clear();
        }
        oreList.add(item);
        firstItem = item;
    }
    // Add the last generated list
    groupedItems.add(new ArrayList<>(oreList));
    return groupedItems;
}
Also used : FluidSpringPopulator(gregtech.api.worldgen.populator.FluidSpringPopulator) ItemStack(net.minecraft.item.ItemStack)

Example 4 with FluidSpringPopulator

use of gregtech.api.worldgen.populator.FluidSpringPopulator in project GregTech by GregTechCE.

the class GTOreInfo method findSurfaceBlock.

// Finds the generated surface block or material. In the case of Fluid generation, finds a bucket of the fluid
public ItemStack findSurfaceBlock(IVeinPopulator veinPopulator) {
    Material mat;
    IBlockState state;
    ItemStack stack = new ItemStack(Items.AIR);
    FluidStack fStack;
    // Legacy Surface rock Support
    if (veinPopulator instanceof SurfaceRockPopulator) {
        mat = ((SurfaceRockPopulator) veinPopulator).getMaterial();
        // Create a Tiny Dust for the Identifier.
        stack = OreDictUnifier.getDust(mat.createMaterialStack(M / 9));
        return stack.isEmpty() ? new ItemStack(Items.AIR) : stack;
    } else // Surface Block support
    if (veinPopulator instanceof SurfaceBlockPopulator) {
        state = ((SurfaceBlockPopulator) veinPopulator).getBlockState();
        stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
        return stack;
    } else // Fluid generation support
    if (veinPopulator instanceof FluidSpringPopulator) {
        state = ((FluidSpringPopulator) veinPopulator).getFluidState();
        Block temp = state.getBlock();
        if (temp instanceof IFluidBlock) {
            Fluid fluid = ((IFluidBlock) temp).getFluid();
            fStack = new FluidStack(fluid, 1000);
            stack = FluidUtil.getFilledBucket(fStack);
            return stack;
        }
    }
    // No defined surface rock
    return stack;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) SurfaceBlockPopulator(gregtech.api.worldgen.populator.SurfaceBlockPopulator) SurfaceRockPopulator(gregtech.api.worldgen.populator.SurfaceRockPopulator) Block(net.minecraft.block.Block) Material(gregtech.api.unification.material.type.Material) FluidSpringPopulator(gregtech.api.worldgen.populator.FluidSpringPopulator) ItemStack(net.minecraft.item.ItemStack)

Aggregations

FluidSpringPopulator (gregtech.api.worldgen.populator.FluidSpringPopulator)4 ItemStack (net.minecraft.item.ItemStack)3 SurfaceBlockPopulator (gregtech.api.worldgen.populator.SurfaceBlockPopulator)2 SurfaceRockPopulator (gregtech.api.worldgen.populator.SurfaceRockPopulator)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 Material (gregtech.api.unification.material.type.Material)1 BlacklistedBlockFiller (gregtech.api.worldgen.filler.BlacklistedBlockFiller)1 FillerEntry (gregtech.api.worldgen.filler.FillerEntry)1 SimpleBlockFiller (gregtech.api.worldgen.filler.SimpleBlockFiller)1 WorldGeneratorImpl (gregtech.api.worldgen.generator.WorldGeneratorImpl)1 IOException (java.io.IOException)1