public IFlexibleBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)) { throw new IllegalArgumentException( "can't bake vanilla weighted models to the format that doesn't fit into the default one: " + format); } if (variants.size() == 1) { Variant v = variants.get(0); IModel model = models.get(0); return model.bake( addUV(v.isUvLocked(), MultiModelState.getPartState(state, model, 0)), format, bakedTextureGetter); } WeightedBakedModel.Builder builder = new WeightedBakedModel.Builder(); for (int i = 0; i < variants.size(); i++) { IModel model = models.get(i); Variant v = variants.get(i); builder.add( model.bake( addUV(v.isUvLocked(), MultiModelState.getPartState(state, model, i)), format, bakedTextureGetter), variants.get(i).getWeight()); } return new FlexibleWeightedBakedModel(builder.build(), Attributes.DEFAULT_BAKED_FORMAT); }
public IFlexibleBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)) { throw new IllegalArgumentException( "can't bake vanilla models to the format that doesn't fit into the default one: " + format); } ModelBlock model = this.model; if (model == null) return getMissingModel() .bake(getMissingModel().getDefaultState(), format, bakedTextureGetter); List<TRSRTransformation> newTransforms = Lists.newArrayList(); for (int i = 0; i < model.getElements().size(); i++) { newTransforms.add(null); } ItemCameraTransforms transforms = model.func_181682_g(); boolean uvlock = false; if (state instanceof UVLock) { uvlock = true; state = ((UVLock) state).getParent(); } Map<TransformType, TRSRTransformation> tMap = Maps.newHashMap(); tMap.putAll(IPerspectiveAwareModel.MapWrapper.getTransforms(transforms)); tMap.putAll(IPerspectiveAwareModel.MapWrapper.getTransforms(state)); IModelState perState = new SimpleModelState(ImmutableMap.copyOf(tMap)); if (hasItemModel(model)) { return new ItemLayerModel(model).bake(perState, format, bakedTextureGetter); } if (isCustomRenderer(model)) return new IFlexibleBakedModel.Wrapper(new BuiltInModel(transforms), format); return bakeNormal( model, perState, state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity()), newTransforms, format, bakedTextureGetter, uvlock); }