Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Informing client that texture has changed without spamming packets?


pantheis
 Share

Recommended Posts

My mod has a block that you can rotate. I have this working and am using custom packets to communicate the information to all players within a radius around the block so that their clients all update and show the new orientation. This only fires when the block changes orientation, which is a good thing.

 

The problem I'm thinking I'm going to run into is if a player that isn't in range to receive that packet then comes into range of the block. That player will not have accurate information as to the block orientation and so will not see the textures correctly. I thought about using PacketDispatcher.sendPacketToAllAround in updateEntity with a tick delay of 10 (so fires every 1/2 second), but that seems like an awful waste of bandwidth. There's no reason to keep updating any player near the block if the texture hasn't actually changed.

 

Is there a way to identify when a player has moved into range of my block and send just that player the correct updated information via a packet? I've looked through the Minecraft base source and a bunch of Forge files but I haven't been able to figure out how best to do this. I don't want my mod spamming a ton of packets.

 

Link to comment
Share on other sites

Well, you'll have to be able to:

  • Figure out when the texture changes. Easy.
  • Figure out who has the right textures.
  • Send packets and update who's got them.

Just do those things.

Can't be more help, I *suck* at packets and things.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Thanks for the advice atrain. I'll look into that as an option but I'd rather not be responsible for tracking player entities in a range around my block.

 

I wonder how mods like IC2, RedPower, Buildcraft etc handle it...

Well, when their TE's send a packet, they include that data.

I've tested it.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Well, when their TE's send a packet, they include that data.

I've tested it.

 

I can send packets updating the client with the proper data, that isn't the issue. I just don't want to be sending packets every 1/2 a second to every player in range of any of my blocks. On a busy server with lots of my blocks, that would be a lot of packet traffic for absolutely no use. There's got to be some event or method that I can use to send updated information to players that enter the visual range. Like when the server sends the chunk to a player...

 

Link to comment
Share on other sites

Well, when their TE's send a packet, they include that data.

I've tested it.

 

I can send packets updating the client with the proper data, that isn't the issue. I just don't want to be sending packets every 1/2 a second to every player in range of any of my blocks. On a busy server with lots of my blocks, that would be a lot of packet traffic for absolutely no use. There's got to be some event or method that I can use to send updated information to players that enter the visual range. Like when the server sends the chunk to a player...

Well, the event bus may have something for you.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.