Search in sources :

Example 1 with Material

use of net.minecraft.client.resources.model.Material in project MinecraftForge by MinecraftForge.

the class SeparatePerspectiveModel method getTextures.

@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
    Set<Material> textures = Sets.newHashSet();
    textures.addAll(baseModel.getMaterials(modelGetter, missingTextureErrors));
    for (BlockModel model : perspectives.values()) textures.addAll(model.getMaterials(modelGetter, missingTextureErrors));
    return textures;
}
Also used : Material(net.minecraft.client.resources.model.Material) BlockModel(net.minecraft.client.renderer.block.model.BlockModel)

Example 2 with Material

use of net.minecraft.client.resources.model.Material in project MinecraftForge by MinecraftForge.

the class DynamicBucketModel method bake.

@Override
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) {
    Material particleLocation = owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : null;
    Material baseLocation = owner.isTexturePresent("base") ? owner.resolveTexture("base") : null;
    Material fluidMaskLocation = owner.isTexturePresent("fluid") ? owner.resolveTexture("fluid") : null;
    Material coverLocation = owner.isTexturePresent("cover") ? owner.resolveTexture("cover") : null;
    ModelState transformsFromModel = owner.getCombinedTransform();
    TextureAtlasSprite fluidSprite = fluid != Fluids.EMPTY ? spriteGetter.apply(ForgeHooksClient.getBlockMaterial(fluid.getAttributes().getStillTexture())) : null;
    TextureAtlasSprite coverSprite = (coverLocation != null && (!coverIsMask || baseLocation != null)) ? spriteGetter.apply(coverLocation) : null;
    ImmutableMap<TransformType, Transformation> transformMap = PerspectiveMapWrapper.getTransforms(new CompositeModelState(transformsFromModel, modelTransform));
    TextureAtlasSprite particleSprite = particleLocation != null ? spriteGetter.apply(particleLocation) : null;
    if (particleSprite == null)
        particleSprite = fluidSprite;
    if (particleSprite == null && !coverIsMask)
        particleSprite = coverSprite;
    // if the fluid is lighter than air, will manipulate the initial state to be rotated 180deg to turn it upside down
    if (flipGas && fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir()) {
        modelTransform = new SimpleModelState(modelTransform.getRotation().blockCornerToCenter().compose(new Transformation(null, new Quaternion(0, 0, 1, 0), null, null)).blockCenterToCorner());
    }
    Transformation transform = modelTransform.getRotation();
    ItemMultiLayerBakedModel.Builder builder = ItemMultiLayerBakedModel.builder(owner, particleSprite, new ContainedFluidOverrideHandler(overrides, bakery, owner, this), transformMap);
    if (baseLocation != null) {
        // build base (insidest)
        builder.addQuads(ItemLayerModel.getLayerRenderType(false), ItemLayerModel.getQuadsForSprites(ImmutableList.of(baseLocation), transform, spriteGetter));
    }
    if (fluidMaskLocation != null && fluidSprite != null) {
        TextureAtlasSprite templateSprite = spriteGetter.apply(fluidMaskLocation);
        if (templateSprite != null) {
            // build liquid layer (inside)
            int luminosity = applyFluidLuminosity ? fluid.getAttributes().getLuminosity() : 0;
            int color = tint ? fluid.getAttributes().getColor() : 0xFFFFFFFF;
            builder.addQuads(ItemLayerModel.getLayerRenderType(luminosity > 0), ItemTextureQuadConverter.convertTexture(transform, templateSprite, fluidSprite, NORTH_Z_FLUID, Direction.NORTH, color, 1, luminosity));
            builder.addQuads(ItemLayerModel.getLayerRenderType(luminosity > 0), ItemTextureQuadConverter.convertTexture(transform, templateSprite, fluidSprite, SOUTH_Z_FLUID, Direction.SOUTH, color, 1, luminosity));
        }
    }
    if (coverIsMask) {
        if (coverSprite != null && baseLocation != null) {
            TextureAtlasSprite baseSprite = spriteGetter.apply(baseLocation);
            builder.addQuads(ItemLayerModel.getLayerRenderType(false), ItemTextureQuadConverter.convertTexture(transform, coverSprite, baseSprite, NORTH_Z_COVER, Direction.NORTH, 0xFFFFFFFF, 2));
            builder.addQuads(ItemLayerModel.getLayerRenderType(false), ItemTextureQuadConverter.convertTexture(transform, coverSprite, baseSprite, SOUTH_Z_COVER, Direction.SOUTH, 0xFFFFFFFF, 2));
        }
    } else {
        if (coverSprite != null) {
            builder.addQuads(ItemLayerModel.getLayerRenderType(false), ItemTextureQuadConverter.genQuad(transform, 0, 0, 16, 16, NORTH_Z_COVER, coverSprite, Direction.NORTH, 0xFFFFFFFF, 2));
            builder.addQuads(ItemLayerModel.getLayerRenderType(false), ItemTextureQuadConverter.genQuad(transform, 0, 0, 16, 16, SOUTH_Z_COVER, coverSprite, Direction.SOUTH, 0xFFFFFFFF, 2));
        }
    }
    builder.setParticle(particleSprite);
    return builder.build();
}
Also used : Transformation(com.mojang.math.Transformation) Quaternion(com.mojang.math.Quaternion) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelState(net.minecraft.client.resources.model.ModelState) Material(net.minecraft.client.resources.model.Material) TransformType(net.minecraft.client.renderer.block.model.ItemTransforms.TransformType)

Aggregations

Material (net.minecraft.client.resources.model.Material)2 Quaternion (com.mojang.math.Quaternion)1 Transformation (com.mojang.math.Transformation)1 BlockModel (net.minecraft.client.renderer.block.model.BlockModel)1 TransformType (net.minecraft.client.renderer.block.model.ItemTransforms.TransformType)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 ModelState (net.minecraft.client.resources.model.ModelState)1