Jump to content

Recommended Posts

Posted

Hello

I'm making a mod that's working fine, except for the fact that my custom TNT renders white...

 

Code:

 

  Reveal hidden contents

 

 

Thank you, and I realize that I'm probably missing something huge.

Posted

I suspect that your fuse counter (variable within your entity class) does only change within the serverside scope, which means the fuse won't be visible to the client and thus rendering your entity white all the time.

You need to sync the fuse with the client and the easiest way to do this is to use a DataWatcher.

Define a new DataWatcherObject (with this.dataWatcher.addObject(...)) within entityInit

on the server side (if worldObj.isRemote == false) set the object's value to the fuse variable in your onUpdate method after it gets updated with dataWatcher.updateObject(...)

on the client side (if worldObj.isRemote == true)  set the value of the fuse variable to the dataWatcherObject's value with getWatchableObjectInt(...)

 

If you don't understand what I mean, here have some pseudocode:

Entity Class
----------
entityInit():
    dataWatcher->addObject(id, Integer.valueOf(0))    | id must be unique! If you get a crash because an already given ID, try another one
                                                      | second param must be casted to the datatype you wanna put in there, here Integer (BTW, the cast is not pseudocode)

onUpdate(): (at the end within the method)
    if world is not remote:
        dataWatcher->updateObject(id, fuse)    | id must be the same as the above defined one
    else:
        fuse = dataWatcher->getWatchableObjectInt(id)    | id, same as above

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 2/20/2014 at 5:40 PM, Cookie160 said:

Thank you, you make a great point, but, where exactly in the code should this Data Watcher go?

 

Every entity has already a dataWatcher instance. Everything else is explained in my previous post.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.