net.minecraftforge.client.model.ModelLoaderRegistry Java Examples

The following examples show how to use net.minecraftforge.client.model.ModelLoaderRegistry. 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: 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 #2
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 #3
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 #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: 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 #6
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 #7
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 #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: 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 #10
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 #11
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 #12
Source File: SurvivalistMod.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void clientSetup(FMLClientSetupEvent event)
{
    ScreenManager.registerFactory(DryingRackContainer.TYPE, DryingRackScreen::new);
    ScreenManager.registerFactory(SawmillContainer.TYPE, SawmillScreen::new);

    ModelLoaderRegistry.registerLoader(location("rack"), DryingRackBakedModel.ModelLoader.INSTANCE);

    //RenderTypeLookup.setRenderLayer(SurvivalistBlocks.RACK.get(), (layer) -> layer == RenderType.getSolid() || layer == RenderType.getCutout());
}
 
Example #13
Source File: OpenClientProxy.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void preInit() {
	ClientCommandHandler.instance.registerCommand(new CommandConfig("om_config_c", false));
	ClientCommandHandler.instance.registerCommand(new CommandSource("om_source_c", false, OpenMods.instance.getCollector()));
	ClientCommandHandler.instance.registerCommand(new CommandGlDebug());

	if (LibConfig.enableCalculatorCommands) {
		final ICommandComponent commandRoot = new CommandCalcFactory(new File(getMinecraftDir(), "scripts")).getRoot();
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "config"));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "eval", "="));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "fun"));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "let"));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "execute"));
	}

	RenderUtils.registerFogUpdater();

	MinecraftForge.EVENT_BUS.register(new BlockSelectionHandler());

	ModelLoaderRegistry.registerLoader(MappedModelLoader.builder()
			.put("with-dependencies", ModelWithDependencies.EMPTY)
			.put("multi-layer", MultiLayerModel.EMPTY)
			.put("variantmodel", VariantModel.EMPTY_MODEL)
			.put("textureditem", TexturedItemModel.INSTANCE)
			.put("stateitem", ItemStateModel.EMPTY)
			.put("eval", EvalModel.EMPTY)
			.put("eval-expand", EvalExpandModel.EMPTY)
			.put("perspective-aware", PerspectiveAwareModel.EMPTY)
			.build(OpenMods.MODID));

	((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(hitboxManager);

	FramebufferBlitter.setup();
}
 
Example #14
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 #15
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 #16
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 #17
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 #18
Source File: ModelFilter.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) {
	IBakedModel whitelist;
	IBakedModel blacklist;
	try {
		whitelist = ModelLoaderRegistry.getModel(whitelistRL).bake(state, format, bakedTextureGetter);
		blacklist = ModelLoaderRegistry.getModel(blacklistRL).bake(state, format, bakedTextureGetter);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	return new BakedModelFilter(whitelist, blacklist);
}
 
Example #19
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 #20
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 #21
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 #22
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void registerBlockModels()
{
    ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.BARREL, new BakedModelBarrel.StateMapper());
    ModelLoaderRegistry.registerLoader(new BakedModelBarrel.ModelLoaderBarrel());

    ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.INSERTER, new BakedModelInserter.StateMapper());
    ModelLoaderRegistry.registerLoader(new BakedModelInserter.ModelLoaderInserter());

    ModelLoaderRegistry.registerLoader(new ModelCamouflageBlock.ModelLoaderCamouflageBlocks());

    ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.ELEVATOR,       (new StateMap.Builder()).ignore(BlockElevator.COLOR).build());
    ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.ELEVATOR_SLAB,  (new StateMap.Builder()).ignore(BlockElevator.COLOR).build());
    ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.ELEVATOR_LAYER, (new StateMap.Builder()).ignore(BlockElevator.COLOR).build());
}
 
Example #23
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void registerAllItemModels()
{
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.ENDER_CAPACITOR);
    registerItemModelWithVariants(EnderUtilitiesItems.ENDER_PART);
    registerItemModelWithVariants(EnderUtilitiesItems.LINK_CRYSTAL);

    registerItemModel(EnderUtilitiesItems.BUILDERS_WAND);
    registerItemModel(EnderUtilitiesItems.CHAIR_WAND);
    registerItemModel(EnderUtilitiesItems.DOLLY);
    registerItemModel(EnderUtilitiesItems.ENDER_ARROW);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.ENDER_BAG);
    registerItemModel(EnderUtilitiesItems.ENDER_BOW);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.ENDER_BUCKET);
    registerItemModel(EnderUtilitiesItems.ENDER_LASSO);
    registerItemModelWithVariants(EnderUtilitiesItems.ENDER_PEARL_REUSABLE);
    registerItemModelWithVariants(EnderUtilitiesItems.ENDER_PORTER);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.ENDER_SWORD);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.ENDER_TOOL);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.HANDY_BAG);
    registerItemModelWithVariants(EnderUtilitiesItems.ICE_MELTER);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.INVENTORY_SWAPPER);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.LIVING_MANIPULATOR);
    registerItemModel(EnderUtilitiesItems.MOB_HARNESS);
    registerItemModelWithNamePrefix(EnderUtilitiesItems.NULLIFIER, 0, "item_");
    registerItemModel(EnderUtilitiesItems.PET_CONTRACT);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.PICKUP_MANAGER);
    registerItemModelWithVariantsAndMeshDefinition(EnderUtilitiesItems.QUICK_STACKER);
    registerItemModel(EnderUtilitiesItems.PORTAL_SCALER);
    registerItemModel(EnderUtilitiesItems.RULER);
    registerItemModelWithVariants(EnderUtilitiesItems.SYRINGE);
    registerItemModelWithNameSuffix(EnderUtilitiesItems.VOID_PICKAXE, 0, "_normal");

    ModelLoaderRegistry.registerLoader(ModelEnderBucket.LoaderEnderBucket.instance);
    ModelLoaderRegistry.registerLoader(ModelEnderTools.LoaderEnderTools.instance);
    ModelLoaderRegistry.registerLoader(new ModelNullifierBaked.ModelLoaderNullifier());
}
 
Example #24
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void replaceSmallVesselModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
	try {
		IModel model = ModelLoaderRegistry.getModel(modelLocation);
		IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
		if(standard instanceof IPerspectiveAwareModel) {
			IBakedModel finalModel = new BakedSmallVesselModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK);

			event.getModelRegistry().putObject(modelVariantLocation, finalModel);
		}

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example #25
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void replacePitKilnModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
	try {
		IModel model = ModelLoaderRegistry.getModel(modelLocation);
		IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
		if(standard instanceof IPerspectiveAwareModel) {
			IBakedModel finalModel = new BakedPitKilnModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK);

			event.getModelRegistry().putObject(modelVariantLocation, finalModel);
		}

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example #26
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void replaceAnvilModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
	try {
		IModel model = ModelLoaderRegistry.getModel(modelLocation);
		IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
		if(standard instanceof IPerspectiveAwareModel) {
			IBakedModel finalModel = new BakedAnvilModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK);

			event.getModelRegistry().putObject(modelVariantLocation, finalModel);
		}

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example #27
Source File: ModelRocket.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
		Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	
	IModel subComponent;
	try {
		subComponent = ModelLoaderRegistry.getModel(resource);
		IBakedModel bakedModelCore = subComponent.bake(state, format, bakedTextureGetter);
		return bakedModelCore;
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
Example #28
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 4 votes vote down vote up
private static IBakedModel bakeModel(ResourceLocation model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	IModel baseModel = ModelLoaderRegistry.getModelOrLogError(model, "Couldn't load MultiLayerModel dependency: " + model);
	return baseModel.bake(new ModelStateComposition(state, baseModel.getDefaultState()), format, bakedTextureGetter);
}
 
Example #29
Source File: OpenClientProxy.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public IAnimationStateMachine loadAsm(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
	return ModelLoaderRegistry.loadASM(location, parameters);
}
 
Example #30
Source File: AnimatedMachineTileBase.java    From EmergingTechnology with MIT License 4 votes vote down vote up
public void initialiseAnimator(MachineTileBase target, String name) {

        subscribe(target);
        asm = isClientForAnimator() ? ModelLoaderRegistry.loadASM(getResourceLocation(name), ImmutableMap.of()) : null;
    }