93 parent::readStateFromWorld();
94 $tile = $this->position->getWorld()->getTile($this->position);
95 if($tile instanceof TileCampfire){
96 $this->inventory = $tile->getInventory();
97 $this->cookingTimes = $tile->getCookingTimes();
99 $this->inventory =
null;
100 $this->cookingTimes = [];
160 if($slot < 0 || $slot > 3){
161 throw new \InvalidArgumentException(
"Slot must be in range 0-3");
163 if($time < 0 || $time > $this->getFurnaceType()->getCookDurationTicks()){
164 throw new \InvalidArgumentException(
"CookingTime must be in range 0-" . $this->getFurnaceType()->getCookDurationTicks());
166 $this->cookingTimes[$slot] = $time;
189 if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
192 $this->position->getWorld()->addSound($this->position, new BlazeShootSound());
194 }elseif($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){
195 if($item instanceof Durable){
196 $item->applyDamage(1);
201 }elseif($item instanceof Shovel){
202 $item->applyDamage(1);
207 $inventory = $this->inventory;
208 if($inventory !==
null && $this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($this->getFurnaceType())->match($item) !==
null){
209 $ingredient = clone $item;
210 $ingredient->setCount(1);
211 if(count($inventory->
addItem($ingredient)) === 0){
213 $this->position->getWorld()->addSound($this->position,
new ItemFrameAddItemSound());
246 if($this->lit && ($inventory = $this->inventory) !== null){
248 $furnaceType = $this->getFurnaceType();
249 $maxCookDuration = $furnaceType->getCookDurationTicks();
250 foreach($items as $slot => $item){
251 $this->setCookingTime($slot, min($maxCookDuration, $this->getCookingTime($slot) + self::UPDATE_INTERVAL_TICKS));
252 if($this->getCookingTime($slot) >= $maxCookDuration){
254 ($recipe = $this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($furnaceType)->match($item)) instanceof
FurnaceRecipe ?
255 $recipe->getResult() :
261 if ($ev->isCancelled()){
265 $inventory->
setItem($slot, VanillaItems::AIR());
266 $this->setCookingTime($slot, 0);
267 $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $ev->getResult());
270 if(count($items) > 0){
271 $this->position->getWorld()->setBlock($this->position, $this);
273 if(mt_rand(1, 6) === 1){
274 $this->position->getWorld()->addSound($this->position, $furnaceType->getCookSound());
276 $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS);