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, Here's my code.

 

I'm having trouble getting the getItemDropped function to actually be called. I created a new class called ModBlockDoor that extends BlockDoor. I overwrote the getItemDropped function like this:

 

@Override
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        System.out.println("INSIDE");
        return /*state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? Items.field_190931_a : */this.getModItem();
    }

    public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
    {
        return new ItemStack(this.getItem());
    }

    private Item getModItem()
    {
        System.out.println("Blocks equal? " + (this == BlockHandler.glassDoor) + " : " + (this.blockName == BlockHandler.glassDoor.blockName));
        return this.blockName == BlockHandler.glassDoor.blockName ? BlockHandler.iGlassDoor : null;
    }

Also, I had to comment out part of the line in the return of getItemDropped because otherwise forge complains that it can't find the symbol for Items.field_190931_a. (And yes, net.minecraft.init.Items is imported at the top..., and when I go to Items.java, I can see the field, which is public, so I don't know why I get this error....)

 

Anyway, nothing get's printed out into the console when I destroy the block in-game, and an item doesn't drop.

 

Any help would be appreciated.

Any log output? Also is the function getItemDropped show as a little green arrow at the left? 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

  • Author

Here's the compiler output when I uncomment the piece of the return statement:

warning: [options] bootstrap class path not set in conjunction with -source 1.6
R:\Minecraft\1.11.2\ExpandedAesthetics\build\sources\main\java\com\DragonFerocity\expanded\blocks\ModBlockDoor.java:57: error: cannot find symbol
        return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? Items.field_190931_a : this.getModItem();
                                                                           ^
  symbol:   variable field_190931_a
  location: class Items
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
1 warning
:compileJava FAILED

As for the log output? That's exactly it, getItemDropped function appears to not be being called since the the text in the println statement never shows up.

 

Also, I'm using Visual Studio, instead of Eclipse. Probably should have stated that before.

 

Also, everything builds just fine, and runs without any errors in the game-run log.

When a block is broken, it will call Block#harvestBlock > dropBlockAsItem > dropBlockAsItemWithChance > getDrops > getItemDropped. You could try putting a breakpoint in there and tracing through the chain to see where it goes awry.

  • Author

So, I tried setting a breakpoint on Block#harvestBlock, and it doesn't appear to hit it. Ever. Also, in creative mode, when you destroy a block is it supposed to drop itself? Nothing is dropping itself currently. And in survival, when I break a block, the harvestBlock function doesn't call the breakpoint I set.

 

Maybe I'm doing something wrong though.

53 minutes ago, DragonFerocity said:

when you destroy a block is it supposed to drop itself?

Absolutely fucking not.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Let me restate that. I realize that that is wrong.

 

In creative mode, when you destroy a block, is it supposed to drop it's corresponding item? Currently nothing is dropping anything - zilch - when I destroy something in creative mode.

17 minutes ago, DragonFerocity said:

In creative mode, when you destroy a block, is it supposed to drop it's corresponding item?

No.

It is not.

It is not supposed to drop anything. Creative mode literally bypasses all harvestblock code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

 

1 hour ago, DragonFerocity said:

And in survival, when I break a block, the harvestBlock function doesn't call the breakpoint I set.

So where does it get to?

  • Author
2 minutes ago, Draco18s said:

No.

It is not.

It is not supposed to drop anything. Creative mode literally bypasses all harvestblock code.

Ok, that's... interesting

4 minutes ago, Jay Avery said:

 

So where does it get to?

I'm not sure. I started a survival mode world and destroyed some blocks, and the breakpoint still never triggered.

You know that /gamemode 0 exists, right?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Well, it does drop its respect item when I switch to survival...

 

Could have avoided this if I knew about /gamemode 0.. But oh well. Now I do.

 

Thanks,

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.