Tag Provider, list to array function, surface builder fix

This commit is contained in:
paulevsGitch 2021-12-04 11:16:13 +03:00
parent f8eb65d600
commit 7f17e1261c
6 changed files with 52 additions and 8 deletions

View file

@ -6,6 +6,8 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Registry;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.blocks.BaseBarrelBlock;
@ -17,13 +19,17 @@ import ru.bclib.client.render.BaseChestBlockEntityRenderer;
import ru.bclib.client.render.BaseSignBlockEntityRenderer;
import ru.bclib.interfaces.PostInitable;
import ru.bclib.interfaces.RenderLayerProvider;
import ru.bclib.interfaces.TagProvider;
import ru.bclib.registry.BaseBlockEntities;
import ru.bclib.util.CollectionsUtil;
import java.util.List;
import java.util.function.Consumer;
public class PostInitAPI {
private static List<Consumer<Boolean>> postInitFunctions = Lists.newArrayList();
private static List<Tag.Named<Block>> blockTags = Lists.newArrayList();
private static List<Tag.Named<Item>> itemTags = Lists.newArrayList();
/**
* Register a new function which will be called after all mods are initiated. Will be called on both client and server.
@ -49,6 +55,8 @@ public class PostInitAPI {
}
});
postInitFunctions = null;
blockTags = null;
itemTags = null;
BiomeAPI.loadFabricAPIBiomes();
}
@ -83,5 +91,12 @@ public class PostInitAPI {
else if (block instanceof BaseFurnaceBlock) {
BaseBlockEntities.FURNACE.registerBlock(block);
}
if (block instanceof TagProvider) {
TagProvider.class.cast(block).addTags(blockTags, itemTags);
TagAPI.addTags(block, CollectionsUtil.toArray(blockTags));
TagAPI.addTags(block, CollectionsUtil.toArray(itemTags));
blockTags.clear();
itemTags.clear();
}
}
}