Search in sources :

Example 1 with RailcraftBlocks

use of mods.railcraft.common.blocks.RailcraftBlocks in project Railcraft by Railcraft.

the class ClientProxy method initializeClient.

@Override
public void initializeClient() {
    ModelLoaderRegistry.registerLoader(OutfittedTrackModel.Loader.INSTANCE);
    ModelLoaderRegistry.registerLoader(OutfittedTrackItemModel.Loader.INSTANCE);
    ModelLoaderRegistry.registerLoader(ActuatorModel.Loader.INSTANCE);
    MinecraftForge.EVENT_BUS.register(RCSoundHandler.INSTANCE);
    MinecraftForge.EVENT_BUS.register(JSONModelRenderer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(FluidModelRenderer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(GoggleAuraWorldRenderer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(new Object() {

        @SubscribeEvent
        public void textureStitch(TextureStitchEvent.Pre event) {
            //                CartContentRendererRedstoneFlux.instance().setRedstoneIcon(event.getMap().registerSprite(new ResourceLocation("railcraft:entities/carts/cart_redstone_flux")));
            //                CartContentRendererRedstoneFlux.instance().setFrameIcon(event.getMap().registerSprite(new ResourceLocation("railcraft:entities/carts/cart_redstone_flux_frame")));
            ParticleSpark.sprite = event.getMap().registerSprite(new ResourceLocation("railcraft:particle/spark"));
            ParticlePumpkin.sprite = event.getMap().registerSprite(new ResourceLocation("railcraft:particle/pumpkin"));
            for (RailcraftBlocks blockContainer : RailcraftBlocks.VALUES) {
                Block block = blockContainer.block();
                if (block instanceof IRailcraftBlock) {
                    IRailcraftBlock railcraftBlock = (IRailcraftBlock) block;
                    railcraftBlock.registerTextures(event.getMap());
                }
            }
        }
    });
    //        Set<IRailcraftObjectContainer<IRailcraftItemSimple>> items = new HashSet<>();
    //        items.addAll(Arrays.asList(RailcraftItems.VALUES));
    //        items.addAll(Arrays.asList(RailcraftCarts.VALUES));
    //        for (IRailcraftObjectContainer<IRailcraftItemSimple> itemContainer : items) {
    //            itemContainer.getObject().ifPresent(IRailcraftItemSimple::initializeClient);
    //        }
    RailcraftObjects.processItems(IRailcraftItemSimple::initializeClient);
    //        for (RailcraftBlocks blockContainer : RailcraftBlocks.VALUES) {
    //            ItemBlock item = blockContainer.item();
    //            blockContainer.getObject().ifPresent(block -> {
    //                block.initializeClient();
    //                if (item != null) {
    //                    ((IRailcraftObject) item).initializeClient();
    //                    IVariantEnum[] variants = block.getVariants();
    //                    if (variants != null) {
    //                        for (IVariantEnum variant : variants) {
    //                            ItemStack stack = blockContainer.getStack(variant);
    //                            if (stack != null)
    //                                block.registerItemModel(stack, variant);
    //                        }
    //                    } else {
    //                        ItemStack stack = blockContainer.getStack();
    //                        if (stack != null)
    //                            block.registerItemModel(stack, null);
    //                    }
    //                }
    //            });
    //        }
    RailcraftObjects.processBlocks((block, item) -> {
        block.initializeClient();
        if (item != null)
            item.initializeClient();
    }, (block, variant) -> {
        ItemStack stack = block.getStack(variant);
        if (stack != null)
            block.registerItemModel(stack, variant);
    });
    JSONModelRenderer.INSTANCE.registerModel(CartContentRendererRedstoneFlux.CORE_MODEL);
    JSONModelRenderer.INSTANCE.registerModel(CartContentRendererRedstoneFlux.FRAME_MODEL);
    JSONModelRenderer.INSTANCE.registerModel(TESRManipulatorFluid.PIPE_MODEL);
    RenderingRegistry.registerEntityRenderingHandler(EntityTunnelBore.class, RenderTunnelBore::new);
    RenderingRegistry.registerEntityRenderingHandler(EntityMinecart.class, RenderCart::new);
}
Also used : RailcraftBlocks(mods.railcraft.common.blocks.RailcraftBlocks) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) IRailcraftBlock(mods.railcraft.common.blocks.IRailcraftBlock) ResourceLocation(net.minecraft.util.ResourceLocation) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) Block(net.minecraft.block.Block) IRailcraftBlock(mods.railcraft.common.blocks.IRailcraftBlock) IRailcraftItemSimple(mods.railcraft.common.items.IRailcraftItemSimple) ItemStack(net.minecraft.item.ItemStack)

Example 2 with RailcraftBlocks

use of mods.railcraft.common.blocks.RailcraftBlocks in project Railcraft by Railcraft.

the class RailcraftConfig method loadBlocks.

private static void loadBlocks() {
    configBlocks.addCustomCategoryComment(CAT_BLOCKS, "Here you can disable entire blocks.\n" + "Changing these will have adverse effects on existing worlds.\n" + "For the list of which sub-blocks are on each ID see the sub-block section below.");
    configBlocks.addCustomCategoryComment(CAT_SUB_BLOCKS, "Here is were you can enable/disable various sub-blocks.\n" + "Railcraft will attempt to compensate for any missing component by providing alternatives (usually).");
    for (RailcraftBlocks block : RailcraftBlocks.VALUES) {
        loadBlockProperty(block.getBaseTag());
        Class<? extends IVariantEnum> variantClass = block.getVariantClass();
        if (variantClass != null)
            for (IVariantEnum variant : variantClass.getEnumConstants()) {
                String tag = block.getBaseTag() + RailcraftConstants.SEPERATOR + variant.getResourcePathSuffix();
                loadBlockFeature(tag);
            }
    }
    loadBlockProperty("fluid.creosote");
    loadBlockProperty("fluid.steam");
    // TODO: Move to own file?
    for (TrackKits type : TrackKits.VALUES) {
        //            if (type.isDeprecated())
        //                continue;
        loadBlockFeature(type.getRegistryName());
    }
    Map<String, Property> blocks = configBlocks.getCategory(CAT_BLOCKS);
    blocks.keySet().retainAll(enabledBlocks.keySet());
    Map<String, Property> subBlocks = configBlocks.getCategory(CAT_SUB_BLOCKS);
    subBlocks.keySet().retainAll(enabledSubBlocks.keySet());
//        for (EnumGeneric type : EnumGeneric.VALUES) {
//            loadBlockFeature(type.getTag());
//        }
//
//        for (EnumPost type : EnumPost.VALUES) {
//            loadBlockFeature(type.getTag());
//        }
//        for (EnumWallAlpha type : EnumWallAlpha.VALUES) {
//            loadBlockFeature(type.getTag());
//        }
//
//        for (EnumWallBeta type : EnumWallBeta.VALUES) {
//            loadBlockFeature(type.getTag());
//        }
//        for (BlockMaterial mat : BlockMaterial.STAIR_MATS) {
//            loadBlockFeature(BlockRailcraftStairs.getTag(mat));
//        }
//
//        for (BlockMaterial mat : BlockMaterial.SLAB_MATS) {
//            loadBlockFeature(BlockRailcraftSlab.getTag(mat));
//        }
//        for (BlockMaterial mat : BlockLantern.STONE_LANTERN.values()) {
//            loadBlockFeature(BlockLantern.getTag(mat));
//        }
//
//        for (BlockMaterial mat : BlockLantern.METAL_LANTERN.values()) {
//            loadBlockFeature(BlockLantern.getTag(mat));
//        }
//        for (EnumOre type : EnumOre.values()) {
//            if (!type.isDeprecated())
//                loadBlockFeature(type.getTag());
//        }
//        Set<IEnumMachine<?>> machineVariants = new HashSet<>();
//        machineVariants.addAll(Arrays.asList(EnumMachineAlpha.VALUES));
//        machineVariants.addAll(Arrays.asList(EnumMachineBeta.values()));
//        machineVariants.addAll(Arrays.asList(EnumMachineGamma.values()));
//        machineVariants.addAll(Arrays.asList(EnumMachineDelta.values()));
//        machineVariants.addAll(Arrays.asList(EnumMachineEpsilon.values()));
//
//        for (IEnumMachine<?> type : machineVariants) {
//            loadBlockFeature(type.getTag());
//        }
//
//        for (EnumSignal type : EnumSignal.values()) {
//            if (type.getModule() != null)
//                loadBlockFeature(type.getTag());
//        }
}
Also used : RailcraftBlocks(mods.railcraft.common.blocks.RailcraftBlocks) TrackKits(mods.railcraft.common.blocks.tracks.outfitted.TrackKits) IVariantEnum(mods.railcraft.api.core.IVariantEnum) Property(net.minecraftforge.common.config.Property)

Aggregations

RailcraftBlocks (mods.railcraft.common.blocks.RailcraftBlocks)2 IVariantEnum (mods.railcraft.api.core.IVariantEnum)1 IRailcraftBlock (mods.railcraft.common.blocks.IRailcraftBlock)1 TrackKits (mods.railcraft.common.blocks.tracks.outfitted.TrackKits)1 IRailcraftItemSimple (mods.railcraft.common.items.IRailcraftItemSimple)1 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 TextureStitchEvent (net.minecraftforge.client.event.TextureStitchEvent)1 Property (net.minecraftforge.common.config.Property)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1