Skip to content
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

1.7 custom_payload 0x3f varshort for Forge compatibility #120

Closed
wants to merge 1 commit into from

Conversation

deathcap
Copy link
Member

Requires ProtoDef-io/node-protodef#52

http://wiki.vg/Minecraft_Forge_Handshake#Differences_from_Forge_1.7.10 "However, forge makes some more changes to the server to client packet [0x3f](but not the client to server packet [0x17]): Rather than using a short for the length, a varshort is used"

Note this is backwards-compatibile with vanilla 1.7, since short lengths would never be negative. varshorts extend short by adding an extra byte (to extend 16-bit range to 23-bit) following the negative short with MSB set. Tested on forge-1.7.10-10.13.4.1614. Would like this for PrismarineJS/node-minecraft-protocol-forge#7 (couldn't make the change there since it is a lower-level protocol change, but at least this is backwards-compatible with vanilla, so it should be safe - only extends the protocol)

@rom1504
Copy link
Member

rom1504 commented Feb 20, 2016

This can now be moved to nmp-forge using https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/client_custom_packets/client_custom_packets.js (expose a customPackets in nmp-forge probably to be used along createClient probably ? maybe there should be a better way to install this but I'm not sure what)

@deathcap
Copy link
Member Author

deathcap commented Mar 6, 2016

Hmm I can't see how I can use the customPackets option here, nmp-forge needs to change the custom packet definitions after it has already been created because the forgeHandshake and autoVersionForge plugins augment node-minecraft-protocol createClient after setup, but by this time the serializers/deserializes have already been created.

@rom1504
Copy link
Member

rom1504 commented Mar 6, 2016

@deathcap what about providing a require('minecraft-protocol-forge').customPackets ?

@deathcap
Copy link
Member Author

deathcap commented Mar 7, 2016

        "custom_payload": {
          "id": "0x3f",
          "fields": [
            {
              "name": "channel",
              "type": "string"
            },
            {
              "name": "data",
              "type": [
                "buffer",
                {
                  "countType": "varshort"
                }
              ]
            }
          ]
        },

in customPackets should work, but the problem is where to add it.

src/client/forgeHandshake (the node-minecraft-protocol "plugin"), exports this function to augment client for Forge support:

module.exports = function(client, options) {
  client.tagHost = '\0FML\0';
  client.on('custom_payload', function(packet) {
    if (packet.channel === 'FML|HS') {
      fmlHandshakeStep(client, packet.data, options);
    }
  });
};

would like to also augment it to change the custom_payload 0x3f protocol definition. By this time, the constructor for createClient() has already been called.

Trying to access client.serializer.proto but not clear how/if it can be modified to change this definition. There is a packet type but it only contains the read, write, and sizeOf functions. Is it possible to get to the packet types directly through client.serializer.proto?

@rom1504
Copy link
Member

rom1504 commented Mar 7, 2016

@deathcap I really don't understand what is the problem with doing this:

var mc = require('minecraft-protocol');
var forgeHandshake = require('minecraft-protocol-forge').forgeHandshake;
var client = mc.createClient({
    host: host,
    port: port,
    username: username,
    password: password,
    customPackets: require('minecraft-protocol-forge').customPackets
});

forgeHandshake(client, {forgeMods: [
  { modid: 'mcp', version: '9.18' },
  { modid: 'FML', version: '8.0.99.99' },
  { modid: 'Forge', version: '11.15.0.1715' },
  { modid: 'IronChest', version: '6.0.121.768' }
]);

Also see https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/client_custom_packets/client_custom_packets.js#L8
The format of custom packets has changed (same as in mcdata protocol.json)

@rom1504
Copy link
Member

rom1504 commented Mar 7, 2016

(if you really want to modify the serializer after it has been created you could expose and call createProtocol (https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/transforms/serializer.js#L19) and then change the protocol in serializer)

edit: except this would be really annoying to do because there are several serializers/parsers (8)

@rom1504
Copy link
Member

rom1504 commented Mar 7, 2016

Oh and customPackets are merged, so for example https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/client_custom_packets/client_custom_packets.js#L8 adds a packet, it doesn't remove them all.

@rom1504
Copy link
Member

rom1504 commented Jan 1, 2018

tracked elsewhere

@rom1504 rom1504 closed this Jan 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants