Jump to content

How do I add a drop to leaves ?


Irhala

Recommended Posts

Thanks ! It's working, cuz tree leaves now :

- are Instabreakable

- don't loot sticks

- are non-transparent

 

Leaves still disappear when tree is broken, and have light opacity to 1

 

Need to fix this, and more and more thanks to you !

\o_ \o/ _o/

||    ||    ||

/ \  / \  / \

Link to comment
Share on other sites

Thanks ! It's working, cuz tree leaves now :

- are Instabreakable

- don't loot sticks

- are non-transparent

 

Leaves still disappear when tree is broken, and have light opacity to 1

 

Need to fix this, and more and more thanks to you !

\o_ \o/ _o/

||    ||    ||

/ \  / \  / \

 

i'm confused is that good or bad?

 

also... why the dancing stick men?

Link to comment
Share on other sites

It's good, because this means we (you) achieved to replace Leaves by MyLeaves (i checked, and even in the creative inventory, with the leaves ID, it's 4 non-named blocks with leaves textures)

 

I need to give MyLeaves the characteristics I want, but it may be easier from now :)

EDIT : I don't know how to do it --'

          Aren't BlockLeaves methods supposed to be usable with BlockMyLeaves ?

 

Link to comment
Share on other sites

haha, ok. Look through the wiki a bit and see what you can figure out, Try to do as much as you can without help as it's a better way of learning and you'll start to figure out how to solve these things in the future. If you get completely stuck post it or feel free DM me with the problem and i'll do my best to get back to you, and point you in the right direction. There is also quite a lot of good stuff on youtube if you do a quick search.

 

Link to comment
Share on other sites

          Aren't BlockLeaves methods supposed to be usable with BlockMyLeaves ?

 

yes. They should be if you extended it. The properties of the leaves however you will need to set using .setHardness and various other methods. Look here if you're not sure how to set the properties, it's a touch out of date, but all that's really changed is textures and you don't need to do anything about that.

Link to comment
Share on other sites

In the BlockMyLeaves class, I use the constructor

public BlockMyLeaves(int par1) {
	super(par1);
        setHardness(0.2F);
        setLightOpacity(1);
        setStepSound(soundGrassFootstep);
        setUnlocalizedName("leaves");
}

and super(...) is BlockLeaves(...) from vanilla

protected BlockLeaves(int par1)
    {
        super(par1, Material.leaves, false);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

 

I don't understand why MyLeaves doesn't have the Material.leaves properties, while it is created as a block with leaves material :/

Link to comment
Share on other sites

In the BlockMyLeaves class, I use the constructor

public BlockMyLeaves(int par1) {
	super(par1);
        setHardness(0.2F);
        setLightOpacity(1);
        setStepSound(soundGrassFootstep);
        setUnlocalizedName("leaves");
}

and super(...) is BlockLeaves(...) from vanilla

protected BlockLeaves(int par1)
    {
        super(par1, Material.leaves, false);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

 

I don't understand why MyLeaves doesn't have the Material.leaves properties, while it is created as a block with leaves material :/

Material.leaves is linked to a few scattered properties; the "material" thing isn't very well organized. What properties is your block missing?

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

from memory I think it's these methods, Kinda set it up so my code does most of this automatically now, so i could be missing something.

@Override
public boolean renderAsNormalBlock()
{
	return false;
}

@Override
public boolean isOpaqueCube()
{
	return false;
}

 

to drop items I think something like this:

    public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
    {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();

        int count = quantityDropped(metadata, fortune, world.rand);
        for(int i = 0; i < count; i++)
        {
            int id = idDropped(metadata, world.rand, fortune);
            if (id > 0)
            {
                ret.add(new ItemStack(id, 1, damageDropped(metadata)));
            }
        }

        ret.add(new ItemStack(Item.stick));
        return ret;
    }

Link to comment
Share on other sites

I only redefined public void dropBlockAsItemWithChance(...)

public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
    {
        if (!par1World.isRemote)
        {
            int j1 = 20;

            if ((par5 & 3) == 3)
            {
                j1 = 40;
            }

            if (par7 > 0)
            {
                j1 -= 2 << par7;

                if (j1 < 10)
                {
                    j1 = 10;
                }
            }

            if (par1World.rand.nextInt(j1) == 0)
            {
                int k1 = this.idDropped(par5, par1World.rand, par7);
                this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5)));
            }
            
            j1 = 20;

            if ((par5 & 3) == 3)
            {
                j1 = 40;
            }

            if (par7 > 0)
            {
                j1 -= 2 << par7;

                if (j1 < 10)
                {
                    j1 = 10;
                }
            }
            
            if (par1World.rand.nextInt(j1) == 0)
            {
                int k1 = Item.stick.itemID;
                this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5)));
            }

            j1 = 200;

            if (par7 > 0)
            {
                j1 -= 10 << par7;

                if (j1 < 40)
                {
                    j1 = 40;
                }
            }

            if ((par5 & 3) == 0 && par1World.rand.nextInt(j1) == 0)
            {
                this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.appleRed, 1, 0));
            }
        }
    }
}

 

And it works ! Sticks drop of leaves as often as saplings !

Only 2 problems left : Add recipe for spruce, birch and jungle saplings, and change transparency of leaves to make it appear correctly

EDIT : The first one was simple, i looked on sandstone recipes to know how to add :1, :2, :3 to the block ID :)

EDIT 2 : Transparency problem screenshot :

http://puu.sh/3bIOI

Link to comment
Share on other sites

BlockMyLeaves is already extending BlockLeaves, which extends BlockLeavesBase

 

I tried with renderAsNormalBlock(), isOpaqueCube(), setGraphicsLevel(), shouldSideBeRendered() and isLeaves(), and all in same time, but none of them makes it work properly. Fast graphics also render as fancy.

Link to comment
Share on other sites

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

You'll need a graphicsLevel variable, set up as in BlockLeaves and BlockLeavesBase.

if graphicsLevel = "fancy":
    return True
else:
    return super(self, blah).shouldSideBeRendered()

You'll also want to override isOpaqueCube:

    public boolean isOpaqueCube(){
        return !this.graphicsLevel;
    }

And you'll need two sets of icons, one opaque and one transparent. Look at BlockLeaves.iconArray for how it's done.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

You'll need a graphicsLevel variable, set up as in BlockLeaves and BlockLeavesBase.

if graphicsLevel = "fancy":
    return True
else:
    return super(self, blah).shouldSideBeRendered()

 

Look at the BlockLeaves class, you can adapt the code where graphicsLevel is used (it's a boolean).

You don't need to declare a new variable in your block class, just use the Block.leaves.graphicsLevel reference, since the variable is public.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

You'll need a graphicsLevel variable, set up as in BlockLeaves and BlockLeavesBase.

if graphicsLevel = "fancy":
    return True
else:
    return super(self, blah).shouldSideBeRendered()

 

Look at the BlockLeaves class, you can adapt the code where graphicsLevel is used (it's a boolean).

You don't need to declare a new variable in your block class, just use the Block.leaves.graphicsLevel reference, since the variable is public.

Good point. I guess I didn't want to bother doing more research than necessary :)

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

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

    • 🤑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.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Slot Aster88 adalah bocoran slot rekomendasi gacor dari Aster88 yang bisa anda temukan di SLOT Aster88. Situs SLOT Aster88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Aster88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Aster88 merupakan SLOT Aster88 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 Aster88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Aster88 hari ini yang telah disediakan SLOT Aster88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Aster88 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 Aster88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Aster88 di link SLOT Aster88.
  • Topics

×
×
  • Create New...

Important Information

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