diff --git a/src/pocketmine/block/tile/BrewingStand.php b/src/pocketmine/block/tile/BrewingStand.php new file mode 100644 index 000000000..bf4de785c --- /dev/null +++ b/src/pocketmine/block/tile/BrewingStand.php @@ -0,0 +1,118 @@ +inventory = new BrewingStandInventory($this); + $this->inventory->addChangeListeners(CallbackInventoryChangeListener::onAnyChange(function(Inventory $unused){ + $this->world->scheduleDelayedBlockUpdate($this->getBlock(), 0); + })); + parent::__construct($world, $pos); + } + + public function readSaveData(CompoundTag $nbt) : void{ + $this->loadName($nbt); + $this->loadItems($nbt); + + $this->brewTime = $nbt->getShort(self::TAG_BREW_TIME, $nbt->getShort(self::TAG_BREW_TIME_PE, 0)); + $this->maxFuelTime = $nbt->getShort(self::TAG_MAX_FUEL_TIME, 0); + $this->remainingFuelTime = $nbt->getShort(self::TAG_REMAINING_FUEL_TIME, $nbt->getShort(self::TAG_REMAINING_FUEL_TIME_PE, 0)); + if($this->maxFuelTime === 0){ + $this->maxFuelTime = $this->remainingFuelTime; + } + if($this->remainingFuelTime === 0){ + $this->maxFuelTime = $this->remainingFuelTime = $this->brewTime = 0; + } + } + + protected function writeSaveData(CompoundTag $nbt) : void{ + $this->saveName($nbt); + $this->saveItems($nbt); + + $nbt->setShort(self::TAG_BREW_TIME_PE, $this->brewTime); + $nbt->setShort(self::TAG_MAX_FUEL_TIME, $this->maxFuelTime); + $nbt->setShort(self::TAG_REMAINING_FUEL_TIME_PE, $this->remainingFuelTime); + } + + public function getDefaultName() : string{ + return "Brewing Stand"; + } + + public function close() : void{ + if(!$this->closed){ + $this->inventory->removeAllViewers(true); + $this->inventory = null; + + parent::close(); + } + } + + /** + * @return BrewingStandInventory + */ + public function getInventory(){ + return $this->inventory; + } + + /** + * @return BrewingStandInventory + */ + public function getRealInventory(){ + return $this->inventory; + } + + public function onUpdate() : bool{ + return false; //TODO + } + +} diff --git a/src/pocketmine/inventory/BrewingStandInventory.php b/src/pocketmine/inventory/BrewingStandInventory.php new file mode 100644 index 000000000..a699ed184 --- /dev/null +++ b/src/pocketmine/inventory/BrewingStandInventory.php @@ -0,0 +1,38 @@ +