Search in sources :

Example 1 with OreDepositDefinition

use of gregtech.api.worldgen.config.OreDepositDefinition in project GregTech by GregTechCE.

the class CachedGridEntry method populateChunk.

public boolean populateChunk(World world, int chunkX, int chunkZ, Random random) {
    long chunkId = (long) chunkX << 32 | chunkZ & 0xFFFFFFFFL;
    ChunkDataEntry chunkDataEntry = dataByChunkPos.get(chunkId);
    GTWorldGenCapability capability = retrieveCapability(world, chunkX, chunkZ);
    capability.setFrom(masterEntry);
    if (chunkDataEntry != null && chunkDataEntry.populateChunk(world)) {
        for (OreDepositDefinition definition : chunkDataEntry.generatedOres) {
            IVeinPopulator veinPopulator = definition.getVeinPopulator();
            if (veinPopulator instanceof VeinChunkPopulator) {
                ((VeinChunkPopulator) veinPopulator).populateChunk(world, chunkX, chunkZ, random, definition, this);
            }
        }
        return true;
    }
    return false;
}
Also used : VeinChunkPopulator(gregtech.api.worldgen.populator.VeinChunkPopulator) OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) IVeinPopulator(gregtech.api.worldgen.populator.IVeinPopulator)

Example 2 with OreDepositDefinition

use of gregtech.api.worldgen.config.OreDepositDefinition in project GregTech by GregTechCE.

the class GTJeiPlugin method register.

@Override
public void register(IModRegistry registry) {
    IJeiHelpers jeiHelpers = registry.getJeiHelpers();
    registry.addRecipes(IntCircuitRecipeWrapper.create(), IntCircuitCategory.UID);
    MultiblockInfoCategory.registerRecipes(registry);
    registry.handleRecipes(CustomItemReturnShapedOreRecipeRecipe.class, recipe -> new CustomItemReturnRecipeWrapper(jeiHelpers, recipe), VanillaRecipeCategoryUid.CRAFTING);
    registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin());
    ModularUIGuiHandler modularUIGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper());
    registry.addAdvancedGuiHandlers(modularUIGuiHandler);
    registry.addGhostIngredientHandler(modularUIGuiHandler.getGuiContainerClass(), modularUIGuiHandler);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(modularUIGuiHandler, VanillaRecipeCategoryUid.CRAFTING);
    for (RecipeMap<?> recipeMap : RecipeMap.getRecipeMaps()) {
        List<GTRecipeWrapper> recipesList = recipeMap.getRecipeList().stream().filter(recipe -> !recipe.isHidden() && recipe.hasValidInputsForDisplay()).map(GTRecipeWrapper::new).collect(Collectors.toList());
        registry.addRecipes(recipesList, GTValues.MODID + ":" + recipeMap.unlocalizedName);
    }
    for (FuelRecipeMap fuelRecipeMap : FuelRecipeMap.getRecipeMaps()) {
        List<GTFuelRecipeWrapper> recipeList = fuelRecipeMap.getRecipeList().stream().map(GTFuelRecipeWrapper::new).collect(Collectors.toList());
        registry.addRecipes(recipeList, GTValues.MODID + ":" + fuelRecipeMap.unlocalizedName);
    }
    for (ResourceLocation metaTileEntityId : GregTechAPI.META_TILE_ENTITY_REGISTRY.getKeys()) {
        MetaTileEntity metaTileEntity = GregTechAPI.META_TILE_ENTITY_REGISTRY.getObject(metaTileEntityId);
        assert metaTileEntity != null;
        if (metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null) != null) {
            IControllable workableCapability = metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null);
            if (workableCapability instanceof AbstractRecipeLogic) {
                RecipeMap<?> recipeMap = ((AbstractRecipeLogic) workableCapability).recipeMap;
                registry.addRecipeCatalyst(metaTileEntity.getStackForm(), GTValues.MODID + ":" + recipeMap.unlocalizedName);
                if (recipeMap instanceof RecipeMapFurnace) {
                    registry.addRecipeCatalyst(metaTileEntity.getStackForm(), VanillaRecipeCategoryUid.SMELTING);
                }
            } else if (workableCapability instanceof FuelRecipeLogic) {
                FuelRecipeMap recipeMap = ((FuelRecipeLogic) workableCapability).recipeMap;
                registry.addRecipeCatalyst(metaTileEntity.getStackForm(), GTValues.MODID + ":" + recipeMap.unlocalizedName);
            }
        }
    }
    for (MetaTileEntity breweryTile : MetaTileEntities.BREWERY) {
        registry.addRecipeCatalyst(breweryTile.getStackForm(), VanillaRecipeCategoryUid.BREWING);
    }
    String semiFluidMapId = GTValues.MODID + ":" + RecipeMaps.SEMI_FLUID_GENERATOR_FUELS.getUnlocalizedName();
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_BRONZE_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_STEEL_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_TITANIUM_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_TUNGSTENSTEEL_BOILER.getStackForm(), semiFluidMapId);
    registry.addIngredientInfo(Objects.requireNonNull(Materials.Air.getFluid(1000)), VanillaTypes.FLUID, I18n.format("gregtech.machine.air_collector.jei_description"));
    String primitiveBlastId = GTValues.MODID + ":" + "primitive_blast_furnace";
    registry.addRecipes(RecipeMaps.PRIMITIVE_BLAST_FURNACE_RECIPES.stream().map(PrimitiveBlastRecipeWrapper::new).collect(Collectors.toList()), primitiveBlastId);
    registry.addRecipeCatalyst(MetaTileEntities.PRIMITIVE_BLAST_FURNACE.getStackForm(), primitiveBlastId);
    String cokeOvenId = GTValues.MODID + ":" + "coke_oven";
    registry.addRecipes(RecipeMaps.COKE_OVEN_RECIPES.stream().map(CokeOvenRecipeWrapper::new).collect(Collectors.toList()), cokeOvenId);
    registry.addRecipeCatalyst(MetaTileEntities.COKE_OVEN.getStackForm(), cokeOvenId);
    List<OreByProduct> oreByproductList = new CopyOnWriteArrayList<>();
    for (Material material : Material.MATERIAL_REGISTRY) {
        if (material instanceof DustMaterial && OreDictUnifier.get(OrePrefix.ore, material) != ItemStack.EMPTY) {
            final OreByProduct oreByProduct = new OreByProduct((DustMaterial) material);
            if (oreByProduct.hasByProducts())
                oreByproductList.add(oreByProduct);
        }
    }
    String oreByProductId = GTValues.MODID + ":" + "ore_by_product";
    registry.addRecipes(oreByproductList, oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.MACERATOR) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.ORE_WASHER) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.CENTRIFUGE) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.THERMAL_CENTRIFUGE) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.CHEMICAL_BATH) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    // Ore Veins
    List<OreDepositDefinition> oreVeins = WorldGenRegistry.getOreDeposits();
    List<GTOreInfo> oreInfoList = new CopyOnWriteArrayList<>();
    for (OreDepositDefinition vein : oreVeins) {
        oreInfoList.add(new GTOreInfo(vein));
    }
    String oreSpawnID = GTValues.MODID + ":" + "ore_spawn_location";
    registry.addRecipes(oreInfoList, oreSpawnID);
    registry.addRecipeCatalyst(MetaItems.SCANNER.getStackForm(), oreSpawnID);
    // Ore Veins End
    ingredientRegistry = registry.getIngredientRegistry();
    for (int i = 0; i <= IntCircuitIngredient.CIRCUIT_MAX; i++) {
        registry.addIngredientInfo(IntCircuitIngredient.getIntegratedCircuit(i), VanillaTypes.ITEM, "metaitem.circuit.integrated.jei_description");
    }
    registry.addRecipeCatalyst(MetaTileEntities.WORKBENCH.getStackForm(), VanillaRecipeCategoryUid.CRAFTING);
    for (MetaTileEntity machine : MetaTileEntities.FLUID_CANNER) {
        registry.addIngredientInfo(machine.getStackForm(), VanillaTypes.ITEM, "gregtech.machine.fluid_canner.jei_description");
    }
    // Multiblock info page registration
    MultiblockInfoCategory.multiblockRecipes.values().forEach(v -> {
        MultiblockInfoPage infoPage = v.getInfoPage();
        registry.addIngredientInfo(infoPage.getController().getStackForm(), VanillaTypes.ITEM, infoPage.getDescription());
    });
}
Also used : OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) ResourceLocation(net.minecraft.util.ResourceLocation) CustomItemReturnRecipeWrapper(gregtech.integration.jei.utils.CustomItemReturnRecipeWrapper) ModularUIGuiHandler(gregtech.api.gui.impl.ModularUIGuiHandler) AbstractRecipeLogic(gregtech.api.capability.impl.AbstractRecipeLogic) IControllable(gregtech.api.capability.IControllable) Material(gregtech.api.unification.material.type.Material) DustMaterial(gregtech.api.unification.material.type.DustMaterial) FuelRecipeMap(gregtech.api.recipes.machines.FuelRecipeMap) GTFuelRecipeWrapper(gregtech.integration.jei.recipe.fuel.GTFuelRecipeWrapper) RecipeMapFurnace(gregtech.api.recipes.machines.RecipeMapFurnace) MultiblockInfoPage(gregtech.integration.jei.multiblock.MultiblockInfoPage) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) FuelRecipeLogic(gregtech.api.capability.impl.FuelRecipeLogic) DustMaterial(gregtech.api.unification.material.type.DustMaterial) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 3 with OreDepositDefinition

use of gregtech.api.worldgen.config.OreDepositDefinition in project GregTech by GregTechCE.

the class CachedGridEntry method triggerVeinsGeneration.

public void triggerVeinsGeneration() {
    this.veinGeneratedMap = new HashMap<>();
    if (!cachedDepositMap.isEmpty()) {
        int currentCycle = 0;
        int maxCycles = ConfigHolder.minVeinsInSection + (ConfigHolder.additionalVeinsInSection == 0 ? 0 : gridRandom.nextInt(ConfigHolder.additionalVeinsInSection + 1));
        ArrayList<OreDepositDefinition> veins = new ArrayList<>();
        while (currentCycle < cachedDepositMap.size() && currentCycle < maxCycles) {
            // instead of removing already generated veins, we swap last element with one we selected
            int randomEntryIndex = GTUtility.getRandomItem(gridRandom, cachedDepositMap, cachedDepositMap.size() - currentCycle);
            OreDepositDefinition randomEntry = cachedDepositMap.get(randomEntryIndex).getValue();
            Collections.swap(cachedDepositMap, randomEntryIndex, cachedDepositMap.size() - 1 - currentCycle);
            // need to put into list first to apply priority properly, so
            // red granite vein will be properly filled with ores from other veins
            veins.add(randomEntry);
            if (!randomEntry.isVein())
                maxCycles++;
            currentCycle++;
        }
        veins.sort(COMPARATOR);
        for (OreDepositDefinition depositDefinition : veins) {
            doGenerateVein(depositDefinition);
        }
    }
}
Also used : OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) TLongArrayList(gnu.trove.list.array.TLongArrayList)

Aggregations

OreDepositDefinition (gregtech.api.worldgen.config.OreDepositDefinition)3 TLongArrayList (gnu.trove.list.array.TLongArrayList)1 IControllable (gregtech.api.capability.IControllable)1 AbstractRecipeLogic (gregtech.api.capability.impl.AbstractRecipeLogic)1 FuelRecipeLogic (gregtech.api.capability.impl.FuelRecipeLogic)1 ModularUIGuiHandler (gregtech.api.gui.impl.ModularUIGuiHandler)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 FuelRecipeMap (gregtech.api.recipes.machines.FuelRecipeMap)1 RecipeMapFurnace (gregtech.api.recipes.machines.RecipeMapFurnace)1 DustMaterial (gregtech.api.unification.material.type.DustMaterial)1 Material (gregtech.api.unification.material.type.Material)1 IVeinPopulator (gregtech.api.worldgen.populator.IVeinPopulator)1 VeinChunkPopulator (gregtech.api.worldgen.populator.VeinChunkPopulator)1 MultiblockInfoPage (gregtech.integration.jei.multiblock.MultiblockInfoPage)1 GTFuelRecipeWrapper (gregtech.integration.jei.recipe.fuel.GTFuelRecipeWrapper)1 CustomItemReturnRecipeWrapper (gregtech.integration.jei.utils.CustomItemReturnRecipeWrapper)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ResourceLocation (net.minecraft.util.ResourceLocation)1