Search in sources :

Example 66 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project BuildCraft by BuildCraft.

the class ComplexRefiningManager method registerModels.

@SideOnly(Side.CLIENT)
public static void registerModels(ModelBakeEvent event) {
    for (FluidDefinition def : allFluids) {
        IModel model = new ModelFluid(def.fluid);
        IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
        ModelResourceLocation loc = ModelHelper.getBlockResourceLocation(def.block);
        event.getModelRegistry().putObject(loc, baked);
    }
}
Also used : FluidDefinition(buildcraft.core.lib.fluids.FluidDefinition) IModel(net.minecraftforge.client.model.IModel) ModelFluid(net.minecraftforge.client.model.ModelFluid) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 67 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project BuildCraft by BuildCraft.

the class ItemRenderUtil method renderItemStack.

/**
 * Used to render a lot of items in sequential order. Assumes that you don't change the glstate inbetween calls.
 * You must call {@link #endItemBatch()} after your have rendered all of the items.
 */
public static void renderItemStack(double x, double y, double z, ItemStack stack, int lightc, EnumFacing dir, BufferBuilder bb) {
    if (stack.isEmpty()) {
        return;
    }
    if (dir == null) {
        dir = EnumFacing.EAST;
    }
    dir = BCLibConfig.rotateTravelingItems.changeFacing(dir);
    IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
    model = model.getOverrides().handleItemState(model, stack, null, null);
    boolean requireGl = stack.hasEffect() || model.isBuiltInRenderer();
    if (bb != null && !requireGl) {
        bb.setTranslation(x, y, z);
        float scale = 0.30f;
        MutableQuad q = new MutableQuad(-1, null);
        for (EnumPipePart part : EnumPipePart.VALUES) {
            for (BakedQuad quad : model.getQuads(null, part.face, 0)) {
                q.fromBakedItem(quad);
                q.translated(-0.5, -0.5, -0.5);
                q.scaled(scale);
                q.rotate(EnumFacing.SOUTH, dir, 0, 0, 0);
                if (quad.hasTintIndex()) {
                    int colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.getTintIndex());
                    if (EntityRenderer.anaglyphEnable) {
                        colour = TextureUtil.anaglyphColor(colour);
                    }
                    q.multColouri(colour, colour >> 8, colour >> 16, 0xFF);
                }
                q.lighti(lightc);
                Vector3f normal = q.getCalculatedNormal();
                q.normalvf(normal);
                q.multShade();
                q.render(bb);
            }
        }
        bb.setTranslation(0, 0, 0);
        return;
    }
    if (!inBatch) {
        inBatch = true;
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        GL11.glScaled(0.3, 0.3, 0.3);
        RenderHelper.disableStandardItemLighting();
    }
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightc % (float) 0x1_00_00, lightc / (float) 0x1_00_00);
    Minecraft.getMinecraft().getRenderItem().renderItem(stack, model);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vector3f(javax.vecmath.Vector3f) EnumPipePart(buildcraft.api.core.EnumPipePart) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 68 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project BuildCraft by BuildCraft.

the class BuildCraftBakedModel method createQuadsItemLayer.

public static List<MutableQuad> createQuadsItemLayer(final List<TextureAtlasSprite> sprites) {
    ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
    for (int i = 0; i < sprites.size(); i++) {
        builder.add(new ResourceLocation("buildcraftbakedmodel:spriteindex" + i));
    }
    final ImmutableList<ResourceLocation> locations = builder.build();
    ItemLayerModel model = new ItemLayerModel(locations);
    IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.BLOCK, new Function<ResourceLocation, TextureAtlasSprite>() {

        @Override
        public TextureAtlasSprite apply(ResourceLocation input) {
            return sprites.get(locations.indexOf(input));
        }
    });
    Matrix4f itemToEdge = new Matrix4f();
    itemToEdge.setIdentity();
    itemToEdge.setRotation(new AxisAngle4f(0, 1, 0, (float) (Math.PI / 2)));
    Matrix4f translation = new Matrix4f();
    translation.setIdentity();
    translation.setTranslation(new Vector3f(-15 / 32f, 0, 1));
    translation.mul(itemToEdge);
    List<MutableQuad> mutableQuads = ModelUtil.toMutableQuadList(baked, false);
    for (MutableQuad mutable : mutableQuads) {
        mutable.transform(translation);
        mutable.setTint(-1);
    }
    return mutableQuads;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) Matrix4f(javax.vecmath.Matrix4f) ResourceLocation(net.minecraft.util.ResourceLocation) Vector3f(javax.vecmath.Vector3f) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) AxisAngle4f(javax.vecmath.AxisAngle4f) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 69 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Adventurers-Toolbox by the-realest-stu.

the class AxeModel method bake.

@Override
public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
    TRSRTransformation transform = (TRSRTransformation.identity());
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    if (headTexture != null && haftTexture != null && handleTexture != null) {
        ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
        if (haftTexture != null) {
            texBuilder.add(haftTexture);
        }
        if (headTexture != null) {
            texBuilder.add(headTexture);
        }
        if (handleTexture != null) {
            texBuilder.add(handleTexture);
        }
        if (adornmentTexture != null) {
            texBuilder.add(adornmentTexture);
        }
        ImmutableList<ResourceLocation> textures = texBuilder.build();
        IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter);
        builder.addAll(model.getQuads(null, null, 0));
    }
    return new BakedAxeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType) ItemOverride(net.minecraft.client.renderer.block.model.ItemOverride)

Example 70 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Adventurers-Toolbox by the-realest-stu.

the class HandpickModel method bake.

@Override
public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
    TRSRTransformation transform = (TRSRTransformation.identity());
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    if (headTexture != null && haftTexture != null && handleTexture != null) {
        ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
        if (haftTexture != null) {
            texBuilder.add(haftTexture);
        }
        if (headTexture != null) {
            texBuilder.add(headTexture);
        }
        if (handleTexture != null) {
            texBuilder.add(handleTexture);
        }
        if (adornmentTexture != null) {
            texBuilder.add(adornmentTexture);
        }
        ImmutableList<ResourceLocation> textures = texBuilder.build();
        IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter);
        builder.addAll(model.getQuads(null, null, 0));
    }
    return new BakedHandpickModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType) ItemOverride(net.minecraft.client.renderer.block.model.ItemOverride)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)197 IBlockState (net.minecraft.block.state.IBlockState)94 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)42 BlockPos (net.minecraft.util.math.BlockPos)40 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)38 EnumFacing (net.minecraft.util.EnumFacing)38 ResourceLocation (net.minecraft.util.ResourceLocation)36 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 ItemStack (net.minecraft.item.ItemStack)27 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)24 Block (net.minecraft.block.Block)23 IModel (net.minecraftforge.client.model.IModel)22 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)22 ArrayList (java.util.ArrayList)20 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)15 List (java.util.List)14 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)14 ImmutableList (com.google.common.collect.ImmutableList)13