Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello.

 

I got Some problems with my Block Drops.

 

File:

 

 

package spmod.tools.src.blocks;

 

import java.util.Random;

 

import net.minecraft.src.Block;

import net.minecraft.src.EntityPlayer;

import net.minecraft.src.Item;

import net.minecraft.src.ItemStack;

import net.minecraft.src.Material;

 

public class BlockCustomDirt extends Block

{

    public BlockCustomDirt(int par1, int par2)

    {

        super(par1, par2, Material.ground);

        this.setHardness(0.5F);

    }

   

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

    {

        ItemStack par5 = par4.getCurrentEquippedItem();

        if(par5 != null && par5.itemID == Item.stick.shiftedIndex)

        {

        return par2Random.nextInt(10 - par3 * 3) == 0 ? Item.flint.shiftedIndex : this.blockID;

        }

        else

        {

        return this.blockID;

        }

    }

}

 

 

 

But it do not Drop Flint. What do i do wrong?

Did you tried to add messages to check what is going in the code?

 

System.out.println("This will appear in the console.");

 

Do you know what the par3 mean in the

idDropped()

?

 

Btw,the problem could be at par2Random.nextInt(10 - par3 * 3).

 

Check the Minecraft's source next time. (BlockGravel)

 

Add this snippet

if (par3 > 3)
        {
            par3 = 3;
        }

 

before

 

return par2Random.nextInt(10 - par3 * 3) == 0 ? Item.flint.shiftedIndex : this.blockID;

  • Author

When i copy the code from gravel and paste it in my customdirt than it do drop flint. But the thing what does not work when i write the if(he has a stick in his hand) than he only drops dirt nothing else. same as change it (than he would drop only flint and sometimes dirt. but that didn't work too.

 

and no i do not know what par3 means. par1 is for the metadata but par3 idk.

 

befor i send this answer i tell you what i want to do.

 

Gravel is very rare at minecraft (At the start).

And my mod do need it at the start so without you are stuck.

To help the player i want that when the player holds a stick in his hand and mines dirt than he has a chance to get flint, and when i paste the gravelcode. and a technic moduser use my mod he has to much flint because a quarry mines everything.

  • Author

The code did not work.

 

with this i override the dirt:

 

Block.blockslist[3] = null;

Block.blockslist[3] = new BlockCustomDirt(3, 2).setBlockName("dirt");

 

Here my code of the dirt

 

 

package spmod.tools.src.blocks;

 

import java.util.Random;

 

import net.minecraft.src.Block;

import net.minecraft.src.EntityPlayer;

import net.minecraft.src.Item;

import net.minecraft.src.ItemStack;

import net.minecraft.src.Material;

 

public class BlockCustomDirt extends Block

{

    public BlockCustomDirt(int par1, int par2)

    {

        super(par1, par2, Material.ground);

        this.setHardness(0.5F);

    }

   

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

    {

        ItemStack par5 = par4.getCurrentEquippedItem(); //to change to inventory didnt bring anything

        if(par5 != null && par5.itemID == Item.stick.shiftedIndex)

        {

          return par2Random.nextInt(10 - par3 * 3) == 0 ? Item.flint.shiftedIndex : this.blockID;

        }

        else

        {

          return this.blockID;

        }

    }

}

 

 

  • Author

I am at version 1.2.5 not 1.3.2 or 1.4.6

How Can make it to drop something else than dirt when the player hold a stick in his hand.

  • Author

Ill change my workspace to 1.3.2 at the 1.2.2013.

But every event what forge add comes from the minecraft source and this is compatible to the most versions.

 

Try to use my code and finish it please. And please try to use only minecraft and no forge.

  • Author

English is not my motherlanguage. I do not have the knowlegde to tell what i want to tell.

 

My mod tries to hold it self*.

 

*Does not need other mods and apis

 

And only 5 things does my mod uses from forge.

 

1st: Config File

2nd: Texture Provider

3rd: Furnace Recipes

4th: CraftDamage (Crafting Handler)

5th: ToolClass

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.