Search in sources :

Example 6 with ItemLayerModel

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

the class ToolHeadModel 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();
    ImmutableList<ResourceLocation> textures = ImmutableList.<ResourceLocation>of(new ResourceLocation(modid, "items/" + toolName + "/" + partName + "_" + matName));
    builder.addAll(new ItemLayerModel(textures).bake(state, format, bakedTextureGetter).getQuads(null, null, 0));
    return new BakedToolHeadModel(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) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)

Example 7 with ItemLayerModel

use of net.minecraftforge.client.model.ItemLayerModel in project BuildCraft by BuildCraft.

the class VariablePartTextureExpand method addQuads.

@Override
public void addQuads(List<MutableQuad> addTo, ITextureGetter spriteLookup) {
    if (visible.evaluate()) {
        float[] f = bakePosition(from);
        float[] t = bakePosition(to);
        float[] size = { t[0] - f[0], t[1] - f[1], t[2], f[2] };
        boolean s = shade.evaluate();
        int l = (int) (light.evaluate() & 15);
        int rgba = RenderUtil.swapARGBforABGR((int) colour.evaluate());
        VariableFaceData data = faceUv.evaluate(spriteLookup);
        // TODO: Use the UV data! (only take part of the texture)
        ItemLayerModel model = new ItemLayerModel(ImmutableList.of(new ResourceLocation(".")));
        IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, (loc) -> data.sprite);
        List<BakedQuad> quads = baked.getQuads(null, null, 0);
        for (BakedQuad q : quads) {
            MutableQuad mut = new MutableQuad();
            mut.fromBakedItem(q);
            mut.translated(0, 0, -(7.5 / 16.0));
            mut.scaled(1, 1, 16);
            mut.rotate(EnumFacing.SOUTH, evaluateFace(this.face), 0.5f, 0.5f, 0.5f);
            mut.scalef(size[0], size[1], size[2]);
            mut.translated(f[0], f[1], f[2]);
            mut.setCalculatedNormal();
            mut.setShade(s);
            mut.lighti(l, 0);
            mut.colouri(rgba);
            mut.setSprite(data.sprite);
            addTo.add(mut);
        }
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) ResourceLocation(net.minecraft.util.ResourceLocation) VariableFaceData(buildcraft.lib.client.model.json.VariablePartCuboidBase.VariableFaceData) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 8 with ItemLayerModel

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

the class DaggerModel 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 (bladeTexture != null && handleTexture != null) {
        ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
        if (bladeTexture != null) {
            texBuilder.add(bladeTexture);
        }
        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 BakedDaggerModel(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 9 with ItemLayerModel

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

the class HammerModel 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 BakedHammerModel(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 10 with ItemLayerModel

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

the class HoeModel 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 BakedHoeModel(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