Search in sources :

Example 1 with ItemLayerModel

use of net.minecraftforge.client.model.ItemLayerModel 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 2 with ItemLayerModel

use of net.minecraftforge.client.model.ItemLayerModel 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 3 with ItemLayerModel

use of net.minecraftforge.client.model.ItemLayerModel 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)

Example 4 with ItemLayerModel

use of net.minecraftforge.client.model.ItemLayerModel in project Adventurers-Toolbox by the-realest-stu.

the class MaceModel 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 BakedMaceModel(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 5 with ItemLayerModel

use of net.minecraftforge.client.model.ItemLayerModel in project Adventurers-Toolbox by the-realest-stu.

the class ShovelModel 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 BakedShovelModel(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

ItemLayerModel (net.minecraftforge.client.model.ItemLayerModel)13 ImmutableList (com.google.common.collect.ImmutableList)12 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)12 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)12 ResourceLocation (net.minecraft.util.ResourceLocation)12 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)11 TransformType (net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)10 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)9 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)9 MutableQuad (buildcraft.lib.client.model.MutableQuad)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 VariableFaceData (buildcraft.lib.client.model.json.VariablePartCuboidBase.VariableFaceData)1 Nonnull (javax.annotation.Nonnull)1 AxisAngle4f (javax.vecmath.AxisAngle4f)1 Matrix4f (javax.vecmath.Matrix4f)1 Vector3f (javax.vecmath.Vector3f)1 BakedItemModel (net.minecraftforge.client.model.BakedItemModel)1