Java Code Examples for net.minecraftforge.client.model.IModel#retexture()

The following examples show how to use net.minecraftforge.client.model.IModel#retexture() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelCamouflageBlock.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IModel retexture(ImmutableMap<String, String> textures)
{
    IModel baseModel    = ModelLoaderRegistry.getMissingModel();
    IModel overlayModel = null;

    try
    {
        baseModel = ModelLoaderRegistry.getModel(this.baseModelLocation);
        baseModel = baseModel.retexture(textures);

        if (this.overlayModelLocation != null)
        {
            overlayModel = ModelLoaderRegistry.getModel(this.overlayModelLocation);
            overlayModel = overlayModel.retexture(textures);
        }
    }
    catch (Exception e)
    {
        EnderUtilities.logger.warn("Failed to load a model for a camouflage block", e);
    }

    return new ModelCamouflageBlockBase(this.baseModelLocation, this.overlayModelLocation, baseModel, overlayModel, textures);
}
 
Example 2
Source File: BakedModelBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IModel retexture(ImmutableMap<String, String> textures)
{
    IModel baseModel = ModelLoaderRegistry.getMissingModel();
    IModel overlayModel = ModelLoaderRegistry.getMissingModel();
    
    try
    {
        baseModel = ModelLoaderRegistry.getModel(BARREL_BASE_MODEL);
        baseModel = baseModel.retexture(this.textures);

        overlayModel = ModelLoaderRegistry.getModel(BARREL_OVERLAY_MODEL);
        overlayModel = overlayModel.retexture(this.textures);
    }
    catch (Exception e)
    {
        EnderUtilities.logger.warn("Failed to load the base model for a Barrel", e);
    }

    return new ModelBarrel(baseModel, overlayModel, textures);
}
 
Example 3
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    IModel baseModel = null;
    IModel lockedModel = null;

    try
    {
        baseModel   = ModelLoaderRegistry.getModel(BASE_MODEL);
        lockedModel = ModelLoaderRegistry.getModel(LOCKED_MODEL);
        lockedModel = lockedModel.retexture(ImmutableMap.of("layer0", TEX_LOCKED));
    }
    catch (Exception e)
    {
        EnderUtilities.logger.warn("Failed to load a model for the Nullifier!");
    }

    return new ModelNullifierBaked(baseModel, lockedModel, state, format, bakedTextureGetter);
}
 
Example 4
Source File: BakedModelInserter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private BakedModelInserter(ModelInserter inserterModel, IModel baseModel, IModel sideModel, IModelState modelState, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    ImmutableMap<String, String> textures = inserterModel.getTextureMapping();
    this.baseModel        = baseModel.retexture(textures);
    this.sideModelValid   = sideModel.retexture(ImmutableMap.of("side", textures.get("side_valid")));
    this.sideModelInvalid = sideModel.retexture(ImmutableMap.of("side", textures.get("side_invalid")));
    this.format = format;
    this.bakedTextureGetter = bakedTextureGetter;
    this.bakedBaseModel = this.baseModel.bake(modelState, format, bakedTextureGetter);
    this.particle = bakedTextureGetter.apply(new ResourceLocation(textures.get("particle")));
}
 
Example 5
Source File: BakedModelBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private BakedModelBarrel(IModel baseModel, IModel overlayModel, IModelState state, VertexFormat format,
        Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ImmutableMap<String, String> textures)
{
    IBlockState defaultState = EnderUtilitiesBlocks.BARREL.getDefaultState().withProperty(BlockBarrel.LABEL_FRONT, true);
    this.baseModel = baseModel.retexture(textures);
    this.overlayModel = overlayModel.retexture(textures);
    this.bakedBaseModel = this.baseModel.retexture(this.getTexturesBaseModel(defaultState, textures)).bake(state, format, bakedTextureGetter);
    this.format = format;
    this.bakedTextureGetter = bakedTextureGetter;
    this.textures = textures;
    String particleName = this.textures.get("particle");
    this.particle = particleName != null ? bakedTextureGetter.apply(new ResourceLocation(particleName)) : this.bakedBaseModel.getParticleTexture();
    this.itemQuads = BakedModelCamouflageBlock.buildItemModel(this.bakedBaseModel, null);
}
 
Example 6
Source File: TexturedItemOverrides.java    From OpenModsLib with MIT License 5 votes vote down vote up
private IModel retextureModel(IModel overrideModel, ResourceLocation texture) {
	final ImmutableMap.Builder<String, String> textures = ImmutableMap.builder();
	for (String t : texturesToReplace)
		textures.put(t, texture.toString());

	return overrideModel.retexture(textures.build());
}