mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 03:47:16 +00:00
Fixed block-pick on crops giving the crop block itself
This commit is contained in:
parent
42ed03fd02
commit
451f5d0cd7
@ -2580,9 +2580,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
$block = $this->level->getBlockAt($packet->blockX, $packet->blockY, $packet->blockZ);
|
||||
|
||||
//TODO: this doesn't handle crops correctly (need more API work)
|
||||
$item = Item::get($block->getItemId(), $block->getVariant());
|
||||
|
||||
$item = $block->getPickedItem();
|
||||
if($packet->addUserData){
|
||||
$tile = $this->getLevel()->getTile($block);
|
||||
if($tile instanceof Tile){
|
||||
|
@ -50,4 +50,8 @@ class Beetroot extends Crops{
|
||||
ItemFactory::get(Item::BEETROOT_SEEDS, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(Item::BEETROOT_SEEDS);
|
||||
}
|
||||
}
|
@ -425,6 +425,14 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item that players will equip when middle-clicking on this block.
|
||||
* @return Item
|
||||
*/
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get($this->getItemId(), $this->getVariant());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time in ticks which the block will fuel a furnace for.
|
||||
* @return int
|
||||
|
@ -43,4 +43,8 @@ class Carrot extends Crops{
|
||||
ItemFactory::get(Item::CARROT, 0, $this->meta >= 0x07 ? mt_rand(1, 4) : 1)
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(Item::CARROT);
|
||||
}
|
||||
}
|
@ -88,4 +88,8 @@ class MelonStem extends Crops{
|
||||
ItemFactory::get(Item::MELON_SEEDS, 0, mt_rand(0, 2))
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(Item::MELON_SEEDS);
|
||||
}
|
||||
}
|
@ -43,4 +43,8 @@ class Potato extends Crops{
|
||||
ItemFactory::get(Item::POTATO, 0, $this->getDamage() >= 0x07 ? mt_rand(1, 4) : 1)
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(Item::POTATO);
|
||||
}
|
||||
}
|
@ -88,4 +88,8 @@ class PumpkinStem extends Crops{
|
||||
ItemFactory::get(Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2))
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(Item::PUMPKIN_SEEDS);
|
||||
}
|
||||
}
|
@ -50,4 +50,8 @@ class Wheat extends Crops{
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(Item::WHEAT_SEEDS);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user