
Jhary
Members-
Posts
14 -
Joined
-
Last visited
Everything posted by Jhary
-
hmm ok it was not the lighting. I get just a 3D block completely covered in dark grey. Not as in too dark, as in here: http://www.directupload.net/file/d/3658/ondfi9un_png.htm The texture binding seems to work correctly because if I remove the .png file extension for testing I get an exception on startup. I disable the GL11 lighting at the beginning of my method and enable it again at the end. That is right? Or do I have to do that before and after every single Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("modid","textures/blocks/filename.png")); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 3)); tessellator.draw(); code block? (the parameters of the Resource Location constructor are different in my case)
-
I did now bind one texture at a time as I needed it But.. nothing gets better. Probably it is more of a lighting problem and if I get that sorted out I see the textures.(Now its just dark .. perhaps the textures are therer but without lighting?) But as I said above: I tried to setup the lighting of my tessellator with tessellator.setBrightness(int) but I can't figure out how to get the brightness value. block.getMixedBrightnessForBlock(...) needs a world and coordinates that I don't have in this method.
-
Yeah I already tried that, if I bin my textures beforehand like this : Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("mymod:block_front")); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("mymod:block_top")); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("mymod:block_side")); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("mymod:block_back")); But then the 3D block renders very dark and I cannot see if it is just black or my textures.. I tried to setup the lighting of my tessellator with tessellator.setBrightness(int) but I can't figure out how to get the brightness value. block.getMixedBrightnessForBlock(...) needs a world and coordinates that I don't have in this method.
-
No you get me wrong. The textures are fine. The block renders if placed correctly with all the textures. Just like I want it. I just don't get it to work in my inventory / hand. I just get a 3D block with the purple/black texture... @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; block.setBlockBoundsForItemRender(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 2)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 3)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 4)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 5)); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); } The error log shows not a single error..
-
This implementation seems to work. I got a 3D block now in my inventory But.. no valid textures. Maybe the renderer.getBlockIconFromSide(..) seems to find no IIcon..strange. renderer.getBlockIconFromSideAndMetadata(..) has no effect, too.
-
Yeah its turned off, right. But if I turn it on, the only difference is that it is just invisible in my inventory/hand. You are right, it should be set to true, but that does not solve the rendering because I still don't really know what to do in the renderInventoryBlock(...) method of my ISimpleBlockRenderingHandler.. Here is what I tried: @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { IIcon top = renderer.getBlockIconFromSide(block, 1); IIcon bottom = renderer.getBlockIconFromSide(block, 0); IIcon north = renderer.getBlockIconFromSide(block, 2); IIcon south = renderer.getBlockIconFromSide(block, 3); IIcon west = renderer.getBlockIconFromSide(block, 4); IIcon east = renderer.getBlockIconFromSide(block, 5); renderer.renderFaceXNeg(block, 0, 0, 0, west); renderer.renderFaceXPos(block, 0, 0, 0, east); renderer.renderFaceYNeg(block, 0, 0, 0, bottom); renderer.renderFaceYPos(block, 0, 0, 0, top); renderer.renderFaceZNeg(block, 0, 0, 0, north); renderer.renderFaceZPos(block, 0, 0, 0, south); } renderer.renderFace* needs coordinates that I don't got here. And if I use renderer.renderBlockAsItem(block, 3, 1.0F); instead I just get a Stack Overflow Exception.. I am a bit clueless at the moment..
-
*sigh* Hi again ! As solved in this topic : http://www.minecraftforge.net/forum/index.php/topic,20137.0.html my custom rendered block now does everything I want, but .. it does not render as an item in my hand or in my inventory. I just get a flat not found texture (the black/purple thingy) My ISimpleBlockRenderingHelper implementation hast got this method here that seems what I have to use: @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { } But how do I use it correctly? There is a method from the RenderBlocks class called .renderBlockAsItem(Block block, int noclue, float noclue). But just using this method and testing with the values did not change a single thing. I even tried defining each IIcon to render on every side using the methods from the RenderBlocks class (.renderFace*) and then calling the .renderBlockAsItem method but that didn't work either.. On http://greyminecraftcoder.blogspot.com.au/ there is an article about rendering custom blocks in inventories but I don't really get it this time. For reference, here is my custom renderer implementation : public class MyTileRenderer implements ISimpleBlockRenderingHandler{ @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { IIcon top = block.getIcon(world, x, y, z, 1); IIcon bottom = block.getIcon(world, x, y, z, 0); IIcon north = block.getIcon(world, x, y, z, 2); IIcon south = block.getIcon(world, x, y, z, 3); IIcon west = block.getIcon(world, x, y, z, 4); IIcon east = block.getIcon(world, x, y, z, 5); renderer.renderFaceXNeg(block, x, y, z, west); renderer.renderFaceXPos(block, x, y, z, east); renderer.renderFaceYNeg(block, x, y, z, bottom); renderer.renderFaceYPos(block, x, y, z, top); renderer.renderFaceZNeg(block, x, y, z, north); renderer.renderFaceZPos(block, x, y, z, south); TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityMyTile){ //wonky rendering incoming switch(((TileEntityMyTile)tile).orientation.ordinal()){ case 0: //Bottom renderer.uvRotateNorth=2; //west renderer.uvRotateSouth=1; //east renderer.uvRotateWest=2; //south renderer.uvRotateEast=1; //north break; case 1: //Top renderer.uvRotateNorth=1; renderer.uvRotateSouth=2; renderer.uvRotateWest=1; renderer.uvRotateEast=2; break; case 2: //North renderer.uvRotateTop = 1; renderer.uvRotateBottom = 2; break; case 3: //South renderer.uvRotateTop=2; renderer.uvRotateBottom=1; renderer.uvRotateNorth=3; renderer.flipTexture=true; //east break; case 4: //West renderer.uvRotateTop=4; renderer.uvRotateBottom=4; break; case 5: //East renderer.uvRotateTop=3; renderer.uvRotateBottom=3; renderer.flipTexture=true; break; } } boolean flag = renderer.renderStandardBlock(block, x, y, z); //important reset afterwards! renderer.flipTexture=false; renderer.uvRotateNorth=0; //west renderer.uvRotateSouth=0; //east renderer.uvRotateWest=0; //south renderer.uvRotateEast=0; //north renderer.uvRotateTop=0; renderer.uvRotateBottom=0; return flag; } @Override public int getRenderId() { return ClientProxy.myTileRenderID; } @Override public boolean shouldRender3DInInventory(int modelId) { return false; } }
-
Ok finally had the time to give it a try and it works like a charm if I just don't use the tessellator and therefore use the RenderBlocks object. Rotation is easily done and for the lighting is no additional setup neccessary. I will post the code here if anyone else needs a reference Thanks again! @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { IIcon up = block.getIcon(world, x, y, z, 1); IIcon down = block.getIcon(world, x, y, z, 0); IIcon north = block.getIcon(world, x, y, z, 2); IIcon south = block.getIcon(world, x, y, z, 3); IIcon west = block.getIcon(world, x, y, z, 4); IIcon east = block.getIcon(world, x, y, z, 5); renderer.renderFaceXNeg(block, x, y, z, west); renderer.renderFaceXPos(block, x, y, z, east); renderer.renderFaceYNeg(block, x, y, z, down); renderer.renderFaceYPos(block, x, y, z, up); renderer.renderFaceZNeg(block, x, y, z, north); renderer.renderFaceZPos(block, x, y, z, south); TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityMyTile){ //wonky rendering incoming switch(((TileEntityMyTile)tile).orientation.ordinal()){ case 0: //Bottom renderer.uvRotateNorth=2; //west renderer.uvRotateSouth=1; //east renderer.uvRotateWest=2; //south renderer.uvRotateEast=1; //north break; case 1: //Top renderer.uvRotateNorth=1; renderer.uvRotateSouth=2; renderer.uvRotateWest=1; renderer.uvRotateEast=2; break; case 2: //North renderer.uvRotateTop = 1; renderer.uvRotateBottom = 2; break; case 3: //South renderer.uvRotateTop=2; renderer.uvRotateBottom=1; renderer.uvRotateNorth=3; renderer.flipTexture=true; //east break; case 4: //West renderer.uvRotateTop=4; renderer.uvRotateBottom=4; break; case 5: //East renderer.uvRotateTop=3; renderer.uvRotateBottom=3; renderer.flipTexture=true; break; } } boolean flag = renderer.renderStandardBlock(block, x, y, z); //important reset afterwards! renderer.flipTexture=false; renderer.uvRotateNorth=0; //west renderer.uvRotateSouth=0; //east renderer.uvRotateWest=0; //south renderer.uvRotateEast=0; //north renderer.uvRotateTop=0; renderer.uvRotateBottom=0; return flag; }
-
ok I got it now working that it renders correctly. Here is my method so far: @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; IIcon up = block.getIcon(world, x, y, z, 1); IIcon down = block.getIcon(world, x, y, z, 0); IIcon north = block.getIcon(world, x, y, z, 2); IIcon south = block.getIcon(world, x, y, z, 3); IIcon west = block.getIcon(world, x, y, z, 4); IIcon east = block.getIcon(world, x, y, z, 5); //Down 0 tessellator.addVertexWithUV(x+1, y , z , (double)down.getMaxU(), (double)down.getMaxV()); tessellator.addVertexWithUV(x+1, y , z+1, (double)down.getMaxU(), (double)down.getMinV()); tessellator.addVertexWithUV(x , y , z+1, (double)down.getMinU(), (double)down.getMinV()); tessellator.addVertexWithUV(x , y , z , (double)down.getMinU(), (double)down.getMaxV()); //Up 1 tessellator.addVertexWithUV(x+1, y+1, z+1, (double)up.getMaxU(), (double)up.getMaxV()); tessellator.addVertexWithUV(x+1, y+1, z , (double)up.getMaxU(), (double)up.getMinV()); tessellator.addVertexWithUV(x , y+1, z , (double)up.getMinU(), (double)up.getMinV()); tessellator.addVertexWithUV(x , y+1, z+1, (double)up.getMinU(), (double)up.getMaxV()); //North 2 tessellator.addVertexWithUV(x , y , z , (double)north.getMaxU(), (double)north.getMaxV()); tessellator.addVertexWithUV(x , y+1, z , (double)north.getMaxU(), (double)north.getMinV()); tessellator.addVertexWithUV(x+1, y+1, z , (double)north.getMinU(), (double)north.getMinV()); tessellator.addVertexWithUV(x+1, y , z , (double)north.getMinU(), (double)north.getMaxV()); //South 3 tessellator.addVertexWithUV(x+1, y , z+1, (double)south.getMaxU(), (double)south.getMaxV()); tessellator.addVertexWithUV(x+1, y+1, z+1, (double)south.getMaxU(), (double)south.getMinV()); tessellator.addVertexWithUV(x , y+1, z+1, (double)south.getMinU(), (double)south.getMinV()); tessellator.addVertexWithUV(x , y , z+1, (double)south.getMinU(), (double)south.getMaxV()); //West 4 tessellator.addVertexWithUV(x , y , z+1, (double)west.getMaxU(), (double)west.getMaxV()); tessellator.addVertexWithUV(x , y+1, z+1, (double)west.getMaxU(), (double)west.getMinV()); tessellator.addVertexWithUV(x , y+1, z , (double)west.getMinU(), (double)west.getMinV()); tessellator.addVertexWithUV(x , y , z , (double)west.getMinU(), (double)west.getMaxV()); //East 5 tessellator.addVertexWithUV(x+1, y , z , (double)east.getMaxU(), (double)east.getMaxV()); tessellator.addVertexWithUV(x+1, y+1, z , (double)east.getMaxU(), (double)east.getMinV()); tessellator.addVertexWithUV(x+1, y+1, z+1, (double)east.getMinU(), (double)east.getMinV()); tessellator.addVertexWithUV(x+1, y , z+1, (double)east.getMinU(), (double)east.getMaxV()); return true; } It does not rotate the textures at this point. But it seems to work so far, but with one problem. Depending on different angles when moving around the block, the textures seem to flicker some times between just a black pane and the expected texture... does anyone know why? Next question would be, where in this method do I have to do the rotation with the renderer.uvRotate* thingy? Edit: the "flickering" does occur on all placed blocks at the same time when looking at them from some angles
-
Hmm ok I can't really wrap my head around this tessellator stuff, but it seems to be exactly what I need. Sadly I can't find a good example of someone using this with 1.7. I understand how to first setup the tessellator and that I have to do for each side of a block 4 times the "addVertexWithUV(x, y, z, u, v)" method. But I don't really understand how to setup the parameters. Lets say my block has the in world coordinates [10 ; 10 ; 10]. How would I setup the first four addVertexWithUV calls, lets say for the south side? In this article (http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html) there are four points defined as A, B, C and D I would understand this as follows according to the picture in the article : A: .addVertexWithUV(11, 10, 10, u, v) B: .addVertexWithUV(11, 11, 10, u, v) C: .addVertexWithUV(10, 11, 10, u, v) D: .addVertexWithUV(10, 10, 10, u, v) Would here x, y, z be correct? And if yes, how would I now find out what I have to use for u and v ?
-
Thanks for the links. I will study the content and try to get it working. I will post again after I tried everything out
-
Hi! I want to rotate the textures of some block faces based of the orientation of the block. The problem is, I don't want to setup a texture for every possible state, that would be too much I know I can achieve this with using an ISimpleBlockRenderingHandler and registering it with my custom block. But I can't really figure out how to properly write the public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { } method in my custom rendering class. More details of what I want to achieve: The TileEntity can already face in any of the six minecraft directions. Based on its orientation the textures that are not "front" and "back" have to be rotated properly because of their visuals. I searched a bit here and there but I did not find a source I could work with. Maybe I did not understand something the right way. The problem is, I don't really know how to setup the renderWorldBlock method. Only thing that I think I am knowing is that I have to use the "uveRotate*" methods of the RenderBlocks class.. Regards, Jhary
-
Many thanks dude. Because of your post I realized that I did a silly mistake. I wanted to spawn the new EntityItem exactly 1 block away in south direction (because of its rotation) of my TileEntity. So I thought spawn coords x, y, z+1 in relation to my TE are what I want... but no this would spawn the Entity partially underground and a bit to near. So it popped in an other direction all the time. After using x+0.5D, y+0.5D, z+1.5D relative to my TE, the EntityItem spawned 100% correctly in the middle of the block exactly south of the TE. Thanks again
-
Hi there! I want to spawn an EntityItem at given x,y,z coordinates. If I use something like this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord, this.zCoord-1, itemStack)); the EntityItem gets properly spawned but propelled away in an strange angle. I already tried to first define the EntityItem and alter the motion values before spawning it, but that didn't help. Is there a reliable way to spawn an EntityItem at exact coordinates? Regards, Jhary