-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian Fechner
authored and
Florian Fechner
committed
Feb 25, 2018
1 parent
6d780ca
commit adbd57a
Showing
13 changed files
with
279 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ | |
body | ||
{ | ||
height: 100%; | ||
|
||
padding: 0; | ||
margin: 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
function parseSchematicFile(fileName, onCalculationFinished) | ||
{ | ||
let nbt = require('nbt'); | ||
|
||
let data = fs.readFileSync(fileName); | ||
|
||
let schematic = {}; | ||
|
||
nbt.parse(data, (error, data) => | ||
{ | ||
if (error) { throw error; } | ||
|
||
let width = data.value.Width.value; | ||
let height = data.value.Height.value; | ||
let length = data.value.Length.value; | ||
|
||
let dimension = Math.max(width, height, length); | ||
|
||
let blockIds = data.value.Blocks.value; | ||
let metaData = data.value.Data.value; | ||
|
||
let blocks = new Array(dimension * dimension * dimension).fill({ id: 0, metaData: 0 }); | ||
|
||
for(let x=0; x<width; x++) | ||
{ | ||
for(let y=0; y<height; y++) | ||
{ | ||
for(let z=0; z<length; z++) | ||
{ | ||
let blockId = blockIds[x + y * length * width + z * width]; | ||
let blockMetaData = metaData[x + y * length * width + z * width]; | ||
|
||
blocks[x + y * dimension + z * dimension * dimension] = { id: charToUnsignedChar(blockId), metaData: blockMetaData }; | ||
} | ||
} | ||
} | ||
|
||
let schematic = { width: dimension, height: dimension, depth: dimension, blocks : blocks }; | ||
|
||
onCalculationFinished(schematic); | ||
}); | ||
|
||
return schematic; | ||
} | ||
|
||
function charToUnsignedChar(char) | ||
{ | ||
if(char > 0) return char; | ||
return (256 + char); | ||
} | ||
|
||
module.exports = parseSchematicFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
let alternate = false; | ||
|
||
function uploadTexturePack(filePath, callback) | ||
{ | ||
const fs = require('fs'); | ||
const app = require('electron').app; | ||
const path = require("path"); | ||
const unzip = require("unzip"); | ||
|
||
const applicationPath = path.join('../../package.json'); | ||
const applicationName = require(applicationPath).name; | ||
const appDataPath = app.getPath("appData"); | ||
const fileStoragePath = path.join(appDataPath, applicationName); | ||
|
||
const texturePackPath = path.join(fileStoragePath, "texture-pack", path.basename(filePath, '.zip')); | ||
|
||
|
||
alternate = !alternate; | ||
|
||
fs.createReadStream(filePath) | ||
.pipe( | ||
unzip.Extract({ path: texturePackPath }) | ||
.on('close', () => | ||
{ | ||
callback(texturePackPath); | ||
}) | ||
); | ||
} | ||
|
||
module.exports = uploadTexturePack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.