Jump to content

Recommended Posts

Posted

I need to find a way to make an existing block (sand, in this case) drop a custom item.

 

Can this be done without editing the core class?

 

Everything I've found on this involves creating a new block (there seems to be more focus on dropping items with custom blocks and less focus on making existing blocks drop items).  Problem is, I really, really need it to be Sand.  If it can't be done, then I'll find another way to get the item in the game, it just won't be from a block drop.

Posted

you *could* replace all sand generated with a dummy sand block that you have created and have that drop your custom item/block.

Also, I should have you know that you are reading my signature.

Posted

There is an much easier way what does not currupt the world and you do not need forge for it (Sorry but forge uses the slowest and hardest way)

 

You delete the class from the sand. this is the code you have to write into your files

 

i = SandBlockID (12)

 

blocksList = null;

 

now the block sand exsist but is an unfinished block than you do this;

 

blocksList[12] = (new BlockCustomSand(12, 18)).setHardness(0.5F).setStepSound(soundSandFootstep);

 

now you have the class BlockCustomSand

 

this is the sand class:

 

 

  Reveal hidden contents

 

 

you can copy the class if you want or make your own sand. but i think you want to add a specail drop like gravel?

 

than add this:

 

    public int idDropped(int par1, Random par2Random, int par3)

    {

        if (par3 > 3)

        {

            par3 = 3;

        }

 

        return par2Random.nextInt(10 - par3 * 3) == 0 ? modname.itemname/blockname.item/blockID : this.blockID;

    }

 

so now you overriden the basic sand class.

and if someone use your mod and think he do not want it anymore the world getting not currupted!

 

i hope it helps.

 

 

 

Posted

i was thinking overriding the world generation of sand.

or maybe you could have an onContactWith event with sand, when it contacts the player it destroyes itself and places a new item on gorund?

Also, I should have you know that you are reading my signature.

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



×
×
  • Create New...

Important Information

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