Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
Export, and gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Luminoso-256 committed Jan 18, 2021
1 parent 4a2e6a6 commit d1b5993
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/bin/
/obj/
/.vs/
23 changes: 18 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ static void Main(string[] args)

Console.WriteLine("Minecraft Earth Buildplate File Format Editor \n Version " + version + "\n Enter path to input file:");
// String targetFilePath = Console.ReadLine();
String targetFilePath = @"C:\Workspace\Programming\c#\EarthBuildplateEditor\plates\test.plate";
String targetFilePath = @"C:\Workspace\Programming\c#\EarthBuildplateEditor\plates\test_c.plate";
if (!File.Exists(targetFilePath))
{
Console.WriteLine("Error: File does not exist");
return;
}
String fileData = File.ReadAllText(targetFilePath);
String fileName = targetFilePath.Split(@"\")[targetFilePath.Split(@"\").Length - 1]; //get the filename with .plate
int fileRev = 1; //used for saving so we dont save over a prior rev. useful when preparing multiple tests.
fileName = fileName.Split(".")[0]; //remove the .plate
//Deserialize
Buildplate plate = JsonConvert.DeserializeObject<Buildplate>(fileData);
Console.WriteLine("Version: " + plate.format_version + " Subchunk Count: " + plate.sub_chunks.Count + " Entity Count: " + plate.entities.Count);
Expand All @@ -48,7 +51,7 @@ static void Main(string[] args)

//Render Data
List<Texture2D> textures = new List<Texture2D> { };
Dictionary<int, int> airVals = new Dictionary<int, int>();
Dictionary<int, int> chunkAirValues = new Dictionary<int, int>();
Dictionary<int, int> chunkTextureOffsets = new Dictionary<int, int>();

//editor data
Expand Down Expand Up @@ -81,7 +84,7 @@ static void Main(string[] args)
}
else
{
airVals.Add(subchunk, paletteIndex);
chunkAirValues.Add(subchunk, paletteIndex);
}
}
}
Expand Down Expand Up @@ -113,7 +116,7 @@ static void Main(string[] args)
if (x == 16) { x = 0; y += 1; }
if (y == 16) { y = 0; z += 1; }

if (plate.sub_chunks[currentSubchunk].blocks[currentBlock] != airVals[currentSubchunk])
if (plate.sub_chunks[currentSubchunk].blocks[currentBlock] != chunkAirValues[currentSubchunk])
{
int textureIndex = plate.sub_chunks[currentSubchunk].blocks[currentBlock]; //index

Expand All @@ -126,7 +129,8 @@ static void Main(string[] args)

DrawText("Current Subchunk: " + currentSubchunk, 10, 10, 10, BLACK);
DrawText("Left/Right arrow to change subchunk", 10, 30, 10, BLACK);
DrawText("Current air val: " + airVals[currentSubchunk], 10, 50, 10, BLACK);
DrawText("Current air val: " + chunkAirValues[currentSubchunk], 10, 50, 10, BLACK);
DrawText("Press E to export to plate64", 10, 80, 10, BLACK);

EndDrawing();

Expand All @@ -152,6 +156,15 @@ static void Main(string[] args)
currentSubchunk += 1;
if (currentSubchunk > maxSubChunk) { currentSubchunk = maxSubChunk; }
}
if (IsKeyPressed(KeyboardKey.KEY_E))
{

string exportPath = @"./exports/" + fileName + "_"+ fileRev+ ".plate64";
fileRev++;
string exportData = Util.Base64Encode(JsonConvert.SerializeObject(plate));
System.IO.Directory.CreateDirectory("./exports/");
System.IO.File.WriteAllText(exportPath, exportData);
}

}
CloseWindow();
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
EarthBuildplateEditor
## Earth Buildplate Editor
*A simple tool to edit Minecraft Earth's buildplate format.

Currently very early, and much spagetti code

### Notes
- To get the resources, youl need to get your hands on a copy of Minecraft Earth's resouce pack and make some modifications. Copyright prohibits distribution.
- .plate is the unencrypted json of the Minecraft Earth tile format. .plate64 is this data with base64 encryption, as this is what the Minecraft Earth server uses
20 changes: 20 additions & 0 deletions Util.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace EarthBuildplateEditor
{
class Util
{
public static string Base64Encode(string normal)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(normal);
return System.Convert.ToBase64String(plainTextBytes);
}
public static string Base64Decode(string base64)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
}
}

0 comments on commit d1b5993

Please sign in to comment.