wojtab Posted April 7, 2014 Posted April 7, 2014 Hi, I want to do something like autosmelting pickaxe, or like Thaumcraft's Pickaxe of the core, but I just don't know how to deal with it. First of all I don't know where to put Random, because if I put it in function func_150897_b (which should be named canToolBreak or something) it's called multiple times. I could set return of this function to always be false and spawn my item in onBlockDestroyed, but that just makes speed of breaking blocks as if I were breaking them with a fist. So my question is - could I still be breaking blocks at reasonable speed without them dropping? Quote
LTLightning Posted April 7, 2014 Posted April 7, 2014 Something like this should work: public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player){ if (!player.worldObj.isRemote){ player.worldObj.setBlockToAir(x, y, z); // spawn item here } itemstack.damageItem(1, player); return false; } Quote
wojtab Posted April 7, 2014 Author Posted April 7, 2014 Something like this should work: public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player){ if (!player.worldObj.isRemote){ player.worldObj.setBlockToAir(x, y, z); // spawn item here } itemstack.damageItem(1, player); return false; } Thanks, it worked, I didn't realise that I can look for this method in Item.class, I checked ItemPickaxe and ItemTool, but it wasn't there. TY very much. Quote
jabelar Posted April 8, 2014 Posted April 8, 2014 Thanks, it worked, I didn't realise that I can look for this method in Item.class, I checked ItemPickaxe and ItemTool, but it wasn't there. TY very much. That is what "extends" means in Java. If a class extends another class it gets all of its methods unless you purposefully override them. As a modder it is a good idea to check out the methods in all the parent classes for whatever you're modding. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.