Posted February 9, 20187 yr I have TESR that I need to render an obj with, (there will be animation and the obj in question is not always rendered in every circumstance, so yes, it really does need to be a tesr). Unfortunately, when it tries to load the model it crashes with this error: java.lang.RuntimeException: java.io.FileNotFoundException: demesne:models/item/retort_liquid. I don't really understand why it would event be looking for an item model, but I added the model to models/item as well as models/block and I still get the exact same error. For reference this is my TESR code: Spoiler public class CauldronTESR extends TileEntitySpecialRenderer<CauldronTile> { private IModel modelRetort; private IBakedModel bakedModelRetort; private IBakedModel getBakedModel() { if (bakedModelRetort == null) { try { modelRetort = OBJLoader.INSTANCE.loadModel(new ResourceLocation(DemConstants.MODID, "models/block/retort_liquid")); } catch (Exception e) { throw new RuntimeException(e); } bakedModelRetort = modelRetort.bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString())); } return bakedModelRetort; } @Override public void render(CauldronTile te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { GlStateManager.pushAttrib(); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.disableRescaleNormal(); if(!te.getStackInSlot(0).isEmpty()) { Color color = new Color(ReagentItem.getColorFromStack(te.getStackInSlot(0))); renderReagent(te, color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F); } renderItemFlat(te, 0, 0.25F, 0.625F, 0.25F); renderItem(te, 1, 0.775F, 0.7F, 0.775F); renderItem(te, 2, 0.6F, 0.7F, 0.85F); renderItem(te, 3, 0.425F, 0.7F, 0.85F); renderItem(te, 4, 0.25F, 0.7F, 0.775F); GlStateManager.popMatrix(); GlStateManager.popAttrib(); } private void renderReagent(CauldronTile te, float red, float green, float blue) { GlStateManager.pushMatrix(); GlStateManager.enableBlend(); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel( getWorld(), getBakedModel(), getWorld().getBlockState(te.getPos()), te.getPos(), Tessellator.getInstance().getBuffer(), false); tessellator.draw(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } private void renderItem(CauldronTile te, int slot, float x, float y, float z) { ItemStack stack = te.getStackInSlot(slot); if (!stack.isEmpty()) { RenderHelper.enableStandardItemLighting(); GlStateManager.enableLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.scale(.2f, .2f, .2f); Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); } } private void renderItemFlat(CauldronTile te, int slot, float x, float y, float z) { ItemStack stack = te.getStackInSlot(slot); if (!stack.isEmpty() && !(stack.getItem() == DemItems.reagentItem && slot == 0)) { RenderHelper.enableStandardItemLighting(); GlStateManager.enableLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.scale(.25f, .25f, .25f); GlStateManager.rotate(90.0f, 1.0f, 0, 0); GlStateManager.rotate(180.0f, 0, 0, 1.0f); Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); } } } and the crash report can be found here: https://pastebin.com/jpgxfm6m Edited February 11, 20187 yr by Codasylph
February 9, 20187 yr hey actually simple you need to add .obj to the location string if (bakedModelRetort == null) { try { modelRetort = OBJLoader.INSTANCE.loadModel(new ResourceLocation(DemConstants.MODID, "models/block/retort_liquid.obj")); } catch (Exception e) { throw new RuntimeException(e); } bakedModelRetort = modelRetort.bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString())); } Edited February 9, 20187 yr by sir_titi Always looking for new challenges, and happy to help the people where ever I can
February 9, 20187 yr Author weird, the example I saw did not do that. But it was older than 1.12, so that could be it. Thank you!
February 9, 20187 yr well i do it and everything works just fine, and no prob Always looking for new challenges, and happy to help the people where ever I can
February 9, 20187 yr Author Ok, one more little thing. I don't crash anymore, and it renders the obj properly. But it renders very very dark, almost black. I can tell its actually rendering the texture, just super dark. I've tried using the RenderHelper#enableStandardItemLighting and a few other lighting things within GlStateManager but nothing seems to make the slightest difference. I saw one other post with a similar issue here, but it had no replies. For reference here is my updated code just for rendering the obj (since I wasn't actually binding a texture or anything in the previously posted code): private void renderReagent(CauldronTile te, float red, float green, float blue) { GlStateManager.pushMatrix(); bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); // GlStateManager.enableBlend(); // GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GlStateManager.color(red, green, blue, .2f); GlStateManager.enableLight(1); GlStateManager.translate(-te.getPos().getX(), -te.getPos().getY()+1.0F, -te.getPos().getZ()+1.0F); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel( getWorld(), getBakedModel(), getWorld().getBlockState(te.getPos()), te.getPos(), Tessellator.getInstance().getBuffer(), true); tessellator.draw(); // GlStateManager.disableBlend(); GlStateManager.translate(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ()); GlStateManager.popMatrix(); }
February 10, 20187 yr well for starters i use this bufferBuilder.begin(GL11.GL_QUADS,Attributes.DEFAULT_BAKED_FORMAT); and not bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); not that i am saying that it could not work, but you are using bakedModels private void renderReagent(CauldronTile te, float red, float green, float blue){ GlStateManager.pushMatrix(); /*maybe this could help for the dark model \/\/*/ GL11.glDisable(GL11.GL_LIGHTING); bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); // GlStateManager.enableBlend(); // GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GlStateManager.color(red, green, blue, .2f); GlStateManager.translate(-te.getPos().getX(), -te.getPos().getY()+1.0F, -te.getPos().getZ()+1.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(GL11.GL_QUADS, Attributes.DEFAULT_BAKED_FORMAT);//I prefer this since you are using bakedModels Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(getWorld(),getBakedModel(), getWorld().getBlockState(te.getPos()),te.getPos(),bufferbuilder, true); tessellator.draw(); // GlStateManager.disableBlend(); GlStateManager.translate(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ()); GlStateManager.popMatrix(); /*maybe this could help for the dark model \/\/*/ GL11.glEnable(GL11.GL_LIGHTING); } And why are you translating back when done rendering? xs Edited February 10, 20187 yr by sir_titi Always looking for new challenges, and happy to help the people where ever I can
February 11, 20187 yr Author The Default baked format thing fixed it. As for the translating back thing, literally just because i've gotten this idea in my head that when you do openGL things you have to undo them. There's no actual good reason. Thanks again for the help!
February 11, 20187 yr well yes that is true for openGL stuff, but that is to what i know, if you pop the let's say the matrix everything in that matrix will be canceled. But i may be wrong about that . Anyways glad to be able to help And for the translating back that could be useful if you have some other parts that need to be rendered. but yea if it works for you sure go ahead . And to be honest i don't use the Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel I made my own method's to render the models Greets Sir_titi Edited February 11, 20187 yr by sir_titi Always looking for new challenges, and happy to help the people where ever I can
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.