Jump to content

How do I add a drop to leaves ?


Irhala

Recommended Posts

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  ;)

Link to comment
Share on other sites

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. :P

Link to comment
Share on other sites

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. :P

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.

Link to comment
Share on other sites

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. :P 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 :)

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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;
    }

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 !)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 -.-

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.