net.minecraft.client.renderer.block.model.IBakedModel Java Examples
The following examples show how to use
net.minecraft.client.renderer.block.model.IBakedModel.
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: ModelNullifierBaked.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
private void addQuadsForSide(EnumFacing side, ModelNullifierBaked nullifierModel, IBakedModel itemModel, IBakedModel textModel, boolean locked) { ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); builder.addAll(nullifierModel.modelBase.getQuads(null, side, 0)); if (locked) { builder.addAll(nullifierModel.modelLocked.getQuads(null, side, 0)); } if (itemModel != null) { builder.addAll(itemModel.getQuads(null, side, 0)); } this.quads.put(side, builder.build()); }
Example #3
Source File: GuiComponentItemStackSpinner.java From OpenModsLib with MIT License | 6 votes |
private void renderItem(ItemStack itemStack) { parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); final RenderItem itemRenderer = parent.getItemRenderer(); final ItemModelMesher itemModelMesher = itemRenderer.getItemModelMesher(); final IBakedModel model = itemModelMesher.getItemModel(stack); GlStateManager.disableLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.pushMatrix(); itemRenderer.renderItem(stack, model); GlStateManager.cullFace(CullFace.BACK); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); GlStateManager.enableLighting(); }
Example #4
Source File: BakedModelBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
private List<BakedQuad> getQuadsForCamoModelSide(EnumFacing side, IBlockState state, IBakedModel bakedModel, long rand) { EnumFacing relativeSide = PositionUtils.getRelativeFacing(state.getValue(BlockBarrel.FACING_H), side); switch (relativeSide) { case DOWN: return state.getValue(BlockBarrel.LABEL_DOWN) ? bakedModel.getQuads(state, side, rand) : EMPTY_QUADS; case UP: return state.getValue(BlockBarrel.LABEL_UP) ? bakedModel.getQuads(state, side, rand) : EMPTY_QUADS; case NORTH: return state.getValue(BlockBarrel.LABEL_FRONT) ? bakedModel.getQuads(state, side, rand) : EMPTY_QUADS; case SOUTH: return state.getValue(BlockBarrel.LABEL_BACK) ? bakedModel.getQuads(state, side, rand) : EMPTY_QUADS; case WEST: return state.getValue(BlockBarrel.LABEL_RIGHT) ? bakedModel.getQuads(state, side, rand) : EMPTY_QUADS; case EAST: return state.getValue(BlockBarrel.LABEL_LEFT) ? bakedModel.getQuads(state, side, rand) : EMPTY_QUADS; default: } return EMPTY_QUADS; }
Example #5
Source File: BWBakedModel.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public BWBakedModel(IBakedModel wrapped, VertexFormat format, Optional<IBlockState> state, long rand) { this.wrapped = wrapped; this.format = format; this.matrix.translate(-0.5, -0.5, -0.5); this.blockState = state; this.rand = rand; if (!format.getElements().stream().anyMatch(VertexFormatElement::isPositionElement)) return; // VertexFormat doesn't have a position Arrays.stream(Direction.values()) .map(this::getQuads) .flatMap(Collection::stream) .map(this::quadToFace) .forEachOrdered(faces::add); }
Example #6
Source File: TilePitKiln.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) public static PropertyItem.PItem getDisplayItem(ItemStack stack, World world, EntityLivingBase entity, float x, float z) { if(stack == null) return null; IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, entity); if(model == null || model.isBuiltInRenderer()) { // missing model so people don't go paranoid when their chests go missing model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getMissingModel(); } PropertyItem.PItem item = new PropertyItem.PItem(model, x,0,z, 0.5f, (float) (Math.PI/2)); if(stack.getItem() instanceof ItemBlock) { item.y = -0.3125f; item.s = 0.375f; item.r = 0; } return item; }
Example #7
Source File: TileSmallVessel.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) public static PropertyItem.PItem getDisplayItem(ItemStack stack, World world, EntityLivingBase entity, float x, float z, EnumFacing.Axis axis) { if(stack == null) return null; IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, entity); if(model == null || model.isBuiltInRenderer()) { // missing model so people don't go paranoid when their chests go missing model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getMissingModel(); } float rotation = 0; if(axis == EnumFacing.Axis.X) { rotation = (float)Math.PI /2f; } PropertyItem.PItem item = new PropertyItem.PItem(model, x,0,z, 0.45f, axis == EnumFacing.Axis.X ? (float) (Math.PI/2f) : 0); if(stack.getItem() instanceof ItemBlock) { item.y = -0.3125f; item.s = 0.375f; item.r = 0; } return item; }
Example #8
Source File: EventsClient.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { GibsModelRegistry.onModelBakeEvent(event); ResourceLocation modelResourceLocation = new ResourceLocation(ValkyrienSkiesMod.MOD_ID, "item/infuser_core_main"); try { IModel model = ModelLoaderRegistry.getModel(modelResourceLocation); IBakedModel inventoryModel = model .bake(model.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); IBakedModel handModel = event.getModelRegistry() .getObject(new ModelResourceLocation( ValkyrienSkiesMod.MOD_ID + ":" + ValkyrienSkiesMod.INSTANCE.physicsCore .getTranslationKey() .substring(5), "inventory")); event.getModelRegistry() .putObject( new ModelResourceLocation(ValkyrienSkiesMod.MOD_ID + ":testmodel", "inventory"), new InfuserCoreBakedModel(handModel, inventoryModel)); } catch (Exception e) { e.printStackTrace(); } }
Example #9
Source File: BlockModelRenderEvent.java From ForgeHax with MIT License | 6 votes |
public BlockModelRenderEvent( IBlockAccess worldIn, IBakedModel modelIn, IBlockState stateIn, BlockPos posIn, BufferBuilder buffer, boolean checkSides, long rand) { this.blockAccess = worldIn; this.bakedModel = modelIn; this.blockState = stateIn; this.blockPos = posIn; this.buffer = buffer; this.checkSides = checkSides; this.rand = rand; }
Example #10
Source File: BakedModelInserter.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
private List<IBakedModel> getSideModels(IBlockState state) { List<IBakedModel> models = new ArrayList<IBakedModel>(); for (EnumFacing side : EnumFacing.values()) { BlockInserter.Connection conn = state.getValue(BlockInserter.CONNECTIONS.get(side.getIndex())); if (conn == BlockInserter.Connection.VALID) { models.add(this.sideModelValid.bake(TRSRTransformation.from(side), this.format, this.bakedTextureGetter)); } else if (conn == BlockInserter.Connection.INVALID) { models.add(this.sideModelInvalid.bake(TRSRTransformation.from(side), this.format, this.bakedTextureGetter)); } } return models; }
Example #11
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 #12
Source File: RenderUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reimplement vanilla item so we can draw pearl stacks with opacity support. */ private static void renderEffect(IBakedModel model) { GlStateManager.depthMask(false); GlStateManager.depthFunc(514); GlStateManager.disableLighting(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE); Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT); GlStateManager.matrixMode(5890); GlStateManager.pushMatrix(); GlStateManager.scale(8.0F, 8.0F, 8.0F); float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F; GlStateManager.translate(f, 0.0F, 0.0F); GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F); renderModel(model, -8372020, ItemStack.EMPTY); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.scale(8.0F, 8.0F, 8.0F); float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F; GlStateManager.translate(-f1, 0.0F, 0.0F); GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F); renderModel(model, -8372020, ItemStack.EMPTY); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.enableLighting(); GlStateManager.depthFunc(515); GlStateManager.depthMask(true); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.scale(1 / 8.0F, 1 / 8.0F, 1 / 8.0F); }
Example #13
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 #14
Source File: SurfaceHelper.java From ForgeHax with MIT License | 5 votes |
private static void renderItemModelIntoGUI( ItemStack stack, double x, double y, IBakedModel bakedmodel, double scale) { GlStateManager.pushMatrix(); MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); MC.getTextureManager() .getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE) .setBlurMipmap(false, false); GlStateManager.enableRescaleNormal(); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); GlStateManager.blendFunc( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.translate(x, y, 100.0F + MC.getRenderItem().zLevel); GlStateManager.translate(8.0F, 8.0F, 0.0F); GlStateManager.scale(1.0F, -1.0F, 1.0F); GlStateManager.scale(scale, scale, scale); if (bakedmodel.isGui3d()) { GlStateManager.enableLighting(); } else { GlStateManager.disableLighting(); } bakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms( bakedmodel, ItemCameraTransforms.TransformType.GUI, false); MC.getRenderItem().renderItem(stack, bakedmodel); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.popMatrix(); MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); }
Example #15
Source File: RenderUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static void drawBlockModelQuadOverlayBatched(IBakedModel model, IBlockState state, BlockPos pos, Color4f color, double expand, BufferBuilder buffer) { long rand = MathHelper.getPositionRandom(pos); for (final EnumFacing side : PositionUtils.FACING_ALL) { renderModelQuadOverlayBatched(pos, buffer, color, model.getQuads(state, side, rand)); } renderModelQuadOverlayBatched(pos, buffer, color, model.getQuads(state, null, rand)); }
Example #16
Source File: FastBlockModelRenderer.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
private static void generateRenderDataFor(World world, IBlockState state) { VERTEX_BUILDER.begin(7, DefaultVertexFormats.BLOCK); BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft() .getBlockRendererDispatcher(); IBakedModel modelFromState = blockrendererdispatcher.getModelForState(state); blockrendererdispatcher.getBlockModelRenderer() .renderModel(Minecraft.getMinecraft().world, modelFromState, Blocks.AIR.getDefaultState(), offsetPos, VERTEX_BUILDER, false, 0); BufferBuilder.State toReturn = VERTEX_BUILDER.getVertexState(); VERTEX_BUILDER.finishDrawing(); VERTEX_BUILDER.reset(); blockstateToVertexData.put(state, toReturn); }
Example #17
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 #18
Source File: FacadeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private static VertexLighterFlat setupLighter(CCRenderState ccrs, Matrix4 translation, IBlockState state, IBlockAccess access, BlockPos pos, IBakedModel model) { boolean renderAO = Minecraft.isAmbientOcclusionEnabled() && state.getLightValue(access, pos) == 0 && model.isAmbientOcclusion(); VertexLighterFlat lighter = renderAO ? lighterSmooth.get() : lighterFlat.get(); AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs); lighter.setParent(consumer); consumer.setTranslation(translation); return lighter; }
Example #19
Source File: ClientProxy.java From AdvancedRocketry with MIT License | 5 votes |
@SubscribeEvent public void modelBakeEvent(ModelBakeEvent event) { Object object = event.getModelRegistry().getObject(ModelRocket.resource); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel)object; ModelRocket customModel = new ModelRocket(); event.getModelRegistry().putObject(ModelRocket.resource, existingModel); } }
Example #20
Source File: InfuserCoreBakedModel.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType) { switch (cameraTransformType) { case GUI: return inventoryModel.handlePerspective(cameraTransformType); default: return handModel.handlePerspective(cameraTransformType); } }
Example #21
Source File: BakedCompositeModel.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public void add(IBakedModel model, IBlockState state, EnumFacing side, long rand) { int index; if(side == null) { index = 6; } else { index = side.getIndex(); } builders[index].addAll(model.getQuads(state, side, rand)); }
Example #22
Source File: BakedCompositeModel.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public BakedCompositeModel build(IBakedModel parent) { ImmutableMap.Builder<Optional<EnumFacing>, ImmutableList<BakedQuad>> map = ImmutableMap.builder(); map.put(Optional.<EnumFacing>absent(), builders[6].build()); for(EnumFacing side : EnumFacing.values()) { map.put(Optional.of(side), builders[side.getIndex()].build()); } return new BakedCompositeModel(parent, map.build()); }
Example #23
Source File: ModelBakeHandler.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public static void replaceAnvilModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedAnvilModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
Example #24
Source File: ModelBakeHandler.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public static void replacePitKilnModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedPitKilnModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
Example #25
Source File: ModelBakeHandler.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public static void replaceSmallVesselModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedSmallVesselModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
Example #26
Source File: PropertyItem.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public PItem(IBakedModel model, float x, float y, float z, float s, float r) { this.model = model; this.x = x; this.y = y; this.z = z; this.s = s; this.r = r; }
Example #27
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 #28
Source File: PerspectiveAwareModel.java From OpenModsLib with MIT License | 5 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { IBakedModel model = models.get(cameraTransformType); if (model == null) model = base; return model.handlePerspective(cameraTransformType); }
Example #29
Source File: BakedModelBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override synchronized public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { // Item model if (state == null) { return this.itemQuads; } IExtendedBlockState extendedState = (IExtendedBlockState) state; IBlockState actualState = extendedState.getClean(); IBlockState camoState = extendedState.getValue(BlockEnderUtilitiesTileEntity.CAMOBLOCKSTATE); boolean validCamo = camoState != null && camoState.getBlock() != Blocks.AIR; Optional<IBlockState> key = Optional.of(actualState); Map<Optional<IBlockState>, ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>>> cache = validCamo ? QUAD_CACHE_CAMO : QUAD_CACHE_NORMAL; ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> map = cache.get(key); if (map == null) { IBakedModel bakedModel = validCamo ? this.getBakedOverlayModel(actualState) : this.getBakedBaseModel(actualState); map = this.getQuadsForState(bakedModel, extendedState, rand, validCamo); cache.put(key, map); } return map.get(Optional.ofNullable(side)); }
Example #30
Source File: BakedModelDefaultTexture.java From WearableBackpacks with MIT License | 5 votes |
@SuppressWarnings("unchecked") public BakedModelDefaultTexture(IBakedModel base) { _baseModel = base; _sideQuads = Arrays.stream(EnumFacing.VALUES) .map((side) -> filterQuads(_baseModel.getQuads(null, side, 0))) .toArray((length) -> new List[length]); _defaultQuads = filterQuads(_baseModel.getQuads(null, null, 0)); }