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

项目:CustomWorldGen    文件:AnimationItemOverrideList.java   
@Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
{
    if(stack.hasCapability(net.minecraftforge.common.model.animation.CapabilityAnimation.ANIMATION_CAPABILITY, null))
    {
        // TODO: caching?
        IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
        if(world == null)
        {
            world = entity.worldObj;
        }
        if(world == null)
        {
            world = Minecraft.getMinecraft().theWorld;
        }
        IModelState state = asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft();
        return model.bake(new ModelStateComposition(state, this.state), format, bakedTextureGetter);
    }
    return super.handleItemState(originalModel, stack, world, entity);
}
项目: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    文件:TexturedItemModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    final IModel untexturedModel = getModel(this.untexturedModel);
    final IBakedModel untexturedBakedModel = untexturedModel.bake(new ModelStateComposition(state, untexturedModel.getDefaultState()), format, bakedTextureGetter);

    final IModel texturedModel = getModel(this.texturedModel);
    final IBakedModel texturedBakedModel = texturedModel.bake(new ModelStateComposition(state, texturedModel.getDefaultState()), format, bakedTextureGetter);

    final ItemOverrideList overrides = new TexturedItemOverrides(untexturedBakedModel, texturedModel, texturedBakedModel.getOverrides().getOverrides(), textures, state, format, bakedTextureGetter);

    return new BakedModel(untexturedBakedModel, PerspectiveMapWrapper.getTransforms(state), overrides);
}
项目:enderutilities    文件:ModelEnderBucket.java   
private IModelState getTransformedModelState(IModelState state, float offZ, float scaleZ)
{
    TRSRTransformation tr = new TRSRTransformation(new Vector3f(0f, 0f, offZ), null, new Vector3f(1f, 1f, scaleZ), null);
    return new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(tr));
}
项目:enderutilities    文件:ModelEnderTools.java   
private IModelState getTransformedModelState(IModelState state, String module)
{
    ModuleTransforms mt = new ModuleTransforms(this, this.tool, module);
    TRSRTransformation tr = new TRSRTransformation(new Vector3f(mt.tx, mt.ty, mt.tz), null, new Vector3f(mt.sx, mt.sy, mt.sz), null);
    return new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(tr));
}
项目:enderutilities    文件:ModelNullifierBaked.java   
private void addQuads(ModelNullifierBaked nullifierModel, boolean locked, ItemStack containedStack)
{
    IBakedModel itemModel = null;
    IBakedModel textModel = null;

    if (containedStack.isEmpty() == false)
    {
        ItemType type = new ItemType(containedStack, true);
        itemModel = ITEM_MODEL_CACHE.get(type);

        if (itemModel == null)
        {
            IModel iModel = this.getItemModel(containedStack);

            if (iModel != null && iModel.getClass().getName().equals("net.minecraftforge.client.model.FancyMissingModel") == false)
            {
                TRSRTransformation trn = new TRSRTransformation(new javax.vecmath.Vector3f(-0.5f, -0.5f, -0.5f), null, null, null);
                TRSRTransformation trr = new TRSRTransformation(ModelRotation.X0_Y180);
                TRSRTransformation trp = new TRSRTransformation(new javax.vecmath.Vector3f( 0.5f,  0.5f,  0.5f), null, null, null);
                TRSRTransformation trs = new TRSRTransformation(null, null, new javax.vecmath.Vector3f(0.6f, 0.6f, 0.6f), null);
                TRSRTransformation tr = trn.compose(trr).compose(trp).compose(trs);

                IModelState state = new ModelStateComposition(this.modelState, TRSRTransformation.blockCenterToCorner(tr));
                itemModel = iModel.bake(state, this.format, this.bakedTextureGetter);
            }
            else
            {
                Minecraft mc = Minecraft.getMinecraft();
                itemModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(containedStack);
                itemModel = itemModel.getOverrides().handleItemState(itemModel, containedStack, mc.world, mc.player);
            }

            ITEM_MODEL_CACHE.put(type, itemModel);
        }
    }

    this.addQuadsForSide(null, nullifierModel, itemModel, textModel, locked);

    for (EnumFacing side : EnumFacing.values())
    {
        this.addQuadsForSide(side, nullifierModel, itemModel, textModel, locked);
    }
}
项目:OpenModsLib    文件:BakedEvalModel.java   
private IBakedModel bakeModelWithTransform(IModelState transform) {
    final IModelState compositeState = new ModelStateComposition(this.originalState, transform);
    return model.bake(compositeState, format, bakedTextureGetter);
}
项目:OpenModsLib    文件:MultiLayerModel.java   
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);
}
项目:OpenModsLib    文件:PerspectiveAwareModel.java   
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);
}