mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
ShulkerBox: fixed incorrect block-picking behaviour
This commit is contained in:
parent
dcbc0bc2a6
commit
f64ef50ce3
@ -59,19 +59,30 @@ class ShulkerBox extends Opaque{
|
|||||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asItem() : Item{
|
private function addDataFromTile(TileShulkerBox $tile, Item $item) : void{
|
||||||
$item = parent::asItem();
|
$shulkerNBT = $tile->getCleanedNBT();
|
||||||
$shulker = $this->pos->getWorld()->getTile($this->pos);
|
if($shulkerNBT !== null){
|
||||||
if($shulker instanceof TileShulkerBox){
|
$item->setNamedTag($shulkerNBT);
|
||||||
$shulkerNBT = $shulker->getCleanedNBT();
|
|
||||||
if($shulkerNBT !== null){
|
|
||||||
$item->setNamedTag($shulkerNBT);
|
|
||||||
}
|
|
||||||
if($shulker->hasName()){
|
|
||||||
$item->setCustomName($shulker->getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $item;
|
if($tile->hasName()){
|
||||||
|
$item->setCustomName($tile->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDropsForCompatibleTool(Item $item) : array{
|
||||||
|
$drop = $this->asItem();
|
||||||
|
if(($tile = $this->pos->getWorld()->getTile($this->pos)) instanceof TileShulkerBox){
|
||||||
|
$this->addDataFromTile($tile, $drop);
|
||||||
|
}
|
||||||
|
return [$drop];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPickedItem(bool $addUserData = false) : Item{
|
||||||
|
$result = parent::getPickedItem($addUserData);
|
||||||
|
if($addUserData && ($tile = $this->pos->getWorld()->getTile($this->pos)) instanceof TileShulkerBox){
|
||||||
|
$this->addDataFromTile($tile, $result);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user