Search in sources :

Example 1 with BaseStone

use of io.github.lukebemish.excavated_variants.data.BaseStone in project excavated_variants by lukebemish.

the class BlockStateAssembler method setupClientAssets.

public static void setupClientAssets(Collection<Pair<BaseOre, BaseStone>> original_pairs, List<Pair<BaseOre, BaseStone>> to_make) {
    int_original_pairs = original_pairs;
    int_to_make = to_make;
    for (Pair<BaseOre, BaseStone> p : to_make) {
        var full_id = p.last().id + "_" + p.first().id;
        // null textures *should* just be ignored. In theory, since they won't ever be referenced...
        int max_tex_num = p.first().texture_count * p.last().texture_count;
        ArrayList<ResourceLocation> targets = new ArrayList<>(List.of(new ResourceLocation(ExcavatedVariants.MOD_ID, "blockstates/" + full_id + ".json")));
        for (int i = 0; i < max_tex_num; i++) {
            targets.add(new ResourceLocation(ExcavatedVariants.MOD_ID, "models/block/" + full_id + i + ".json"));
            targets.add(new ResourceLocation(ExcavatedVariants.MOD_ID, "textures/block/" + full_id + i + ".png"));
        }
        for (ResourceLocation rl : targets) {
            DynAssetGeneratorClientAPI.planLoadingStream(rl, new ResettingHolder(rl));
        }
    }
}
Also used : BaseStone(io.github.lukebemish.excavated_variants.data.BaseStone) BaseOre(io.github.lukebemish.excavated_variants.data.BaseOre) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 2 with BaseStone

use of io.github.lukebemish.excavated_variants.data.BaseStone in project excavated_variants by lukebemish.

the class ExcavatedVariants method registerBlockAndItem.

public static void registerBlockAndItem(BiConsumer<ResourceLocation, Block> blockRegistrar, BiFunction<ResourceLocation, Supplier<Item>, Supplier<Item>> itemRegistrar, RegistryFuture future) {
    if (!future.done) {
        future.done = true;
        String id = future.full_id;
        BaseOre o = future.ore;
        BaseStone s = future.stone;
        ResourceLocation rlToReg = new ResourceLocation(ExcavatedVariants.MOD_ID, future.full_id);
        ModifiedOreBlock.setupStaticWrapper(o, s);
        ModifiedOreBlock b = new ModifiedOreBlock(o, s);
        blockRegistrar.accept(rlToReg, b);
        blocks.put(id, b);
        Supplier<Item> i = itemRegistrar.apply(rlToReg, () -> new BlockItem(b, new Item.Properties().tab(Services.CREATIVE_TAB_LOADER.getCreativeTab())));
        items.add(i);
        ClientServices.RENDER_TYPE_HANDLER.setRenderTypeMipped(b);
    }
}
Also used : BaseStone(io.github.lukebemish.excavated_variants.data.BaseStone) Item(net.minecraft.world.item.Item) BlockItem(net.minecraft.world.item.BlockItem) BaseOre(io.github.lukebemish.excavated_variants.data.BaseOre) ResourceLocation(net.minecraft.resources.ResourceLocation) BlockItem(net.minecraft.world.item.BlockItem)

Example 3 with BaseStone

use of io.github.lukebemish.excavated_variants.data.BaseStone in project excavated_variants by lukebemish.

the class ExcavatedVariantsClient method init.

public static void init() {
    LangBuilder langBuilder = new LangBuilder();
    Collection<String> modids = Services.PLATFORM.getModIds();
    // Texture/asset extraction. Not shared with common code, so it's not visible from the oreStoneList.
    Map<String, BaseStone> stoneMap = new HashMap<>();
    Map<String, List<BaseOre>> oreMap = new HashMap<>();
    for (ModData mod : ExcavatedVariants.getConfig().mods) {
        if (modids.containsAll(mod.mod_id)) {
            for (BaseStone stone : mod.provided_stones) {
                if (!ExcavatedVariants.getConfig().blacklist_stones.contains(stone.id)) {
                    stoneMap.put(stone.id, stone);
                }
            }
            for (BaseOre ore : mod.provided_ores) {
                if (!ExcavatedVariants.getConfig().blacklist_ores.contains(ore.id)) {
                    oreMap.computeIfAbsent(ore.id, k -> new ArrayList<>());
                    oreMap.get(ore.id).add(ore);
                }
            }
        }
    }
    List<String> extractedOres = new ArrayList<>();
    Map<String, Pair<BaseOre, BaseStone>> extractorMap = new HashMap<>();
    for (ModData mod : ExcavatedVariants.getConfig().mods) {
        if (modids.containsAll(mod.mod_id)) {
            Map<String, BaseStone> internalStoneMap = new HashMap<>();
            for (BaseStone stone : mod.provided_stones) {
                if (!ExcavatedVariants.getConfig().blacklist_stones.contains(stone.id)) {
                    internalStoneMap.put(stone.id, stone);
                }
            }
            for (BaseOre ore : mod.provided_ores) {
                if (!extractedOres.contains(ore.id)) {
                    for (String stone_id : ore.stone) {
                        if (internalStoneMap.get(stone_id) != null && extractorMap.get(ore.id) == null) {
                            var extractor = new Pair<>(ore, internalStoneMap.get(stone_id));
                            extractorMap.put(ore.id, extractor);
                        } else if (stoneMap.get(stone_id) != null && extractorMap.get(ore.id) == null) {
                            var extractor = new Pair<>(ore, stoneMap.get(stone_id));
                            extractorMap.put(ore.id, extractor);
                        }
                    }
                    extractedOres.add(ore.id);
                }
            }
        }
    }
    for (List<BaseOre> oreList : oreMap.values()) {
        BaseOre ore = oreList.get(0);
        for (String stone_id : ore.stone) {
            if (stoneMap.get(stone_id) != null && extractorMap.get(ore.id) == null) {
                var extractor = new Pair<>(ore, stoneMap.get(stone_id));
                extractorMap.put(ore.id, extractor);
            }
        }
    }
    List<Pair<BaseOre, BaseStone>> to_make = new ArrayList<>();
    ExcavatedVariants.setupMap();
    for (Pair<BaseOre, HashSet<BaseStone>> p : ExcavatedVariants.oreStoneList) {
        var ore = p.first();
        for (BaseStone stone : p.last()) {
            String full_id = stone.id + "_" + ore.id;
            to_make.add(new Pair<>(ore, stone));
            DynAssetGeneratorClientAPI.planLoadingStream(new ResourceLocation(ExcavatedVariants.MOD_ID, "models/item/" + full_id + ".json"), JsonHelper.getItemModel(full_id));
            langBuilder.add(full_id, stone, ore);
        }
    }
    DynAssetGeneratorClientAPI.planLoadingStream(new ResourceLocation(ExcavatedVariants.MOD_ID, "lang/en_us.json"), langBuilder.build());
    BlockStateAssembler.setupClientAssets(extractorMap.values(), to_make);
}
Also used : ModData(io.github.lukebemish.excavated_variants.data.ModData) BaseStone(io.github.lukebemish.excavated_variants.data.BaseStone) BaseOre(io.github.lukebemish.excavated_variants.data.BaseOre) ResourceLocation(net.minecraft.resources.ResourceLocation) Pair(io.github.lukebemish.excavated_variants.util.Pair)

Example 4 with BaseStone

use of io.github.lukebemish.excavated_variants.data.BaseStone in project excavated_variants by lukebemish.

the class OreFinderUtil method setupBlocks.

public static void setupBlocks() {
    for (Block block : Services.REGISTRY_UTIL.getAllBlocks()) {
        ((IOreFound) block).excavated_variants$set_pair(null);
        ((IOreFound) block).excavated_variants$set_stone(null);
        if (ExcavatedVariants.setupMap()) {
            for (Pair<BaseOre, HashSet<BaseStone>> p : ExcavatedVariants.oreStoneList) {
                for (ResourceLocation rl : p.first().block_id) {
                    Block bl2 = Services.REGISTRY_UTIL.getBlockById(rl);
                    if (bl2 == block) {
                        ((IOreFound) block).excavated_variants$set_pair(p);
                    }
                }
                for (BaseStone stone : p.last()) {
                    if (stone.block_id.equals(Services.REGISTRY_UTIL.getRlByBlock(block))) {
                        ((IOreFound) block).excavated_variants$set_stone(stone);
                    }
                }
            }
        }
    }
}
Also used : BaseStone(io.github.lukebemish.excavated_variants.data.BaseStone) BaseOre(io.github.lukebemish.excavated_variants.data.BaseOre) ResourceLocation(net.minecraft.resources.ResourceLocation) Block(net.minecraft.world.level.block.Block) HashSet(java.util.HashSet)

Example 5 with BaseStone

use of io.github.lukebemish.excavated_variants.data.BaseStone in project excavated_variants by lukebemish.

the class JeiCompat method registerRecipes.

@Override
public void registerRecipes(@NotNull IRecipeRegistration registration) {
    if (ExcavatedVariants.getConfig().add_conversion_recipes && ExcavatedVariants.getConfig().jei_rei_compat) {
        List<CraftingRecipe> recipes = new ArrayList<>();
        OreConversionRecipe.assembleOrNull();
        for (Pair<BaseOre, HashSet<BaseStone>> p : ExcavatedVariants.oreStoneList) {
            ArrayList<Item> items = new ArrayList<>();
            for (BaseStone stone : p.last()) {
                ResourceLocation rl = new ResourceLocation(ExcavatedVariants.MOD_ID, stone.id + "_" + p.first().id);
                Item item = Services.REGISTRY_UTIL.getItemById(rl);
                if (item != null) {
                    items.add(item);
                }
            }
            Item outItem = Services.REGISTRY_UTIL.getItemById(p.first().block_id.get(0));
            if (items.size() > 0 && outItem != null) {
                Ingredient input = Ingredient.of(items.stream().map(ItemStack::new));
                ItemStack output = new ItemStack(outItem);
                NonNullList<Ingredient> inputs = NonNullList.of(Ingredient.EMPTY, input);
                String ore_id = p.first().id;
                recipes.add(new ShapelessRecipe(new ResourceLocation(ExcavatedVariants.MOD_ID, ore_id + "_conversion"), "excavated_variants.ore_conversion", output, inputs));
            }
        }
        registration.addRecipes(RecipeTypes.CRAFTING, recipes);
    }
}
Also used : ArrayList(java.util.ArrayList) CraftingRecipe(net.minecraft.world.item.crafting.CraftingRecipe) BaseStone(io.github.lukebemish.excavated_variants.data.BaseStone) Item(net.minecraft.world.item.Item) BaseOre(io.github.lukebemish.excavated_variants.data.BaseOre) Ingredient(net.minecraft.world.item.crafting.Ingredient) ResourceLocation(net.minecraft.resources.ResourceLocation) ShapelessRecipe(net.minecraft.world.item.crafting.ShapelessRecipe) ItemStack(net.minecraft.world.item.ItemStack) HashSet(java.util.HashSet)

Aggregations

BaseOre (io.github.lukebemish.excavated_variants.data.BaseOre)13 BaseStone (io.github.lukebemish.excavated_variants.data.BaseStone)13 ResourceLocation (net.minecraft.resources.ResourceLocation)13 HashSet (java.util.HashSet)6 Block (net.minecraft.world.level.block.Block)6 Item (net.minecraft.world.item.Item)4 Pair (io.github.lukebemish.excavated_variants.util.Pair)3 ModData (io.github.lukebemish.excavated_variants.data.ModData)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 Supplier (java.util.function.Supplier)2 BlockItem (net.minecraft.world.item.BlockItem)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 NativeImage (com.mojang.blaze3d.platform.NativeImage)1 DynAssetGeneratorServerAPI (io.github.lukebemish.dynamic_asset_generator.api.DynAssetGeneratorServerAPI)1 ClientPrePackRepository (io.github.lukebemish.dynamic_asset_generator.client.api.ClientPrePackRepository)1 DynAssetGeneratorClientAPI (io.github.lukebemish.dynamic_asset_generator.client.api.DynAssetGeneratorClientAPI)1