kenoba10 Posted July 16, 2013 Share Posted July 16, 2013 Hi. I'm working on making a mod and in it I want there to be tools with really cool abilitys: Sword that shoots fireballs Pickaxe with auto smelting Axe with a feature similar to TreeCapacitator The only one I have any idea to go about making is the sword a bit but I still vould use some help Any help please? Quote Link to comment Share on other sites More sharing options...
Guff Posted July 16, 2013 Share Posted July 16, 2013 For pickaxe you'll want to change the way it handles blocks being harvested/destroyed. It should be handled to check whether the item being dropped has a smelting recipe, and if it does, it should drop that instead of the normal drop (look at FurnaceRecipes.java). For axe just check all above blocks and see if they are also wood/logs, etc, and have them affected as well. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 16, 2013 Author Share Posted July 16, 2013 For pickaxe you'll want to change the way it handles blocks being harvested/destroyed. It should be handled to check whether the item being dropped has a smelting recipe, and if it does, it should drop that instead of the normal drop (look at FurnaceRecipes.java). For axe just check all above blocks and see if they are also wood/logs, etc, and have them affected as well. Is is possible you could send me a code example? Quote Link to comment Share on other sites More sharing options...
Guff Posted July 16, 2013 Share Posted July 16, 2013 See what methods you can override in your class, and see what you need to do. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 16, 2013 Author Share Posted July 16, 2013 See what methods you can override in your class, and see what you need to do. Ok thanks I'll play around with the code Quote Link to comment Share on other sites More sharing options...
Guff Posted July 16, 2013 Share Posted July 16, 2013 Once you start to get somewhere, come back and I'll help you. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 Once you start to get somewhere, come back and I'll help you. I've started to do some research and figured out how i could do the axe but I don't know how to make it so it only happens when you use the axe any ideas? Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 What did you come up with? Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 What did you come up with? I found a tutorial about making your own mod block so it destorys all other blocks of the same block around it which you put in the block class, but how could i do this for a pre existing block and only putting it in my pickaxe class without editing base classes Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 Look at onBlockBreak() in Item.java. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 Look at onBlockBreak() in Item.java. I can't find it Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 Whoops, this is what I meant: @Override public boolean onBlockDestroyed(ItemStack stack, World world, int id, int i, int j, int k, EntityLivingBase entity) { //code return true; } Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 Whoops, this is what I meant: @Override public boolean onBlockDestroyed(ItemStack stack, World world, int id, int i, int j, int k, EntityLivingBase entity) { //code return true; } Oh I see would I override this method in my axe class and then put the code for breaking the wood in this method? Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 You got it. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 You got it. Ok is there anyway i could alter this code to work inside the method? @Override public void breakBlock(World world, int i, int j, int k, int par5, int par6){ //Reading the gag's tile entity. TileEntityGag tileEntity = (TileEntityGag)world.getBlockTileEntity(i, j, k); //If not make this check, the game may crash if there's no tile entity at i, j, k. if (tileEntity != null){ //Actually destroys primary block. world.destroyBlock(tileEntity.primary_x, tileEntity.primary_y, tileEntity.primary_z, false); //Forces removing tile entity from primary block coordinates, //cause sometimes minecraft forgets to do that. world.removeBlockTileEntity(tileEntity.primary_x, tileEntity.primary_y, tileEntity.primary_z); } //Same as above, but for the gag block tile entity. world.removeBlockTileEntity(i, j, k); } //This method checks if primary block exists. @Override public void onNeighborBlockChange(World world, int i, int j, int k, int par5){ TileEntityGag tileEntity = (TileEntityGag)world.getBlockTileEntity(i, j, k); if (tileEntity != null){ //No need to check if block's Id matches the Id of our primary block, //because if a player want to change a block, he needs to brake it first, //and in this case block will be set to Air (Id = 0) if(world.getBlockId(tileEntity.primary_x, tileEntity.primary_y, tileEntity.primary_z) < 1){ world.destroyBlock(i, j, k, false); world.removeBlockTileEntity(i, j, k); } } } Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 You're trying to make an axe that destroys an entire tree, correct? I don't see how your code there with the TileEntity actually correlates to that concept, so I don't know what it does, let alone how it would be possible to put on an item. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 You're trying to make an axe that destroys an entire tree, correct? I don't see how your code there with the TileEntity actually correlates to that concept, so I don't know what it does, let alone how it would be possible to put on an item. oh ok do you have any idea how i could destory the tree then? Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 It'd be easiest to check an area, perhaps a 3x15x3 region to check if the blocks are logs, and then make them drop a log at that position (for-loops). Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 It'd be easiest to check an area, perhaps a 3x15x3 region to check if the blocks are logs, and then make them drop a log at that position (for-loops). Ok I've never actually done anything with deleting blocks and checking areas I'll look some stuff up unless you can help me in any way Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 Nested for-loops, one for each x, y, and z range. Use -1 to <= 1 as each range for x and z, and 0 to <= 15 for y. Then check if(world.getBlockId(par4 + x, par5 + y, par6 + z) == Block.log.blockID), and then get the metadata, create a new ItemStack of Block, set the block to 0 and then spawn an EntityItem at par4 + x, par5 + y, par6 + z. Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 Nested for-loops, one for each x, y, and z range. Use -1 to <= 1 as each range for x and z, and 0 to <= 15 for y. Then check if(world.getBlockId(par4 + x, par5 + y, par6 + z) == Block.log.blockID), and then get the metadata, create a new ItemStack of Block, set the block to 0 and then spawn an EntityItem at par4 + x, par5 + y, par6 + z. Ok well it would be nice if it was a bit simpler i cant really understand it exactly Quote Link to comment Share on other sites More sharing options...
Guff Posted July 18, 2013 Share Posted July 18, 2013 if(world.getBlockId(i, j, k) == Block.wood.blockID) { for(int x = -1; x <= 1; x++) { for(int y = 0; y <= 15; y++) { for(int z = -1; z <= 1; z++) { if(world.getBlockId(i + x, j + y, k + z) == Block.wood.blockID) { int meta = world.getBlockMetadata(i + x, j + y, k + z); ItemStack drop = new ItemStack(Block.wood, 1, meta); EntityItem item = new EntityItem(world, i + x, j + y, k + z, drop); world.setBlock(i + x, j + y, k + z, 0); world.spawnEntityInWorld(item); } } } } } Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 18, 2013 Author Share Posted July 18, 2013 if(world.getBlockId(i, j, k) == Block.wood.blockID) { for(int x = -1; x <= 1; x++) { for(int y = 0; y <= 15; y++) { for(int z = -1; z <= 1; z++) { if(world.getBlockId(i + x, j + y, k + z) == Block.wood.blockID) { int meta = world.getBlockMetadata(i + x, j + y, k + z); ItemStack drop = new ItemStack(Block.wood, 1, meta); EntityItem item = new EntityItem(world, i + x, j + y, k + z, drop); world.setBlock(i + x, j + y, k + z, 0); world.spawnEntityInWorld(item); } } } } } Thanks so much for the help! Quote Link to comment Share on other sites More sharing options...
kenoba10 Posted July 19, 2013 Author Share Posted July 19, 2013 Nested for-loops, one for each x, y, and z range. Use -1 to <= 1 as each range for x and z, and 0 to <= 15 for y. Then check if(world.getBlockId(par4 + x, par5 + y, par6 + z) == Block.log.blockID), and then get the metadata, create a new ItemStack of Block, set the block to 0 and then spawn an EntityItem at par4 + x, par5 + y, par6 + z. Ok for the auto smelting pickaxe what would i override in my pickaxe class? Quote Link to comment Share on other sites More sharing options...
Guff Posted July 19, 2013 Share Posted July 19, 2013 Same thing. Quote Link to comment Share on other sites More sharing options...
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.