Jump to content

Recommended Posts

Posted

I'm trying to port the ClaySoldiersMod to 1.3.1 incl. MP compatibility. For stuff which should be shown on the clay soldier (like the stick weapon) will be handled per dataWatcher. Now I ran into a problem: the dataWatcher instance from the entity supports only 32 fields and 18 fields are already occupied for vanilla stuff. But I need more than 13 fields for the little clay soldier.

So I decided to make my own dataWatcher instance, which is called "clayWatcher". The problem is that the clayWatcher fields are only updated when they spawn with this code:

 

  Reveal hidden contents

 

I want to make that the fields are updated while playing, like the dataWatcher, but I don't know how to do that. I probably have to send my own packets, but I don't know how because I never worked with packets before.

So if someone can show me what I have to do or where I can look, I would be very thankful.

 

 

Thanks in advance.

 

 

EDIT: I will use bitflags for my booleans now to decrease the amount of needed dataWatcher objects. Also the superclasses of my entity (EntityCreature->EntityLiving->Entity) occupy only 3 (instead of 18 which I thought) objects: index 0, 1 and 8.

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

How exactly are 18 taken up[ by vanilla items?

Also, That seems like a horrible idea to have so many objects synced between client and server.

You may need a re-design to lower that number. What exactly are you watching?

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted
  On 8/20/2012 at 2:55 AM, LexManos said:

How exactly are 18 taken up[ by vanilla items?

Also, That seems like a horrible idea to have so many objects synced between client and server.

You may need a re-design to lower that number. What exactly are you watching?

 

1. ups, I saw a tutorial somewhere for dataWatchers which said that 18 are occupied by the superclasses (EntityCreature->EntityLiving->Entity). I've looked into these now and occupied are, as far as I saw, only 0, 1 and 8.

2. I would never use so many if I need those, but I looked in some classes which send the dataWatcher and it seems the dataWatcher will be send completely with all 32 possible fields, so it souldn't be that horrible. Please correct me if I'm wrong :P

3. Here's a list what I have to watch:

 

  Reveal hidden contents

 

These are needed, because they will be rendered from the soldier, for example if it has a blaze rod, it renders a blaze rod in its hand.

I could put all these boolean stuff into one [short] field and access them with bitwise operators, but I just want to test stuff out before I improve the coding.

 

But thank you for opening me the eyes because of these occupied dataWatchers. For now I can use more.

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

You should use Bitflags for all the booleans.

 

1 Byte = 8 bits = 00000000

 

1. bit = if it has gravel

2. bit = if it has snowballs

3  bit = if it has firecharges

4. bit = if it has a shield

5. bit = if it has a bone and how many uses it has

6. bit = if it has a studded shield

7. bit = if it's camouflaged

8. bit = if it has blaze powder

 

How to set and get single bits: http://www.vipan.com/htdocs/bitwisehelp.html

(couldn't find a better tutorial and it looks harder than it really is)

 

Just use bitwiseOperaters.

 

Posted
  On 8/20/2012 at 12:15 PM, pitman-87 said:

You should use Bitflags for all the booleans.

 

1 Byte = 8 bits = 00000000

 

1. bit = if it has gravel

2. bit = if it has snowballs

3  bit = if it has firecharges

4. bit = if it has a shield

5. bit = if it has a bone and how many uses it has

6. bit = if it has a studded shield

7. bit = if it's camouflaged

8. bit = if it has blaze powder

 

How to set and get single bits: http://www.vipan.com/htdocs/bitwisehelp.html

(couldn't find a better tutorial and it looks harder than it really is)

 

Just use bitwiseOperaters.

 

I know how to use bitwise stuff, but thanks :)

Yes, I think I'll stick with bitflags for all my booleans.

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

For example, my TF2 dispenser mod uses a byte "options"

 

1. bit = heal player

2. bit = feed player

3. bit = repair players tool

4. bit = neutralize effects

 

In my TileEntity I'm using custom packets, but in your Entity you can use datawatcher instead :)

 

 

  Reveal hidden contents

 

Posted
  On 8/20/2012 at 12:30 PM, pitman-87 said:

For example, my TF2 dispenser mod uses a byte "options"

 

1. bit = heal player

2. bit = feed player

3. bit = repair players tool

4. bit = neutralize effects

 

In my TileEntity I'm using custom packets, but in your Entity you can use datawatcher instead :)

 

 

  Reveal hidden contents

 

 

Well, I think I'll stick with a short datatype, because I have some more booleans to handle than 8 ^^

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.