net.minecraftforge.client.model.IModel Java Examples

The following examples show how to use net.minecraftforge.client.model.IModel. 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: EvalExpandModel.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 IModel model = loadBaseModel(state, format, bakedTextureGetter);

	IBlockState blockState = null;

	if (defaultBlockState.isPresent()) {
		final Block defaultBlock = Block.REGISTRY.getObject(defaultBlockState.get());
		if (defaultBlock != Blocks.AIR) {
			blockState = defaultBlock.getDefaultState();
			if (!(blockState instanceof IExtendedBlockState) ||
					!((IExtendedBlockState)blockState).getUnlistedNames().contains(EvalModelState.PROPERTY)) {
				Log.warn("State %s does not contain eval state property", blockState);
			}
		} else {
			Log.warn("Can't find default block: %s", defaultBlockState.get());
		}
	}

	final IVarExpander expander = evaluatorFactory.createExpander();
	return new BakedEvalExpandModel(model, state, format, bakedTextureGetter, blockState, expander);
}
 
Example #2
Source File: VanillaLoader.java    From VanillaFix with MIT License 6 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
    // Load vanilla model
    ModelBlock vanillaModel;
    ResourceLocation vanillaModelLocation = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath() + ".json");
    try (IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(vanillaModelLocation);
         Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
        vanillaModel = ModelBlock.deserialize(reader);
        vanillaModel.name = modelLocation.toString();
    }

    // Load armature animation (currently disabled for efficiency, see MixinModelBlockAnimation)
    String modelPath = modelLocation.getPath();
    if (modelPath.startsWith("models/")) {
        modelPath = modelPath.substring("models/".length());
    }
    ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json");
    ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(Minecraft.getMinecraft().getResourceManager(), armatureLocation);

    // Return the vanilla model weapped in a VanillaModelWrapper
    return new VanillaModelWrapper(modelLocation, vanillaModel , false, animation);
}
 
Example #3
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 #4
Source File: VariantLoader.java    From VanillaFix with MIT License 6 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
    ModelResourceLocation variant = (ModelResourceLocation) modelLocation;
    ModelBlockDefinition definition = getModelBlockDefinition(variant);

    if (definition.hasVariant(variant.getVariant())) {
        return new WeightedRandomModel(definition.getVariant(variant.getVariant()));
    } else {
        if (definition.hasMultipartData()) {
            Block block = ModelLocationInformation.getBlockFromBlockstateLocation(new ResourceLocation(variant.getNamespace(), variant.getPath()));
            if (block != null) {
                definition.getMultipartData().setStateContainer(block.getBlockState());
            }
        }

        return new MultipartModel(new ResourceLocation(variant.getNamespace(), variant.getPath()), definition.getMultipartData());
    }
}
 
Example #5
Source File: BuiltinLoader.java    From VanillaFix with MIT License 6 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
    String path = modelLocation.getPath();

    if ("builtin/generated".equals(path) || "block/builtin/generated".equals(path) || "item/builtin/generated".equals(path)) { // TODO: why is this necessary?
        return ItemLayerModel.INSTANCE; //new VanillaModelWrapper(modelLocation, MODEL_GENERATED);
    }

    if ("builtin/entity".equals(path)) {
        return new VanillaModelWrapper(modelLocation, MODEL_ENTITY);
    }

    if ("builtin/missing".equals(path)) {
        return WRAPPED_MODEL_MISSING;
    }

    throw new FileNotFoundException(modelLocation.toString());
}
 
Example #6
Source File: EventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
    GibsModelRegistry.onModelBakeEvent(event);

    ResourceLocation modelResourceLocation = new ResourceLocation(ValkyrienSkiesMod.MOD_ID,
        "item/infuser_core_main");
    try {
        IModel model = ModelLoaderRegistry.getModel(modelResourceLocation);
        IBakedModel inventoryModel = model
            .bake(model.getDefaultState(), DefaultVertexFormats.ITEM,
                ModelLoader.defaultTextureGetter());
        IBakedModel handModel = event.getModelRegistry()
            .getObject(new ModelResourceLocation(
                ValkyrienSkiesMod.MOD_ID + ":" + ValkyrienSkiesMod.INSTANCE.physicsCore
                    .getTranslationKey()
                    .substring(5), "inventory"));

        event.getModelRegistry()
            .putObject(
                new ModelResourceLocation(ValkyrienSkiesMod.MOD_ID + ":testmodel", "inventory"),
                new InfuserCoreBakedModel(handModel, inventoryModel));
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example #7
Source File: GibsModelRegistry.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
public static void registerTextures(TextureStitchEvent event) {
    System.out.println(
        "Valkyrien Skies got a register textures pre event! " + NAMES_TO_RESOURCE_LOCATION
            .size());

    for (ResourceLocation location : NAMES_TO_RESOURCE_LOCATION.values()) {
        try {
            // Get the model so that registry will remember to register its textures.
            IModel model = ModelLoaderRegistry.getModel(location);
            Collection<ResourceLocation> resourceLocations = model.getTextures();
            for (ResourceLocation texture : resourceLocations) {
                // Register the found texture into the texture map.
                event.getMap()
                    .registerSprite(texture);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example #8
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 #9
Source File: BakedModelInserter.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 sideModel = null;

    try
    {
        baseModel = ModelLoaderRegistry.getModel(BASE_MODEL);
        sideModel = ModelLoaderRegistry.getModel(SIDE_MODEL);
    }
    catch (Exception e)
    {
        EnderUtilities.logger.warn("Failed to load a model for the Inserter!");
    }

    return new BakedModelInserter(this, baseModel, sideModel, state, format, bakedTextureGetter);
}
 
Example #10
Source File: BakedModelCamouflageBlock.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
public static IBakedModel getRotatedBakedModel(@Nullable IModel model, @Nullable IBakedModel bakedModelDefault, IBlockState state,
        VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    if (model != null)
    {
        if (state.getPropertyKeys().contains(BlockEnderUtilities.FACING))
        {
            return model.bake(TRSRTransformation.from(state.getValue(BlockEnderUtilities.FACING)), format, bakedTextureGetter);
        }
        else if (state.getPropertyKeys().contains(BlockEnderUtilities.FACING_H))
        {
            return model.bake(TRSRTransformation.from(state.getValue(BlockEnderUtilities.FACING_H)), format, bakedTextureGetter);
        }
    }

    return bakedModelDefault;
}
 
Example #11
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 #12
Source File: VariantModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IModel process(ImmutableMap<String, String> customData) {
	final ModelUpdater updater = new ModelUpdater(customData);

	final Optional<ResourceLocation> base = updater.get(KEY_BASE, ModelUpdater.MODEL_LOCATION, this.base);

	VariantModelData modelData = this.modelData;
	if (customData.containsKey(KEY_VARIANTS) || customData.containsKey(KEY_EXPANSIONS)) {
		updater.markChanged();
		Optional<String> variants = Optional.ofNullable(customData.get(KEY_VARIANTS));
		Optional<String> expansions = Optional.ofNullable(customData.get(KEY_EXPANSIONS));
		modelData = modelData.update(variants, expansions);
	}

	return updater.hasChanged()? new VariantModel(base, modelData) : this;
}
 
Example #13
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 #14
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 #15
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 #16
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 #17
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 #18
Source File: TexturedItemOverrides.java    From OpenModsLib with MIT License 5 votes vote down vote up
private IModel getOverrideModel(Optional<ResourceLocation> overrideLocation) {
	if (overrideLocation.isPresent()) {
		final ResourceLocation location = overrideLocation.get();
		return ModelLoaderRegistry.getModelOrLogError(location, "Couldn't load model: " + location);
	} else {
		return texturedModel;
	}
}
 
Example #19
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ModelNullifierBaked(IModel baseModel, IModel lockedModel, IModelState state, VertexFormat format,
        Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    this.modelState = state;
    this.modelBase = baseModel.bake(state, format, bakedTextureGetter);
    this.modelLocked = lockedModel.bake(state, format, bakedTextureGetter);
    this.format = format;
    this.bakedTextureGetter = bakedTextureGetter;
    this.particle = bakedTextureGetter.apply(new ResourceLocation(ModelNullifier.TEX_BASE));
    this.transformMap = PerspectiveMapWrapper.getTransforms(state);
}
 
Example #20
Source File: TexturedItemOverrides.java    From OpenModsLib with MIT License 5 votes vote down vote up
public TexturedItemOverrides(IBakedModel untexturedModel, IModel texturedModel, List<ItemOverride> texturedModelOverrides, Set<String> texturesToReplace, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	super(Lists.reverse(texturedModelOverrides));
	this.untexturedModel = untexturedModel;
	this.texturedModel = texturedModel;
	this.texturesToReplace = ImmutableSet.copyOf(texturesToReplace);
	this.state = state;
	this.format = format;
	this.bakedTextureGetter = bakedTextureGetter;
}
 
Example #21
Source File: BakedModelCamouflageBlock.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BakedModelCamouflageBlock(IModel baseModel, @Nullable IModel overlayModel, ImmutableMap<String, String> textures,
        IModelState modelState, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    this.baseModel = baseModel;
    this.overlayModel = overlayModel;
    this.modelState = modelState;
    this.format = format;
    this.bakedTextureGetter = bakedTextureGetter;
    this.bakedBaseModel = baseModel.bake(modelState, format, bakedTextureGetter);
    this.bakedOverlayModel = overlayModel != null ? overlayModel.bake(modelState, format, bakedTextureGetter) : null;

    this.itemQuads = buildItemModel(this.bakedBaseModel, this.bakedOverlayModel);
}
 
Example #22
Source File: ModelEnderTools.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IModel process(ImmutableMap<String, String> customData)
{
    for (Map.Entry<String, String> entry : customData.entrySet())
    {
        String key = entry.getKey();
        //System.out.printf("customData: %s => %s\n", key, entry.getValue());
        if (key != null && key.startsWith("tr_"))
        {
            moduleTransforms.put(key, entry.getValue());
        }
    }

    String toolClass = customData.get("toolClass");
    boolean broken = (customData.get("broken") != null ? customData.get("broken").equals("true") : false);
    boolean powered = (customData.get("powered") != null ? customData.get("powered").equals("true") : false);
    boolean creative = (customData.get("creative") != null ? customData.get("creative").equals("true") : false);
    int mode = 1;
    int core = 0;
    int capacitor = 0;
    int linkCrystal = 0;

    if (customData.containsKey("mode"))
    {
        try
        {
            mode = Integer.parseInt(customData.get("mode")) + 1;
            core = Integer.parseInt(customData.get("core")) + 1;
            capacitor = Integer.parseInt(customData.get("capacitor")) + 1;
            linkCrystal = Integer.parseInt(customData.get("lc")) + 1;
        }
        catch (NumberFormatException e)
        {
            EnderUtilities.logger.warn("ModelEnderTools: Failed to parse tool/module types");
        }
    }

    return new ModelEnderTools(toolClass, powered, creative, broken, mode, core, capacitor, linkCrystal);
}
 
Example #23
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 #24
Source File: MultipartModel.java    From VanillaFix with MIT License 5 votes vote down vote up
public MultipartModel(ResourceLocation location, Multipart multipart) throws Exception {
    this.location = location;
    this.multipart = multipart;
    ImmutableMap.Builder<Selector, IModel> builder = ImmutableMap.builder();
    for (Selector selector : multipart.getSelectors()) {
        builder.put(selector, new WeightedRandomModel(selector.getVariantList()));
    }
    partModels = builder.build();
}
 
Example #25
Source File: EvalModel.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 = loadBaseModel(state, format, bakedTextureGetter);

	final ITransformEvaluator evaluator = evaluatorFactory.createEvaluator(c -> model.getClip(c));
	return new BakedEvalModel(model, state, format, bakedTextureGetter, evaluator);
}
 
Example #26
Source File: ModelWithDependencies.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public IModel process(ImmutableMap<String, String> customData) {
	final ModelUpdater updater = new ModelUpdater(customData);

	final Optional<ResourceLocation> base = updater.get("base", ModelUpdater.MODEL_LOCATION, this.base);
	final Set<ResourceLocation> dependencies = updater.get("dependencies", ModelUpdater.MODEL_LOCATION, this.dependencies);

	return updater.hasChanged()? new ModelWithDependencies(base, dependencies, this.textures) : this;
}
 
Example #27
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 #28
Source File: ProxyClient.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static IModel getModel(ResourceLocation location) {
	try {
		IModel model = ModelLoaderRegistry.getModel(location);
		if (model == null) WearableBackpacks.LOG.error(
			"Model " + location + " is missing! THIS WILL CAUSE A CRASH!");
		return model;
	} catch (Exception e) { e.printStackTrace(); return null; }
}
 
Example #29
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nullable
private IModel getItemModel(ItemStack stack)
{
    // Unfortunately this can't be done before the init phase...
    this.reflectMaps();

    Item item = stack.getItem();
    ModelResourceLocation mrl = null;
    Int2ObjectMap<ModelResourceLocation> map = LOCATIONS.get(item.delegate);

    if (map != null)
    {
        mrl = map.get(stack.getMetadata());
    }

    if (mrl == null)
    {
        ItemMeshDefinition mesh = SHAPERS.get(item);

        if (mesh != null)
        {
            mrl = mesh.getModelLocation(stack);
        }
    }

    if (mrl != null)
    {
        try
        {
            return ModelLoaderRegistry.getModel(mrl);
        }
        catch (Exception e)
        {
            return STATE_MODELS.get(mrl);
        }
    }

    return null;
}
 
Example #30
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());
}