Java Code Examples for net.minecraftforge.client.model.ModelLoaderRegistry#getMissingModel()

The following examples show how to use net.minecraftforge.client.model.ModelLoaderRegistry#getMissingModel() . 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: ModelLoader.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation resourceLocation) {
	String resourcePath = resourceLocation.getResourcePath();
	/*if (!resourcePath.startsWith(SMART_MODEL_RESOURCE_LOCATION)) {
		assert false : "loadModel expected " + SMART_MODEL_RESOURCE_LOCATION + " but found " + resourcePath;
	}*/
	String modelName = resourcePath;//.substring(SMART_MODEL_RESOURCE_LOCATION.length());

	if (modelName.contains("rocketmotor")) {
		return new ModelRocket();
	} else {
		try {
			return ModelLoaderRegistry.getModel(new ResourceLocation(modelName));
		} catch (Exception e) {
			return ModelLoaderRegistry.getMissingModel();
		}// ModelLoaderRegistry.getMissingModel();
	}
}
 
Example 2
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 3
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 4
Source File: VariantModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<ResourceLocation, IBakedModel> bakedSubModels = Maps.newHashMap();

	for (ResourceLocation subModel : modelData.getAllModels()) {
		IModel model = ModelLoaderRegistry.getModelOrLogError(subModel, "Couldn't load sub-model dependency: " + subModel);
		bakedSubModels.put(subModel, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter));
	}

	final IModel baseModel;
	if (base.isPresent()) {
		ResourceLocation baseLocation = base.get();
		baseModel = ModelLoaderRegistry.getModelOrLogError(baseLocation, "Couldn't load base-model dependency: " + baseLocation);
	} else {
		baseModel = ModelLoaderRegistry.getMissingModel();
	}

	final IBakedModel bakedBaseModel = baseModel.bake(new ModelStateComposition(state, baseModel.getDefaultState()), format, bakedTextureGetter);

	return new BakedModel(bakedBaseModel, modelData, bakedSubModels, PerspectiveMapWrapper.getTransforms(state));
}
 
Example 5
Source File: MultiLayerModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<BlockRenderLayer, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter));

	IModel missing = ModelLoaderRegistry.getMissingModel();
	IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter);

	final IBakedModel bakedBase;
	if (base.isPresent()) {
		bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter);
	} else {
		bakedBase = bakedMissing;
	}

	return new MultiLayerBakedModel(
			bakedModels,
			bakedBase,
			bakedMissing,
			PerspectiveMapWrapper.getTransforms(state));
}
 
Example 6
Source File: ItemStateModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final IModel defaultModel;

	if (this.defaultModel.isPresent()) {
		defaultModel = getModel(this.defaultModel.get());
	} else if (!this.stateModels.isEmpty()) {
		final ResourceLocation first = this.stateModels.values().iterator().next();
		defaultModel = getModel(first);
	} else {
		defaultModel = ModelLoaderRegistry.getMissingModel();
	}

	final IBakedModel bakedDefaultModel = defaultModel.bake(defaultModel.getDefaultState(), format, bakedTextureGetter);

	final Map<State, IBakedModel> bakedStateModels = Maps.transformValues(stateModels, input -> {
		final IModel model = getModel(input);
		return model.bake(model.getDefaultState(), format, bakedTextureGetter);
	});

	return new ItemStateOverrideList(bakedStateModels).wrapModel(bakedDefaultModel);
}
 
Example 7
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<TransformType, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter));

	IModel missing = ModelLoaderRegistry.getMissingModel();
	IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter);

	final IBakedModel bakedBase;
	if (base.isPresent()) {
		bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter);
	} else {
		bakedBase = bakedMissing;
	}

	return new PerspectiveAwareBakedModel(
			bakedModels,
			bakedBase,
			PerspectiveMapWrapper.getTransforms(state));
}
 
Example 8
Source File: ModelPortableBarrel.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	try {
		parentModel = ModelLoaderRegistry.getModel(PARENT_RL);
	} catch (Exception e) {
		e.printStackTrace();
		parentModel = ModelLoaderRegistry.getMissingModel();
	}
	parent = parentModel.bake(state, format, bakedTextureGetter);
	return this;
}
 
Example 9
Source File: EvalModelBase.java    From OpenModsLib with MIT License 5 votes vote down vote up
protected IModel loadBaseModel(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	if (baseModel.isPresent()) {
		return ModelLoaderRegistry.getModelOrLogError(baseModel.get(), "Couldn't load eval model dependency: " + baseModel.get());
	} else {
		return ModelLoaderRegistry.getMissingModel();
	}
}
 
Example 10
Source File: TexturedItemModel.java    From OpenModsLib with MIT License 5 votes vote down vote up
private static IModel getModel(Optional<ResourceLocation> model) {
	if (model.isPresent()) {
		ResourceLocation location = model.get();
		return ModelLoaderRegistry.getModelOrLogError(location, "Couldn't load base-model dependency: " + location);
	} else {
		return ModelLoaderRegistry.getMissingModel();
	}
}
 
Example 11
Source File: ModelWithDependencies.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final IModel model;
	if (base.isPresent()) {
		model = ModelLoaderRegistry.getModelOrLogError(base.get(), "Couldn't load MultiLayerModel dependency: " + base.get());
	} else {
		model = ModelLoaderRegistry.getMissingModel();
	}

	return model.bake(state, format, bakedTextureGetter);
}
 
Example 12
Source File: GTModelLoader.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation modelLoc) {
	IModel model = modelLookup.get(modelLoc.getResourcePath());
	return model != null ? model : ModelLoaderRegistry.getMissingModel();
}
 
Example 13
Source File: ModelCamouflageBlock.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception
{
    if (modelLocation.equals(LOC_ELEVATOR_NORMAL))
    {
        return new ModelElevator(EnderUtilitiesBlocks.ELEVATOR.getDefaultState(), "_full");
    }
    else if (modelLocation.equals(LOC_ELEVATOR_SLAB_TOP))
    {
        return new ModelElevator(EnderUtilitiesBlocks.ELEVATOR_SLAB.getDefaultState(), "_slab_top");
    }
    else if (modelLocation.equals(LOC_ELEVATOR_SLAB_BOTTOM))
    {
        return new ModelElevator(EnderUtilitiesBlocks.ELEVATOR_SLAB.getDefaultState(), "_slab_bottom");
    }
    else if (modelLocation.equals(LOC_ELEVATOR_LAYER_TOP))
    {
        return new ModelElevator(EnderUtilitiesBlocks.ELEVATOR_LAYER.getDefaultState(), "_layer_top");
    }
    else if (modelLocation.equals(LOC_ELEVATOR_LAYER_BOTTOM))
    {
        return new ModelElevator(EnderUtilitiesBlocks.ELEVATOR_LAYER.getDefaultState(), "_layer_bottom");
    }
    else if (modelLocation.equals(LOC_PORTAL_FRAME))
    {
        return new ModelCamouflageBlockBase(new ResourceLocation("minecraft:block/cube_all"), null);
    }
    else if (modelLocation.equals(LOC_DRAW_BRIDGE_N) || modelLocation.equals(LOC_DRAW_BRIDGE_A))
    {
        ResourceLocation baseModelLocation = new ResourceLocation(Reference.MOD_ID, "block/orientable_directional_individual");
        return new ModelCamouflageBlockBase(baseModelLocation, null);
    }
    else if (modelLocation.equals(LOC_BARREL_NORMAL))
    {
        // The Barrel handles both normal and overlay models with the same custom model
        return new ModelCamouflageBlockBase(ModelLoaderBarrel.LOCATION_NORMAL, ModelLoaderBarrel.LOCATION_NORMAL);
    }
    else if (modelLocation.equals(LOC_BARREL_CREATIVE))
    {
        // The Barrel handles both normal and overlay models with the same custom model
        return new ModelCamouflageBlockBase(ModelLoaderBarrel.LOCATION_CREATIVE, ModelLoaderBarrel.LOCATION_CREATIVE);
    }

    return ModelLoaderRegistry.getMissingModel();
}
 
Example 14
Source File: BakedModelBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private ModelBarrel()
{
    this.baseModel = ModelLoaderRegistry.getMissingModel();
    this.overlayModel = ModelLoaderRegistry.getMissingModel();
    this.textures = ImmutableMap.of();
}