Jump to content

Informing client that texture has changed without spamming packets?


Recommended Posts

Posted

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.

 

Posted

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.

Posted

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

 

Posted

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.

Posted

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

 

Posted

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.

Posted

getDescriptionPacket is the thing you should be looking at.

 

LexManos, thanks again! As always, you rock. I'll take a look at this tomorrow when I work on coding again.

 

Posted

I just wanted to say that this worked perfectly! It looks like the proper function is named getAuxillaryInfoPacket() though, but I figured it out by looking at the TE code for signs and mob spawners.

 

Thanks again!

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.