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
  On 9/18/2012 at 9:40 PM, pantheis said:

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
  On 9/18/2012 at 10:09 PM, atrain99 said:

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
  On 9/18/2012 at 10:28 PM, pantheis said:

  Quote

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
  On 9/19/2012 at 12:52 AM, LexManos said:

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Alright, here is the log file https://mclo.gs/5eCwafV
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post log files as described there, using a site such as https://mclo.gs/ and post the link here.  
    • I tried updating the mods in my modpack which caused incompatibilities so i have tried to revert them back to their older versions i was using before. In the logs it doesnt show me any clear incompatibilities except for tfmg & entity texture features, but when i try to remove those it still doesn't work. I have tried removing the forge-client.toml file which was a suggestion i found on  a few other posts. This is the log file i get. [inline log removed] Any help would be appreciated. Thanks in advance
    • I don't use KubeJS, never even heard of it. But after doing what "Ugdhar" suggested earlier in this post with the "config/Mekanism/generator-storage.toml", I tried going into an individual save's serverconfig folder, and just deleting everything except the parcool folder (I have that mod installed.) Then, a bit of loading and temporary freezing later, seems to have worked. Even when quitting to menu and loading back in, or also when quitting to menu, exiting to desktop, and re-launching MC, choose a save and loading it.
    • [Mekanism] Broken tags in Mekanism recipes detected, please check server logs for details. You will be missing some recipes and machines may not accept expected inputs. Do you use KubeJS? It is some kind of bug with it and not fixed A workaround is setting "allowAsyncStreams" to false in the KubeJS common config file https://github.com/KubeJS-Mods/KubeJS/issues/1016   For the rest of your issues, keep deleting these files - now it is the jei-server.toml file If the file is not in config, check the worldsave serverconfig folder These files usually break after updating mods, game crashes or force closing the game    
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.