Skip to content

Instantly share code, notes, and snippets.

View vogonistic's full-sized avatar

Kent Karlsson vogonistic

  • Vistträsk, Sweden
  • 23:02 (UTC +02:00)
View GitHub Profile
@vogonistic
vogonistic / greedy.js
Last active December 12, 2015 06:19
Updated mesher that takes transparency into account. Unfortunately, it's significantly slower than current greedy.js
var GreedyMesh = (function greedyLoader() {
// contains all forward faces (in terms of scan direction)
var mask = new Int32Array(4096);
// and all backwards faces. needed when there are two transparent blocks
// next to each other.
var invMask = new Int32Array(4096);
// setting 16th bit if transparent
var kTransparentMask = 0x8000;
@vogonistic
vogonistic / testLookAt.js
Created January 25, 2013 19:21
Test bot for lookAt. Has a function looksAt which uses simple ray tracing to figure out which block a player is looking at.
// create and connect the bot
var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({ username: 'testLookAt' });
bot.on('login', function() {
setTimeout(function() {
// find a block to test with
verify(findBlockAtVector(-0.25, -0.5, 0.00));
verify(findBlockAtVector( 0.25, -0.5, 0.00));
verify(findBlockAtVector( 0.00, -0.5, -0.25));
@vogonistic
vogonistic / repl_bot.js
Created January 25, 2013 04:15
REPL example bot for mineflayer. Allows testing javascript over CLI to speed up development.
// REPL example bot for mineflayer
//
// Connects to server but doesn't have any built in logic. The terminal where
// it was started is now a REPL (Read-Eval-Print-Loop). Anything typed will be
// interpreted as javascript printed using util.inspect. Don't forget to try
// tab completion. These variables are exposed as local:
//
// var mineflayer = require('mineflayer');
// var bot = mineflayer.createBot({ username: 'REPL' });
//
@vogonistic
vogonistic / subcommand.py
Created August 31, 2012 16:19 — forked from sampsyo/subcommand.py
subcommand support for Python's optparse
"""A simple addition to Python's optparse module supporting subcommands
like those found in the svn or hg CLIs.
To use it, instantiate the Subcommand class for every subcommand you
want to support. Each subcommand has a name, aliases, a help message,
and a separate OptionParser instance. Then pass a list of Subcommands
to the constructor of SubcommandsOptionParser to make a subcommand-
aware parser. Calling parse_args on that parser gives you the
subcommand invoked, the subcommand's arguments and options, and the
global options all in one fell swoop. See the smoke test at the bottom