Skip to content

Instantly share code, notes, and snippets.

View rom1504's full-sized avatar

Romain Beaumont rom1504

View GitHub Profile
@rom1504
rom1504 / Dockerfile
Last active November 14, 2018 21:56
xmoto-docker
FROM ubuntu:16.04
RUN apt-get update -y
RUN apt-get upgrade -y
# Installing the apps
RUN apt-get install -y xmoto xvfb x11vnc
COPY run.sh run.sh
[
"mapper",
{
"type": "varint",
"mappings": {
"0x00": "server_info",
"0x01": "ping"
}
}
]
@rom1504
rom1504 / manual.js
Created March 12, 2017 17:48
manual code idea
const manuals=[
{
"type":"switch",
"subtypes":[
{
"description": "container including a switch going to u8, u16 or u32",
"encoder":(value,buffer,offset) => {
const {action,result}=value;
offset+=buffer.writeUInt8(action,offset);
switch(action) {
@rom1504
rom1504 / position_chunk.js
Last active June 25, 2016 01:11
position in chunk 1.9
const cursorInBits=getArrayPosition(pos)*this.bitsPerBlock;
const firstLongPosition=Math.floor(cursorInBits/64);
const shouldBePosition=(64-this.bitsPerBlock)-cursorInBits%64;
const positionInFirstLong=Math.max(shouldBePosition,0);
if(shouldBePosition<0)
{
const lastLongPosition=firstLongPosition+1;
const positionInLastLong=64+shouldBePosition;
}
@rom1504
rom1504 / readChunk_1_9.js
Last active January 7, 2017 11:48
read 1.9 chunk using protodef
const fs=require("fs");
// based on http://wiki.vg/SMP_Map_Format#Format
// testing data from https://download.rom1504.fr/minecraft/chunks/chunks-1.9/
// see http://lunarco.de/minecraft/chunks/ for explanations
// also see https://gist.github.com/Gjum/0375b643ec13a42ab3c0
// and https://github.com/SpockBotMC/SpockBot/blob/0535c31/spockbot/plugins/tools/smpmap.py
@rom1504
rom1504 / packet.txt
Created June 14, 2016 23:06
login mcpe packet 0.15
01000000510000111278daed9d5d73aa4a97c74fd5dccdc7d8f7f3142f92ad73171554943634d00853534ff1e21604d418c597a9f994f385a69186a4093a8999bdb3cf8e17abcea1b25790ffafd7ead56d2ff2ed5ffefaebbfbe7981132ebefdfb7f7c9b1ee4c0ed79e1389425e3a8344067f03458cc585f1bdc0d2276604e7c4945f140e35a8e36593d2a22681b28ee6947284143ea6a06b46d46922c238e14632f81680fb45ec0bb73f90858a8fba6bd315820bbd18c853d865144618912660725c9311608b8bcbd56fad283690ad0e76d65c8fb73c0c60d530493a928f4f4a4c9bb06dcb88cbc03e61ea19edfd3cdbd6cf4030d1cd102443b1e2680d7a518c16e9cead14e3025e9c19364c6403e07751b0e9960ece97ec3e19a6b88d4f087bafc077eee78dabf0fc7739101734300dd8130ee8a4f830435fcbe1cc09ec4585803fcef226702766e4f12f444dad8992e0b3975759155ba6a38eac82bbb87b67e2f66a6d9cf12851d9bca01f41466645a0dc51c6c140e05206443eb18ed467ab41f77ed39d0fd64dc6d279626b7a8df81daac95ec5716b389a77f3003fccc5b2bb12afab75b9dd93f66b0adfdf37e1941146f8fbba9c672e3fbef92f83df0db9de6de5ef71eefef16a2fc603dcefdc5900fcd5df42483fbcdb8617abbcda4b369d88319db891f8dc6c44a574f8fdb669b7ffcf15d7ed8c7bafddd376c7dcbde
@rom1504
rom1504 / protocol.json
Last active June 14, 2016 14:10
compacted 1.8 mc protocol
{
"types": {
"varint": "native",
"pstring": "native",
"u16": "native",
"u8": "native",
"i64": "native",
"buffer": "native",
"i32": "native",
"i8": "native",
@rom1504
rom1504 / compact_stringify.js
Last active June 14, 2016 14:09
compact stringify
const p=require('./protocol.json');
const json_string_of_jarray=(a,lb,t) => '['+(lb ? "\n" : "")+(a.map((v,i) => {
const withoutBreak=(lb ? t+" " : "")+json_string_of_jvalue(v,false);
return withoutBreak.length+(i!=(a.length-1) ? 1 : 0)>80 && lb ? (lb ? t+" " : "")+json_string_of_jvalue(v,lb,t+" ") : withoutBreak;
})).join(lb ? ",\n" : ", ")+(lb ? "\n"+t : "")+']';
const json_string_of_jobject=(o,lb,t) => '{'+(lb ? "\n" : "")+Object.keys(o).map((k,i) => {
const withoutBreak=(lb ? t+' ' : '')+'"'+k+'": '+json_string_of_jvalue(o[k],false);
@rom1504
rom1504 / simple_stringify.js
Created June 14, 2016 12:51
simple stringify
// model : https://github.com/rom1504/JsonConv/blob/master/source/json_to_json.ml
const p=require('./protocol.json');
const json_string_of_jarray=a => `[${(a.map(json_string_of_jvalue)).join(",")}]`;
const json_string_of_jobject=o => `{${Object.keys(o).map(k => '"'+k+'":'+json_string_of_jvalue(o[k])).join(",")}}`;
const json_string_of_jvalue=v => {
if(v===null)
return "NULL";
if(v.constructor===Array)
@rom1504
rom1504 / protocol-diff.js
Created June 5, 2016 22:16
script to make a diff between 2 protodef protocols
const equal = require('deep-equal');
if(process.argv.length != 4) {
console.log("Usage : node protocol-diff.js <protocol1.json> <protocol2.json>");
process.exit(1);
}
const p1File=process.argv[2];
const p2File=process.argv[3];