Posted March 25, 201411 yr I wanted to make a block similar that looks similar to a furnace. I need it to change the front face based on where you are looking, like a furnace. If someone could post up code it would be [glow=yellow,2,300]awesome[/glow]! I am new to forge however am experienced in Java!
March 25, 201411 yr BlockFurnace? I think I'd start there for a good example of the code. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 25, 201411 yr Author Ok cool thanks I've copied the code, it all works smoothly, except for one thing, the furnace faces always a set direction; it never changes. I checked the furnace code and well i have been unsuccessful... ------------------------------------------------------------------------------------------------------------------------------- @SideOnly(Side.CLIENT) private Icon furnaceIconTop; @SideOnly(Side.CLIENT) private Icon furnaceIconFront; /** * Called whenever the block is added into the world. Args: world, x, y, z */ public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); } /** * set a blocks direction */ private void setDefaultDirection(World par1World, int par2, int par3, int par4) { if (!par1World.isRemote) { int l = par1World.getBlockId(par2, par3, par4 - 1); int i1 = par1World.getBlockId(par2, par3, par4 + 1); int j1 = par1World.getBlockId(par2 - 1, par3, par4); int k1 = par1World.getBlockId(par2 + 1, par3, par4); byte b0 = 3; if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1]) { b0 = 3; } if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l]) { b0 = 2; } if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1]) { b0 = 5; } if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1]) { b0 = 4; } par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2); } } @SideOnly(Side.CLIENT) /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront)); } @SideOnly(Side.CLIENT) /** * When this method is called, your block should register all the icons it needs with the given IconRegister. This * is the only chance you get to register icons. */ public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("furnace_side"); this.furnaceIconFront = par1IconRegister.registerIcon("furnace_front_off"); this.furnaceIconTop = par1IconRegister.registerIcon("furnace_top"); } ---------------------------------------------------------------------------------------------------------- If i could get some help that would be awesome! For some reason the code thing isn't working.... I am new to forge however am experienced in Java!
March 25, 201411 yr Ok cool thanks I've copied the code, it all works smoothly, except for one thing, the furnace faces always a set direction; it never changes. I checked the furnace code and well i have been unsuccessful... ------------------------------------------------------------------------------------------------------------------------------ So, what you want the face to change sides dynamically when you walk around it? -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 25, 201411 yr Author like you know when you place a furnace it faces you? I want that... This doesn't do that I am new to forge however am experienced in Java!
March 25, 201411 yr You want to copy onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) That is where the direction is determined and set. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 25, 201411 yr Author Thank you so much but one more problem.... the block. When you hold a furnace on the right hand side of the icon is the front and on the left side is the side icon. How can i make the icon of my item like that. both the left and right side is the icon for the side. I am new to forge however am experienced in Java!
March 25, 201411 yr Author Heres an image of what i mean if it works or not is another thing.... but hey! Thanks for your help! I am new to forge however am experienced in Java!
March 25, 201411 yr The Furnace uses metadata to determine it's placed direction (even when rendering on the hotbar.) The facing when in inventory is due to a trick in RenderBlocks where renderBlockAsItem(Block, meta, color) changes the metadata of the furnace used to lookup icon to 2. So, it forces the furnace to face the proper way to render the item in the hotbar. You might have to set your own block renderer to overcome that limitation. A possible workaround I haven't tried is to always create your ItemStack with a furnace with metadata = 2. When it is actually placed it will change accordingly, of course. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 25, 201411 yr The Furnace uses metadata to determine it's placed direction (even when rendering on the hotbar.) The facing when in inventory is due to a trick in RenderBlocks where renderBlockAsItem(Block, meta, color) changes the metadata of the furnace used to lookup icon to 2. So, it forces the furnace to face the proper way to render the item in the hotbar. You might have to set your own block renderer to overcome that limitation. A possible workaround I haven't tried is to always create your ItemStack with a furnace with metadata = 2. When it is actually placed it will change accordingly, of course. You could also do something way more easy. If the furnace is in the inventory, the metadata is 0, but if it's placed down, the metadata is 2,3,4 or 5. So in your getIcon method, check for a metadata that's 0, and if the side is 2, you need to set the front texture. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
March 25, 201411 yr Yes indeed. I hadn't even considered how the furnace will only ever face one of 4 directions, rather than 6. Good advice! -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 26, 201411 yr Author Guys i don't understand a word... Ima noob. Could you give me code and tell me where to put it? thanx. I am new to forge however am experienced in Java!
March 26, 201411 yr I would create a new ItemBlock, that's how wool renders differently in your inventory (and hand) based on metadata. http://www.minecraftforge.net/wiki/Metadata_Based_Subblocks#MultiItemBlock If you are experienced in java you should be able to use this tutorial to get the results you want. --Alix
March 28, 201411 yr Author Thank you so much... It helps! Works now ty! I am new to forge however am experienced in Java!
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.