Skip to content

Instantly share code, notes, and snippets.

View Darthfett's full-sized avatar

Casey Kuball Darthfett

View GitHub Profile
@Darthfett
Darthfett / readme.md
Last active December 11, 2015 23:58 — forked from andrewrk/readme.md

based on mineflayer's api right now (0.0.19), and the existence of mineflayer-navigate, helper bot should be able to resurrect:

  • chat commands
  • navigator 3d
  • task manager
  • aliases
  • chat printer
  • connection notice
  • console
  • death notice
@Darthfett
Darthfett / gist:4666616
Last active December 11, 2015 21:59
The new chat commands structure: You can now register to commands with spaces. One-word commands are run before 2+ word commands (e.g. handlers registered to "dig" would before handlers registered to "dig here").
commands = {
'dig': {
handlers: [
{
handler: someFunction,
minArgs: 0,
maxArgs: Infinity,
},
{
handler: anotherFunction,
@Darthfett
Darthfett / gist:4602297
Created January 23, 2013 05:26
Small hack to convert normal coordinates to pygame coordinates (where y is 0 at bottom left and positive is up, instead of top left corner and positive is down).
def flip_y(y):
"""Small hack to convert normal coordinates to pygame coordinates"""
return -y+GAME_WINDOW_HEIGHT
@Darthfett
Darthfett / readme.md
Last active December 11, 2015 02:09 — forked from andrewrk/readme.md

Proposed Digging API, first pass

event "diggingCompleted"

Fires when the block you were digging has broken.

block.isDiggable

Whether the block is diggable. This returns false for air, water, lava, etc.

@Darthfett
Darthfett / gist:3166718
Created July 23, 2012 22:42
Create a tag
git tag -a Tag_Name 0123456 -m 'MessageHere'
@Darthfett
Darthfett / gist:3006008
Created June 27, 2012 18:56
Search directory for file
find [Path] | grep -i <file name>
# Path defaults to the current directory.
# Using -i for case-insensitive searching.
# Using -E will do regex parsing.
@Darthfett
Darthfett / grade_analyzer.py
Created March 7, 2012 15:25
1. Copy and paste ASU class pages into "classes_and_grades.txt" file in same directory. Delete any empty lines and save. 2. Run script in python 3.x.
import os, sys
with open("classes_and_grades.txt") as classes_and_grades:
for line in classes_and_grades:
data = line.split("\t")
fixed = []
for item in data:
stripped = item.strip()
if stripped:
fixed.append(stripped)
// - DiffuseColor - Returns the Diffuse color for the specified material and light
Vector DiffuseColor(Vector materialDiffuse, SceneLight light, Vector normal, Vector lightv)
{
float distance = lightv.Magnitude();
float distanceTerm = 1.0f / (light.attenuationConstant + light.attenuationLinear * distance + light.attenuationQuadratic * distance * distance);
return materialDiffuse * light.color * (normal.Dot(lightv)) * distanceTerm;
}
Camera camera = m_Scene.m_Camera;
Vector cameraPosition = camera.GetPosition();
// Camera Coordinates directions
Vector negZ = (camera.GetTarget() - cameraPosition).Normalize();
Vector posY = camera.GetUp().Normalize();
Vector posX = negZ.Cross(posY).Normalize();
float FOV = camera.GetFOV();
float nearZ = camera.GetNearClip();
@Darthfett
Darthfett / gist:1362315
Created November 13, 2011 16:49
print token
void printType(string type) {
if (typeOf[type].length()) {
return;
}
vector<string> matches;
for (int i = 0; i < symbols.size(); i++) {
string base = getBaseType(symbols[i]);
if (base.compare(type) == 0 && symbols[i].compare(type)) { // symbols[i]'s base is type, but isn't actually type