Java 类net.minecraftforge.client.model.ModelLoaderRegistry 实例源码

项目:chesttransporter    文件:ModelCT.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    try
    {
        IModel sub = ModelLoaderRegistry.getModel(handle);
        IBakedModel baked = sub.bake(state, format, bakedTextureGetter);

        return new BakedModelCH(baked, ModelRegistry.getInstance().bake(state, format, bakedTextureGetter));
    } catch (Exception e)
    {
        e.printStackTrace();
    }

    return ModelLoaderRegistry.getMissingModel().bake(state, format, bakedTextureGetter);
}
项目:Adventurers-Toolbox    文件:ClientProxy.java   
@Override
public void preInit(FMLPreInitializationEvent event) {
    super.preInit(event);
    ModelLoaderRegistry.registerLoader(ToolHeadModel.LoaderToolHead.INSTANCE);

    ModelLoaderRegistry.registerLoader(PickaxeModel.LoaderPickaxe.INSTANCE);
    ModelLoaderRegistry.registerLoader(AxeModel.LoaderAxe.INSTANCE);
    ModelLoaderRegistry.registerLoader(ShovelModel.LoaderShovel.INSTANCE);
    ModelLoaderRegistry.registerLoader(HoeModel.LoaderHoe.INSTANCE);
    ModelLoaderRegistry.registerLoader(HandpickModel.LoaderHandpick.INSTANCE);
    ModelLoaderRegistry.registerLoader(HammerModel.LoaderHammer.INSTANCE);

    ModelLoaderRegistry.registerLoader(SwordModel.LoaderSword.INSTANCE);
    ModelLoaderRegistry.registerLoader(DaggerModel.LoaderDagger.INSTANCE);
    ModelLoaderRegistry.registerLoader(MaceModel.LoaderMace.INSTANCE);

    ModEntities.initRenderers();
}
项目:CustomWorldGen    文件:Clips.java   
/**
 * Retrieves the clip from the model.
 */
@SideOnly(Side.CLIENT)
public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName)
{
    IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
    if(model instanceof IAnimatedModel)
    {
        Optional<? extends IClip> clip = ((IAnimatedModel)model).getClip(clipName);
        if(clip.isPresent())
        {
            return new ModelClip(clip.get(), modelLocation, clipName);
        }
        FMLLog.getLogger().error("Unable to find clip " + clipName + " in the model " + modelLocation);
    }
    // FIXME: missing clip?
    return new ModelClip(IdentityClip.INSTANCE, modelLocation, clipName);
}
项目:CrystalMod    文件:ClientProxy.java   
@Override
public void preInit(FMLPreInitializationEvent e) {
    super.preInit(e);
    ModItems.initClient();
    ModelLoaderRegistry.registerLoader(new BakedModelLoader());
    ModelLoaderRegistry.registerLoader(ModelSeed.LoaderSeeds.INSTANCE);
    ModelLoaderRegistry.registerLoader(ModelWrappedFood.LoaderWrappedFood.INSTANCE);
    IResourceManager manager = FMLClientHandler.instance().getClient().getResourceManager();
    if(manager !=null && manager instanceof IReloadableResourceManager){
        ((IReloadableResourceManager)manager).registerReloadListener(new GuidePageLoader());
        ((IReloadableResourceManager)manager).registerReloadListener(this);
    }
    MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
    MinecraftForge.EVENT_BUS.register(new DisguiseClientHandler());
    ModBlocks.initClient();
    ModEntites.initClient();
    OBJLoader.INSTANCE.addDomain(CrystalMod.MODID);
}
项目:TombManyGraves    文件:TombManyGravesClientEvents.java   
@SubscribeEvent
public void onModelBake(ModelBakeEvent event)
{
    try
    {
        IModel model = ModelLoaderRegistry.getModel(MODEL_grave);
        if (model instanceof IRetexturableModel)
        {
            IRetexturableModel graveModel = (IRetexturableModel) model;
            IBakedModel standard = event.getModelRegistry().getObject(locGrave);
            IBakedModel finalModel = new GoodGraveModel(standard, graveModel);
            event.getModelRegistry().putObject(locGrave, finalModel);
        }
    } catch (Exception e)
    {
        e.printStackTrace();
    }
}
项目:Qbar    文件:RetexturedOBJModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
                        Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    try
    {
        IModel model = ModelLoaderRegistry.getModel(sourceModel);
        if (model instanceof QBarOBJModel)
        {
            model = ((QBarOBJModel) model).retexture(replacedTextures);

            return model.bake(state, format, bakedTextureGetter);
        }
    } catch (Exception e)
    {
        throw new RuntimeException(e);
    }
    return null;
}
项目:Qbar    文件:ClientProxy.java   
@Override
public void preInit(final FMLPreInitializationEvent e)
{
    OBJLoader.INSTANCE.addDomain(QBarConstants.MODID);
    ModelLoaderRegistry.registerLoader(QBarOBJLoader.INSTANCE);
    QBarOBJLoader.INSTANCE.addDomain(QBarConstants.MODID);

    MinecraftForge.EVENT_BUS.register(this);
    super.preInit(e);

    QBarOBJLoader.INSTANCE.addRetexturedModel("_belt_animated.mwm",
            new ResourceLocation(QBarConstants.MODID + ":block/belt.mwm"), new String[]{"Top"},
            new String[]{"qbar:blocks/belt_top_anim"});
    QBarOBJLoader.INSTANCE.addRetexturedModel("_belt_slope_animated.mwm",
            new ResourceLocation(QBarConstants.MODID + ":block/belt_slope.mwm"), new String[]{"None"},
            new String[]{"qbar:blocks/belt_slope_anim"});
    QBarOBJLoader.INSTANCE.addRetexturedModel("_belt_slope2_animated.mwm",
            new ResourceLocation(QBarConstants.MODID + ":block/belt_slope2.mwm"), new String[]{"None"},
            new String[]{"qbar:blocks/belt_slope_anim"});

    ClientProxy.registerFluidsClient();
    MinecraftForge.EVENT_BUS.register(new ClientTickHandler());

    QBarItems.ITEMS.stream().filter(item -> item instanceof IItemModelProvider)
            .forEach(item -> ((IItemModelProvider) item).registerVariants());
}
项目:CommonUtils    文件:ModelBakerBase.java   
protected IModel getModel(ResourceLocation modelLoc, ResourceLocation fallback) {
    try {
        return ModelLoaderRegistry.getModel(modelLoc);
    } catch (Exception e) {
        if (fallback != null) {
            try {
                return ModelLoaderRegistry.getModel(fallback);
            } catch (Exception e2) {
                logger.warn("Could not find model {} or fallback {}", modelLoc, fallback);
                return ModelLoaderRegistry.getMissingModel();
            }
        }
        logger.warn("Could not find model {}", modelLoc);
        return ModelLoaderRegistry.getMissingModel();
    }
}
项目:CodeChickenLib    文件:CCFinalMultiVariant.java   
@Override
public IModel process(IModel base) {
    boolean hasBase = base != ModelLoaderRegistry.getMissingModel();
    if (hasBase) {
        base = baseVariant.process(base);
    }

    List<IModel> subModels = new LinkedList<>();
    for (Variant variant : finalVariants) {
        if (!variant.getModelLocation().equals(new ResourceLocation("builtin/missing"))) {
            IModel subModel = ModelLoaderRegistry.getModelOrLogError(variant.getModelLocation(), "Unable to load subModel's Model: " + variant.getModelLocation());
            subModels.add(variant.process(new StateOverrideIModel(subModel, variant.getState())));
        }
    }

    return new CCMultiModel(hasBase ? base : null, baseProperties, subModels);
}
项目:Cyclic    文件:BaseTESR.java   
protected IBakedModel getBakedModel() {
  // Since we cannot bake in preInit() we do lazy baking of the model as soon as we need it
  if (bakedModel == null && resource != null) {
    try {
      model = ModelLoaderRegistry.getModel(new ResourceLocation(Const.MODID, resource));
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
    bakedModel = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM,
        new Function<ResourceLocation, TextureAtlasSprite>() {
          @Override
          public TextureAtlasSprite apply(ResourceLocation location) {
            return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
          }
        });
  }
  return bakedModel;
}
项目:enderutilities    文件:BakedModelInserter.java   
@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);
}
项目:enderutilities    文件:ModelCamouflageBlock.java   
protected ModelCamouflageBlockBase(ResourceLocation baseModelLocation, @Nullable ResourceLocation overlayModelLocation)
{
    this.baseModelLocation = baseModelLocation;
    this.overlayModelLocation = overlayModelLocation;
    this.textures = ImmutableMap.of();

    IModel baseModel    = ModelLoaderRegistry.getMissingModel();
    IModel overlayModel = null;

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

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

    this.baseModel = baseModel;
    this.overlayModel = overlayModel;
}
项目:enderutilities    文件:BakedModelBarrel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    IModel baseModel = null;

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

    return new BakedModelBarrel(this, baseModel, state, format, bakedTextureGetter);
}
项目:enderutilities    文件:ModelNullifierBaked.java   
@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);
}
项目:OpenBlocks    文件:TileEntityGuideRenderer.java   
@SubscribeEvent
public void onModelBake(ModelBakeEvent evt) {
    final IModel model = ModelLoaderRegistry.getModelOrMissing(MARKER_MODEL_LOCATION);

    final TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks();
    final IBakedModel bakedModel = model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM,
            input -> textureMapBlocks.getAtlasSprite(input.toString()));

    renderer.onModelBake(() -> {
        final Tessellator tessellator = Tessellator.getInstance();

        BufferBuilder vertexBuffer = tessellator.getBuffer();
        vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);

        for (EnumFacing enumfacing : EnumFacing.values())
            renderQuads(vertexBuffer, bakedModel.getQuads(null, enumfacing, 0L));

        renderQuads(vertexBuffer, bakedModel.getQuads(null, null, 0L));

        vertexBuffer.finishDrawing();

        return vertexBuffer;
    });
}
项目:OpenModsLib    文件:VariantModel.java   
@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));
}
项目:OpenModsLib    文件:MultiLayerModel.java   
@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));
}
项目:OpenModsLib    文件:ItemStateModel.java   
@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);
}
项目:OpenModsLib    文件:PerspectiveAwareModel.java   
@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));
}
项目:EnderIO    文件:PaintRegistry.java   
@SubscribeEvent()
@SideOnly(Side.CLIENT)
public void bakeModels(ModelBakeEvent event) {
  cache.clear();

  for (Entry<String, Pair<ResourceLocation, PaintMode>> entry : modelLocations.entrySet()) {
    try {
      ResourceLocation resourceLocation = entry.getValue().getLeft();
      if (resourceLocation != null) {
        IModel model = ModelLoaderRegistry.getModel(resourceLocation);
        models.put(entry.getKey(), model);
      } else {
        models.put(entry.getKey(), ModelLoaderRegistry.getMissingModel());
      }
    } catch (Exception e) {
      Log.warn("Model '" + entry.getValue() + "' failed to load: " + e);
    }
  }
}
项目:genera    文件:ModelHandle.java   
private static IBakedModel loadModel(ModelHandle handle)
{
    IBakedModel model = loadedModels.get(handle.getKey());
    if (model != null)
        return model;

    try
    {
        IModel mod = ModelLoaderRegistry.getModel(handle.getModel());
        if (handle.getTextureReplacements().size() > 0)
        {
            mod = mod.retexture(ImmutableMap.copyOf(handle.getTextureReplacements()));
        }
        if (handle.uvLocked())
        {
            mod = mod.uvlock(true);
        }
        IModelState state = handle.getState();
        if (state == null) state = mod.getDefaultState();
        model = mod.bake(state, handle.getVertexFormat(), ModelLoader.defaultTextureGetter());
        loadedModels.put(handle.getKey(), model);
        return model;
    }
    catch (Exception e)
    {
        throw new ReportedException(new CrashReport("Error loading custom model " + handle.getModel(), e));
    }
}
项目:harshencastle    文件:HarshenClientUtils.java   
public static IBakedModel getModel(ResourceLocation resourceLocation) 
{
    IBakedModel bakedModel;
    IModel model;
    try {
        model = ModelLoaderRegistry.getModel(resourceLocation);
    } catch (Exception e) {
         throw new RuntimeException(e);
    }
    bakedModel = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK,
            location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString()));
    return bakedModel;
}
项目:RunicArcana    文件:DustModelHandler.java   
public static IBakedModel getBakedModel(String modelLocation){

        IModel model;
        try {
            model = ModelLoaderRegistry.getModel(new ResourceLocation(RunicArcana.MOD_ID, modelLocation));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        IBakedModel bakedModel = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, DustModelHandler::textureGetter);

        return bakedModel;
    }
项目:Etheric    文件:PipeModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
        Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    IBakedModel[] connections = new IBakedModel[6];
    IBakedModel[] endings = new IBakedModel[6];
    IBakedModel[] nodeSides = new IBakedModel[6];
    //IBakedModel node = null;

    // d u n s w e
    ModelRotation[] rotations = new ModelRotation[] { ModelRotation.X90_Y0, ModelRotation.X270_Y0,
            ModelRotation.X0_Y0, ModelRotation.X0_Y180, ModelRotation.X0_Y270, ModelRotation.X0_Y90 };

    try {
        IModel nodeSideModel = ModelLoaderRegistry.getModel(new ResourceLocation(Etheric.MODID, "block/pipe_node_side"));
        IModel connectionModel = ModelLoaderRegistry
                .getModel(new ResourceLocation(Etheric.MODID, "block/pipe_connection"));
        IModel endingModel = ModelLoaderRegistry.getModel(new ResourceLocation(Etheric.MODID, "block/pipe_end"));

        //node = nodeModel.bake(new TRSRTransformation(ModelRotation.X0_Y0), DefaultVertexFormats.BLOCK,
        //      ModelLoader.defaultTextureGetter());
        for (int i = 0; i < connections.length; i++) {
            connections[i] = connectionModel.bake(new TRSRTransformation(rotations[i]), DefaultVertexFormats.BLOCK,
                    ModelLoader.defaultTextureGetter());
            endings[i] = endingModel.bake(new TRSRTransformation(rotations[i]), DefaultVertexFormats.BLOCK,
                    ModelLoader.defaultTextureGetter());
            nodeSides[i] = nodeSideModel.bake(new TRSRTransformation(rotations[i]), DefaultVertexFormats.BLOCK,
                    ModelLoader.defaultTextureGetter());
        }
    } catch (Exception e) {
        Etheric.logger.warn(e.getMessage());
    }

    if (connections[0] == null) {
        return ModelLoaderRegistry.getMissingModel().bake(state, format, bakedTextureGetter);
    }
    return new BakedPipeModel(nodeSides, connections, endings);
}
项目:Etheric    文件:RenderUtil.java   
@SubscribeEvent
   public static void setupModels(ModelBakeEvent event) {
    try {
        lodestone_sliver = ModelLoaderRegistry.getModel(new ResourceLocation(Etheric.MODID, "item/lodestone_sliver")).bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
    } catch (Exception e) {
        Etheric.logger.error("Error loading seeing stone submodel", e);
        lodestone_sliver = ModelLoaderRegistry.getMissingModel().bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
    }
}
项目:chesttransporter    文件:ModelRegistry.java   
public Map<ResourceLocation, IBakedModel> bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) throws Exception
{
    Map<ResourceLocation, IBakedModel> ret = Maps.newHashMap();

    for (TransportableChest chest : ChestRegistry.getChests())
    {
        for (ResourceLocation location : chest.getChestModels())
        {
            IModel model = ModelLoaderRegistry.getModel(location);
            ret.put(location, model.bake(state, format, bakedTextureGetter));
        }
    }

    return ret;
}
项目:Solar    文件:ClientProxy.java   
@Override
public void preInit(FMLPreInitializationEvent event) {
    registerResourceReloadListener(SpriteManager.INSTANCE);
    registerResourceReloadListener(ShaderManager.INSTANCE);
    ModelLoaderRegistry.registerLoader(new DummyModelLoader());
    ModRenders.preInit();
}
项目:Solar    文件:TilePhenomena.java   
public TilePhenomena() {
    if(FMLCommonHandler.instance().getSide() == Side.CLIENT) {
        animation = ModelLoaderRegistry.loadASM(ASM, ImmutableMap.of());
    } else {
        animation = null;
    }
}
项目:BetterWithAddons    文件:ToolShardModelHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
@SideOnly(Side.CLIENT)
public void onModelBake(ModelBakeEvent event)
{
    if(!InteractionBWA.ARMOR_SHARD_RENDER)
        return;

    for (Item item : Item.REGISTRY) {
        if (!ItemUtil.isTool(item)) continue;
        for (String s : getVariantNames(event.getModelLoader(), item)) {
            ResourceLocation file = getItemLocation(s);
            ModelResourceLocation memory = ModelLoader.getInventoryVariant(s);
            IModel model = null;
            try {
                model = ModelLoaderRegistry.getModel(file);
            } catch (Exception e) {
                try {
                    model = ModelLoaderRegistry.getModel(memory);
                } catch (Exception e1) {
                    //e1.printStackTrace();
                }
            }
            if(model == null) continue;
            IModel brokenmodel = new ModelToolShardInner(ImmutableList.copyOf(model.getTextures()));
            IBakedModel bakedbrokenmodel = brokenmodel.bake(brokenmodel.getDefaultState(), DefaultVertexFormats.ITEM, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString()));
            ToolShardOverrideHandler.INSTANCE.addModel(item,bakedbrokenmodel);
        }
    }
}
项目:BetterWithAddons    文件:ItemModels.java   
public static void register()
{
    ModBlocks.LIST.forEach(ItemModels::registerBlock);
    ModItems.LIST.forEach(ItemModels::registerItem);

    ModelLoaderRegistry.registerLoader(ModelToolShard.LoaderToolShard.INSTANCE);
}
项目:Thelta    文件:ClientContext.java   
public IModel loadModel(ResourceLocation location) {
    assertState(ContextState.LoadingModels);
    try {
        return ModelLoaderRegistry.getModel(location);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:Thelta    文件:AutoModel.java   
public void loadModelAndBake() {
    try {
        model = ModelLoaderRegistry.getModel(new ResourceLocation(objPath));
        if (flipV)
            model = model.process(ImmutableMap.<String, String>builder().put("flip-v", "true").build());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    bakedModel = model.bake(transformation, DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
}
项目:Wizardry    文件:TileJarRenderer.java   
@SuppressWarnings("unused")
private void getBakedModels() {
    IModel model = null;
    if (modelJar == null) {
        try {
            model = ModelLoaderRegistry.getModel(new ResourceLocation(Wizardry.MODID, "block/jar"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        modelJar = model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM,
                location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString()));
    }
}
项目:Qbar    文件:RetexturedOBJModel.java   
@Override
public Collection<ResourceLocation> getTextures()
{
    try
    {
        List<ResourceLocation> ret = new ArrayList<>(ModelLoaderRegistry.getModel(sourceModel).getTextures());
        for (String tex : replacedTextures.values())
            ret.add(new ResourceLocation(tex));
        return ret;
    } catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
项目:CodeChickenLib    文件:CCFinalVariant.java   
@Override
public IModel process(IModel base) {

    boolean hasBase = base != ModelLoaderRegistry.getMissingModel();

    if (hasBase) {
        base = base.retexture(textures).smoothLighting(smooth).gui3d(gui3d).uvlock(isUvLock()).process(customData);
    }

    return base;
}
项目:CodeChickenLib    文件:CCModelCube.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {

    Map<BlockRenderLayer, IBakedModel> layerModelMap = new HashMap<>();
    TextureAtlasSprite particle = TextureUtils.getMissingSprite();
    for (Entry<BlockRenderLayer, Map<EnumFacing, String>> layerEntry : layerFaceSpriteMap.entrySet()) {
        Map<String, String> kvTextures = new HashMap<>();
        for (Entry<EnumFacing, String> faceEntry : layerEntry.getValue().entrySet()) {
            if (faceEntry.getKey() == null) {
                kvTextures.put("particle", faceEntry.getValue());
            } else {
                kvTextures.put(faceEntry.getKey().getName(), faceEntry.getValue());
            }
        }
        IModel vanillaModel = ModelLoaderRegistry.getModelOrLogError(new ResourceLocation("minecraft:block/cube"), "Unable to get vanilla model wrapper..");
        vanillaModel = vanillaModel.retexture(ImmutableMap.copyOf(addMissing(kvTextures)));
        IBakedModel model = vanillaModel.bake(state, format, bakedTextureGetter);

        if (layerEntry.getKey() == BlockRenderLayer.SOLID) {
            particle = model.getParticleTexture();
        }

        layerModelMap.put(layerEntry.getKey(), model);
    }

    ModelProperties.Builder builder = ModelProperties.builder();
    builder.withAO(isAO).withGui3D(gui3d);
    builder.withParticle(particle);

    return new PerspectiveAwareLayeredModelWrapper(layerModelMap, builder.withState(state).build());
}
项目:CodeChickenLib    文件:ProxyClient.java   
@Override
public void preInit() {
    super.preInit();

    OpenGLUtils.loadCaps();
    CustomParticleHandler.init();
    CCBlockStateLoader.initialize();
    ModelBakery.init();
    CCRenderEventHandler.init();

    MinecraftForge.EVENT_BUS.register(new TextureUtils());
    MinecraftForge.EVENT_BUS.register(new MapRenderRegistry());
    MinecraftForge.EVENT_BUS.register(new ModelRegistryHelper());

    ModelLoaderRegistry.registerLoader(CCCubeLoader.INSTANCE);
    ModelLoaderRegistry.registerLoader(CCBakeryModelLoader.INSTANCE);

    PacketCustom.assignHandler(PacketDispatcher.NET_CHANNEL, new ClientPacketHandler());

    ClientCommandHandler.instance.registerCommand(new DumpModelLocationsCommand());
    ClientCommandHandler.instance.registerCommand(new NukeCCModelCacheCommand());
    ClientCommandHandler.instance.registerCommand(new DumpItemInfoCommand());

    RenderingRegistry.registerEntityRenderingHandler(DummyEntity.class, manager -> {
        sanitizeEntityRenderers(manager);
        return new Render<DummyEntity>(manager) {
            @Override
            protected ResourceLocation getEntityTexture(DummyEntity entity) {
                return null;
            }
        };
    });
}
项目:Toms-Mod    文件:TomsModUtils.java   
@SideOnly(Side.CLIENT)
public static IModel getModelOBJ(ResourceLocation loc) {
    if (!EventHandlerClient.models.containsKey(loc)) {
        IModel model = null;
        try {
            model = OBJLoader.INSTANCE.loadModel(loc);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (model == null)
            model = ModelLoaderRegistry.getMissingModel();
        EventHandlerClient.models.put(loc, model);
    }
    return EventHandlerClient.models.get(loc);
}
项目:Toms-Mod    文件:TomsModUtils.java   
@SideOnly(Side.CLIENT)
public static IModel getModelJSON(ResourceLocation loc) {
    if (!EventHandlerClient.models.containsKey(loc)) {
        IModel model = null;
        try {
            model = ModelLoaderRegistry.getModel(loc);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (model == null)
            model = ModelLoaderRegistry.getMissingModel();
        EventHandlerClient.models.put(loc, model);
    }
    return EventHandlerClient.models.get(loc);
}
项目:geomastery    文件:RenderBeamThick.java   
/** @return A model whose location begins with "jjmod:block/beam/". */
protected static IModel model(String beam) {

    return ModelLoaderRegistry.getModelOrLogError(new ResourceLocation(
            Geomastery.MODID, "block/beam/" + beam),
            "Error loading model for delayed multipart thick beam!");
}