Posted March 13, 20187 yr Hey guys, I am trying to render a model of a block, which I want to retrieve directly from the json file which is located in the normal location for block models for my mod. I don't want to have it go through the model registry, because the model must be dynamic, for it changes while the game is running, and I don't want to have to reload all the resources every time that that one model has to change. I think there should be other ways to do this rather then using a TESR, but I don't know any of them, so if you know another, possibly simpler way, please tell me. Thanks in advance, Lenardjee
March 13, 20187 yr Wait what? You want to render a JSON model, but that that JSON model changes during runtime, so you don't want the IBakedModel created from that JSON file. Why the hell is that JSON model dynamic? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 13, 20187 yr Author 3 minutes ago, Draco18s said: Wait what? You want to render a JSON model, but that that JSON model changes during runtime, so you don't want the IBakedModel created from that JSON file. Why the hell is that JSON model dynamic? Well, that is because I am trying to recreate the chisel and bits mod, and I have all the logic set up already. Only the displaying of the different bits doesn't work yet. I even made a function that changes the json file when the a piece is added or removed from the block. Edited March 13, 20187 yr by Lenardjee
March 13, 20187 yr 4 minutes ago, Lenardjee said: I even made a function that changes the json file This is disgusting. Do not do this. JSON is a serialization format, you are dealing with runtime data, use runtime storage techniques. Don't serialize the data, then deserialize it back into memory, that's fucking retarded. On top of that, you're trying to make one JSON file handled an arbitrary number of different model results by overwriting the file every time you need to render. This is a massive fucking mess. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 13, 20187 yr 3 minutes ago, Draco18s said: use runtime storage techniques Calculate your data, then render your calculations. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 13, 20187 yr Author Yeah, I get that, but how do I 'render' these calculations? What I have is an accurate ArrayList<Obj> where Obj extends AxisAlignedBB with as only change that you have to pass a IBlockState into the constructer which I want to use to get the texture of each small piece of the block. Patches of bits the same type of block that are next to each other are being combined into 1 Obj, so after each change of the block the ArrayList<Obj> is changed so that it contains all the small pieces of the block. I can reach that list from the TESR and so retrieve the individual pieces that it should render. The only problem is that I don't know how to render it, let alone what the most efficient way of rendering is. Edited March 13, 20187 yr by Lenardjee
March 13, 20187 yr You're storing all that data in your TE somewhere, right? Grab that data from inside your TESR render call, and build a series of quads for each "bit" Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 15, 20187 yr Author Ok, I think I understand what I have to do, but I do not understand how to do these quads. The last 4 hours I've been trying to find an tutorial on how to use them to draw boxes with a certain texture, but I just can't get it to work. this is the code in my TESR as far as it is now: public void render(TileEntityMiniBlock te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f); GlStateManager.enableBlend(); RenderHelper.enableStandardItemLighting(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.pushMatrix(); te = (TileEntityMiniBlock) Minecraft.getMinecraft().getIntegratedServer().getWorld(Minecraft.getMinecraft().world.provider.getDimension()).getTileEntity(te1.getPos()); BufferBuilder ver = Tessellator.getInstance().getBuffer(); ArrayList<Obj> objs = te.objs; for(int i = 0; i < objs.size(); i++) { ver.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); ver.pos(objs.get(i).minX, objs.get(i).minY + 1.0, objs.get(i).minZ).tex(16, 16).color(200, 0, 200, 100).endVertex(); ver.pos(objs.get(i).maxX, objs.get(i).maxY + 1.0, objs.get(i).maxZ).tex(16, 16).color(200, 0, 200, 100).endVertex(); // ver.finishDrawing(); Tessellator.getInstance().draw(); } GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); } By the way, I have not a single idea on how to give it a texture either...
March 15, 20187 yr Use less GLManager and more VertexBuffer / Tessellator The VertexBuffer (or Tessellator, if you're familiar with it, it got renamed) is essentially just a wrapper around the GL code, but it makes things easier. Edited March 15, 20187 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 16, 20187 yr Author Ok, I understand that, but now I am trying to use vertexes to draw some textures and it kind of works, but there are a lot of weird things going on now, such as mobs showing up in strange locations, with parts of their body just flying around and moving weirdly and items in my inventory shift a few pixels sometimes... I don't know how to prevent that from happening... EDIT the selectedBoundingBox of blocks is moving around as well Edited March 16, 20187 yr by Lenardjee
March 16, 20187 yr Author And this is the code in my TESR: @Override public void render(TileEntityMiniBlock te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { // System.out.println("render"); renderBlock(te, x, y, z, partialTicks, destroyStage, alpha); } public void renderBlock(TileEntityMiniBlock te1, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { // System.out.println("renderBlock"); if(Minecraft.getMinecraft().getIntegratedServer().getWorld(Minecraft.getMinecraft().world.provider.getDimension()).getTileEntity(te1.getPos()) != null) { if(Minecraft.getMinecraft().getIntegratedServer().getWorld(Minecraft.getMinecraft().world.provider.getDimension()).getTileEntity(te1.getPos()) instanceof TileEntityMiniBlock) { te = (TileEntityMiniBlock) Minecraft.getMinecraft().getIntegratedServer().getWorld(Minecraft.getMinecraft().world.provider.getDimension()).getTileEntity(te1.getPos()); BufferBuilder ver = Tessellator.getInstance().getBuffer(); ArrayList<Obj> objs = te.objs; for(int i = 0; i < objs.size(); i++) { // GlStateManager.pushMatrix(); // GlStateManager.enableRescaleNormal(); // GlStateManager.enableBlend(); ver.setTranslation(x, y, z); ver.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); // ver.pos(objs.get(i).maxX, objs.get(i).minY + 1.0, objs.get(i).minZ).tex(0.3, 0.1).color(200, 0, 200, 100).endVertex(); // ver.pos(objs.get(i).maxX, objs.get(i).maxY + 1.0, objs.get(i).minZ).tex(0.3, 0.0).color(200, 0, 200, 100).endVertex(); // ver.pos(objs.get(i).minX, objs.get(i).maxY + 1.0, objs.get(i).minZ).tex(0.2, 0.0).color(200, 0, 200, 100).endVertex(); // ver.pos(objs.get(i).minX, objs.get(i).minY + 1.0, objs.get(i).minZ).tex(0.2, 0.1).color(200, 0, 200, 100).endVertex(); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); // Minecraft.getMinecraft()TESRMiniBlock.get ver.pos(0.0f, 1.0f, 20.0f).tex( 0.1 / 3.125 * 20, 0.1 / 3.125 * 20).normal((float) x, (float) y, (float) z).endVertex(); ver.pos(0.0f, 21.0f, 20.0f).tex(0.1 / 3.125 * 20, 0.1 / 3.125 * 0).normal((float) x, (float) y, (float) z).endVertex(); ver.pos(0.0f, 21.0f, 0.0f).tex( 0.1 / 3.125 * 0, 0.1 / 3.125 * 0).normal((float) x, (float) y, (float) z).endVertex(); ver.pos(0.0f, 1.0f, 0.0f).tex( 0.1 / 3.125 * 0, 0.1 / 3.125 * 20).normal((float) x, (float) y, (float) z).endVertex(); ver.endVertex(); Tessellator.getInstance().draw(); ver.reset(); // GlStateManager.disableRescaleNormal(); // GlStateManager.disableBlend(); // GlStateManager.popMatrix(); } } }
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.