PHP: public function test(PlayerLoginEvent $event) { $item = (new Item(Item::SNOWBALL, 0, 16, "Testy"))->setCustomName("Testy"); $namedTag = $item->getNamedTag(); $namedTag->offsetSet("Test", new FloatTag("Test", 0.05)); $item->setNamedTag($namedTag); $p->getInventory()->setItem(0, $item); } This FloatTag makes the Snowball unusable. Please help! EDIT: Sometimes (float) 0.0 works!, switched to (float) 0.05 Using PocketMine #4ace4b9
PHP: public function test(PlayerLoginEvent $event) { $item = Item::get(Item::SNOWBALL, 0, 1); $namedTag = new CompoundTag("", []); $namedTag->display = new CompoundTag("display", [ "Name" => new StringTag("Name", "Testy") ]); $namedTag->Test = new FloatTag("Test", 0.05); $item->setNamedTag($namedTag); $p->getInventory()->setItem(0, $item); }
I've just solved this by using this hack before the setItem() function: PHP: $item->setCompoundTag($item->getCompoundTag()); This release the cachedNBT and it works. Now i need an explaination for this (and more convenient code if available).