Skip to content

Instantly share code, notes, and snippets.

@mackthehobbit
mackthehobbit / Vec3.cpp
Created March 30, 2016 23:23
Minecraft PE Vector3 struct, with useful methods + implementation. Compatible with the game
#include "Vec3.h"
float Vec3::lengthSquared() const {
return x * x + y * y + z * z;
}
float Vec3::length() const {
return sqrtf(lengthSquared());
}
@mackthehobbit
mackthehobbit / NDK Build with Android Studio
Created November 24, 2015 11:38
Android Studio's default support for building NDK doesn't appear to ever work for me. Here's a way to make a build process work.
// add all of these to build.gradle (the one in your app directory, NOT the root of the project)
// to see all files and be able to add your jni directory, you might need to change the view from 'Android' to 'Project' in the file browser
// this goes inside android > defaultConfig (probably after all the other fields eg. versionCode etc)
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}
// these two go at the end of the 'android' block (but still inside it)
@mackthehobbit
mackthehobbit / Redstone Block.cpp
Last active November 23, 2015 22:07
Basic idea of a redstone-activated block in 0.13 (definitely works). Won't compile as-is, obviously.
// however you're adding blocks
initBlocks hook {
// create & register a MyBlock instance etc
}
#pragma once
#include <string>
class Level;
class Mob;
class TileSource;
class Vec3;
class Vec2;
#pragma once
#include "TextureUVCoordinateSet.h"
class TickingTexture {
public:
// this is the complete struct
// void** vtable;
// this seems like it determines the area of the atlas to be animated
@mackthehobbit
mackthehobbit / Multiple_Results.cpp
Last active August 29, 2015 14:25
Return multiple items from a recipe in an addon (like buckets from a cake)
#include "Recipes.h"
...
/* Any existing recipes function. Try hooking ToolRecipes::addRecipes(Recipes*), etc. */
void addSomeRecipes(Recipes* recipes) {
...
std::vector<Recipes::Type> ingredients;
@mackthehobbit
mackthehobbit / Recipes.h
Last active August 29, 2015 14:23
Addon Recipes example
#pragma once
// this goes in minecraftpe/recipes/ !!!
#include <vector>
#include <string>
#include "minecraftpe/item/ItemInstance.h"
class Recipe;