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

项目: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);
}
项目: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    文件:RenderTileCrystalCluster.java   
public static IBakedModel getBakedCluster(){
    if(bakedCluster == null){
        IModel model;
        try {
            model = OBJLoader.INSTANCE.loadModel(CrystalMod.resourceL("models/block/obj/cluster.obj"));
            Function<ResourceLocation, TextureAtlasSprite> textureGetter;
            textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
            {
                @Override
                public TextureAtlasSprite apply(ResourceLocation location)
                {
                    return RenderUtil.getSprite(location);
                }
            };

            bakedCluster = model.bake(new SimpleModelState(DynamicBaseModel.DEFAULT_PERSPECTIVE_TRANSFORMS), DefaultVertexFormats.BLOCK, textureGetter);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return bakedCluster;
}
项目:TombManyGraves    文件:GoodGraveModel.java   
protected  IBakedModel getActualModel(String texture)
{
    IBakedModel bakedModel = standard;

    if (texture!=null)
    {
        if (cache.containsKey(texture))
        {
            bakedModel = cache.get(texture);
        }
        else if (retexturableModel != null)
        {
            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
            builder.put("bottom", texture);
            builder.put("top", texture);
            builder.put("side", texture);
            IModel retexturedModel = retexturableModel.retexture(builder.build());
            bakedModel = retexturedModel.bake(TRSRTransformation.identity(), Attributes.DEFAULT_BAKED_FORMAT, ModelLoader.defaultTextureGetter());
            cache.put(texture, bakedModel);
        }
    }

    return bakedModel;
}
项目: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;
}
项目: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);
}
项目:Toms-Mod    文件:ModelledItemModel.java   
@SuppressWarnings("unchecked")
@Override
public Collection<ResourceLocation> getTextures() {
    normalModels.clear();
    Set<ResourceLocation> textures = Sets.newHashSet();
    for (Entry<ResourceLocation, Integer> e : item.LOCATION_TO_META.entrySet()) {
        ResourceLocation loc = e.getKey();
        if (item.OVERRIDES.containsKey(e.getKey())) {
            ResourceLocation[][] o = item.OVERRIDES.get(e.getKey());
            textures.addAll(Arrays.asList(o[1]));
            loc = o[0][0];
        }
        if (!normalModels.containsKey(loc)) {
            normalModels.put(loc, getModel(loc));
        }
        IModel model = normalModels.get(loc);
        textures.addAll(model.getTextures().stream().filter(l -> !l.getResourcePath().startsWith("texture")).collect(Collectors.toSet()));
    }
    return textures;
}
项目:Toms-Mod    文件:TerminalBlockModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    CustomModelLoader.log.info("Baking " + nameN + " Model...");
    IBlockState s = block.getDefaultState();
    TerminalBakedModel.Builder builder = new Builder(bakedTextureGetter.apply(new ResourceLocation(hasFront ? imgLoc + "Front" : "tomsmodstorage:blocks/terminalFront")), block);
    ResourceLocation base = new ResourceLocation("tomsmodstorage:block/" + block.getUnlocalizedName().substring(8, block.getUnlocalizedName().length() - 6) + "_base");
    ResourceLocation front = new ResourceLocation("tomsmodstorage:block/terminalFront");
    ResourceLocation terminalItemTransformsL = new ResourceLocation("tomsmodstorage:block/terminalitemtransforms");
    IModel modelFront = getModel(front);
    IModel terminalItemTransforms = getModel(terminalItemTransformsL);
    TextureInjector injectorFront = new TextureInjector(bakedTextureGetter, hasFront ? imgLoc + "Front" : "tomsmodstorage:blocks/terminalFront");
    TextureInjector injectorFrontP = new TextureInjector(bakedTextureGetter, hasFront ? imgLoc + "FrontP" : "tomsmodstorage:blocks/terminalFrontP");
    TextureInjector injectorFrontOn = new TextureInjector(bakedTextureGetter, hasFront ? imgLoc + "FrontOn" : "tomsmodstorage:blocks/terminalFrontOn");
    builder.setItemCameraTransformsModel(terminalItemTransforms.bake(state, format, bakedTextureGetter));
    // load(null, builder, modelBase, modelFront, bakedTextureGetter,
    // injectorFront, injectorFrontOn, format, s);
    for (int ss = 0;ss < block.getStates();ss++) {
        for (int i = 0;i < TileEntityBasicTerminal.TerminalState.VALUES.length;i++) {
            TileEntityBasicTerminal.TerminalState termState = TileEntityBasicTerminal.TerminalState.VALUES[i];
            load(termState, builder, base, modelFront, bakedTextureGetter, injectorFront, injectorFrontP, injectorFrontOn, format, s, ss);
        }
    }
    TerminalBakedModel model = builder.makeModel();
    CustomModelLoader.log.info(nameN + " Model Baking Complete.");
    return model;
}
项目:geomastery    文件:RenderWallComplex.java   
@Override
public IModel getConnectedSide(boolean isTop,
        boolean isBottom, boolean isDouble) {

    if (!isDouble) {

        return isBottom ? isTop ? this.singleSideLone :
                this.singleSideBottom : isTop ?
                this.singleSideTop : this.singleSideMiddle;

    } else {

        return isBottom ? isTop ? this.doubleSideLone :
                this.doubleSideBottom : isTop ?
                this.doubleSideTop : this.doubleSideMiddle;
    }
}
项目:geomastery    文件:RenderWallComplex.java   
/** @return Model for this wall's post with given properties. */
protected IModel getPostModel(boolean isTop, boolean isBottom,
        boolean isDouble) {

    if (!isDouble) {

        return isBottom ? isTop ? this.singlePostLone :
                this.singlePostBottom : isTop ?
                this.singlePostTop : this.singlePostMiddle;

    } else {

        return isBottom ? isTop ? this.doublePostLone :
                this.doublePostBottom : isTop ?
                this.doublePostTop : this.doublePostMiddle;
    }
}
项目:ARKCraft    文件:ModelCable.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
        Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    ARKCraft.logger.info("Baking Cable Model");
    ResourceLocation noc = new ResourceLocation("arkcraft:block/cable_noc");
    ResourceLocation center = new ResourceLocation("arkcraft:block/cable_base");
    ResourceLocation connection = new ResourceLocation("arkcraft:block/cable_c");
    ResourceLocation vertical = new ResourceLocation("arkcraft:block/cable_v");
    ResourceLocation centerP = new ResourceLocation("arkcraft:block/cable_base_powered");
    ResourceLocation connectionP = new ResourceLocation("arkcraft:block/cable_c_powered");
    ResourceLocation verticalP = new ResourceLocation("arkcraft:block/cable_v_powered");
    IBakedModel[] connections = new IBakedModel[4];
    IBakedModel[] connectionsP = new IBakedModel[4];
    IModel modelConnection = getModel(connection);
    IModel modelConnectionP = getModel(connectionP);
    for(EnumFacing f : EnumFacing.HORIZONTALS){
        connections[f.ordinal() - 2] = modelConnection.bake(new TRSRTransformation(getMatrix(f)), format, bakedTextureGetter);
        connectionsP[f.ordinal() - 2] = modelConnectionP.bake(new TRSRTransformation(getMatrix(f)), format, bakedTextureGetter);
    }
    return new BakedCableModel(getModel(noc).bake(state, format, bakedTextureGetter),
            new IBakedModel[]{getModel(center).bake(state, format, bakedTextureGetter), getModel(centerP).bake(state, format, bakedTextureGetter)},
            new IBakedModel[][]{connections, connectionsP},
            new IBakedModel[]{getModel(vertical).bake(state, format, bakedTextureGetter), getModel(verticalP).bake(state, format, bakedTextureGetter)});
}
项目:Factorization    文件:FzModel.java   
@SubscribeEvent
public void bakeModels(TextureStitchEvent.Post event) {
    final TextureMap map = event.map;
    Function<ResourceLocation,TextureAtlasSprite> lookup = new Function<ResourceLocation, TextureAtlasSprite>() {
        @Nullable
        @Override
        public TextureAtlasSprite apply(@Nullable ResourceLocation input) {
            if (input == null) return map.getAtlasSprite(null);
            return map.getAtlasSprite(input.toString());
        }
    };
    for (FzModel fzm : instances) {
        IModel rawModel = raws.get(fzm);
        if (rawModel == null) {
            fzm.model = null;
            continue;
        }
        fzm.model = rawModel.bake(fzm.trsrt, fzm.getFormat(), lookup);
    }
    raws.clear();
}
项目: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    文件:PipeModel.java   
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
    if (model == null) {
        model = new PipeModel();
    }
    return model;
}
项目: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;
}
项目:Adventurers-Toolbox    文件:BakedToolModel.java   
public BakedToolModel(IModel parent, ImmutableList<BakedQuad> quads, VertexFormat format,
        ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms,
        Map<String, IBakedModel> cache) {
    this.quads = quads;
    this.format = format;
    this.parent = parent;
    this.transforms = itemTransforms();
    this.cache = cache;
}
项目:Adventurers-Toolbox    文件:MaceModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.mace) {
        return originalModel;
    }

    BakedMaceModel model = (BakedMaceModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:DaggerModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.dagger) {
        return originalModel;
    }

    BakedDaggerModel model = (BakedDaggerModel) originalModel;

    String key = IBladeTool.getBladeMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("blade", IBladeTool.getBladeMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:HoeModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.hoe) {
        return originalModel;
    }

    BakedHoeModel model = (BakedHoeModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:PickaxeModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.pickaxe) {
        return originalModel;
    }

    BakedPickaxeModel model = (BakedPickaxeModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:AxeModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.axe) {
        return originalModel;
    }

    BakedAxeModel model = (BakedAxeModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:HammerModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.hammer) {
        return originalModel;
    }

    BakedHammerModel model = (BakedHammerModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:ShovelModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.shovel) {
        return originalModel;
    }

    BakedShovelModel model = (BakedShovelModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:ToolHeadModel.java   
@Override
public IModel loadModel(ResourceLocation modelLocation) {
    String path = modelLocation.getResourcePath().substring(3);
    int index = path.indexOf('_');
    if(path.charAt(0) == 'c') index = path.indexOf('_', index + 1);
    String toolName = path.substring(0, index);
    path = path.substring(index + 1);
    index = path.indexOf('_');
    String partName = path.substring(0, index);
    path = path.substring(index + 1);
    String matName = path;

    return new ToolHeadModel(modelLocation.getResourceDomain(), toolName, partName, matName);
}
项目:Adventurers-Toolbox    文件:SwordModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.sword) {
        return originalModel;
    }

    BakedSwordModel model = (BakedSwordModel) originalModel;

    String key = IBladeTool.getBladeMat(stack).getName() + "|"
            + ICrossguardTool.getCrossguardMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("blade", IBladeTool.getBladeMat(stack).getName());
        builder.put("crossguard", ICrossguardTool.getCrossguardMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:Adventurers-Toolbox    文件:HandpickModel.java   
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
        @Nullable World world, @Nullable EntityLivingBase entity) {

    if (stack.getItem() != ModItems.handpick) {
        return originalModel;
    }

    BakedHandpickModel model = (BakedHandpickModel) originalModel;

    String key = IHeadTool.getHeadMat(stack).getName() + "|"
            + IHaftTool.getHaftMat(stack).getName() + "|"
            + IHandleTool.getHandleMat(stack).getName() + "|"
            + IAdornedTool.getAdornmentMat(stack).getName();

    if (!model.cache.containsKey(key)) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        builder.put("head", IHeadTool.getHeadMat(stack).getName());
        builder.put("haft", IHaftTool.getHaftMat(stack).getName());
        builder.put("handle", IHandleTool.getHandleMat(stack).getName());
        if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
            builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
        }
        IModel parent = model.parent.retexture(builder.build());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
            public TextureAtlasSprite apply(ResourceLocation location) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };
        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
                textureGetter);
        model.cache.put(key, bakedModel);
        return bakedModel;
    }

    return model.cache.get(key);
}
项目:CustomWorldGen    文件:AnimationItemOverrideList.java   
public AnimationItemOverrideList(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, List<ItemOverride> overrides)
{
    super(overrides);
    this.model = model;
    this.state = state;
    this.format = format;
    this.bakedTextureGetter = bakedTextureGetter;
}
项目: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);
        }
    }
}
项目:Thelta    文件:ClientContext.java   
public IModel loadModel(ResourceLocation location) {
    assertState(ContextState.LoadingModels);
    try {
        return ModelLoaderRegistry.getModel(location);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:CrystalMod    文件:ModelWrappedFood.java   
@Override
   public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
   {
       ItemStack food = ItemWrappedFood.getFood(stack);

       // not a crop item
       if (!ItemStackTools.isValid(food))
       {
           return originalModel;
       }

       //BakedSeed model = (BakedSeed)originalModel;
       BakedItemModel model = (BakedItemModel)originalModel;
       String name = ItemUtil.getStringForItemStack(food, true, false);
       String cacheName = name+"v1";
       if (!cache.containsKey(cacheName))
       {
           IModel parent = model.parent.process(ImmutableMap.of("food", name));
           Function<ResourceLocation, TextureAtlasSprite> textureGetter;
           textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
           {
               @Override
public TextureAtlasSprite apply(ResourceLocation location)
               {
                   return RenderUtil.getSprite(location);
               }
           };

           IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter);
           cache.put(cacheName, bakedModel);
           return bakedModel;
       }

       return cache.get(cacheName);
   }
项目:CrystalMod    文件:ModelSeed.java   
@Override
   public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
   {
       IMaterialCrop crop = ItemMaterialSeed.getCrop(stack);

       // not a crop item
       if (crop == null)
       {
           return originalModel;
       }

       //BakedSeed model = (BakedSeed)originalModel;
       BakedItemModel model = (BakedItemModel)originalModel;
       String name = crop.getUnlocalizedName();
       String cacheName = name+"v11";
       if (!cache.containsKey(cacheName))
       {
           IModel parent = model.parent.process(ImmutableMap.of("crop", name));
           Function<ResourceLocation, TextureAtlasSprite> textureGetter;
           textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
           {
               @Override
public TextureAtlasSprite apply(ResourceLocation location)
               {
                   return RenderUtil.getSprite(location);
               }
           };

           IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter);
           cache.put(cacheName, bakedModel);
           return bakedModel;
       }

       return cache.get(cacheName);
   }
项目:CrystalMod    文件:BuiltinModelLoader.java   
@Override
public IModel loadModel( ResourceLocation modelLocation ) throws Exception
{
    String loc = ""+modelLocation;
    if(loc.equals("crystalmod:models/block/pipe") || loc.equals("crystalmod:models/block/builtin/pipe"))return new ModelPipe();
    //if(loc.contains("block/pipe") || loc.contains("builtin"))return new ModelPipe();
    return builtInModels.get( modelLocation.getResourcePath() );
}
项目:CrystalMod    文件:BuiltinModelLoader.java   
@Override
public void onResourceManagerReload( IResourceManager resourceManager )
{
    for( IModel model : builtInModels.values() )
    {
        if( model instanceof IResourceManagerReloadListener )
        {
            ( (IResourceManagerReloadListener) model ).onResourceManagerReload( resourceManager );
        }
    }
}
项目: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    文件:QBarOBJModel.java   
@Override
public IModel retexture(ImmutableMap<String, String> textures)
{
    QBarOBJModel ret = new QBarOBJModel(this.getMatLib().makeLibWithReplacements(textures), getResourceLocation()
            , getCustomData());
    return ret;
}