Jump to content

Recommended Posts

Posted

Why?

Seems to me like a single channel is enough for anyone. Just use it correctly.

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

k, maybe to can help explain this to me then.

 

@Override
public void onPacketData(NetworkManager manager,
		Packet250CustomPayload packet, Player playerEntity)
{
	if (packet.channel.equals("HSPacket")) {
		handleRandom(packet);
	} else if (packet.channel.equals("HSPacket2")) {
		System.out.println("Working packet2");
		handleRandom2(packet);
	}
}

 

I know "HSPacket2" will not be called due to my mod_.java channels is set to "HSPacket".

 

However I already have 2 boolean and 3 int tied to static variables with the "HSPacket" for the tileentity.

 

If I was to send the same packet for my Server.isDaylight() sync with client, wouldn't that screw up my tileEntity and Time sync each time the packet is sent at the wrong time. Mainly if both events happen at once?, or is the packet processed quickly enough to not worry about that?

Posted

Nevermind, after a quick shave I thought about it for a bit.

 

I believe I just need to set up a if statement checking the first bit of data I send. Based on the value of this data, it will call required methods.

 

The template I am using from the tut posted here is just too cut and dry to handle multiple packet usage. I see that now :)

 

Thanks

Posted

Why?

Seems to me like a single channel is enough for anyone. Just use it correctly.

 

reading that, I'm doing it the other way too ... so, I'm pondering, what are the advantages and disadvantages of using

a) single packet class (Packet250CustomPayload) and multiple channels

and

b) single channel and multiple placket classes.

 

Realising now that of course the vanilla code uses 70+ different packet types, there has to be an advantage of using different packages instead of different channels...

running minecraft on Mac OS X - Sierra --- creating code since 1986 ... --- मेरा दिल भारतवासी है!

width=289 height=100http://www.arno-saxena.de/pictures/chococraft/banner_signature.png[/img]

Posted

-.- Not gunna get into basic design concepts.

But The 'channels' are shared, and you can stick as much data in that packet as you want.

Every time you make a channel you have to worry about another mod using the same channel, if it does you conflict, think of things like block id conflicts. The less of the limited resource you use, the less you're gunna have an issue.

 

If you look at MC, it does the exact same thing. It tags it with what type of packet it is, the first byte, and then deals with it accordingly.

 

 

So ya, you only need one channel, if you can't figure out how to deal with only one channel, then you really need to rethink what you're doing.

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

true, haven't thought about the channels as a limited resource.

 

Also after changing to single-channel/multiple-packet-classes I found another nifty advantage :D Now my packet handler is very clean and tiny only checking what packet has arrived and calling the handler included in the respective class. (before that the packet handler had been crowded with the handlers ...) Now all code for one network action is packed together into one class and each packet class only is responsible for one network action. Looks nice, works well, what more to wish for :D

running minecraft on Mac OS X - Sierra --- creating code since 1986 ... --- मेरा दिल भारतवासी है!

width=289 height=100http://www.arno-saxena.de/pictures/chococraft/banner_signature.png[/img]

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.