CarbonBasedGhost Posted May 12, 2014 Posted May 12, 2014 So I am making a Core mod for all of my future mods and I stumbled upon the problem of making a block that has sides change depending on how you place it (like the furnace). Does anyone know how to do this or have a tutorial with full ability to be customized in any way. Thanks in Advanced!, CarbonBasedGhost Quote
Abastro Posted May 13, 2014 Posted May 13, 2014 first, override onBlockPlacedBy: /** * Called when the block is placed in the world. */ public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (l == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (l == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); } if (par6ItemStack.hasDisplayName()) { ((TileHeatFurnace)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); } } The metadata is the direction of the furnace. You can see Direction class to see the name of each direction Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
CarbonBasedGhost Posted May 13, 2014 Author Posted May 13, 2014 [embed=425,349]if (par6ItemStack.hasDisplayName()) { ((TileHeatFurnace)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); }[/embed] Whats that doing? Quote
Abastro Posted May 13, 2014 Posted May 13, 2014 It is setting the displayed name in the gui of the tile entity. (This code is from my mod, which contains Heat Furnace.) If your gui-displayed name is constant, you can simply ignore that. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
CarbonBasedGhost Posted May 13, 2014 Author Posted May 13, 2014 if (l == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (l == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (l == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); } if (par6ItemStack.hasDisplayName()) { ((TileHeatFurnace)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); } } I assume I can ignore all the return statements if I am making this a base class for all Blocks/Block Containers? Quote
Abastro Posted May 13, 2014 Posted May 13, 2014 Then, you have to use: if (par6ItemStack.hasDisplayName()) { ((TileXX)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); } when TileXX is the class which has setGuiDisplayName. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
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.