Jump to content

[1.12] Custom dispenser block not working as expected


Willbl3pic

Recommended Posts

So I have a custom block which extends BlockDispenser - it's supposed to place blocks in its inventory when given a redstone signal. I had it working before, in 1.11, but now it doesn't seem to work. Instead of placing the block, it just makes a click noise and the entire inventory empties.

 

I made some breakpoints and stepped through, and it appears that the problem is

TileEntityBlockPlacer.getDispenseSlot()

always returning -1. The cause of this seems to be that the

stacks

variable is always full of stacks of air.

 

As for why that is, I'm not sure... Does anyone have any ideas? I haven't found anything useful yet online, and I'm not really sure where to go from here. The stacks are in the blockplacer, and they persist between minecraft reboots, and yet the list of stacks is empty...

 

Block

IBehaviorDispenseItem

TileEntity

Edited by Willbl3pic
Link to comment
Share on other sites

Your custom TE class does nothing at all remotely useful. It has its own inventory (separate and different than the base class's inventory!) but the overridden methods...do nothing with this new inventory.

 

Your block has several methods that are unused too:

getBehavior() - this method is protected and not referenced by your class

dispense() - this method is protected and not referenced by your class

dropBehavior - this field is private and only referenced by getBehavior() and dispense().

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

12 minutes ago, Draco18s said:

Your custom TE class does nothing at all remotely useful. It has its own inventory (separate and different than the base class's inventory!) but the overridden methods...do nothing with this new inventory.

 

Your block has several methods that are unused too:

getBehavior() - this method is protected and not referenced by your class

dispense() - this method is protected and not referenced by your class

dropBehavior - this field is private and only referenced by getBehavior() and dispense().

You're right about getBehavior and the various things in the tileentity - a lot of that was due to me blindly copying things from the dropper and dispenser, trying to fix the problem. I have now removed them.

 

However, dispense() is called. My breakpoint is always hit.

Link to comment
Share on other sites

Is it an overridden method? That might be why.

If so, mark it with @Override

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

Whoops, I must have missed that, thanks. I'll annotate it, along with createNewTileEntity().

 

I've just tried removing all references to TileEntityBlockPlacer and replacing them with TileEntityDispenser. It works, but now, because the block uses a TileEntityDispenser, it shows 'Dispenser' at the top of the GUI rather than 'Block Placer'.

 

I'm not really sure why TileEntityDispenser works but TileEntityBlockPlacer doesn't, especially as TileEntityBlockPlacer extends it and is exactly the same, except getName(). Perhaps it could be to do with the fact that TileEntityDispenser.stacks is private rather than protected?

Link to comment
Share on other sites

44 minutes ago, Willbl3pic said:

Perhaps it could be to do with the fact that TileEntityDispenser.stacks is private rather than protected?

Probably. Rather than trying to override that inventory, I would just use super calls in the necessary functions.

I haven't messed with custom dispensers since 1.7.10, but maybe that'll help.

You may also be interested in this.

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.