Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

paul-eff/jMCX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jMCX v1.0.0

Version Minecraft Java License

A modern Java library for reading, editing, and writing Minecraft Anvil region files

✨ Features

jMCX provides a comprehensive solution for Minecraft world file manipulation with clean, efficient APIs:

  • 🎯 Complete Anvil Region Format Support - Read, edit, and write .mca region files
  • 🛠️ Fluent Builder API - Modern builder pattern for easy structure creation
  • 📦 Smart Compression - Automatic detection and support for GZIP, ZLIB, and uncompressed files
  • 🔧 Interface-Based Design - Clean APIs
  • Type Safety - Minimal casting

🚀 Quick Start

Read region file:

AnvilReader reader = new AnvilReader();
Region region = reader.readRegion(new File("r.0.0.mca"));
List<Chunk> chunks = region.getChunks();

Edit chunk blocks:

Optional<IChunk> chunkOpt = region.getChunk(0, 0);
if (chunkOpt.isPresent()) {
    IChunk chunk = chunkOpt.get();
    ICompoundTag nbt = chunk.getNBTData();
    IListTag sections = nbt.getList("sections");
    
    // Replace dirt with diamond in block palette
    for (int i = 0; i < sections.size(); i++) {
        ICompoundTag section = (ICompoundTag) sections.get(i);
        ICompoundTag blockStates = section.getCompound("block_states");
        IListTag palette = blockStates.getList("palette");
        
        for (int j = 0; j < palette.size(); j++) {
            ICompoundTag block = (ICompoundTag) palette.get(j);
            if ("minecraft:dirt".equals(block.getString("Name"))) {
                block.setString("Name", "minecraft:diamond_block");
            }
        }
    }
}

Copy chunk data:

Optional<IChunk> targetChunk = region.getChunk(1, 1);
if (targetChunk.isPresent()) {
    targetChunk.get().setNBTData(chunk.getNBTData());
}

Write modified region:

AnvilWriter writer = new AnvilWriter();
writer.writeRegion(region, new File("r.0.0-updated.mca"));

Find chunks with entities:

List<Chunk> ownableChunks = region.getChunksWithOwnables();
for (Chunk chunk : ownableChunks) {
    System.out.println("Chunk at " + chunk.getChunkX() + ", " + chunk.getChunkZ());
}

📋 Status

✅ Supported

  • Complete CRUD operations (Create, Read, Update, Delete)
  • Compression formats: GZIP, ZLIB, None
  • Chunk Management: Coordinate extraction, payload handling, ...
  • Many convenience methods (chunkHasOwnableEntities, getChunkByCoordinates, etc.)

🔮 Future Plans

  • Enhanced editing operations
  • LZ4 compression support
  • Bedrock Region format support
  • McRegion (Alpha) Level format support
  • Graphical interface (maybe!)

📖 Documentation

Explore the examples/ folder for comprehensive usage patterns.

📦 Building

mvn clean package

⚠️ Important Notice

Always backup your world files before modification. While thoroughly tested, data corruption is always possible with world file manipulation tools.

🔗 Related Projects

This library will be used by:

Built with:

  • jNBT - NBT file manipulation

📚 References

Remark

Minecraft is a registered trademark of Mojang AB.

About

A modern Java library for reading, editing, and writing Minecraft Anvil region files

Topics

Resources

License

Stars

Watchers

Forks

Languages