Skip to content

Instantly share code, notes, and snippets.

View eddyb's full-sized avatar

Eduard-Mihai Burtescu eddyb

View GitHub Profile
var pack = require('jspack').jspack, zlib = require('zlib');
(function() {
var ev = '';
'byte ubyte short int long float double str8 str16 bool mobMetadata optionalItem itemList compressedChunk multiBlock'.split(' ').forEach(function(type) {
ev += 'var '+type+' = function '+type+'(n){return ["'+type+'",n||"~"];};';
});
eval(ev);
exports.client2server = {
var proto = require('./protocol'), events = require('events'), net = require('net'), util = require("util"), http = require('http'), https = require('https');
function concatBuffers(a, b) {
var buffer = new Buffer(a.length + b.length);
a.copy(buffer, 0, 0);
b.copy(buffer, a.length, 0);
return buffer;
}
#!/usr/bin/env node
var mc = require('../'), packets = mc.protocol.packets;
var server = mc.createServer(function(c) {
c.on('login', function(u) {
console.log(u+' just logged in');
c.write(packets.LOGIN, {playerEID: server.lastEID++, height: 128, maxPlayers: 100});
c.write(packets.CHAT, {message: 'Hi '+u+' and welcome to a demo server of node-mcsmp :).'});
c.write(packets.PLAYER_POS, {x: 0, y: 64, stance: 65.7, z: 0});
//+---------------- -----------------------------------------------------+
//| Blessing 3 v3.7-6 |
//| May 18, 2010 |
//| Copyright © 2007-2010, MQLCoder.com |
//| In no event will authors be liable for any damages whatsoever. |
//| Use at your own risk. |
//+---------------------------------------------------------------------+
#property copyright "Copyright © 2007-2010, J Talon LLC/FiFtHeLeMeNt"
#property link "http://www.jtatoday.com"
/* License: See the COPYING file in this distribution.
*
* Copyright (c) 2010 Terry Riegel <[email protected]>
* Copyright (c) 2011 Aria Stewart <[email protected]>
*/
var net = require('net');
var stream = require('stream')
var util = require('util');
@eddyb
eddyb / Makefile
Created November 29, 2011 14:21 — forked from lauriro/Makefile
Makefile
#
# Makefile for Project
#
#
# Tags:
# =====
#
# Certain tags are used in comments to assist in indexing common issues:
# - TODO to indicate planned enhancements.
# - FIXME to mark potential problematic code that requires special
<!DOCTYPE html>
<html lang='en'>
<head>
<title>three.js webgl - geometry - minecraft - ao</title>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'>
<style>
body {
color: #61443e;
font-family:Monospace;
function pointHeight(_x, _z) {
var h = 0;
for(var x = Math.floor(_x); x <= Math.floor(_x)+1; x++)
for(var z = Math.floor(_z); z <= Math.floor(_z)+1; z++)
h += (2 - Math.abs(_x - x) - Math.abs(_z - z)) * heightMap[x][z];
return h / 4;
}
var fs = require('fs');
exports.open = function open(path) {
var data = JSON.parse(fs.readFileSync(path));
return Proxy.create({
getOwnPropertyDescriptor: Object.getOwnPropertyDescriptor.bind(Object, data),
getPropertyDescriptor: Object.getPropertyDescriptor.bind(Object, data),
getOwnPropertyNames: Object.getOwnPropertyNames.bind(Object, data),
getPropertyNames: Object.getPropertyNames.bind(Object, data),
defineProperty: function(name, propertyDescriptor) {
var express = require('express');
var app = express.createServer(), io = require('socket.io').listen(app);
app.configure(function() {
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({dumpExceptions: true, showStack: true}));
app.use(app.router);
});