Search in sources :

Example 1 with FurnaceInventory

use of cn.nukkit.inventory.FurnaceInventory in project Nukkit by Nukkit.

the class BlockEntityFurnace method initBlockEntity.

@Override
protected void initBlockEntity() {
    this.inventory = new FurnaceInventory(this);
    if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
        this.namedTag.putList(new ListTag<CompoundTag>("Items"));
    }
    for (int i = 0; i < this.getSize(); i++) {
        this.inventory.setItem(i, this.getItem(i));
    }
    if (!this.namedTag.contains("BurnTime") || this.namedTag.getShort("BurnTime") < 0) {
        burnTime = 0;
    } else {
        burnTime = this.namedTag.getShort("BurnTime");
    }
    if (!this.namedTag.contains("CookTime") || this.namedTag.getShort("CookTime") < 0 || (this.namedTag.getShort("BurnTime") == 0 && this.namedTag.getShort("CookTime") > 0)) {
        cookTime = 0;
    } else {
        cookTime = this.namedTag.getShort("CookTime");
    }
    if (!this.namedTag.contains("MaxTime")) {
        maxTime = burnTime;
        burnDuration = 0;
    } else {
        maxTime = this.namedTag.getShort("MaxTime");
    }
    if (this.namedTag.contains("BurnTicks")) {
        burnDuration = this.namedTag.getShort("BurnTicks");
        this.namedTag.remove("BurnTicks");
    }
    if (burnTime > 0) {
        this.scheduleUpdate();
    }
    super.initBlockEntity();
}
Also used : FurnaceInventory(cn.nukkit.inventory.FurnaceInventory) ListTag(cn.nukkit.nbt.tag.ListTag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

FurnaceInventory (cn.nukkit.inventory.FurnaceInventory)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 ListTag (cn.nukkit.nbt.tag.ListTag)1