Substrate is a .NET/Mono SDK written in C# for reading, writing, and manipulating data in Minecraft worlds. Substrate isolates the different levels of map data such as blocks, chunks, and regions, and natively supports modifying Alpha and Beta worlds using the same block and chunk interfaces. Substrate also provides interfaces for other data such as Entities, players, and general level data.
--- Requirements
Substrate requires .NET Framework 2.0 or higher, or Mono, to run. Compiling Substrate source code requires a compiler that supports C# 3.0 or higher (Visual C# 2008 Express or higher, or comparable Linux tools).
For convenience to developers, Substrate ships with separate .NET-2.0 and .NET-4.0 assemblies, so that you can include the assembly that best matches your application's target framework.
--- Download
The latest version of Substrate can be found on the project download page: http://code.google.c.../substrate-mine ... loads/list
If you are interested in the development of Substrate, follow or fork the project on the Github Project Page
--- Additional Information
See the Introduction wiki page for more information on important classes provided by Substrate: Introduction
Largely complete API documentation is included with the Substrate download. A number of example projects are also included in the download, and available in the source tree.
Substrate is provided under the permissive MIT license. If you find this project useful in your software, consider mentioning it in the credits or about box of your application, but this is not required.
Of course, any feedback, ideas, bug reports, etc. are welcome either in this thread, or on the project page.
--- Examples
using System;
using Substrate;
// This example replaces all instances of one block ID with another in a world.
// Substrate will handle all of the lower-level headaches that can pop up, such
// as maintaining correct lighting or replacing TileEntity records for blocks
// that need them.
// For a more advanced Block Replace example, see replace.cs in NBToolkit.
namespace BlockReplace
{
class Program
{
static void Main (string[] args)
{
if (args.Length != 3) {
Console.WriteLine("Usage: BlockReplace &--#60;world&--#62; &--#60;before-id&--#62; &--#60;after-id&--#62;");
return;
}
string dest = args[0];
int before = Convert.ToInt32(args[1]);
int after = Convert.ToInt32(args[2]);
// Open our world
BetaWorld world = BetaWorld.Open(dest);
// The chunk manager is more efficient than the block manager for
// this purpose, since we'll inspect every block
BetaChunkManager cm = world.GetChunkManager();
foreach (ChunkRef chunk in cm) {
// You could hardcode your dimensions, but maybe some day they
// won't always be 16. Also the CLR is a bit stupid and has
// trouble optimizing repeated calls to Chunk.Blocks.xx, so we
// cache them in locals
int xdim = chunk.Blocks.XDim;
int ydim = chunk.Blocks.YDim;
int zdim = chunk.Blocks.ZDim;
// x, z, y is the most efficient order to scan blocks (not that
// you should care about internal detail)
for (int x = 0; x &--#60; xdim; x++) {
for (int z = 0; z &--#60; zdim; z++) {
for (int y = 0; y &--#60; ydim; y++) {
// Replace the block with after if it matches before
if (chunk.Blocks.GetID(x, y, z) == before) {
chunk.Blocks.SetData(x, y, z, 0);
chunk.Blocks.SetID(x, y, z, after);
}
}
}
}
// Save the chunk
cm.Save();
}
}
}
}
--- Projects Using Substrate
- NBTExplorer - A graphical NBT data editor.
- MACE - Random cities generator.
- Teeth of Time - Simulates effects of weather and time on worlds.
- Eedit - A simple graphical editor for item enchantments.
- Avanti! - A Paint-like Minecraft world editor.
- SeeSharp - A Minecraft map exporter / renderer.
If you've published a tool using Substrate and would like it listed, post your request.
--- Update History
[1.3.7]
- Fix: Wrong tag name for additional block IDs ("AddBlocks" instead of "Add")
- Fix: Anvil worlds can now handle block IDs >255
- Fix: Empty chunk sections below heightmap were not written
- Fix: NBT Tree discarding root node name on load
- Fix: Various Entity and TileEntity issues
- Raw NBT tree exposed on more objects (Entities, TileEntities, Items...)
- Generic TileEntity objects will be created if specific types are unknown
- Region files multithread safe
- MobSpawnerTileEntities have updated data fields
[1.3.6]
- Fix: Bug in index calculations of Anvil composite byte/nibble arrays, causing incorrect block updates.
- Block updates for Minecraft 1.4.
[1.3.5]
- Minor changes to RegionFile to make it easier to extend (e.g. for Cubic Chunks). (not released)
[1.3.4]
- Fix: Bug in unicode handling of NBT strings which could result in inconsistent NBT binaries being written.
[1.3.3]
- Fix: Bug in player loading that could cause Anvil 1.2 worlds to not load. Was introduced in 1.3.2.
[1.3.2]
- Fix: ChunkManager.SetChunk did not set chunks at the requested location correctly.
- Fix: ResetLava in BlockFluid could possibly convert lava blocks into water.
- Fix: BlockManager could not set blocks above 127. BlockManager is now abstract and split into two concrete classes for Alpha and Anvil.
- Block, item, and player data updates for Minecraft 1.3.
[1.3.1]
- Fixes bug in chunk creation causing the Z coordinate to be used for both X and Z.
[1.3.0]
- Unified Anvil map support
- Multiple breaking changes for Anvil support
- Block and item updates through Minecraft 1.2
[1.2.0]
- Anvil beta (not officially released)
[1.1.0]
- Adds TileTick management throughout most of the API
- AutoTileTick property in AlphaBlockCollection for automatically managing TileTicks.
[1.0.3]
- Fixes a bug where clearing the player spawn would have no effect
- Fixes a bug where deleting a chunk would correctly update the cache, resulting in lost work
[1.0.2]
- Fixes a bug reading items with enchantments
- Fixes a bug enumerating entities not registered with EntityFactory
- Fixes a bug setting text on sign TileEntities
- Exposes more direct access to the Chunk cache
[1.0.1]
- Fixes a serious bug where entities were written out with invalid data, causing chunk regeneration
- Several block data enums where updated with fixes
- Animal entity types are now subclasses of EntityAnimal
[1.0.0]
- Ionic.Zlib integrated into the Substrate assembly
- Project split into .NET2/.NET4 output
- Added full Enchantment API for items
- Player and Mob classes updated with additional data
- Entity/TileEntity registires are enumerable
- ChangeValueType added to TagNodeList class
[0.9.0]
- Data resource / map (item) editing
- Conversion utilities for map editing
- NbtFile updated to handle differing compression requirements
[0.8.4]
- Fixes TileEntity data not being copied with chunks
- Unknown/Nonstandard NBT tags are now round-tripped in most objects
[0.8.3]
- Fixes painting entities not being updated correctly when their chunk is relocated
- Entities and TileEntities support MoveBy method for special relocation handling
[0.8.2]
- Fixes a bug where Entity/TileEntity coordinates were not updated with chunk
[0.8.1]
- Fixes a bug where chunk modified chunk coordinates are not saved
[0.8.0]
- 1.9pre5 block, item, and entity types
- Fixed several bugs in Entities, including an exception caused by Enderman
- Entity/TileEntity architecture updated to support inheritance, avoid future bugs
- Optional cache size parameter in OpenWorld/CreateWorld
[0.7.3]
- Fixed crash when encountering XPOrb while enumerating entities
[0.7.2]
- 1.8 Entity types
- Added missing properties to Arrow and all Mob entities
- Fixed lighting bug with Chest blocks
[0.7.1]
- 1.8 Block and Item types
[0.7.0]
- Major refactoring. You will need to tweak your projects
- CHM documentation for most of the common APIs
- Intellisense XML file for the same
- 1.7 Block and Item types
- Schematic import and export support
- CLS Compliance
- Enumerable PlayerManager
- Timestamp data exposed
- NBT Validator event support
- Numerous bugfixes including cache and TileEntity bugs
[0.6.2]
- Fixes bugs with some entities and tile entities
[0.6.1]
- Fixes bug with TileEntity updates
[0.6.0]
- Added fluid simulation for water and lava
- AutoFluid property (disabled by default)
[0.5.3]
- Fixes performance regression
- Fixes additional lighting bugs
[0.5.2]
- Lighting bugfixes and performance improvements
- TileEntity fixes
- Beta 1.6 block and item types
- 'State' property to BlockInfo (solid/nonsolid/fluid)
- Chunk copying / setting
- ItemInfo classes and supporting data enums
- Re-exposed the PlayerManager
- All missing examples added
[0.5.1]
- Numerous lighting fixes including possible crashing bug
- Added Beta 1.5 level attributes
[0.5.0]
- Major refactoring of Chunk/ChunkRef breaks compatibility, but should be easy to repair
- Fixes missing Player attributes and bug in level.dat generation
- Fixes more lighting bugs. Now correctly lights half steps, stairs, and other special blocks
- Updated chunk caching back-end
[0.4.1]
- Lighting fixes for manual chunk relighting
- Performance fixes for lighting
[0.4.0]
- Fixes cache consistency bug, among others
- Adds manual chunk relighting
- Example code
[0.3.0]
- Adds automatic blocklight and skylight recalculation for all setblockid operations via ChunkRefs or the BlockManager.
[0.2.1]
- Fixes serious bug in creating TileEntity or Entity objects.
[0.2.0]
- First public release











