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));
}
}
}
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);
}
}
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);
}
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);
}
}
}
}
}
}
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);
}
}
Aggregations