Jump to content

Overwritten getItemDropped not being called


DragonFerocity

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.