Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED] Custom Item Drops for Blocks for 1.12.2
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 2
34486

[SOLVED] Custom Item Drops for Blocks for 1.12.2

By 34486, March 23, 2018 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

34486    0

34486

34486    0

  • Tree Puncher
  • 34486
  • Members
  • 0
  • 21 posts
Posted March 23, 2018 (edited)

Forge 1.12.2

Hopefully I am asking in the correct place! How can I make my blocks in my mod drop specific items, or a list of items. I have googled this already, and found that nothing is 'working' I get no errors once I fix the things Eclipse Oxygen.2 tells me to do, and the game runs and starts with no error, but does not drop what I want when I break the block.. again with no error!  I am sorry that I have not been able to successfully google something that is clear for my stupid mind to comprehend, so I post here for help, I hope. 

 

How and where can I implement a custom block drop?  I'll post some images of my work space so you can tell me where I need to put what and how. I'll open some classes too, which I feel might need to have something changed. 

Screenshot 1.PNG

oreblocks.PNG

Blockbase.PNG

Normal Block reference for oreblock.PNG

IHasModel.PNG

modblocks.PNG

moditems.PNG

Registry Handler.PNG

Edited March 23, 2018 by 34486
Changed the title..
  • Quote

Gregtech FOR THE WIN! (I miss GT from 1.4)

Share this post


Link to post
Share on other sites

larsgerrits    514

larsgerrits

larsgerrits    514

  • Reality Controller
  • larsgerrits
  • Members
  • 514
  • 3462 posts
Posted March 23, 2018

Override Block#getDrops.

 

Also, the IHasModel method of registering models makes no sense. Every Block and Item needs a model.

  • Quote

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Share this post


Link to post
Share on other sites

34486    0

34486

34486    0

  • Tree Puncher
  • 34486
  • Members
  • 0
  • 21 posts
Posted March 23, 2018
8 minutes ago, larsgerrits said:

Override Block#getDrops.

 

Also, the IHasModel method of registering models makes no sense. Every Block and Item needs a model.

Eclipse suggested I add this into BlockBase class

public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
        // TODO Auto-generated method stub
        return null;
    }

 

I put this in the OreBlock class

@Override
     public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
     ArrayList<ItemStack> stack = super.getDrops(world, x, y, z, metadata, fortune);
     stack.add(new ItemStack(Items.APPLE, 2));
     return stack;
     }

 

I get NO errors when loading, running or exiting the client. It does not drop an APPLE, Which I am using for simplicity, and to drop 2 of them. 

 

Is this what you mean by Override Block#getDrops? I'm really dumb, sorry, trying to learn this for the 4th time, tried in 1.6, failed, 1.7, failed, .1.10, failed, trying 1.12.2

  • Quote

Gregtech FOR THE WIN! (I miss GT from 1.4)

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted March 23, 2018

What version are you coding in? In 1.12.x you should be using 

void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
  • Quote

Share this post


Link to post
Share on other sites

34486    0

34486

34486    0

  • Tree Puncher
  • 34486
  • Members
  • 0
  • 21 posts
Posted March 23, 2018
2 minutes ago, diesieben07 said:

What version are you coding in? In 1.12.x you should be using 


void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)

1.12.2, Latest Forge Version. 

  • Quote

Gregtech FOR THE WIN! (I miss GT from 1.4)

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted March 23, 2018

That is impossible there is no ArrayList-returning getDrops in latest Forge.

  • Quote

Share this post


Link to post
Share on other sites

34486    0

34486

34486    0

  • Tree Puncher
  • 34486
  • Members
  • 0
  • 21 posts
Posted March 23, 2018
4 minutes ago, diesieben07 said:

That is impossible there is no ArrayList-returning getDrops in latest Forge.

Ok, In my OreBlocks source I added this

public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
        
        
        
    }

 

But what do I put inside the brackets, getDrops(); just gets crossed out with an error and drops.* has nothing useful. 

  • Quote

Gregtech FOR THE WIN! (I miss GT from 1.4)

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted March 23, 2018

You know how a List works in Java, yes? If not, you need to go learn basic Java.

  • Quote

Share this post


Link to post
Share on other sites

34486    0

34486

34486    0

  • Tree Puncher
  • 34486
  • Members
  • 0
  • 21 posts
Posted March 23, 2018
2 minutes ago, diesieben07 said:

You know how a List works in Java, yes? If not, you need to go learn basic Java.

Ok, I understand that the arraylist was used in 1.7 and not 1.12.2, I cannot find anything useful, and yes (I hope...) , for example you can take numbers, then print them out in the console, added or not. 

 

What exactly do I need to put where? Currently I am trying to find something similar to this in other peoples source, and right now am having no luck.

  • Quote

Gregtech FOR THE WIN! (I miss GT from 1.4)

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted March 23, 2018

It's a list of item stacks. If you want something to be dropped, at it to the list...

  • Quote

Share this post


Link to post
Share on other sites

34486    0

34486

34486    0

  • Tree Puncher
  • 34486
  • Members
  • 0
  • 21 posts
Posted March 23, 2018

Ok, I just used this... I was unsure of the itemstacks, Like return Moditems.x wasn't working. 

 

public Item getItemDropped(IBlockState state, Random rand, int fortune) {
          return YourItemClassName.ItemYouWantToDrop;
         }
    
    public int quantityDropped(IBlockState state, int fortune, Random random) {
          return random.nextInt(2) + 1;               // <--- This will drop 1 to 2 items, and the +1 is so its not from 0 to 2. 
         }

 

  • Quote

Gregtech FOR THE WIN! (I miss GT from 1.4)

Share this post


Link to post
Share on other sites

hetsunami    0

hetsunami

hetsunami    0

  • Tree Puncher
  • hetsunami
  • Members
  • 0
  • 7 posts
Posted December 13, 2018
On 3/23/2018 at 7:25 PM, 34486 said:

Ok, I just used this... I was unsure of the itemstacks, Like return Moditems.x wasn't working. 

 

public Item getItemDropped(IBlockState state, Random rand, int fortune) {
          return YourItemClassName.ItemYouWantToDrop;
         }
    
    public int quantityDropped(IBlockState state, int fortune, Random random) {
          return random.nextInt(2) + 1;               // <--- This will drop 1 to 2 items, and the +1 is so its not from 0 to 2. 
         }

 

Man you're actually the best person ever. I'm super new to this yet your code is super understandable and made getting multiple drops form one piece of ore really easy. Thanks man. 

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • samjviana
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana · Posted just now

      I making some custom emchantment, and would like them to show up on an Custom ItemGroup, but i don't know where to start, i tried looking into some classes and did some google about it, but can't find anything usefull.
    • ESCCarp
      Forge says this file does not have an app associated with it.

      By ESCCarp · Posted 42 minutes ago

      i do  
    • LexManos
      forge a jar file not exe

      By LexManos · Posted 1 hour ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.   Also, 1.12 is out of support, update.
    • Modder31
      forge a jar file not exe

      By Modder31 · Posted 1 hour ago

      i am unable to install jar files only exe files i would ask if you could change all the files to exe files, like the older versions i want the most recent version of 1.12.2 for a certain mod but cant cause its a jar file
    • diesieben07
      Forge says this file does not have an app associated with it.

      By diesieben07 · Posted 1 hour ago

      Make sure you have Java installed.
  • Topics

    • samjviana
      0
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started Just now

    • ESCCarp
      2
      Forge says this file does not have an app associated with it.

      By ESCCarp
      Started 1 hour ago

    • Modder31
      1
      forge a jar file not exe

      By Modder31
      Started 1 hour ago

    • JaydenB14
      1
      Minecraft Unexpected error on 1.7.10 forge modded

      By JaydenB14
      Started 3 hours ago

    • Molotove_
      1
      Problem adding RAM to a Forge Server

      By Molotove_
      Started 4 hours ago

  • Who's Online (See full list)

    • samjviana
    • w.dgaster662006@gmail.com
    • rjakobs
    • MrBelieve
    • Kyloren_du22
    • Talp1
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED] Custom Item Drops for Blocks for 1.12.2
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community