right: 2,
});
let self = this;
- this.input = new dragonblocks.Itemstack();
- this.input.addUpdateListener(_ => {
+ this.input = new dragonblocks.ItemStack();
+ this.input.addEventListener("update", _ => {
self.update();
});
- this.fuel = new dragonblocks.Itemstack();
- this.fuel.addUpdateListener(_ => {
+ this.fuel = new dragonblocks.ItemStack();
+ this.fuel.addEventListener("update", _ => {
self.update();
});
- this.burnProgressDisplay = new dragonblocks.Itemstack();
- this.burnProgressDisplay.parse("furnace:burn_progress_0");
+ this.burnProgressDisplay = new dragonblocks.ItemStack();
+ this.burnProgressDisplay.deserialize("furnace:burn_progress_0");
this.burnProgressDisplay.action = _ => {};
- this.burnProgressDisplay.onredraw = _ => {
+ this.burnProgressDisplay.addEventListener("redraw", _ => {
dragonblocks.Inventory.getStackDisplay(self.burnProgressDisplay.id).style.backgroundColor = "";
dragonblocks.Inventory.getStackDisplay(self.burnProgressDisplay.id).style.border = "none";
- };
- this.fuelProgressDisplay = new dragonblocks.Itemstack();
- this.fuelProgressDisplay.parse("furnace:fuel_progress_0");
+ });
+ this.fuelProgressDisplay = new dragonblocks.ItemStack();
+ this.fuelProgressDisplay.deserialize("furnace:fuel_progress_0");
this.fuelProgressDisplay.action = _ => {};
- this.fuelProgressDisplay.onredraw = _ => {
+ this.fuelProgressDisplay.addEventListener("redraw", _ => {
dragonblocks.Inventory.getStackDisplay(self.fuelProgressDisplay.id).style.backgroundColor = "";
dragonblocks.Inventory.getStackDisplay(self.fuelProgressDisplay.id).style.border = "none";
- };
+ });
this.clear();
this.clearFuel();
this.update();
draw(parent, x, y){
if(! super.draw(parent, x, y))
return false;
- dragonblocks.Inventory.drawStack(this.getDisplay(), 2 * dragonblocks.settings.inventory.scale * 1.1, 0.5 * dragonblocks.settings.inventory.scale * 1.1, this.input);
- dragonblocks.Inventory.drawStack(this.getDisplay(), 3 * dragonblocks.settings.inventory.scale * 1.1, 1.5 * dragonblocks.settings.inventory.scale * 1.1, this.burnProgressDisplay);
- dragonblocks.Inventory.drawStack(this.getDisplay(), 2 * dragonblocks.settings.inventory.scale * 1.1, 1.5 * dragonblocks.settings.inventory.scale * 1.1, this.fuelProgressDisplay);
- dragonblocks.Inventory.drawStack(this.getDisplay(), 2 * dragonblocks.settings.inventory.scale * 1.1, 2.5 * dragonblocks.settings.inventory.scale * 1.1, this.fuel);
+ 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;
}
isEmpty(){
return this.inventory.isEmpty() && ! this.fuel.item && ! this.input.item;
}
- parse(str){
+ deserialize(str){
let obj = JSON.parse(str);
- this.inventory.parse(obj.inventory);
- this.input.parse(obj.input);
- this.fuel.parse(obj.fuel);
+ this.inventory.deserialize(obj.inventory);
+ this.input.deserialize(obj.input);
+ this.fuel.deserialize(obj.fuel);
}
- stringify(){
+ serialize(){
return JSON.stringify({
- inventory: this.inventory.stringify(),
- input: this.input.stringify(),
- fuel: this.fuel.stringify()
+ inventory: this.inventory.serialize(),
+ input: this.input.serialize(),
+ fuel: this.fuel.serializes()
});
}
getRecipe(){
else
this.clear();
}
- this.burnProgressDisplay.parse("furnace:burn_progress_" + parseInt(this.burnProgress / this.getRecipeTime() * 5));
- this.fuelProgressDisplay.parse("furnace:fuel_progress_" + (parseInt(this.fuelPower / this.fullFuelPower * 5) || 0));
+ 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));
}
}