lukas2005 Posted July 22, 2017 Posted July 22, 2017 hello i have this piece of code net.minecraft.client.renderer.RenderBlocks#getBlockIconFromSideAndMetadata and i cant figure out what is its equivalent in 1.10.2 Quote
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 im trying to port this bit of code to 1.10.2 (from 1.7.10) IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, meta); double tu0 = (double)icon.getMinUV(); double tu1 = (double)icon.getMaxU(); double tv0 = (double)icon.getMinV(); double tv1 = (double)icon.getMaxV(); Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 What is your overall goal? What feature is this code a part of? We need some more context than a snippet of code. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 (edited) On 7/22/2017 at 12:31 PM, diesieben07 said: That code alone does precisely nothing. Expand yes i know its because its part of bigger thing On 7/22/2017 at 12:31 PM, Choonster said: What is your overall goal? What feature is this code a part of? We need some more context than a snippet of code. Expand im using this to then be able to use tessalator to render some stuff Edited July 22, 2017 by lukas2005 Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 12:35 PM, lukas2005 said: im using this to then be able to use tessalator to render some stuff Expand What "stuff"? You're being very vague, which makes it hard to help you. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 On 7/22/2017 at 12:38 PM, Choonster said: What "stuff"? You're being very vague, which makes it hard to help you. Expand i just use this little snippet for rendering an i need to know what is repacment for IIcon and RenderBlocks Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 12:41 PM, lukas2005 said: i just use this little snippet for rendering an i need to know what is repacment for IIcon and RenderBlocks Expand But what are you trying to render? Where are you rendering it? IIcon and RenderBlocks were replaced by the baked model system, but it's hard to tell you what you need to do when we don't actually know what you're trying to do. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 i am trying to make terrain smoother rather than just blocks and i need to know the size of textures for tesselator whole render method: (1.7.10) public static boolean renderChunk(int pass, int cx, int cy, int cz, IBlockAccess cache, RenderBlocks renderer) { if(!ModConfig.MOD_ENABLED) { return false; } else if(pass != 0) { return false; } else { Tessellator tess = Tessellator.getInstance(); int[] dims = new int[]{16, 16, 16}; int[] c = new int[]{cx, cy, cz}; int[] x = new int[3]; int[] r = new int[]{1, dims[0] + 3, (dims[0] + 3) * (dims[1] + 3)}; float[] grid = new float[8]; float[][] buffer = new float[r[2] * 2][3]; int bufno = 1; for(x[2] = 0; x[2] < dims[2] + 1; r[2] = -r[2]) { int m = 1 + (dims[0] + 3) * (1 + bufno * (dims[1] + 3)); for(x[1] = 0; x[1] < dims[1] + 1; m += 2) { for(x[0] = 0; x[0] < dims[0] + 1; ++m) { int mask = 0; int g = 0; for(int k = 0; k < 2; ++k) { for(int j = 0; j < 2; ++j) { for(int i = 0; i < 2; ++g) { float p = getBlockDensity(c[0] + x[0] + i, c[1] + x[1] + j, c[2] + x[2] + k, cache); grid[g] = p; mask |= p > 0.0F?1 << g:0; ++i; } } } if(mask != 0 && mask != 255) { Block block = Blocks.AIR; int meta = 0; label368: for(int k = -1; k < 2; ++k) { for(int j = -1; j < 2; ++j) { for(int i = -1; i < 2; ++i) { IBlockState bs = cache.getBlockState(new BlockPos(c[0] + x[0] + i, c[1] + x[1] + k, c[2] + x[2] + j)); Block b = bs.getBlock(); if(Main.shouldSmooth(b) && block != Blocks.SNOW_LAYER && block != Blocks.GRASS) { block = b; meta = b.getMetaFromState(bs); if(b == Blocks.SNOW_LAYER || b == Blocks.GRASS) { break label368; } } } } } int[] br = new int[]{c[0] + x[0], c[1] + x[1] + 1, c[2] + x[2]}; label594: for(int k = -1; k < 2; ++k) { for(int j = -2; j < 3; ++j) { for(int i = -1; i < 2; ++i) { IBlockState bs = cache.getBlockState(new BlockPos(c[0] + x[0] + i, c[1] + x[1] + k, c[2] + x[2] + j)); Block b = bs.getBlock(); if(!b.isOpaqueCube(bs)) { br[0] = c[0] + x[0] + i; br[1] = c[1] + x[1] + k; br[2] = c[2] + x[2] + j; break label594; } } } } IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, meta); double tu0 = (double)icon.getMinUV(); double tu1 = (double)icon.getMaxU(); double tv0 = (double)icon.getMinV(); double tv1 = (double)icon.getMaxV(); int edgemask = edge_table[mask]; int ecount = 0; float[] v = new float[]{0.0F, 0.0F, 0.0F}; for(int i = 0; i < 12; ++i) { if((edgemask & 1 << i) != 0) { ++ecount; int e0 = cube_edges[i << 1]; int e1 = cube_edges[(i << 1) + 1]; float g0 = grid[e0]; float g1 = grid[e1]; float t = g0 - g1; if(Math.abs(t) > 0.0F) { t = g0 / t; int j = 0; for(int k = 1; j < 3; k <<= 1) { int a = e0 & k; int b = e1 & k; if(a != b) { v[j] += a != 0?1.0F - t:t; } else { v[j] += a != 0?1.0F:0.0F; } ++j; } } } } float s = 1.0F / (float)ecount; for(int i = 0; i < 3; ++i) { v[i] = (float)(c[i] + x[i]) + s * v[i]; } int tx = x[0] == 16?0:x[0]; int ty = x[1] == 16?0:x[1]; int tz = x[2] == 16?0:x[2]; long i1 = (long)(tx * 3129871) ^ (long)tz * 116129781L ^ (long)ty; i1 = i1 * i1 * 42317861L + i1 * 11L; v[0] = (float)((double)v[0] - ((double)((float)(i1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.2D); v[1] = (float)((double)v[1] - ((double)((float)(i1 >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D); v[2] = (float)((double)v[2] - ((double)((float)(i1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.2D); buffer[m] = v; for(int i = 0; i < 3; ++i) { if((edgemask & 1 << i) != 0) { int iu = (i + 1) % 3; int iv = (i + 2) % 3; if(x[iu] != 0 && x[iv] != 0) { int du = r[iu]; int dv = r[iv]; //tess.setBrightness(block.getMixedBrightnessForBlock(Minecraft.getMinecraft().theWorld, br[0], br[1], br[2])); //tess.setColorOpaque_I(block.colorMultiplier(cache, c[0] + x[0], c[1] + x[1], c[2] + x[2])); dont know what to do with these too float[] v0 = buffer[m]; float[] v1 = buffer[m - du]; float[] v2 = buffer[m - du - dv]; float[] v3 = buffer[m - dv]; if((mask & 1) != 0) { tess.addVertexWithUV((double)v0[0], (double)v0[1], (double)v0[2], tu0, tv1); tess.addVertexWithUV((double)v1[0], (double)v1[1], (double)v1[2], tu1, tv1); tess.addVertexWithUV((double)v2[0], (double)v2[1], (double)v2[2], tu1, tv0); tess.addVertexWithUV((double)v3[0], (double)v3[1], (double)v3[2], tu0, tv0); } else { tess.addVertexWithUV((double)v0[0], (double)v0[1], (double)v0[2], tu0, tv1); tess.addVertexWithUV((double)v3[0], (double)v3[1], (double)v3[2], tu1, tv1); tess.addVertexWithUV((double)v2[0], (double)v2[1], (double)v2[2], tu1, tv0); tess.addVertexWithUV((double)v1[0], (double)v1[1], (double)v1[2], tu0, tv0); } } } } } ++x[0]; } ++x[1]; } ++x[2]; bufno ^= 1; } return true; } } static { int k = 0; for(int i = 0; i < 8; ++i) { for(int j = 1; j <= 4; j <<= 1) { int p = i ^ j; if(i <= p) { cube_edges[k++] = i; cube_edges[k++] = p; } } } for(int i = 0; i < 256; ++i) { int em = 0; for(int j = 0; j < 24; j += 2) { boolean a = (i & 1 << cube_edges[j]) != 0; boolean b = (i & 1 << cube_edges[j + 1]) != 0; em |= a != b?1 << (j >> 1):0; } edge_table[i] = em; } } Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 The main problem you'll run into is that blocks no longer have textures, they now have models. An IBakedModel can have any number of BakedQuads, each of which belongs to an EnumFacing (or null) and has a texture. You can use IBakedModel#getQuads to get the BakedQuads for an optional IBlockState and optional EnumFacing. You'll need to work out what to do if the model has either zero or more than one BakedQuads for EnumFacing.UP (probably blacklist that state from being smoothed). Look at BlockRendererDispatcher#renderBlock to see how it gets the actual state from the in-world state, the model from the actual state and the extended state from the actual state before rendering the model. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 On 7/22/2017 at 1:07 PM, Choonster said: The main problem you'll run into is that blocks no longer have textures, they now have models. An IBakedModel can have any number of BakedQuads, each of which belongs to an EnumFacing (or null) and has a texture. You can use IBakedModel#getQuads to get the BakedQuads for an optional IBlockState and optional EnumFacing. You'll need to work out what to do if the model has either zero or more than one BakedQuads for EnumFacing.UP (probably blacklist that state from being smoothed). Look at BlockRendererDispatcher#renderBlock to see how it gets the actual state from the in-world state, the model from the actual state and the extended state from the actual state before rendering the model. Expand how do i get the IBakedModel from block? Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 1:14 PM, lukas2005 said: how do i get the IBakedModel from block? Expand As I said, look at BlockRendererDispatcher#renderBlock. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 (edited) On 7/22/2017 at 1:17 PM, Choonster said: As I said, look at BlockRendererDispatcher#renderBlock. Expand well it uses non-static method getModelForState then how do i get BlockRendererDispatcher instance?EDIT ok i got it Minecraft.getMinecraft().getBlockRendererDispatcher() Edited July 22, 2017 by lukas2005 Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 1:18 PM, lukas2005 said: well it uses non-static method getModelForState Expand Yes, you should use it too. Use Minecraft#getBlockRendererDispatcher to get the BlockRenderDispatcher instance. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 now in IBakedModel#getQuads teres a strange long at the and called rand what shlou it be? random long? Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 1:23 PM, lukas2005 said: now in IBakedModel#getQuads teres a strange long at the and called rand what shlou it be? random long? Expand That's a "random" number derived from the BlockPos, use MathHelper.getPositionRandom to calculate it. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 (edited) ok i have the quads list now what do i do with a quad?] EDIT: i got an object called TextureAtlasSprite from a quad and it seems to have almost same functions as the old IIcon object wich is great Edited July 22, 2017 by lukas2005 Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 1:36 PM, lukas2005 said: ok i have the quads list now what do i do with a quad? Expand Get its texture with BakedQuad#getSprite. This is a TextureAtlasSprite, a sprite on the block/item texture atlas (like IIcon). Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted July 22, 2017 Author Posted July 22, 2017 ok i now have my sizes but there is one more thing what are these? tess.setBrightness(block.getMixedBrightnessForBlock(Minecraft.getMinecraft().theWorld, br[0], br[1], br[2])); tess.setColorOpaque_I(block.colorMultiplier(cache, c[0] + x[0], c[1] + x[1], c[2] + x[2])); Quote
Choonster Posted July 22, 2017 Posted July 22, 2017 On 7/22/2017 at 1:41 PM, lukas2005 said: ok i now have my sizes but there is one more thing what are these? tess.setBrightness(block.getMixedBrightnessForBlock(Minecraft.getMinecraft().theWorld, br[0], br[1], br[2])); tess.setColorOpaque_I(block.colorMultiplier(cache, c[0] + x[0], c[1] + x[1], c[2] + x[2])); Expand I can't really help you with rendering specifics like this, all I can suggest is looking at ForgeBlockModelRenderer#renderModelFlat/ForgeBlockModelRenderer#renderModelSmooth (called by BlockModelRenderer#renderModel) to see how they render block models. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Recommended Posts
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.