Koward Posted October 22, 2015 Posted October 22, 2015 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. Quote
jeffryfisher Posted October 22, 2015 Posted October 22, 2015 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. Quote 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.
Koward Posted October 22, 2015 Author Posted October 22, 2015 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. Quote
[email protected] Posted October 22, 2015 Posted October 22, 2015 show more code so the error can be found because the error is somewhere there Quote
Koward Posted October 22, 2015 Author Posted October 22, 2015 Sure, here is a pastebin of my code : Custom Block itself : http://pastebin.com/C6NG6Nvd ; (I changed the drop to Diamond Block to check, and the problem is still there) A rendering class like explained in BedrockMiner's Tutorials : http://pastebin.com/HM1MAmdE ; Quote
Koward Posted October 23, 2015 Author Posted October 23, 2015 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. Quote
jeffryfisher Posted October 23, 2015 Posted October 23, 2015 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. Quote 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.
Recommended Posts
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.