PrismarineJS / PrismarineJS/node-minecraft-protocol
Ladders arent working
Open
Nobody has claimed this yet.
possible bug
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 290
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 7
Description
[v] The FAQ doesn't contain a resolution to my issue
Versions
- minecraft-protocol: 1.47.0
- server: paper 1.20.4
- node: 18.19.1
Detailed description of a problem
Proxying through node-minecraft-protocol, ladders arent working
Current code
const tunKey = 'no';
const host = '192.168.0.158';
const port = 32323;
const mc = require('minecraft-protocol');
const ws = require('ws');
const sock = new ws.WebSocket('https://minecraft-tunneling.zelix.space/minecraft');
sock.on('open', async () => {
sock.send(JSON.stringify({
key: tunKey
}));
});
function createText(msg, version) {
if (['1.20.3', '1.20.4'].includes(version)) {
return {
type: 'string',
value: msg
};
} else if (['1.19.4', '1.19.3', '1.19.2', '1.19.1'].includes(version)) {
return JSON.stringify(msg);
} else if (version == '1.19') {
return JSON.stringify(msg);
} else {
return JSON.stringify(msg);
}
}
function createChatPacket(msg, version) {
if (['1.20.3', '1.20.4'].includes(version)) {
return {
name: 'system_chat',
data: {
content: msg,
isActionBar: false
}
}
} else if (['1.19.4', '1.19.3', '1.19.2', '1.19.1', '1.20.2', '1.20.1', '1.20'].includes(version)) {
return {
name: 'system_chat',
data: {
content: JSON.stringify(msg),
isActionBar: false
}
};
} else if (version == '1.19') {
return {
name: 'system_chat',
data: {
content: JSON.stringify(msg),
type: 1
}
};
} else {
return {
name: 'chat',
data: {
message: JSON.stringify(msg),
position: 1,
sender: NIL
}
};
}
}
/**
* @type {Object.<string, mc.Client>}
*/
const clients = {};
sock.on('message', async (msg) => {
const j = JSON.parse(msg);
if (j.ok) {
console.log(`Tunneling to ${j.address}`);
}
if (j.connect) {
const client = mc.createClient({
username: j.username,
version: j.version,
host,
port,
keepAlive: false,
disableChatSigning: true
});
clients[j.username] = client;
console.log(`${j.username} connects from ${j.remoteAddress} [${j.version}]`);
client.on('error', async (err) => {
console.error(err);
});
client.on('end', async () => {
console.log(`${j.username} disconnects`);
sock.send(JSON.stringify({
kick: true,
username: j.username
}));
delete clients[j.username];
});
client.on('packet', async (data, meta) => {
if (meta.state == mc.states.PLAY && meta.name != 'custom_payload') {
if (client.version == '1.20.3' || client.version == '1.20.4') {
if (meta.name == 'player_chat') {
if (data.unsignedChatContent && data.type == 4) {
const packet = createChatPacket(data.unsignedChatContent, client.version);
meta.name = packet.name;
data = packet.data;
}
}
}
sock.send(JSON.stringify(
{
packet: meta.name,
state: meta.state,
data: JSON.stringify(data),
username: j.username
}
));
}
});
}
if (j.disconnect) {
const c = clients[j.username];
console.log(`${j.username} disconnected (request by server)`);
if (!c) return;
clients[j.username].end();
delete clients[j.username];
}
if (j.name && j.username) {
const c = clients[j.username];
if (!c) {
// sock.send(JSON.stringify({
// kick: true,
// username: j.username
// }));
return;
}
if (c.state == mc.states.PLAY && j.state == 'play') {
if (j.name == 'custom_payload') return;
c.write(j.name, JSON.parse(j.data));
}
}
});
Expected behavior
Ladders should work
Additional context
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/FAQ.md and reproduce the supplied JavaScript proxy using minecraft-protocol 1.47.0, Node 18.19.1, and Paper 1.20.4. Trace the packet forwarding between the client's packet handler and c.write, using the supplied ladder behavior and video as the reference; done means ladders work correctly through the proxy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100