Jump to content

Recommended Posts

Posted

G'Day everyone

 

I do have a little strange issue: Whenever I insert a single item into my generator (like coal), the item is consumed but client-side still displayed (consumed = tested with some logging that the itemstack which represents the said slot is null).

Closing and re-open the GUI or just clicking on the item removes it from the GUI.

Since I've just started with modding I'm very confused. Especially since I thought I did understood the vanilla furnace updateEntity method and adapted it for my purposes.

 

I learned from the vanilla code and made my own furnace (in this custom furnace it works with a single fuel item too) and added a few methods, suggested by wuppy's mod dev book (I'm talking about the TileEntityGenerator.onDataPacket() and the TileEntityGenerator.getDescriptionPacket() methods)

But still I did not understood everything, so please don't blame me, TileEntityGenerator.decrStackSize(int, int)

and ContainerGenerator.transferStackInSlot(EntityPlayer, int) are mostly copied from the vanilla furnace and slightly renamed the variables.

 

Thus I do have this questions:

 

- Does anyone see why the above mentioned 'ghost item' thingy happens? The funny part is, that if I put two items into the slot, the stacksize gets immediately decreased by one (as expected).

 

Thank you in advance and feel free to criticize my coding, as mentioned before, I'm a forge newbie.

Sincerely -pick

 

Appending the code:

 

TileEntityGenerator.java:

 

  Reveal hidden contents

 

 

GUIGenerator.java:

 

  Reveal hidden contents

 

 

ContainerGenerator.java

 

  Reveal hidden contents

 

 

EDIT: Corrected the closing spoiler tags

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

Add this line anywhere the inventory changes:

 

if (worldObj != null) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);

 

That tells the server it needs to send the changes to the client.

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.

Posted

Hi Draco18s

 

Thank you for your reply.

 

Unfortunately this does not help solving the mentioned issue.

The item is still displayed, after consumption and it still displays the decreased stackSize correctly when putting more than one fuel item into it.

 

I guess the problem is somewhere in my updateEntity method, which I changed slightly.

 

Sincerely -pick

 

New TileEntityGenerator.updateEntity() method:

 

  Reveal hidden contents

 

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

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.