@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder(); builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE); TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno")); for (Map.Entry<String, Material> e : matLib.materials.entrySet()) { if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#")) { FMLLog.log.fatal("OBJLoader: Unresolved texture '{}' for obj model '{}'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation); builder.put(e.getKey(), missing); } else { builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation())); } } builder.put("missingno", missing); return new TintedOBJBakedModel(this, state, format, builder.build()); }
@SubscribeEvent public void onModelBaking(ModelBakeEvent event) { // set up camo models for camouflagable blocks for (Block block : Blockss.blocks) { if (block instanceof BlockPneumaticCraftCamo) { Map<IBlockState,ModelResourceLocation> map = event.getModelManager().getBlockModelShapes().getBlockStateMapper().getVariants(block); for (Map.Entry<IBlockState,ModelResourceLocation> entry : map.entrySet()) { Object object = event.getModelRegistry().getObject(entry.getValue()); if (object != null) { IBakedModel existing = (IBakedModel) object; CamoModel customModel = new CamoModel(existing); event.getModelRegistry().putObject(entry.getValue(), customModel); } } } } }
public IBakedModel getBakedModel() { if (this==ModDust.getDustFromID(this.getDustID())) { if (this.bakedModel==null) { this.bakedModel = DustModelHandler.getBakedModel(getModelLocation()); } return this.bakedModel; } else { return ModDust.getDustFromID(this.getDustID()).getBakedModel(); } }
public void renderItem(ItemStack stack, IBakedModel model) { if (stack != null) { GlStateManager.pushMatrix(); GlStateManager.translate(-0.5F, -0.5F, -0.5F); if (model.isBuiltInRenderer()) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableRescaleNormal(); TileEntityItemStackRenderer.instance.renderByItem(stack); } else { this.renderModel(model, stack); if (stack.hasEffect()) { this.renderEffect(model); } } GlStateManager.popMatrix(); } }
@Override @Nonnull public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) { Spell spell = ItemSpellPage.getSpell(stack); if (spell == null || spell.equals(Spell.EMPTY_SPELL)) { return originalModel; } String name = spell.getRegistryName().toString(); if (!cache.containsKey(name)) { ModelSpellPage model = (ModelSpellPage) originalModel; TextureAtlasSprite fontSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(font2.toString()); BakedModelSpellPage bakedBakedModel = rebake(model, spell); cache.put(name, bakedBakedModel); return bakedBakedModel; } return cache.get(name); }
public boolean renderModel(IBlockAccess worldIn, IBakedModel modelIn, IBlockState stateIn, BlockPos posIn, VertexBuffer buffer, boolean checkSides, long rand) { boolean flag = Minecraft.isAmbientOcclusionEnabled() && stateIn.getLightValue() == 0 && modelIn.isAmbientOcclusion(); try { return flag ? this.renderModelSmooth(worldIn, modelIn, stateIn, posIn, buffer, checkSides, rand) : this.renderModelFlat(worldIn, modelIn, stateIn, posIn, buffer, checkSides, rand); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Tesselating block model"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Block model being tesselated"); CrashReportCategory.addBlockInfo(crashreportcategory, posIn, stateIn); crashreportcategory.addCrashSection("Using AO", Boolean.valueOf(flag)); throw new ReportedException(crashreport); } }
@Override @Nonnull public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) { String name = stack.getDisplayName(); if (!cache.containsKey(name)) { ModelKnowledgeBook model = (ModelKnowledgeBook) originalModel; TextureAtlasSprite fontSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(font2.toString()); BakedModelKnowledgeBook bakedBakedModel = rebake(model, name); cache.put(name, bakedBakedModel); return bakedBakedModel; } return cache.get(name); }
protected void renderItemModelIntoGUI(ItemStack stack, int x, int y, IBakedModel bakedmodel) { GlStateManager.pushMatrix(); this.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); this.textureManager.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); this.setupGuiTransform(x, y, bakedmodel.isGui3d()); bakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(bakedmodel, ItemCameraTransforms.TransformType.GUI, false); this.renderItem(stack, bakedmodel); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.popMatrix(); this.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); this.textureManager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); }
@Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) { IBakedModel model; BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer(); if(layer == null) { return quads.get(Optional.fromNullable(side)); } else if(!models.containsKey(Optional.of(layer))) { model = missing; } else { model = models.get(Optional.of(layer)); } // assumes that child model will handle this state properly. FIXME? return model.getQuads(state, side, rand); }
protected void renderItemModel(ItemStack stack, IBakedModel bakedmodel, ItemCameraTransforms.TransformType transform, boolean leftHanded) { if (stack.getItem() != null) { this.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); this.textureManager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.pushMatrix(); // TODO: check if negative scale is a thing bakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(bakedmodel, transform, leftHanded); this.renderItem(stack, bakedmodel); GlStateManager.cullFace(GlStateManager.CullFace.BACK); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); this.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); this.textureManager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); } }
public static IBakedModel getCustomItemModel(ItemStack p_getCustomItemModel_0_, IBakedModel p_getCustomItemModel_1_, ResourceLocation p_getCustomItemModel_2_) { if (p_getCustomItemModel_1_.isGui3d()) { return p_getCustomItemModel_1_; } else if (itemProperties == null) { return p_getCustomItemModel_1_; } else { CustomItemProperties customitemproperties = getCustomItemProperties(p_getCustomItemModel_0_, 1); return customitemproperties == null ? p_getCustomItemModel_1_ : customitemproperties.getModel(p_getCustomItemModel_2_); } }
public static void dbgModel(IBakedModel p_dbgModel_0_) { if (p_dbgModel_0_ != null) { Config.dbg("Model: " + p_dbgModel_0_ + ", ao: " + p_dbgModel_0_.isAmbientOcclusion() + ", gui3d: " + p_dbgModel_0_.isGui3d() + ", builtIn: " + p_dbgModel_0_.isBuiltInRenderer() + ", particle: " + p_dbgModel_0_.getParticleTexture()); EnumFacing[] aenumfacing = EnumFacing.VALUES; for (int i = 0; i < aenumfacing.length; ++i) { EnumFacing enumfacing = aenumfacing[i]; List list = p_dbgModel_0_.getQuads((IBlockState)null, enumfacing, 0L); dbgQuads(enumfacing.getName(), list, " "); } List list1 = p_dbgModel_0_.getQuads((IBlockState)null, (EnumFacing)null, 0L); dbgQuads("General", list1, " "); } }
@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); }
public IBakedModel getItemModel(ItemStack stack) { Item item = stack.getItem(); IBakedModel ibakedmodel = this.getItemModel(item, this.getMetadata(stack)); if (ibakedmodel == null) { ItemMeshDefinition itemmeshdefinition = (ItemMeshDefinition)this.shapers.get(item); if (itemmeshdefinition != null) { ibakedmodel = this.modelManager.getModel(itemmeshdefinition.getModelLocation(stack)); } } if (ibakedmodel == null) { ibakedmodel = this.modelManager.getMissingModel(); } return ibakedmodel; }
public IBakedModel getItemModelWithOverrides(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entitylivingbaseIn) { IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); Item item = stack.getItem(); if (Config.isCustomItems() && item != null && item.hasCustomProperties()) { this.modelLocation = ibakedmodel.getOverrides().applyOverride(stack, worldIn, entitylivingbaseIn); } if (Reflector.ForgeItemOverrideList_handleItemState.exists()) { return (IBakedModel)Reflector.call(ibakedmodel.getOverrides(), Reflector.ForgeItemOverrideList_handleItemState, new Object[] {ibakedmodel, stack, worldIn, entitylivingbaseIn}); } else if (item != null && item.hasCustomProperties()) { ResourceLocation resourcelocation = ibakedmodel.getOverrides().applyOverride(stack, worldIn, entitylivingbaseIn); return resourcelocation == null ? ibakedmodel : this.itemModelMesher.getModelManager().getModel(new ModelResourceLocation(resourcelocation, "inventory")); } else { return ibakedmodel; } }
public void renderModelBrightness(IBakedModel model, IBlockState state, float brightness, boolean p_178266_4_) { Block block = state.getBlock(); GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); int i = this.blockColors.colorMultiplier(state, (IBlockAccess)null, (BlockPos)null, 0); if (EntityRenderer.anaglyphEnable) { i = TextureUtil.anaglyphColor(i); } float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; if (!p_178266_4_) { GlStateManager.color(brightness, brightness, brightness, 1.0F); } this.renderModelBrightnessColor(state, model, brightness, f, f1, f2); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder(); builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE); TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno")); for (Map.Entry<String, Material> e : matLib.materials.entrySet()) { if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#")) { FMLLog.severe("OBJLoader: Unresolved texture '%s' for obj model '%s'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation); builder.put(e.getKey(), missing); } else { builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation())); } } builder.put("missingno", missing); return new OBJBakedModel(this, state, format, builder.build()); }
public static IBakedModel makeModelCube(TextureAtlasSprite p_makeModelCube_0_, int p_makeModelCube_1_) { List list = new ArrayList(); EnumFacing[] aenumfacing = EnumFacing.VALUES; Map<EnumFacing, List<BakedQuad>> map = new HashMap(); for (int i = 0; i < aenumfacing.length; ++i) { EnumFacing enumfacing = aenumfacing[i]; List list1 = new ArrayList(); list1.add(makeBakedQuad(enumfacing, p_makeModelCube_0_, p_makeModelCube_1_)); map.put(enumfacing, list1); } ItemOverrideList itemoverridelist = new ItemOverrideList(new ArrayList()); IBakedModel ibakedmodel = new SimpleBakedModel(list, map, true, true, p_makeModelCube_0_, ItemCameraTransforms.DEFAULT, itemoverridelist); return ibakedmodel; }
@Inject(method = "renderEffect", at = @At("HEAD"), cancellable = true) private void renderEffect(IBakedModel model, CallbackInfo ci) { GlintEffectEvent event = new GlintEffectEvent(GlintEffectEvent.GlintTarget.ITEM); ClientAPI.EVENT_BUS.post(event); if (event.isCancelled()) ci.cancel(); }
private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_) { ItemStack itemstack = itemIn.getEntityItem(); Item item = itemstack.getItem(); if (item == null) { return 0; } else { boolean flag = p_177077_9_.isGui3d(); int i = this.getModelCount(itemstack); float f = 0.25F; float f1 = MathHelper.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F; float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y; GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_); if (flag || this.renderManager.options != null) { float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI); GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F); } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); return i; } }
private static void renderModel(IBakedModel model, VertexFormat fmt) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, fmt); for (BakedQuad bakedquad : model.getQuads(null, null, 0)) { worldrenderer.addVertexData(bakedquad.getVertexData()); } tessellator.draw(); }
private static void renderModel(IBakedModel model, VertexFormat fmt, int color) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, fmt); for (BakedQuad bakedquad : model.getQuads(null, null, 0)) { LightUtil.renderQuadColor(worldrenderer, bakedquad, color); } tessellator.draw(); }
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)); } }
public void itsSnowyHere() { IBakedModel pumpkin = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(Blocks.TALLGRASS.getStateFromMeta(2)); GlStateManager.rotate(90, 0, -1, 0); GlStateManager.translate(0.08, 0.485, -0.1); GlStateManager.scale(2 / 16D, 2 / 16D, 2 / 16D); Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(pumpkin, 0.5f, 255, 255, 255); GlStateManager.translate(-0.08 * 28, 0, 0); Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(pumpkin, 0.5f, 255, 255, 255); }
private void renderModel(IBakedModel model, int color, @Nullable ItemStack stack) { Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.ITEM); for (EnumFacing enumfacing : EnumFacing.values()) { this.renderQuads(vertexbuffer, model.getQuads((IBlockState)null, enumfacing, 0L), color, stack); } this.renderQuads(vertexbuffer, model.getQuads((IBlockState)null, (EnumFacing)null, 0L), color, stack); tessellator.draw(); }
public boolean renderModelFlat(IBlockAccess worldIn, IBakedModel modelIn, IBlockState stateIn, BlockPos posIn, VertexBuffer buffer, boolean checkSides, long rand) { boolean flag = false; BitSet bitset = new BitSet(3); for (EnumFacing enumfacing : EnumFacing.values()) { List<BakedQuad> list = modelIn.getQuads(stateIn, enumfacing, rand); if (!list.isEmpty() && (!checkSides || stateIn.shouldSideBeRendered(worldIn, posIn, enumfacing))) { int i = stateIn.getPackedLightmapCoords(worldIn, posIn.offset(enumfacing)); this.renderQuadsFlat(worldIn, stateIn, posIn, i, false, buffer, list, bitset); flag = true; } } List<BakedQuad> list1 = modelIn.getQuads(stateIn, (EnumFacing)null, rand); if (!list1.isEmpty()) { this.renderQuadsFlat(worldIn, stateIn, posIn, -1, true, buffer, list1, bitset); flag = true; } return flag; }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onModelKnowledgeBookBakeEvent(ModelBakeEvent event) { Object object = event.getModelRegistry().getObject(ModelKnowledgeBook.modelResourceLocation); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel) object; ModelKnowledgeBook knowledgeBookModel = new ModelKnowledgeBook(existingModel); event.getModelRegistry().putObject(ModelKnowledgeBook.modelResourceLocation, knowledgeBookModel); ModelKnowledgeBook.KnowledgeBookOverrideList.INSTANCE.clearCache(); } }
public void renderBlockDamage(IBlockState state, BlockPos pos, TextureAtlasSprite texture, IBlockAccess blockAccess) { if (state.getRenderType() == EnumBlockRenderType.MODEL) { state = state.getActualState(blockAccess, pos); IBakedModel ibakedmodel = this.blockModelShapes.getModelForState(state); IBakedModel ibakedmodel1 = (new SimpleBakedModel.Builder(state, ibakedmodel, texture, pos)).makeBakedModel(); this.blockModelRenderer.renderModel(blockAccess, ibakedmodel1, state, pos, Tessellator.getInstance().getBuffer(), true); } }
@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); }
@SuppressWarnings("SameReturnValue") public static IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (soilTextures == null) { bakeTextures(bakedTextureGetter); bakeModels(); } return INSTANCE; }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { if(transforms.isEmpty()) return Pair.of(this, null); Pair<Baked, TRSRTransformation> p = transforms.get(cameraTransformType); return Pair.of(p.getLeft(), p.getRight().getMatrix()); }
private IBakedModel getModel(@Nonnull ItemStack stack) { String key = getKey(stack); int meta = stack.getMetadata(); if (!modelCache.containsKey(key)) { if (DankTextures.DANKNULL_PANELS == null) { DankTextures.getInstance().registerIcons(RenderUtils.getBlocksTextureMap()); } List<BakedQuad> quads = ItemQuadBakery.bakeItem(DankTextures.DANKNULL_PANELS[meta]); modelCache.put(key, new PerspectiveAwareBakedModel(quads, props)); } return modelCache.get(key); }
public static void renderItemWithTransform(World world, ItemStack stack, ItemCameraTransforms.TransformType transform) { GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); GlStateManager.enableCull(); GlStateManager.depthMask(true); RenderHelper.enableStandardItemLighting(); GlStateManager.enableAlpha(); GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); IBakedModel ibakedmodel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, (EntityLivingBase) null); IBakedModel transformedModel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, transform, false); Minecraft.getMinecraft().getRenderItem().renderItem(stack, transformedModel); GlStateManager.disableBlend(); GlStateManager.disableAlpha(); RenderHelper.disableStandardItemLighting(); GlStateManager.depthMask(false); GlStateManager.disableCull(); GlStateManager.popAttrib(); GlStateManager.popMatrix(); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { if (cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND || cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND) { return Pair.of(this, mat_fp); } if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) { return Pair.of(this, mat_gui); } return Pair.of(this, null); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) return Pair.of(this, mat_gui); return Pair.of(this, mat); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { if(cameraTransformType == ItemCameraTransforms.TransformType.GUI) return Pair.of(this, mat_gui); return Pair.of(this, mat); }
@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)); } IBakedModel bakedModel = builder.makeMultipartModel(); return bakedModel; }
private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_) { ItemStack itemstack = itemIn.getEntityItem(); Item item = itemstack.getItem(); if (item == null) { return 0; } else { boolean flag = p_177077_9_.isGui3d(); int i = this.getModelCount(itemstack); float f = 0.25F; float f1 = shouldBob() ? MathHelper.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0; float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y; GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_); if (flag || this.renderManager.options != null) { float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI); GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F); } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); return i; } }
@Override public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) { Optional<UUID> optional = ((IQuantumStack) stack.getItem()).getKey(stack); if(optional.isPresent()) { ItemStack mirrored = QuantumHandler.getEntanglementStack(optional.get(), 0); if(!mirrored.isEmpty()) { SpecialModelRenderer.setTempItemRenderer(mirrored); } } return originalModel; }