This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed stuff, added model support for items, and added Gui feature
- Loading branch information
Minimine
committed
Apr 28, 2018
1 parent
0403566
commit 4d82458
Showing
11 changed files
with
137 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
package-lock.json | ||
*.bat | ||
test.json |
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 was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,73 @@ | ||
/* | ||
* | ||
* Minetem compiler | ||
* Repository: github.com/MinimineLP/Minetem | ||
* Licensed under MIT, see LICENSE od LICENSE.md file | ||
* Copyright (c) Minimine 2018 | ||
* | ||
*/ | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const data = require("./data.js"); | ||
const util = require("./util.js"); | ||
|
||
module.exports = { | ||
compile: compile | ||
} | ||
|
||
function compile(json, dir) { | ||
|
||
if(json.guis) { | ||
json.guis.forEach(function(value) { | ||
|
||
if(!value.id)console.throwException("CompilingError: Need id for every block"); | ||
if(!Number.isInteger(value.id))console.throwException("CompilingError: The id must be a positive number between 1 and 1562"); | ||
if(parseInt(value.id)<1 || parseInt(value.id)>1562)console.throwException("CompilingError: The id must be a positive number between 1 and 1562"); | ||
|
||
if(value.id in data.ids.diamond_shovel) console.throwException("CompilingError: Can't use that id, please try another, it is propably used for another texture."); | ||
|
||
if(!value.texture)console.throwException("CompilingError: Can't create a gui without a texture"); | ||
|
||
|
||
var json = util.textureFileLayout.gui | ||
.replaceAll('%path%', value.texture) | ||
.replaceAll('\n', '') | ||
.replaceAll(' ', '') | ||
.replaceAll(' ',''); | ||
|
||
|
||
var path = dir+`\\assets\\minecraft\\models\\custom\\diamond_shovel\\${value.id}.json`; | ||
writeFile(path, json); | ||
|
||
// DEBUG: | ||
console.debug(`Compiled gui with id ${value.id} into file `+fixBackslash(path)); | ||
|
||
data.ids.diamond_shovel.push(value.id); | ||
}); | ||
} | ||
} | ||
|
||
function fixBackslash(str) { | ||
return str.replaceAll('\\\\', '/') | ||
} | ||
|
||
function writeFile(file, content) { | ||
if(fs.existsSync(file)) console.throwException("CompilingError: Can't use that id, please try another, it is propably used for another texture."); | ||
|
||
file = file.replaceAll("\\\\", "/"); | ||
|
||
var parts = file.split("/"); | ||
for(var i=1;i<parts.length;i++){ | ||
|
||
var path = ""; | ||
|
||
for(var c=0;c<i;c++) | ||
path += parts[c]+"/"; | ||
|
||
if(!fs.existsSync(path))fs.mkdirSync(path); | ||
|
||
} | ||
|
||
fs.writeFileSync(file, content); | ||
} |
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