-Subproject commit 0a3fe3553f0e6fe9a9cd8d8994c15c873d247e34
+Subproject commit d49b4a9e4d4b4afe6f483139f3c37db58376bfae
 
 class ArrayTexture;
 class BlockTypeRegistry;
 class CubeMap;
+class ShapeRegistry;
 class Sound;
 class Texture;
 class TextureIndex;
        void LoadBlockTypes(const std::string &set_name, BlockTypeRegistry &, TextureIndex &) const;
        CubeMap LoadCubeMap(const std::string &name) const;
        Font LoadFont(const std::string &name, int size) const;
+       void LoadShapes(const std::string &set_name, ShapeRegistry &) const;
        Sound LoadSound(const std::string &name) const;
        Texture LoadTexture(const std::string &name) const;
        void LoadTexture(const std::string &name, ArrayTexture &, int layer) const;
 
 #include "../graphics/Texture.hpp"
 #include "../io/TokenStreamReader.hpp"
 #include "../model/bounds.hpp"
+#include "../model/Shape.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../world/BlockType.hpp"
 #include "../world/BlockTypeRegistry.hpp"
 #include "../world/Entity.hpp"
 
 }
 
-void AssetLoader::LoadBlockTypes(const std::string &set_name, BlockTypeRegistry ®, TextureIndex &tex_index) const {
+void AssetLoader::LoadBlockTypes(const string &set_name, BlockTypeRegistry ®, TextureIndex &tex_index) const {
        string full = data + set_name + ".types";
        std::ifstream file(full);
        if (!file) {
                                type.visible = in.GetBool();
                        } else if (name == "texture") {
                                in.ReadString(tex_name);
-                               type.texture = tex_index.GetID(tex_name);
+                               type.textures.push_back(tex_index.GetID(tex_name));
+                       } else if (name == "textures") {
+                               in.Skip(Token::BRACKET_OPEN);
+                               while (in.Peek().type != Token::BRACKET_CLOSE) {
+                                       in.ReadString(tex_name);
+                                       type.textures.push_back(tex_index.GetID(tex_name));
+                                       if (in.Peek().type == Token::COMMA) {
+                                               in.Skip(Token::COMMA);
+                                       }
+                               }
+                               in.Skip(Token::BRACKET_CLOSE);
                        } else if (name == "rgb_mod") {
                                in.ReadVec(type.rgb_mod);
                        } else if (name == "hsl_mod") {
        return Font(full.c_str(), size);
 }
 
+void AssetLoader::LoadShapes(const string &set_name, ShapeRegistry &shapes) const {
+       string full = data + set_name + ".shapes";
+       std::ifstream file(full);
+       if (!file) {
+               throw std::runtime_error("failed to open shape file " + full);
+       }
+       TokenStreamReader in(file);
+       string shape_name;
+       while (in.HasMore()) {
+               in.ReadIdentifier(shape_name);
+               in.Skip(Token::EQUALS);
+               Shape &shape = shapes.Add(shape_name);
+               shape.Read(in);
+               in.Skip(Token::SEMICOLON);
+       }
+}
+
 Sound AssetLoader::LoadSound(const string &name) const {
        string full = sounds + name + ".wav";
        return Sound(full.c_str());
 
 #include "../app/IntervalTimer.hpp"
 #include "../graphics/SkyBox.hpp"
 #include "../io/WorldSave.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../model/Skeletons.hpp"
 #include "../net/Packet.hpp"
 #include "../ui/HUD.hpp"
 
 private:
        MasterState &master;
+       ShapeRegistry shapes;
        BlockTypeRegistry block_types;
        WorldSave save;
        World world;
 
 // TODO: this clutter is a giant mess
 InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
 : master(master)
+, shapes()
 , block_types()
 , save(master.GetEnv().config.GetWorldPath(master.GetWorldConf().name, master.GetConfig().net.host))
 , world(block_types, master.GetWorldConf())
                save.Write(master.GetWorldConf());
        }
        TextureIndex tex_index;
+       master.GetEnv().loader.LoadShapes("default", shapes);
        master.GetEnv().loader.LoadBlockTypes("default", block_types, tex_index);
        interface.SetInventorySlots(block_types.size() - 1);
        chunk_renderer.LoadTextures(master.GetEnv().loader, tex_index);
 
+++ /dev/null
-#include "Shape.hpp"
-
-#include "bounds.hpp"
-#include "../io/TokenStreamReader.hpp"
-
-#include <string>
-
-using namespace std;
-
-
-namespace blank {
-
-Shape::Shape()
-: bounds()
-, vertices()
-, indices() {
-
-}
-
-
-void Shape::Read(TokenStreamReader &in) {
-       bounds.reset();
-       vertices.clear();
-       indices.clear();
-
-       string name;
-       while (in.HasMore()) {
-               in.ReadIdentifier(name);
-               in.Skip(Token::EQUALS);
-               if (name == "bounds") {
-                       string bounds_class;
-                       in.ReadIdentifier(bounds_class);
-                       in.Skip(Token::BRACKET_OPEN);
-                       if (bounds_class == "Cuboid") {
-                               glm::vec3 min;
-                               glm::vec3 max;
-                               in.ReadVec(min);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(max);
-                               bounds.reset(new CuboidBounds(AABB{min, max}));
-                       } else if (bounds_class == "Stair") {
-                               glm::vec3 min;
-                               glm::vec3 max;
-                               glm::vec2 split;
-                               in.ReadVec(min);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(max);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(split);
-                               bounds.reset(new StairBounds(AABB{min, max}, split));
-                       } else {
-                               while (in.Peek().type != Token::BRACKET_CLOSE) {
-                                       in.Next();
-                               }
-                       }
-                       in.Skip(Token::BRACKET_CLOSE);
-
-               } else if (name == "vertices") {
-                       in.Skip(Token::ANGLE_BRACKET_OPEN);
-                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
-                               in.Skip(Token::ANGLE_BRACKET_OPEN);
-                               Vertex vtx;
-                               in.ReadVec(vtx.position);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(vtx.normal);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(vtx.tex_st);
-                               in.Skip(Token::COMMA);
-                               in.ReadNumber(vtx.tex_id);
-                               if (in.Peek().type == Token::COMMA) {
-                                       in.Skip(Token::COMMA);
-                               }
-                               in.Skip(Token::ANGLE_BRACKET_CLOSE);
-                               if (in.Peek().type == Token::COMMA) {
-                                       in.Skip(Token::COMMA);
-                               }
-                       }
-
-               } else if (name == "indices") {
-                       in.Skip(Token::ANGLE_BRACKET_OPEN);
-                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
-                               indices.push_back(in.GetULong());
-                               if (in.Peek().type == Token::COMMA) {
-                                       in.Skip(Token::COMMA);
-                               }
-                       }
-
-               } else {
-                       // try to skip, might fail though
-                       while (in.Peek().type != Token::SEMICOLON) {
-                               in.Next();
-                       }
-               }
-               in.Skip(Token::SEMICOLON);
-       }
-}
-
-float Shape::TexR(const vector<float> &tex_map, size_t off) noexcept {
-       if (off < tex_map.size()) {
-               return tex_map[off];
-       } else if (!tex_map.empty()) {
-               return tex_map.back();
-       } else {
-               return 0.0f;
-       }
-}
-
-void Shape::Fill(
-       EntityMesh::Buffer &buf,
-       const vector<float> &tex_map
-) const {
-       for (const auto &vtx : vertices) {
-               buf.vertices.emplace_back(vtx.position);
-               buf.normals.emplace_back(vtx.normal);
-               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
-       }
-       for (auto idx : indices) {
-               buf.indices.emplace_back(idx);
-       }
-}
-
-void Shape::Fill(
-       EntityMesh::Buffer &buf,
-       const glm::mat4 &transform,
-       const vector<float> &tex_map
-) const {
-       for (const auto &vtx : vertices) {
-               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
-               buf.normals.emplace_back(transform * glm::vec4(vtx.normal, 0.0f));
-               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
-       }
-       for (auto idx : indices) {
-               buf.indices.emplace_back(idx);
-       }
-}
-
-void Shape::Fill(
-       BlockMesh::Buffer &buf,
-       const glm::mat4 &transform,
-       const vector<float> &tex_map,
-       size_t idx_offset
-) const {
-       for (const auto &vtx : vertices) {
-               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
-               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
-       }
-       for (auto idx : indices) {
-               buf.indices.emplace_back(idx_offset + idx);
-       }
-}
-
-}
 
        struct Vertex {
                glm::vec3 position;
                glm::vec3 normal;
-               glm::vec3 tex_st;
+               glm::vec2 tex_st;
                std::size_t tex_id;
        };
        std::vector<Vertex> vertices;
 
--- /dev/null
+#ifndef BLANK_MODEL_SHAPEREGISTRY_HPP_
+#define BLANK_MODEL_SHAPEREGISTRY_HPP_
+
+#include "Shape.hpp"
+
+#include <map>
+#include <string>
+
+
+namespace blank {
+
+class ShapeRegistry {
+
+public:
+       ShapeRegistry();
+
+       Shape &Add(const std::string &);
+
+       Shape &Get(const std::string &);
+       const Shape &Get(const std::string &) const;
+
+private:
+       std::map<std::string, Shape> shapes;
+
+};
+
+}
+
+#endif
 
--- /dev/null
+#include "Shape.hpp"
+#include "ShapeRegistry.hpp"
+
+#include "bounds.hpp"
+#include "../io/TokenStreamReader.hpp"
+
+#include <string>
+
+using namespace std;
+
+
+namespace blank {
+
+Shape::Shape()
+: bounds()
+, vertices()
+, indices() {
+
+}
+
+void Shape::Read(TokenStreamReader &in) {
+       bounds.reset();
+       vertices.clear();
+       indices.clear();
+
+       string name;
+       in.Skip(Token::ANGLE_BRACKET_OPEN);
+       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
+               in.ReadIdentifier(name);
+               in.Skip(Token::EQUALS);
+               if (name == "bounds") {
+                       string bounds_class;
+                       in.ReadIdentifier(bounds_class);
+                       in.Skip(Token::PARENTHESIS_OPEN);
+                       if (bounds_class == "Cuboid") {
+                               glm::vec3 min;
+                               glm::vec3 max;
+                               in.ReadVec(min);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(max);
+                               bounds.reset(new CuboidBounds(AABB{min, max}));
+                       } else if (bounds_class == "Stair") {
+                               glm::vec3 min;
+                               glm::vec3 max;
+                               glm::vec2 split;
+                               in.ReadVec(min);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(max);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(split);
+                               bounds.reset(new StairBounds(AABB{min, max}, split));
+                       } else {
+                               while (in.Peek().type != Token::PARENTHESIS_CLOSE) {
+                                       in.Next();
+                               }
+                       }
+                       in.Skip(Token::PARENTHESIS_CLOSE);
+
+               } else if (name == "vertices") {
+                       in.Skip(Token::ANGLE_BRACKET_OPEN);
+                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
+                               in.Skip(Token::ANGLE_BRACKET_OPEN);
+                               Vertex vtx;
+                               in.ReadVec(vtx.position);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(vtx.normal);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(vtx.tex_st);
+                               in.Skip(Token::COMMA);
+                               in.ReadNumber(vtx.tex_id);
+                               if (in.Peek().type == Token::COMMA) {
+                                       in.Skip(Token::COMMA);
+                               }
+                               in.Skip(Token::ANGLE_BRACKET_CLOSE);
+                               if (in.Peek().type == Token::COMMA) {
+                                       in.Skip(Token::COMMA);
+                               }
+                       }
+                       in.Skip(Token::ANGLE_BRACKET_CLOSE);
+
+               } else if (name == "indices") {
+                       in.Skip(Token::ANGLE_BRACKET_OPEN);
+                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
+                               indices.push_back(in.GetULong());
+                               if (in.Peek().type == Token::COMMA) {
+                                       in.Skip(Token::COMMA);
+                               }
+                       }
+                       in.Skip(Token::ANGLE_BRACKET_CLOSE);
+
+               } else {
+                       // try to skip, might fail though
+                       while (in.Peek().type != Token::SEMICOLON) {
+                               in.Next();
+                       }
+               }
+               in.Skip(Token::SEMICOLON);
+       }
+       in.Skip(Token::ANGLE_BRACKET_CLOSE);
+}
+
+float Shape::TexR(const vector<float> &tex_map, size_t off) noexcept {
+       if (off < tex_map.size()) {
+               return tex_map[off];
+       } else if (!tex_map.empty()) {
+               return tex_map.back();
+       } else {
+               return 0.0f;
+       }
+}
+
+void Shape::Fill(
+       EntityMesh::Buffer &buf,
+       const vector<float> &tex_map
+) const {
+       for (const auto &vtx : vertices) {
+               buf.vertices.emplace_back(vtx.position);
+               buf.normals.emplace_back(vtx.normal);
+               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
+       }
+       for (auto idx : indices) {
+               buf.indices.emplace_back(idx);
+       }
+}
+
+void Shape::Fill(
+       EntityMesh::Buffer &buf,
+       const glm::mat4 &transform,
+       const vector<float> &tex_map
+) const {
+       for (const auto &vtx : vertices) {
+               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
+               buf.normals.emplace_back(transform * glm::vec4(vtx.normal, 0.0f));
+               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
+       }
+       for (auto idx : indices) {
+               buf.indices.emplace_back(idx);
+       }
+}
+
+void Shape::Fill(
+       BlockMesh::Buffer &buf,
+       const glm::mat4 &transform,
+       const vector<float> &tex_map,
+       size_t idx_offset
+) const {
+       for (const auto &vtx : vertices) {
+               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
+               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
+       }
+       for (auto idx : indices) {
+               buf.indices.emplace_back(idx_offset + idx);
+       }
+}
+
+
+ShapeRegistry::ShapeRegistry()
+: shapes() {
+
+}
+
+Shape &ShapeRegistry::Add(const string &name) {
+       auto result = shapes.emplace(name, Shape());
+       if (result.second) {
+               return result.first->second;
+       } else {
+               throw runtime_error("duplicate shape " + name);
+       }
+}
+
+Shape &ShapeRegistry::Get(const string &name) {
+       auto entry = shapes.find(name);
+       if (entry != shapes.end()) {
+               return entry->second;
+       } else {
+               throw runtime_error("unknown shape " + name);
+       }
+}
+
+const Shape &ShapeRegistry::Get(const string &name) const {
+       auto entry = shapes.find(name);
+       if (entry != shapes.end()) {
+               return entry->second;
+       } else {
+               throw runtime_error("unknown shape " + name);
+       }
+}
+
+}
 
        const Config &config
 )
 : env(env)
+, shapes()
 , block_types()
 , world(block_types, wc)
 , generator(gc)
 , server(config.net, world, wc, ws)
 , loop_timer(16) {
        TextureIndex tex_index;
+       env.loader.LoadShapes("default", shapes);
        env.loader.LoadBlockTypes("default", block_types, tex_index);
        generator.LoadTypes(block_types);
        skeletons.LoadHeadless();
 
 #include "../ai/Spawner.hpp"
 #include "../app/IntervalTimer.hpp"
 #include "../app/State.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../model/Skeletons.hpp"
 #include "../world/BlockTypeRegistry.hpp"
 #include "../world/ChunkLoader.hpp"
 
 private:
        HeadlessEnvironment &env;
+       ShapeRegistry shapes;
        BlockTypeRegistry block_types;
        World world;
        Generator generator;
 
 )
 : config(config)
 , env(env)
+, shapes()
 , block_types()
 , save(save)
 , world(block_types, wc)
 , preload(env, chunk_loader, chunk_renderer)
 , unload(env, world.Chunks(), save) {
        TextureIndex tex_index;
+       env.loader.LoadShapes("default", shapes);
        env.loader.LoadBlockTypes("default", block_types, tex_index);
        interface.SetInventorySlots(block_types.size() - 1);
        generator.LoadTypes(block_types);
 
 #include "UnloadState.hpp"
 #include "../ai/Spawner.hpp"
 #include "../graphics/SkyBox.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../model/Skeletons.hpp"
 #include "../ui/DirectInput.hpp"
 #include "../ui/HUD.hpp"
 private:
        Config &config;
        Environment &env;
+       ShapeRegistry shapes;
        BlockTypeRegistry block_types;
        const WorldSave &save;
        World world;
 
 #include "../model/bounds.hpp"
 
 #include <glm/glm.hpp>
+#include <vector>
 
 
 namespace blank {
 struct BlockType {
 
        const CollisionBounds *shape;
-       float texture;
+       std::vector<float> textures;
        glm::vec3 hsl_mod;
        glm::vec3 rgb_mod;
        glm::vec3 outline_color;
 
 
 BlockType::BlockType() noexcept
 : shape(&DEFAULT_SHAPE)
-, texture(0)
+, textures()
 , hsl_mod(0.0f, 1.0f, 1.0f)
 , rgb_mod(1.0f, 1.0f, 1.0f)
 , outline_color(-1, -1, -1)
        const glm::mat4 &transform,
        EntityMesh::Index idx_offset
 ) const noexcept {
-       shape->Vertices(buf, transform, texture, idx_offset);
+       if (textures.empty()) {
+               shape->Vertices(buf, transform, 0.0f, idx_offset);
+       } else {
+               shape->Vertices(buf, transform, textures[0], idx_offset);
+       }
        buf.hsl_mods.insert(buf.hsl_mods.end(), shape->VertexCount(), hsl_mod);
        buf.rgb_mods.insert(buf.rgb_mods.end(), shape->VertexCount(), rgb_mod);
 }
        const glm::mat4 &transform,
        BlockMesh::Index idx_offset
 ) const noexcept {
-       shape->Vertices(buf, transform, texture, idx_offset);
+       if (textures.empty()) {
+               shape->Vertices(buf, transform, 0.0f, idx_offset);
+       } else {
+               shape->Vertices(buf, transform, textures[0], idx_offset);
+       }
        buf.hsl_mods.insert(buf.hsl_mods.end(), shape->VertexCount(), hsl_mod);
        buf.rgb_mods.insert(buf.rgb_mods.end(), shape->VertexCount(), rgb_mod);
 }