Jump to content

Recommended Posts

Posted

Hey guys, I'm trying to figure out how to get items to drop. I'm new to modding, and even following tutorials my items wont drop from a test block. Funnily, vanilla items do drop. I am unsure as to whether this is an issue with my items or blocks registries, or the test block itself. I was able to get the modded item to drop by changing 

    @Override
    public Item getItemDropped(IBlockState blockState, Random random, int fortune){
        return drop;
    }

from BlockTestDrops to

    @Override
    public Item getItemDropped(IBlockState blockState, Random random, int fortune){
        return ModItems.ripariusShard;
    }

While it works, it seems inefficient to bloat the blocks package by creating new classes for each block I want to have item drops. 

Here are the relevant classes:

ModItems

  Reveal hidden contents

ModBlocks

  Reveal hidden contents

BlockTestDrops

  Reveal hidden contents

Any help would be greatly appreciated

Posted

Blocks are created and registered before Items, so you can't pass an Item to a Block constructor. When you create your Block instance, your Item fields haven't been initialised yet; so they still contain null.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Alright, that makes sense. I'm feeling pretty dumb here, is there something wrong with this preinit from the CommonProxy?

    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
        File directory = event.getModConfigurationDirectory();
        config =new Configuration(new File(directory.getPath(),"TiberianEclipse.cfg"));
        ModItems.init();
        ModBlocks.init();
        ModRecipes.init();
        ModEntities.init();
        ModBiome.registerBiomes();

 

Edited by TheBrokenLaw
Posted

Blocks should be created and registered before Items. Apart from that, I can't see any obvious problems. What makes you think something is wrong?

 

I highly recommend migrating to registry events, they allow you to register things at the right time without worrying about when that is. This will also make it easier to update to 1.12+, where GameRegistry.register is private.

 

I recommend against having a common proxy; proxies are for sided code, common code belongs in your @Mod class (or classes called from it). I recommend using an interface as the common parent of your proxy classes rather than a common proxy class.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.