Jump to content

[1.7.2] Block dropping it self (block) ! [SOLVED]


proalt

Recommended Posts

hello there i need help with simple block that is giving me HUGE/MASSIVE problems i dont even know why.

 

So i want to create block that drops it self for example: I create Ruby block and when you destroy it i want that Ruby block is dropped and not an item but a block.

 

Here are my current codes:

 

THIS IS MY BLOCK FILE:

public class BlockRubyBlock extends Block
{

        public BlockRubyBlock (Material material)
        {
                super(material);
        }
        private IIcon[] icons = new IIcon[6];
        @Override
        public void registerBlockIcons(IIconRegister iconRegister) {
            for (int i = 0; i < icons.length; i++) {
                icons[i] = iconRegister.registerIcon(wtf.modid + ":" + "BlockRubyBlock" + i);
            }
        }
        @Override
        public IIcon getIcon(int side, int meta) {
            return icons[side];
        }
            
        /**
         * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
         */
        public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
        {
            p_149670_5_.setInWeb();
        }

        /**
         * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
         * cleared to be reused)
         */
        public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
        {
            return null;
        }
}

 

This is codes from original file:

 

public static Block BlockRubyBlock;

BlockRubyBlock = new BlockRubyBlock(Material.web).setHardness(0.05F).setBlockName("BlockRubyBlock").setBlockTextureName(modid + ":" + "BlockRubyBlock");

GameRegistry.registerBlock(BlockRubyBlock, "BlockRubyBlock");

 

~~~~FIX

 

My materal was web so it didnt drop anything becouse i needed special tool to get it.

Changed it to grass and it can be dropped by just hitting it with hands.

Link to comment
Share on other sites

Okay I can see that you have a problem with the dropping of blocks in 1.7.2 so I have some examples for you that could help you out:

[Notice] You must replace the <>

 


//If the block's drop is an item.

public Item getItemDropped1(int metadata, Random random, int fortune)

{

        return YOURMOD.YOURMOD;

}

 

//If the block's drop is a block.

public Item getItemDropped(int metadata, Random random, int fortune) {

    return Item.getItemFromBlock(YOURMOD.TESTBLOCK);

}

 

//If the block's drop is a vanilla item.

public Item getItemDropped(int metadata, Random random, int fortune) {

    return Item.getItemById(<ItemID>);

}

 

//If the block's drop is a vanilla block.

public Item getItemDropped(int metadata, Random random, int fortune) {

    return Item.getItemFromBlock(Block.getBlockById(<BlockID>));

}

Link to comment
Share on other sites

Okay so i have added this:

 

//If the block's drop is a block.

        public Item getItemDropped(int metadata, Random random, int fortune) {

            return Item.getItemFromBlock(wtf.BlockRubyBlock);

        }

~~~

And nothing happens, it doesnt drop a thing or anything i also tried the other one for the item and it didnt work i am not sure what is wrong at that point. I have tried everything...

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



×
×
  • Create New...

Important Information

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