net.minecraftforge.common.model.IModelState Java Examples
The following examples show how to use
net.minecraftforge.common.model.IModelState.
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: EvalExpandModel.java From OpenModsLib with MIT License | 6 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final IModel model = loadBaseModel(state, format, bakedTextureGetter); IBlockState blockState = null; if (defaultBlockState.isPresent()) { final Block defaultBlock = Block.REGISTRY.getObject(defaultBlockState.get()); if (defaultBlock != Blocks.AIR) { blockState = defaultBlock.getDefaultState(); if (!(blockState instanceof IExtendedBlockState) || !((IExtendedBlockState)blockState).getUnlistedNames().contains(EvalModelState.PROPERTY)) { Log.warn("State %s does not contain eval state property", blockState); } } else { Log.warn("Can't find default block: %s", defaultBlockState.get()); } } final IVarExpander expander = evaluatorFactory.createExpander(); return new BakedEvalExpandModel(model, state, format, bakedTextureGetter, blockState, expander); }
Example #2
Source File: BakedModelInserter.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@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 #3
Source File: ModelNullifierBaked.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@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 #4
Source File: VariantModel.java From OpenModsLib with MIT License | 6 votes |
@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: WeightedRandomModel.java From VanillaFix with MIT License | 6 votes |
@Override public WeightedRandomModel retexture(ImmutableMap<String, String> textures) { if (textures.isEmpty()) return this; // Rebuild the texture list taking into account new textures Set<ResourceLocation> modelTextures = Sets.newHashSet(); // Recreate the MultiModelState so that the IModelState data is properly applied to the retextured model ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder(); List<IModel> retexturedModels = Lists.newArrayList(); for (int i = 0; i < variants.size(); i++) { IModel retextured = models.get(i).retexture(textures); modelTextures.addAll(retextured.getTextures()); retexturedModels.add(retextured); builder.add(Pair.of(retextured, variants.get(i).getState())); } return new WeightedRandomModel(variants, locations, modelTextures, retexturedModels, new MultiModelState(builder.build())); }
Example #6
Source File: MultiLayerModel.java From OpenModsLib with MIT License | 6 votes |
@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 #7
Source File: ItemStateModel.java From OpenModsLib with MIT License | 6 votes |
@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 #8
Source File: GTModelTestTube.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> getter) { if (BAKED_BASE == null) BAKED_BASE = GTModelUtils.load(GTMod.MODID, "test_tube_model").bake(state, format, getter); if (BAKED_OVERLAY == null) BAKED_OVERLAY = GTModelUtils.load(GTMod.MODID, "test_tube_overlay_model").bake(state, format, getter); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (fluid != null) { TextureAtlasSprite sprite = getter.apply(fluid.getStill()); if (sprite != null) { List<BakedQuad> quads = BAKED_OVERLAY.getQuads(null, null, 0); quads = GTModelUtils.texAndTint(quads, fluid.getColor(), sprite); builder.addAll(quads); } } builder.addAll(BAKED_BASE.getQuads(null, null, 0)); return new GTBakedTestTube(builder.build(), this, getter.apply(BASE), format); }
Example #9
Source File: PerspectiveAwareModel.java From OpenModsLib with MIT License | 6 votes |
@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 #10
Source File: BakedEvalModel.java From OpenModsLib with MIT License | 5 votes |
@Override public IBakedModel load(final Map<String, Float> key) throws Exception { final IModelState clipTransform = part -> { if (!part.isPresent()) return Optional.empty(); final IModelPart maybeJoint = part.get(); if (!(maybeJoint instanceof IJoint)) return Optional.empty(); final IJoint joint = (IJoint)part.get(); return Optional.of(evaluator.evaluate(joint, key)); }; return bakeModelWithTransform(clipTransform); }
Example #11
Source File: BakedEvalModel.java From OpenModsLib with MIT License | 5 votes |
public BakedEvalModel(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ITransformEvaluator evaluator) { super(model.bake(state, format, bakedTextureGetter), PerspectiveMapWrapper.getTransforms(state)); this.model = model; this.originalState = state; this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.evaluator = evaluator; }
Example #12
Source File: BakedModelCamouflageBlock.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public BakedModelCamouflageBlock(IModel baseModel, @Nullable IModel overlayModel, ImmutableMap<String, String> textures, IModelState modelState, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { this.baseModel = baseModel; this.overlayModel = overlayModel; this.modelState = modelState; this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.bakedBaseModel = baseModel.bake(modelState, format, bakedTextureGetter); this.bakedOverlayModel = overlayModel != null ? overlayModel.bake(modelState, format, bakedTextureGetter) : null; this.itemQuads = buildItemModel(this.bakedBaseModel, this.bakedOverlayModel); }
Example #13
Source File: EvalModelBase.java From OpenModsLib with MIT License | 5 votes |
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 #14
Source File: TexturedItemOverrides.java From OpenModsLib with MIT License | 5 votes |
public TexturedItemOverrides(IBakedModel untexturedModel, IModel texturedModel, List<ItemOverride> texturedModelOverrides, Set<String> texturesToReplace, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { super(Lists.reverse(texturedModelOverrides)); this.untexturedModel = untexturedModel; this.texturedModel = texturedModel; this.texturesToReplace = ImmutableSet.copyOf(texturesToReplace); this.state = state; this.format = format; this.bakedTextureGetter = bakedTextureGetter; }
Example #15
Source File: EvalModel.java From OpenModsLib with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final IModel model = loadBaseModel(state, format, bakedTextureGetter); final ITransformEvaluator evaluator = evaluatorFactory.createEvaluator(c -> model.getClip(c)); return new BakedEvalModel(model, state, format, bakedTextureGetter, evaluator); }
Example #16
Source File: TexturedItemModel.java From OpenModsLib with MIT License | 5 votes |
@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); }
Example #17
Source File: ModelPortableBarrel.java From BetterChests with GNU Lesser General Public License v3.0 | 5 votes |
@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 |
@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: ModelNullifierBaked.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private ModelNullifierBaked(IModel baseModel, IModel lockedModel, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { this.modelState = state; this.modelBase = baseModel.bake(state, format, bakedTextureGetter); this.modelLocked = lockedModel.bake(state, format, bakedTextureGetter); this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.particle = bakedTextureGetter.apply(new ResourceLocation(ModelNullifier.TEX_BASE)); this.transformMap = PerspectiveMapWrapper.getTransforms(state); }
Example #20
Source File: BakedModelBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private BakedModelBarrel(IModel baseModel, IModel overlayModel, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ImmutableMap<String, String> textures) { IBlockState defaultState = EnderUtilitiesBlocks.BARREL.getDefaultState().withProperty(BlockBarrel.LABEL_FRONT, true); this.baseModel = baseModel.retexture(textures); this.overlayModel = overlayModel.retexture(textures); this.bakedBaseModel = this.baseModel.retexture(this.getTexturesBaseModel(defaultState, textures)).bake(state, format, bakedTextureGetter); this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.textures = textures; String particleName = this.textures.get("particle"); this.particle = particleName != null ? bakedTextureGetter.apply(new ResourceLocation(particleName)) : this.bakedBaseModel.getParticleTexture(); this.itemQuads = BakedModelCamouflageBlock.buildItemModel(this.bakedBaseModel, null); }
Example #21
Source File: ModelWithDependencies.java From OpenModsLib with MIT License | 5 votes |
@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 #22
Source File: MultipartModel.java From VanillaFix with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { MultipartBakedModel.Builder builder = new MultipartBakedModel.Builder(); for (Selector selector : multipart.getSelectors()) { builder.putModel(selector.getPredicate(multipart.getStateContainer()), partModels.get(selector).bake(partModels.get(selector).getDefaultState(), format, bakedTextureGetter)); } return builder.makeMultipartModel(); }
Example #23
Source File: BakedModelInserter.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private BakedModelInserter(ModelInserter inserterModel, IModel baseModel, IModel sideModel, IModelState modelState, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<String, String> textures = inserterModel.getTextureMapping(); this.baseModel = baseModel.retexture(textures); this.sideModelValid = sideModel.retexture(ImmutableMap.of("side", textures.get("side_valid"))); this.sideModelInvalid = sideModel.retexture(ImmutableMap.of("side", textures.get("side_invalid"))); this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.bakedBaseModel = this.baseModel.bake(modelState, format, bakedTextureGetter); this.particle = bakedTextureGetter.apply(new ResourceLocation(textures.get("particle"))); }
Example #24
Source File: VanillaModelWrapper.java From VanillaFix with MIT License | 5 votes |
@Override public IBakedModel 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 BuiltinLoader.WRAPPED_MODEL_MISSING.bake(BuiltinLoader.WRAPPED_MODEL_MISSING.getDefaultState(), format, bakedTextureGetter); } List<TRSRTransformation> newTransforms = Lists.newArrayList(); for (int i = 0; i < model.getElements().size(); i++) { BlockPart part = model.getElements().get(i); newTransforms.add(animation.getPartTransform(state, part, i)); } ItemCameraTransforms transforms = model.getAllTransforms(); Map<ItemCameraTransforms.TransformType, TRSRTransformation> tMap = Maps.newEnumMap(ItemCameraTransforms.TransformType.class); tMap.putAll(PerspectiveMapWrapper.getTransforms(transforms)); tMap.putAll(PerspectiveMapWrapper.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 BuiltInModel(transforms, model.createOverrides()); } return bakeNormal(model, perState, state, newTransforms, format, bakedTextureGetter, uvlock); }
Example #25
Source File: WeightedRandomModel.java From VanillaFix with MIT License | 5 votes |
public WeightedRandomModel(VariantList variants) throws Exception { this.variants = variants.getVariantList(); locations = new ArrayList<>(); textures = Sets.newHashSet(); models = new ArrayList<>(); ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder(); for (Variant variant : this.variants) { ResourceLocation location = variant.getModelLocation(); locations.add(location); IModel model = variant.process(ModelLoaderRegistry.getModel(location)); textures.addAll(model.getTextures()); models.add(model); IModelState modelDefaultState = model.getDefaultState(); Preconditions.checkNotNull(modelDefaultState, "Model %s returned null as default state", location); builder.add(Pair.of(model, new ModelStateComposition(variant.getState(), modelDefaultState))); } // If all variants are missing, add one with the missing model and default rotation if (models.size() == 0) { IModel missing = ModelLoaderRegistry.getMissingModel(); models.add(missing); builder.add(Pair.of(missing, TRSRTransformation.identity())); } defaultState = new MultiModelState(builder.build()); }
Example #26
Source File: WeightedRandomModel.java From VanillaFix with MIT License | 5 votes |
private WeightedRandomModel(List<Variant> variants, List<ResourceLocation> locations, Set<ResourceLocation> textures, List<IModel> models, IModelState defaultState) { this.variants = variants; this.locations = locations; this.textures = textures; this.models = models; this.defaultState = defaultState; }
Example #27
Source File: ModelRocket.java From AdvancedRocketry with MIT License | 5 votes |
@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: SpawnerRenderer.java From NotEnoughItems with MIT License | 4 votes |
@Override public IModelState getTransforms() { return TransformUtils.DEFAULT_BLOCK; }
Example #29
Source File: FluidPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public IModelState getTransforms() { return TransformUtils.DEFAULT_BLOCK; }
Example #30
Source File: InvPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public IModelState getTransforms() { return TransformUtils.DEFAULT_BLOCK; }