56 parent::writeStateToWorld();
57 $tile = $this->position->getWorld()->getTile($this->position);
58 assert($tile instanceof TileCauldron);
59 $tile->setCustomWaterColor(
null);
60 $tile->setPotionItem($this->potionItem);
67 if($potionItem !== null && !match($potionItem->getTypeId()){
69 ItemTypeIds::SPLASH_POTION,
70 ItemTypeIds::LINGERING_POTION =>
true,
73 throw new \InvalidArgumentException(
"Item must be a POTION, SPLASH_POTION or LINGERING_POTION");
75 $this->potionItem = $potionItem !==
null ? (clone $potionItem)->setCount(1) :
null;
91 if($this->potionItem !== null && !$usedItem->equals($this->potionItem, true, false)){
92 $this->mix($usedItem, $returnedItem, $returnedItems);
94 $this->addFillLevels($amount, $usedItem, $returnedItem, $returnedItems);
99 match($item->getTypeId()){
100 ItemTypeIds::LINGERING_POTION, ItemTypeIds::POTION, ItemTypeIds::SPLASH_POTION => $this->addFillLevelsOrMix(self::POTION_FILL_AMOUNT, $item, VanillaItems::GLASS_BOTTLE(), $returnedItems),
101 ItemTypeIds::GLASS_BOTTLE => $this->potionItem ===
null ? null : $this->removeFillLevels(self::POTION_FILL_AMOUNT, $item, clone $this->potionItem, $returnedItems),
102 ItemTypeIds::LAVA_BUCKET, ItemTypeIds::POWDER_SNOW_BUCKET, ItemTypeIds::WATER_BUCKET => $this->mix($item, VanillaItems::BUCKET(), $returnedItems),
110 $world = $this->position->getWorld();
111 if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){
112 $cauldron = VanillaBlocks::WATER_CAULDRON()->setFillLevel(FillableCauldron::MAX_FILL_LEVEL);
113 $world->setBlock($this->position, $cauldron);
114 $world->addSound($this->position->add(0.5, 0.5, 0.5), $cauldron->getFillSound());