Search in sources :

Example 1 with IOMode

use of crazypants.enderio.base.render.property.IOMode in project EnderIO by SleepyTrousers.

the class OverlayHolder method collectOverlayQuads.

public static void collectOverlayQuads(@Nonnull ModelBakeEvent event) {
    final Block block = ModObject.block_machine_io.getBlockNN();
    Map<IBlockState, ModelResourceLocation> locations = event.getModelManager().getBlockModelShapes().getBlockStateMapper().getVariants(block);
    NNIterator<IOMode> modes = crazypants.enderio.base.render.property.IOMode.MODES.iterator();
    while (modes.hasNext()) {
        IOMode mode = modes.next();
        IBlockState state = block.getDefaultState().withProperty(IOMode.IO, mode);
        ModelResourceLocation mrl = locations.get(state);
        if (mrl == null) {
            throw new RuntimeException("Model for state " + state + " failed to load from " + mrl + ". ");
        }
        IBakedModel model = event.getModelRegistry().getObject(mrl);
        if (model == null) {
            Log.warn("Model for state " + state + " failed to load from " + mrl + ".");
            continue;
        }
        QuadCollector quads = new QuadCollector();
        BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
        BlockRenderLayer layer = block.getBlockLayer();
        ForgeHooksClient.setRenderLayer(layer);
        List<BakedQuad> generalQuads = model.getQuads(state, null, 0);
        if (!generalQuads.isEmpty()) {
            quads.addQuads(null, layer, generalQuads);
        }
        for (EnumFacing face1 : EnumFacing.values()) {
            List<BakedQuad> faceQuads = model.getQuads(state, mode.getDirection(), 0);
            if (!faceQuads.isEmpty()) {
                quads.addQuads(face1, layer, faceQuads);
            }
        }
        ForgeHooksClient.setRenderLayer(oldRenderLayer);
        data[mode.getDirection().ordinal()][mode.getIomode().ordinal()] = quads;
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IBlockState(net.minecraft.block.state.IBlockState) EnumIOMode(crazypants.enderio.base.render.property.IOMode.EnumIOMode) IOMode(crazypants.enderio.base.render.property.IOMode) EnumFacing(net.minecraft.util.EnumFacing) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) QuadCollector(crazypants.enderio.base.render.util.QuadCollector) Block(net.minecraft.block.Block) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

IOMode (crazypants.enderio.base.render.property.IOMode)1 EnumIOMode (crazypants.enderio.base.render.property.IOMode.EnumIOMode)1 QuadCollector (crazypants.enderio.base.render.util.QuadCollector)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 EnumFacing (net.minecraft.util.EnumFacing)1