Posted March 26, 201312 yr How would I go about this? Here is my current code (Omitted any that has nothing to with the direction of the block) private Icon field_94458_cO; private Icon field_94459_cP; public MyBlock(int ID) { super(ID, Material.iron); this.setCreativeTab(CreativeTabs.tabBlock); } /** * 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); } } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double)(par5EntityLiving.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()) { ((TileEntityFurnace)par1World.getBlockTileEntity(par2, par3, par4)).func_94129_a(par6ItemStack.getDisplayName()); } } @Override public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("et:blockSides"); this.field_94459_cP = par1IconRegister.registerIcon("et:blockFront"); this.field_94458_cO = par1IconRegister.registerIcon("et:blockTop"); } public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) { return par1 == 1 ? this.field_94458_cO : (par1 == 0 ? this.field_94458_cO : (par1 != par2 ? this.blockIcon : this.field_94459_cP)); } public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); } Bumper Cars!
March 26, 201312 yr That depends... When do you need this information? It's possible but depending on when you need the info and what you want to based upon it, you probably need a TileEntity to store, check and update the information If you guys dont get it.. then well ya.. try harder...
March 26, 201312 yr Author Well actually that brings up a 2nd thing I need. I can't seem to locate the method for blocks for when they are activated by redstone. I need that. To answer you first question, I need to find out what direction my block is facing when it is powered by redstone. I just make my block extend TileEntity instead of block to make it a tile entity correct? Bumper Cars!
March 26, 201312 yr No a TileEntity is a whole different file. A TileEntity can hold huge ammounts of data and execute internal logic every update. I suggest you go do some searcing on TilEntitys aswell as opening some to see how they work. I.e: TileEntityFurnace and BlockFurnace -see how they work A block can't hold more than it's metadata of information, most of the time a block can't even reffer to it's location inn the world. TileEntitys is what makes chests, furnaces and workbenches work So start reading up on them If you guys dont get it.. then well ya.. try harder...
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.