Posted June 7, 201312 yr Is there a way to add drops to leaves ? I'm trying to make them drop some sticks sometimes. I found a forge method to add drops to tall grass, MinecraftForge.addGrassSeed(...), but I didn't found the same for leaves. I don't want to change base class files ._. Thanks for your help
June 7, 201312 yr Register a block break event handler? BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 7, 201312 yr Vanilla, look under just about any minecraft block, and you'll see them use it. No, he wants to add to the vanilla leaves' drops, not add his own leaves. Unfortunately I can't remember how to make a block break event handler. BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 7, 201312 yr Then, you should just look under minecraft's leaves, see how they do the "droprate" for their items as well as whatever else you need, and modify their code as you need to. Sorry, if this isn't what you want, I have trouble understanding lots of people.
June 7, 201312 yr Then, you should just look under minecraft's leaves, see how they do the "droprate" for their items as well as whatever else you need, and modify their code as you need to. Sorry, if this isn't what you want, I have trouble understanding lots of people. No, he just needs an event handler. If he does it like that he needs to make it a coremod, and nobody wants to make their mod a coremod if they don't have to. BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 7, 201312 yr Ah. Well, I get it now. Hmm.... Could you make a class that extended the leaf drops?
June 7, 201312 yr there are forge events (like this), but as far as i can tell there isn't one which is called when the block is broken (see full list). Someone correct me if i'm wrong, but after a few Google searches all I've found are people asking why there isn't one. Ah. Well, I get it now. Hmm.... Could you make a class that extended the leaf drops? that probably wouldn't work. Your class wouldn't be called when the block was broken unless you overwrote some vanilla code, which is something i guess you already know you don't want to do. You could, possibly, try doing something like the following where you register your blocks: Block.blocksList[block.leaves.blockID] = null; myLeaves = new BlockMyLeaves(Block.leaves.blockID); //BlockMyLeaves being your extension of BlockLeaves and myLeaves being the block name not sure how well that will work, but it could be worth a shot. good luck github
June 7, 201312 yr Author You could, possibly, try doing something like the following where you register your blocks: Code: [select] Block.blocksList[block.leaves.blockID] = null; myLeaves = new BlockMyLeaves(Block.leaves.blockID); //BlockMyLeaves being your extension of BlockLeaves and myLeaves being the block name not sure how well that will work, but it could be worth a shot. Wouldn't this be useful if I were using my own Leaves, not vanilla's leaves ?
June 7, 201312 yr you create a class which extends BlockLeaves, this class has all the properties of BlockLeaves. Then be removing the vanilla block form the array and replacing it with your block you cause your block to be generated whenever the vanilla leaves would have been. You can then override the drops so that it drops sticks as well as saplings. P.S you will need to override the drops as follows so that the probability of saplings does not change: @Override public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = super.getBlockDropped(world, x, y, z, metadata, fortune); ret.add(new ItemStack(Item.stick.itemID, 1)); return ret; } github
June 7, 201312 yr Author Nevermind. I'll just add a crafting recipe to change saplings into sticks \o/ Still thanks for your help
June 7, 201312 yr shouldn't cause too much incompatibility. Most mods which reference leaves will be doing it by Block.leaves.blockID, which is the same as our blockID, or by if(block instanceof BlockLeaves) which is true for our block also as it extends BlockLeaves. A problem may occur if they do if(block.class == BlockLeaves.Class) but this wouldn't be anything critical, and i think should be fairly uncommon. github
June 7, 201312 yr Author Maybe, but I didn't achieved to create this class extension I started modding yesterday, so i'm not really ready to deal with that sort of coding You can do it for me if you want ! Just kiddin'
June 7, 201312 yr Author Fail : I don't know how to do it for all saplings --' I created a recipe, but it works with oak saplings only
June 7, 201312 yr Author @PostInit public void postload(FMLPostInitializationEvent event) { GameRegistry.addShapelessRecipe(new ItemStack(Item.stick, 1), new Object[] {new ItemStack(Block.sapling)}); }
June 7, 201312 yr Author But if you're able to make the BlockMyLeaves extension work, i'd be grateful, because it would teach me so much more I'd be able to use it for other parts of Minecraft, especially the block breaking system (no longer tree-punching !)
June 7, 201312 yr But if you're able to make the BlockMyLeaves extension work, i'd be grateful, because it would teach me so much more I'd be able to use it for other parts of Minecraft, especially the block breaking system (no longer tree-punching !) Create your BlockMyLeaves extends BlockLeaves, then put this in your @Init: Block.blocksList[blockLeaves.blockID] = new BlockMyLeaves(); BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 7, 201312 yr Author Eclipse tells me to set BlockLeaves.blockID as static and to add an explicit constructor to BlockMyLeaves, but i don't know what to add
June 7, 201312 yr Eclipse tells me to set BlockLeaves.blockID as static and to add an explicit constructor to BlockMyLeaves, but i don't know what to add Er, sorry, I meant Block.blockLeaves.blockID rather than BlockLeaves.blockID. (Derp) BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 7, 201312 yr Create your BlockMyLeaves extends BlockLeaves, then put this in your @Init: Block.blocksList[blockLeaves.blockID] = new BlockMyLeaves(); argh!! not like that! you will get a problem with if (blocksList[par1] != null) { throw new IllegalArgumentException("Slot " + par1 + " is already occupied by " + blocksList[par1] + " when adding " + this); } in the block constructor. Hence i did it how i posted. Block.blocksList[block.leaves.blockID] = null; myLeaves = new BlockMyLeaves(Block.leaves.blockID); //BlockMyLeaves being your extension of BlockLeaves and myLeaves being the block name then the constructor for your block will put it into the array. github
June 7, 201312 yr Author I tried, but when I create the constructor (either as public or protected) protected BlockMyLeaves(int par1) { super(par1); } It tells me to add a BlockMyLeaves(int) constructor, and when i click on it, it creates the same one -.-
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.