mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
FlowerPot (tile): Allow BlockFactory to determine id/data validity
This commit is contained in:
parent
1b629d7ac0
commit
f84040a7ad
@ -43,9 +43,10 @@ class FlowerPot extends Spawnable{
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
if($nbt->hasTag(self::TAG_ITEM, ShortTag::class) and $nbt->hasTag(self::TAG_ITEM_DATA, IntTag::class)){
|
||||
//prevent stupidity with wrong items
|
||||
if(($id = $nbt->getShort(self::TAG_ITEM)) >= 0 and $id <= 255 and ($data = $nbt->getInt(self::TAG_ITEM_DATA)) >= 0 and $data <= 15){
|
||||
$this->setPlant(BlockFactory::get($id, $data));
|
||||
try{
|
||||
$this->setPlant(BlockFactory::get($nbt->getShort(self::TAG_ITEM), $nbt->getInt(self::TAG_ITEM_DATA)));
|
||||
}catch(\InvalidArgumentException $e){
|
||||
//noop
|
||||
}
|
||||
}else{
|
||||
//TODO: new PlantBlock tag
|
||||
|
Loading…
x
Reference in New Issue
Block a user