let self = this;
this.resultfield.action = out => {
out.add(self.resultfield) && self.reduce();
- }
+ };
this.addEventListener("updateStack", _ => {
- self.update();
+ self.updateResult();
});
}
return super.calculateWidth() + dragonblocks.settings.inventory.scale * 1.1 * 2;
}
- draw(parent, x, y)
- {
- if (! super.draw(parent, x, y))
- return false;
-
- this.resultfield.draw(this.getDisplay(), dragonblocks.settings.inventory.scale * 0.1 + (this.width + 1) * dragonblocks.settings.inventory.scale * 1.1, dragonblocks.settings.inventory.scale * 0.1 + (this.height / 2 - 0.5) * dragonblocks.settings.inventory.scale * 1.1);
- }
-
reduce()
{
- for (let stack of this.list) {
- let vstack = new dragonblocks.ItemStack();
- vstack.addOne(stack);
- }
- this.update();
+ for (let stack of this.list)
+ new dragonblocks.ItemStack().addOne(stack);
}
- update()
+ updateResult()
{
this.resultfield.deserialize("");
return this.resultfield.deserialize(recipe.result);
}
}
+
+ initGraphics()
+ {
+ super.initGraphics();
+
+ this.resultfield.draw(this.display, dragonblocks.settings.inventory.scale * 0.1 + (this.width + 1) * dragonblocks.settings.inventory.scale * 1.1, dragonblocks.settings.inventory.scale * 0.1 + (this.height / 2 - 0.5) * dragonblocks.settings.inventory.scale * 1.1);
+ }
};
for (let i = 0; i < this.slots; i++) {
let stack = this.list[i];
+
stack.addEventListener("update", event => {
if (event.stack.refilling)
return;
return super.calculateHeight() + dragonblocks.settings.inventory.scale;
}
- draw(parent, x, y)
+ update()
+ {
+ if (this.page == -1)
+ this.page++;
+
+ if (this.page == this.pages)
+ this.page--;
+
+ this.pageDisplay.textContent = "Page " + (this.page + 1) + " of " + this.pages;
+
+ for (let slot of this.list)
+ slot.update();
+ }
+
+ initGraphics()
{
- if (! super.draw(parent, x, y))
- return false;
-
- let display = this.getDisplay();
- display.style.height = this.calculateHeight();
-
- let creativeDisplay = display.appendChild(document.createElement("div"));
- creativeDisplay.id = "dragonblocks.inventory[" + this.id + "].creative";
- creativeDisplay.style.height = dragonblocks.settings.inventory.scale + "px";
- creativeDisplay.style.width = this.calculateWidth() + "px";
- creativeDisplay.style.left = "0px";
- creativeDisplay.style.top = super.calculateHeight() + "px";
- creativeDisplay.style.position = "absolute";
-
- let pageDisplay = creativeDisplay.appendChild(document.createElement("span"));
- pageDisplay.id = "dragonblocks.inventory[" + this.id + "].creative.page";
- pageDisplay.style.color = "#343434";
- pageDisplay.style.position = "absolute";
- pageDisplay.style.left = dragonblocks.settings.inventory.scale * 1.1 + "px";
- pageDisplay.style.width = "100%";
- pageDisplay.style.fontSize = dragonblocks.settings.inventory.scale / (5 / 3) + "px";
- pageDisplay.style.height = dragonblocks.settings.inventory.scale / (5 / 3) + "px";
-
- dblib.centerVertical(pageDisplay);
+ super.initGraphics();
+
+ let pageContainer = this.display.appendChild(document.createElement("div"));
+ pageContainer.style.height = dragonblocks.settings.inventory.scale + "px";
+ pageContainer.style.width = this.calculateWidth() + "px";
+ pageContainer.style.left = "0px";
+ pageContainer.style.top = super.calculateHeight() + "px";
+ pageContainer.style.position = "absolute";
+
+ this.pageDisplay = pageContainer.appendChild(document.createElement("span"));
+ this.pageDisplay.style.color = "#343434";
+ this.pageDisplay.style.position = "absolute";
+ this.pageDisplay.style.left = dragonblocks.settings.inventory.scale * 1.1 + "px";
+ this.pageDisplay.style.width = "100%";
+ this.pageDisplay.style.fontSize = dragonblocks.settings.inventory.scale / (5 / 3) + "px";
+ this.pageDisplay.style.height = dragonblocks.settings.inventory.scale / (5 / 3) + "px";
+
+ dblib.centerVertical(this.pageDisplay);
let self = this;
for (let dir of ["left", "right"]) {
- let arrow = creativeDisplay.appendChild(document.createElement("div"));
- arrow.id = "dragonblocks.inventory[" + this.id + "].creative.arrow." + dir;
+ let arrow = pageContainer.appendChild(document.createElement("div"));
arrow.style.position = "absolute";
arrow.style.width = dragonblocks.settings.inventory.scale + "px";
arrow.style.height = dragonblocks.settings.inventory.scale + "px";
arrow.style.transform = "rotate(180deg)";
arrow.addEventListener("click", _ => {
- if(dir == "right")
+ if (dir == "right")
self.page++;
else
self.page--;
+
self.update();
});
dblib.centerVertical(arrow);
}
-
- this.update();
- }
-
- update()
- {
- if (this.page == -1)
- this.page++;
-
- if (this.page == this.pages)
- this.page--;
-
- document.getElementById("dragonblocks.inventory[" + this.id + "].creative.page").textContent = "Page " + (this.page + 1) + " of " + this.pages;
-
- for (let slot of this.list)
- slot.update();
}
};
constructor(slots, columns)
{
super();
- this.id = dragonblocks.getToken();
this.slots = slots;
this.columns = columns;
draw(parent, x, y)
{
- if (this.display) {
- let display = this.getDisplay();
- if (display.parentElement == parent) {
- display.style.left = x + "px";
- display.style.top = y + "px";
- return false;
- } else {
- this.remove();
- }
- }
-
- this.display = true;
-
- let display = parent.appendChild(document.createElement("div"));
- display.id = "dragonblocks.inventory[" + this.id + "]";
- display.style.position = "absolute";
- display.style.left = x + "px";
- display.style.top = y + "px";
- display.style.width = this.calculateWidth() + "px";
- display.style.height = this.calculateHeight() + "px";
-
- let scale = dragonblocks.settings.inventory.scale * 1.1;
- let offset = dragonblocks.settings.inventory.scale * 0.1;
+ if (! this.display)
+ this.initGraphics();
- for (let i in this.list) {
- let x = i % this.columns;
- let y = (i - x) / this.columns;
- this.list[i].draw(display, offset + x * scale, offset + y * scale);
- }
-
- return true;
- }
+ if (this.display.parentElement != parent)
+ this.display = parent.appendChild(this.display);
- remove()
- {
- this.getDisplay().remove();
- this.display = false;
- }
+ this.display.style.left = x + "px";
+ this.display.style.top = y + "px";
- show()
- {
- this.getDisplay().style.visibility = "inherit";
this.update();
}
- hide()
+ remove()
{
- this.getDisplay().style.visibility = "hidden";
+ this.display.remove();
}
update()
return this.list[i];
}
- getDisplay()
+ initGraphics()
{
- return document.getElementById("dragonblocks.inventory[" + this.id + "]");
+ this.display = document.createElement("div");
+ this.display.style.position = "absolute";
+ this.display.style.width = this.calculateWidth() + "px";
+ this.display.style.height = this.calculateHeight() + "px";
+
+ let scale = dragonblocks.settings.inventory.scale * 1.1;
+ let offset = dragonblocks.settings.inventory.scale * 0.1;
+
+ for (let i in this.list) {
+ let x = i % this.columns;
+ let y = (i - x) / this.columns;
+ this.list[i].draw(this.display, offset + x * scale, offset + y * scale);
+ }
}
};
draw(parent, x, y)
{
- if (this.display) {
- let display = this.getDisplay();
- if (display.parentElement == parent) {
- display.style.left = x + "px";
- display.style.top = y + "px";
- return false;
- } else {
- this.remove();
- }
- }
+ if (! this.display)
+ this.initGraphics();
- let display = parent.appendChild(document.createElement("div"));
- display.id = "dragonblocks.inventoryContainer[" + this.inventory.id + "]";
- display.style.width = this.calculateWidth() + "px";
- display.style.height = this.calculateHeight() + "px";
- display.style.left = x + "px";
- display.style.top = y + "px";
+ if (this.display.parentElement != parent)
+ this.display = parent.appendChild(this.display);
- this.inventory.draw(display, dragonblocks.settings.inventory.scale * 1.1 * this.left, dragonblocks.settings.inventory.scale * 1.1 * this.top);
+ this.display.style.left = x + "px";
+ this.display.style.top = y + "px";
- this.display = true;
- return true;
- }
-
- serialize()
- {
- return this.inventory.serialize();
- }
-
- deserialize(str)
- {
- this.inventory.deserialize(str);
+ this.inventory.draw(this.display, dragonblocks.settings.inventory.scale * 1.1 * this.left, dragonblocks.settings.inventory.scale * 1.1 * this.top);
}
remove()
{
- this.getDisplay().remove();
- }
-
- show()
- {
- this.getDisplay().style.visibility = "inherit";
- this.update();
- }
-
- hide()
- {
- this.getDisplay().style.visibility = "hidden";
+ this.display.remove();
}
calculateWidth()
return this.inventory.calculateHeight() + dragonblocks.settings.inventory.scale * 1.1 * (this.top + this.bottom);
}
- getDisplay()
- {
- return document.getElementById("dragonblocks.inventoryContainer[" + this.inventory.id + "]");
- }
-
- update()
+ initGraphics()
{
- this.inventory.update();
+ this.display = document.createElement("div");
+ this.display.style.width = this.calculateWidth() + "px";
+ this.display.style.height = this.calculateHeight() + "px";
}
};
{
constructor()
{
- this.id = dragonblocks.getToken();
-
- this._elements = [];
+ this.elements = [];
this.opened = false;
- let display = dragonblocks.addInventoryMenuDisplay(document.createElement("div"));
- display.id = "dragonblocks.inventoryGroup[" + this.id + "]";
- display.style.position = "fixed";
- display.style.backgroundColor = "#535353";
- display.style.visibility = "hidden";
+ this.display = dragonblocks.addInventoryMenuDisplay(document.createElement("div"));
+ this.display.style.position = "fixed";
+ this.display.style.backgroundColor = "#535353";
+ this.display.style.visibility = "hidden";
}
close()
{
this.opened = false;
- document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]").style.visibility = "hidden";
- dragonblocks.outStack.getDisplay().style.visibility = "hidden";
-
- if(this.onNextClose)
- this.onNextClose();
+ this.display.style.visibility = "hidden";
+ dragonblocks.outStack.display.style.visibility = "hidden";
- this.onNextClose = null;
+ this.onNextClose = this.onNextClose && this.onNextClose();
}
open()
{
this.opened = true;
- document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]").style.visibility = "inherit";
- dragonblocks.outStack.getDisplay().style.visibility = "visible";
+ this.display.style.visibility = "inherit";
+ dragonblocks.outStack.display.style.visibility = "visible";
+
+ this.update();
}
toggle()
this.opened ? this.close() : this.open();
}
- set elements(elements)
+ update()
{
- for (let element of this.elements)
- element.hide();
-
- this._elements = elements;
-
- let container = document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]");
-
let height = 0;
let width = 0;
for (let element of this.elements) {
- element.draw(container, 0, height);
+ element.draw(this.display, 0, height);
height += element.calculateHeight();
width = Math.max(width, element.calculateWidth());
- element.show();
}
- container.style.width = width + "px";
- container.style.height = height + "px";
+ this.display.style.width = width + "px";
+ this.display.style.height = height + "px";
- dblib.center(container);
- dblib.centerVertical(container);
+ dblib.center(this.display);
+ dblib.centerVertical(this.display);
}
- get elements()
+ setElements(elements)
{
- return this._elements;
+ for (let element of this.elements)
+ element.remove();
+
+ this.elements = elements;
+
+ this.update();
}
};
this.count = 0;
this.item = null;
- this.id = dragonblocks.getToken();
if (itemstring)
this.deserialize(itemstring);
return this.addItems(itemstack, Math.ceil(itemstack.count / 2));
}
- getDisplay()
- {
- return document.getElementById("dragonblocks.itemstack[" + this.id + "]");
- }
-
draw(parent, x, y)
{
- let display = parent.appendChild(document.createElement("div"));
- display.id = "dragonblocks.itemstack[" + this.id + "]";
- display.stackid = this.id;
- display.style.borderStyle = "solid";
- display.style.borderWidth = "1px";
- display.style.borderColor = "#2D2D2D";
- display.style.width = dragonblocks.settings.inventory.scale + "px";
- display.style.height = dragonblocks.settings.inventory.scale + "px";
- display.style.backgroundColor = "#343434";
- display.style.position = "absolute";
- display.style.left = x + "px";
- display.style.top = y + "px";
-
- let countDisplay = display.appendChild(document.createElement("span"));
- countDisplay.id = "dragonblocks.itemstack[" + this.id + "].count";
- countDisplay.stackid = this.id;
- countDisplay.style.position = "absolute";
- countDisplay.style.right = "5px";
- countDisplay.style.bottom = "5px";
- countDisplay.style.color = "white";
- countDisplay.style.cursor = "default";
+ this.display = parent.appendChild(document.createElement("div"));
+ this.display.style.borderStyle = "solid";
+ this.display.style.borderWidth = "1px";
+ this.display.style.borderColor = "#2D2D2D";
+ this.display.style.width = dragonblocks.settings.inventory.scale + "px";
+ this.display.style.height = dragonblocks.settings.inventory.scale + "px";
+ this.display.style.backgroundColor = "#343434";
+ this.display.style.position = "absolute";
+ this.display.style.left = x + "px";
+ this.display.style.top = y + "px";
+
+ this.countDisplay = this.display.appendChild(document.createElement("span"));
+ this.countDisplay.style.position = "absolute";
+ this.countDisplay.style.right = "5px";
+ this.countDisplay.style.bottom = "5px";
+ this.countDisplay.style.color = "white";
+ this.countDisplay.style.cursor = "default";
let self = this;
- display.addEventListener("mousedown", event => {
+ this.display.addEventListener("mousedown", event => {
let out = dragonblocks.outStack;
if (self.action)
}
});
- display.addEventListener("mouseover", event => {
+ this.display.addEventListener("mouseover", event => {
self.focused = true;
self.redraw();
});
- display.addEventListener("mouseleave", event => {
+ this.display.addEventListener("mouseleave", event => {
self.focused = false;
self.redraw();
});
redraw()
{
- let display = this.getDisplay();
-
- if (! display)
+ if (! this.display)
return;
- let countDisplay = document.getElementById("dragonblocks.itemstack[" + this.id + "].count");
-
if (this.item) {
let item = this.toItem();
- display.title = item.desc;
- display.style.background = dragonblocks.getTexture(item.texture);
+ this.display.title = item.desc;
+ this.display.style.background = dragonblocks.getTexture(item.texture);
if (this.count > 1)
- countDisplay.innerHTML = this.count;
+ this.countDisplay.innerHTML = this.count;
else
- countDisplay.innerHTML = "";
+ this.countDisplay.innerHTML = "";
} else {
- display.title = "";
- display.style.background = "none";
+ this.display.title = "";
+ this.display.style.background = "none";
- countDisplay.innerHTML = "";
+ this.countDisplay.innerHTML = "";
}
- display.style.backgroundColor = this.focused ? "#7E7E7E" : "#343434";
+ this.display.style.backgroundColor = this.focused ? "#7E7E7E" : "#343434";
this.trigger("redraw");
}
*/
dragonblocks.addInventoryMenuDisplay = elem => {
- return document.body.insertBefore(elem, dragonblocks.outStack.getDisplay());
+ return document.body.insertBefore(elem, dragonblocks.outStack.display);
};
setTimeout(_ => {
let out = dragonblocks.outStack = new dragonblocks.ItemStack();
out.draw(document.body, 0, 0);
- out.getDisplay().style.position = "fixed";
+ out.display.style.position = "fixed";
out.addEventListener("redraw", _ => {
- let display = out.getDisplay();
- display.style.backgroundColor = "";
- display.style.border = "none";
+ out.display.style.backgroundColor = "";
+ out.display.style.border = "none";
});
addEventListener("mousemove", event => {
- let display = out.getDisplay();
- display.style.left = event.clientX + 5 + "px";
- display.style.top = event.clientY + 5 + "px";
+ out.display.style.left = event.clientX + 5 + "px";
+ out.display.style.top = event.clientY + 5 + "px";
});
out.update();
setInventoryElements(elems)
{
- this.tmp.inventory.elements = elems;
+ this.tmp.inventory.setElements(elems);
}
resetInventoryElements()
{
- let elems = [this.tmp.mainInventory];
- elems.unshift(this.gamemode == "creative" ? this.tmp.creativeInventory : this.tmp.survivalInventory);
- this.setInventoryElements(elems);
+ this.setInventoryElements([this.gamemode == "creative" ? this.tmp.creativeInventory : this.tmp.survivalInventory, this.tmp.mainInventory]);
}
previousItem()
furnace.recipes = [];
-furnace.registerRecipe = function(obj){
- if(! obj || ! obj.input || ! obj.output || ! obj.time)
+
+furnace.registerRecipe = def => {
+ if (! def || ! def.input || ! def.output || ! def.time)
return;
- furnace.recipes.push(obj);
-}
+
+ furnace.recipes.push(def);
+};
furnace = {};
-$.getScript(dragonblocks.getModpath("furnace") + "/api.js");
-$.getScript(dragonblocks.getModpath("furnace") + "/inventory.js");
-$.getScript(dragonblocks.getModpath("furnace") + "/itemdef.js");
+
+let modpath = dragonblocks.getModpath("furnace");
+
+$.getScript(modpath + "/api.js");
+$.getScript(modpath + "/inventory.js");
+$.getScript(modpath + "/itemdef.js");
-furnace.Inventory = class extends dragonblocks.InventoryContainer{
- constructor(){
+furnace.Inventory = class extends dragonblocks.InventoryContainer
+{
+ constructor()
+ {
super({
inventory: new dragonblocks.Inventory(4, 2),
top: 1,
left: 4,
right: 2,
});
+
let self = this;
+
this.input = new dragonblocks.ItemStack();
this.input.addEventListener("update", _ => {
self.update();
});
+
this.fuel = new dragonblocks.ItemStack();
this.fuel.addEventListener("update", _ => {
self.update();
});
- this.burnProgressDisplay = new dragonblocks.ItemStack();
- this.burnProgressDisplay.deserialize("furnace:burn_progress_0");
- this.burnProgressDisplay.action = _ => {};
- this.burnProgressDisplay.addEventListener("redraw", _ => {
- dragonblocks.Inventory.getStackDisplay(self.burnProgressDisplay.id).style.backgroundColor = "";
- dragonblocks.Inventory.getStackDisplay(self.burnProgressDisplay.id).style.border = "none";
+
+ this.burnProgressStack = new dragonblocks.ItemStack();
+ this.burnProgressStack.deserialize("furnace:burn_progress_0");
+ this.burnProgressStack.action = _ => {};
+ this.burnProgressStack.addEventListener("redraw", event => {
+ event.stack.display.style.backgroundColor = "";
+ event.stack.display.style.border = "none";
});
- this.fuelProgressDisplay = new dragonblocks.ItemStack();
- this.fuelProgressDisplay.deserialize("furnace:fuel_progress_0");
- this.fuelProgressDisplay.action = _ => {};
- this.fuelProgressDisplay.addEventListener("redraw", _ => {
- dragonblocks.Inventory.getStackDisplay(self.fuelProgressDisplay.id).style.backgroundColor = "";
- dragonblocks.Inventory.getStackDisplay(self.fuelProgressDisplay.id).style.border = "none";
+
+ this.fuelProgressStack = new dragonblocks.ItemStack();
+ this.fuelProgressStack.deserialize("furnace:fuel_progress_0");
+ this.fuelProgressStack.action = _ => {};
+ this.fuelProgressStack.addEventListener("redraw", event => {
+ event.stack.display.style.backgroundColor = "";
+ event.stack.display.style.border = "none";
});
+
this.clear();
this.clearFuel();
+
this.update();
}
- draw(parent, x, y){
- if(! super.draw(parent, x, y))
- return false;
- this.input.draw(this.getDisplay(), 2 * dragonblocks.settings.inventory.scale * 1.1, 0.5 * dragonblocks.settings.inventory.scale * 1.1);
- this.burnProgressDisplay.draw(this.getDisplay(), 3 * dragonblocks.settings.inventory.scale * 1.1, 1.5 * dragonblocks.settings.inventory.scale * 1.1);
- this.fuelProgressDisplay.draw(this.getDisplay(), 2 * dragonblocks.settings.inventory.scale * 1.1, 1.5 * dragonblocks.settings.inventory.scale * 1.1);
- this.fuel.draw(this.getDisplay(), 2 * dragonblocks.settings.inventory.scale * 1.1, 2.5 * dragonblocks.settings.inventory.scale * 1.1);
- return true;
+
+ initGraphics()
+ {
+ super.initGraphics();
+
+ this.input.draw(this.display, 2 * dragonblocks.settings.inventory.scale * 1.1, 0.5 * dragonblocks.settings.inventory.scale * 1.1);
+ this.fuel.draw(this.display, 2 * dragonblocks.settings.inventory.scale * 1.1, 2.5 * dragonblocks.settings.inventory.scale * 1.1);
+ this.burnProgressStack.draw(this.display, 3 * dragonblocks.settings.inventory.scale * 1.1, 1.5 * dragonblocks.settings.inventory.scale * 1.1);
+ this.fuelProgressStack.draw(this.display, 2 * dragonblocks.settings.inventory.scale * 1.1, 1.5 * dragonblocks.settings.inventory.scale * 1.1);
}
- isEmpty(){
+
+ isEmpty()
+ {
return this.inventory.isEmpty() && ! this.fuel.item && ! this.input.item;
}
- deserialize(str){
- let obj = JSON.parse(str);
- this.inventory.deserialize(obj.inventory);
- this.input.deserialize(obj.input);
- this.fuel.deserialize(obj.fuel);
+
+ deserialize(str)
+ {
+ let data = JSON.parse(str);
+
+ this.inventory.deserialize(data.inventory);
+ this.input.deserialize(data.input);
+ this.fuel.deserialize(data.fuel);
}
- serialize(){
+
+ serialize()
+ {
return JSON.stringify({
inventory: this.inventory.serialize(),
input: this.input.serialize(),
- fuel: this.fuel.serializes()
+ fuel: this.fuel.serialize()
});
}
- getRecipe(){
- for(let recipe of furnace.recipes)
- if(dragonblocks.itemMatch(recipe.input, this.input.item))
+
+ getRecipe()
+ {
+ for (let recipe of furnace.recipes)
+ if (dragonblocks.itemMatch(recipe.input, this.input.item))
return recipe;
}
- getRecipeOutput(){
+
+ getRecipeOutput()
+ {
return this.getRecipe() && this.getRecipe().output;
}
- getRecipeTime(){
+
+ getRecipeTime()
+ {
return this.getRecipe() && this.getRecipe().time || 1;
}
- clear(){
+
+ clear()
+ {
this.burnProgress = 0;
clearInterval(this.burnInterval);
this.burning = false;
}
- clearFuel(){
+
+ clearFuel()
+ {
this.fuelPower = this.fullFuelPower = 0;
clearInterval(this.fuelInterval);
this.fuelBurning = false;
}
- update(){
- super.update();
+
+ update()
+ {
let self = this;
- if(! this.getRecipeOutput())
+
+ if (! this.getRecipeOutput()) {
this.clear();
- else if(this.burnProgress > this.getRecipeTime()){
- this.inventory.add(this.getRecipeOutput())
+ } else if (this.burnProgress > this.getRecipeTime()) {
+ this.inventory.add(this.getRecipeOutput());
this.clear();
+
this.input.count--;
this.input.update();
- }
- else if(! this.burning){
+ } else if (! this.burning) {
this.burnInterval = setInterval(_ => {
self.burnProgress++;
self.update();
}, 1000);
+
this.burning = true;
}
- if(this.fuelBurning && this.fuelPower <= 0)
+
+ if (this.fuelBurning && this.fuelPower <= 0)
this.clearFuel();
- if(! this.fuelBurning && this.burning){
- if(this.fuel.toItem() && this.fuel.toItem().flammable){
+
+ if (! this.fuelBurning && this.burning) {
+ if (this.fuel.toItem() && this.fuel.toItem().flammable) {
this.fuelBurning = true;
this.fullFuelPower = this.fuelPower = this.fuel.toItem().hardness;
+
this.fuelInterval = setInterval(_ => {
self.fuelPower--;
self.update();
}, 1000);
+
this.fuel.count--;
this.fuel.update();
- }
- else
+ } else {
this.clear();
+ }
}
- this.burnProgressDisplay.deserialize("furnace:burn_progress_" + parseInt(this.burnProgress / this.getRecipeTime() * 5));
- this.fuelProgressDisplay.deserialize("furnace:fuel_progress_" + (parseInt(this.fuelPower / this.fullFuelPower * 5) || 0));
+
+ this.burnProgressStack.deserialize("furnace:burn_progress_" + parseInt(this.burnProgress / this.getRecipeTime() * 5));
+ this.fuelProgressStack.deserialize("furnace:fuel_progress_" + (parseInt(this.fuelPower / this.fullFuelPower * 5) || 0));
}
}
stable: true,
onset: (map, x, y) => {
let meta = map.getNode(x, y).meta;
+
meta.inventory = new furnace.Inventory();
- if(meta.inventoryString)
- meta.inventory.ceserialize(meta.inventoryString);
+
+ if (meta.inventoryString)
+ meta.inventory.deserialize(meta.inventoryString);
},
onclick: (map, x, y) => {
let meta = map.getNode(x, y).meta;
+
dragonblocks.player.setInventoryElements([meta.inventory, dragonblocks.player.tmp.mainInventory]);
dragonblocks.player.openInventory();
+
dragonblocks.player.onNextInventoryClose = _ => {
dragonblocks.player.resetInventoryElements();
meta.inventoryString = meta.inventory.serialize();
return map.getNode(x, y).meta.inventory.isEmpty();
},
});
-for(let i = 0; i < 6; i++){
+
+for (let i = 0; i < 6; i++) {
dragonblocks.registerItem({
name: "furnace:burn_progress_" + i,
texture: "furnace_burn_progress_" + i + ".png",
hidden: true,
desc: "",
});
+
dragonblocks.registerItem({
name: "furnace:fuel_progress_" + i,
texture: "furnace_fuel_progress_" + i + ".png",