#61 Basic canvas rendering is now working

This commit is contained in:
Danielv123 committed 2017-12-11 17:44:11 +01:00
1 parent eba982836c
commit 51c644203e
4 files changed
+48 -12

No files matched your search

+3 -3
View File
@@ -15,9 +15,9 @@ module.exports = class chunkStore {
}
setEntity(x/**{number}*/, y/**{number}*/, newEntity/**{object}*/){
return new Promise((resolve, reject) => {
var localX = Math.round(x % this.chunkSize);
var localX = x > 0 ? Math.round(x % this.chunkSize) : Math.round(x % this.chunkSize)-64;
x = Math.floor(Math.round(x)/this.chunkSize);
var localY = Math.round(y % this.chunkSize);
var localY = y > 0 ? Math.round(y % this.chunkSize) : Math.round(x % this.chunkSize)-64;
y = Math.floor(Math.round(y)/this.chunkSize);
this.getChunk(x,y).then(chunk => {
@@ -43,7 +43,7 @@ module.exports = class chunkStore {
setChunk(x, y, chunk){
return new Promise((resolve, reject) => {
mkdirp(this.path+this.name+"/"+x).then(() => {
fs.writeFile(this.path+this.name+"/"+x+"/"+y, JSON.stringify(chunk), function(err){
fs.writeFile(this.path+this.name+"/"+x+"/"+y, JSON.stringify(chunk, null, 4), function(err){
if(err) {
reject(err);
} else resolve();