-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve custom tasmod server #177
Improve custom tasmod server #177
Conversation
PancakeTAS
commented
May 27, 2023
•
edited by ScribbleTAS
Loading
edited by ScribbleTAS
- Implement asynchronous server
- Write packet and authentication system
- Start to update packets to new server
- Actually finish updating all packets to new server
- Write new connection configuration: WONTFIX until game can launch again
here is the tasmod server as promised. I've done half of the packets but this process is way to difficult for me cuz I have no idea what I'm doing. I've left you eclipse templates in discord and you can look at the code for examples, it should be self explanatory. You might need to rewrite packets with nbt components to not have nbt components, or wrap a ByteBuf (Unpooled.buffer i believe) around it - at that point just write a util. To contribute to this pull request you'll have to pullrequest enhancements/betterserver on my fork. |
Also FRICK that's a lot of merge conflicts. |
Quick guide on the packet system: For the first two you can use the template "write" and "writeAll" in the eclipse file, it puts a nice error logging block around it for you, and makes it easier to create the packets. It looks like this: try {
// packet ${index}:
TASmodClient.client.write(ByteBuffer.allocate(${cursor}).putInt(${index}));
} catch (Exception e) {
TASmod.LOGGER.error("Unable to send packet to server: {}", e);
} This is where you change "index" to a new packet index counting up from the latest one in Client.java. To handle the packet go into Client.java and find the serverside/clientside register method and put "handle" in there. It's pretty self explanatory again, it should look like this:
Put your handling to where the cursor is after entering the index and put your handling stuff in there. Here you can decide to keep it in the Client class and make it super long... or make a method (NOT A NEW CLASS!) in the class it will act in. You can see why this is painful lol... |
f3fe7ff
to
c51f1b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welp here is my review... I'll have to probably fix this myself, so it's more of a to do list for me... I will definitely rewrite the packets myself so fixing the things I pointed out will probably be enough if anyone feels inclined to fix them...
src/main/java/com/minecrafttas/tasmod/tickratechanger/TickrateChangerServer.java
Outdated
Show resolved
Hide resolved
I left my reviews too. Before you go rework all of this I would like to try one more code structuring idea I wanted to for a while now. I'll address both comments in my commits probably tomorrow. |
Absolutely no idea if this works, won't be able to test until the game launches again |
your turn |
Note to self: Add keepalive packet... |
Note to self: Afterwards implement SyncStatePacket... When sending that to the server I got an error idk why... |
Welcome to Scribble losing his mind again doing very dumb mistakes.
Great. This tells me that the packet I am sending inbetween the server and client has no data and it fails to read that data. So you start checking every instance where you send that particular packet. Nope, everything is correct here. Hmmm... Then you find out that the packet is sent twice? Then you check the connection. Nope only one connection. public void onServerInit(MinecraftServer server) {
playbackControllerServer=new PlaybackControllerServer();
PacketHandlerRegistry.register(playbackControllerServer);
} So everytime I join singleplayer, I register a new packethandler. if (!REGISTRY.contains(handler)) {
REGISTRY.add(handler);
} else {
Common.LOGGER.warn("Trying to register packet handler {}, but it is already registered!", handler.getClass().getName());
} but due to the |
buffer underflow exception doesn't necessarily mean there's no data at all, it just means that in the buffer, the Anyways I'll use your small little hiccup as an argument for why registries are a terrible idea :3 By the way, I'm pretty sure the contains() method called equals() on every object, to see if they are equal. If you want to prevent bugs like this in the future, you can override that method in the class and implement your own is equal check. |
Nice idea, however, the object that I'm registering is an interface, meaning I'd have to override all implementations or do some abstract class bs to get this done the same way. Instead I opted for this private static boolean containsClass(PacketHandlerBase handler) {
for(PacketHandlerBase packethandler : REGISTRY) {
if(packethandler.getClass().equals(handler.getClass())) {
return true;
}
}
return false;
} |
- Added an option to packets (In this case TASmodPackets) to be turned off for this trace view
- Fixed the ability to register 2 instances of packet handlers with the same class - Removed STATESYNC_INITIAL - [Savestates] Fixed unexpected behaviour - [PlaybackController] Fixed errors in console
Note to self:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk what I just reviewed, there were only deletions hehe
src/main/java/com/minecrafttas/common/events/EventListenerRegistry.java
Outdated
Show resolved
Hide resolved
This reverts commit 8614dbb.
…stom server on startup
@PancakeTAS How many months did this take? idk, but pls review |
- Fixed clearinputs packet being sent twice - Renamed SYNCSTATE packet to PLAYBACK_STATE - Renamed CLEAR_INPUTS to PLAYBACK_CLEAR_INPUTS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved