Jump to content

[1.8][SOLVED]The item dropped by a custom block shows up no texture in inventory


Recommended Posts

Posted

Hi !

 

During the creation of a custom block, I encountered a problem.

The block itself works perfectly fine. But when you smash it in Survival, you're supposed to get Cobblestone like standard stone. It works but the Cobblestone item don't have its texture rendered when it's in item form.

 

I chose Cobblestone with a simple

public Item getItemDropped(IBlockState state, Random rand, int fortune) {

return Item.getItemFromBlock(Blocks.cobblestone);

}

 

I didn't know I would have to bother with this, as Cobblestone is a standard vanilla block. I have no idea why and how this can happen.

Could anyone help me ?

I do not see any error on the console.

EDIT : Okay, it's even weirder. My custom block has two variants. Only the second one has this problem, the first (the default) is fine.

Posted

Are you sure that the 2nd variant is actually calling that method? I am suspecting that your problem is elsewhere in your code.

 

I recommend setting a breakpoint in that method and running in the debugger to see what it's really doing when you smash variant 2.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

As far as I know variants all call the same methods. Their specific behavior is defined inside methods checking their blockstate's metadata. Anyway, the item that is dropped by the second variant really IS Cobblestone : It's called Cobblestone, it stacks with all other Cobblestones and when placed it's a perfectly normal Cobblestone block. It's just that in inventory, it's texture is the Pink&Black.

 

Therefore, unfortunately, a breakpoint there doesn't reveal anything.

 

Posted

Solved. If anyone has the same problem : the method damageDropped() needs to be coherent with your dropped item.

I had a standard damageDropped() returning the metadata (0 or 1). But I only dropped one item for all variants : Cobblestone. So I just set "return 0;" and now it works perfectly fine.

Posted

If you dropped a block with an undefined damage value, then there should have been at least a warning in your log, something about being unable to find the model or texture for that block type and variant. I'm actually surprised that you didn't start getting mossy cobble. How it managed to stack with normal cobble is a mystery.

 

Glad you found bug. If you walked the execution in the debugger, it dragged you right through that problem method. That's one of the nice things about debuggers. They take you from the method you're thinking about to the other methods you didn't know you should think about.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.