pantheis Posted September 18, 2012 Posted September 18, 2012 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. Quote
atrain99 Posted September 18, 2012 Posted September 18, 2012 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. Quote So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
pantheis Posted September 18, 2012 Author Posted September 18, 2012 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... Quote
atrain99 Posted September 18, 2012 Posted September 18, 2012 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. Quote So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
pantheis Posted September 18, 2012 Author Posted September 18, 2012 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... Quote
atrain99 Posted September 19, 2012 Posted September 19, 2012 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. Quote So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
LexManos Posted September 19, 2012 Posted September 19, 2012 getDescriptionPacket is the thing you should be looking at. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
pantheis Posted September 19, 2012 Author Posted September 19, 2012 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. Quote
pantheis Posted September 19, 2012 Author Posted September 19, 2012 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! Quote
Recommended Posts
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.