mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Added Level->getTileAt()
This commit is contained in:
parent
93443992be
commit
91c256f1a9
@ -2910,7 +2910,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return true;
|
||||
}
|
||||
|
||||
$tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
|
||||
$tile = $this->level->getTileAt($packet->x, $packet->y, $packet->z);
|
||||
if($tile instanceof ItemFrame){
|
||||
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $tile->getBlock(), null, 5 - $tile->getBlock()->getDamage(), PlayerInteractEvent::LEFT_CLICK_BLOCK);
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
@ -211,7 +211,7 @@ class Explosion{
|
||||
|
||||
$this->level->setBlockIdAt($block->x, $block->y, $block->z, 0);
|
||||
|
||||
$t = $this->level->getTile($block);
|
||||
$t = $this->level->getTileAt($block->x, $block->y, $block->z);
|
||||
if($t instanceof Tile){
|
||||
if($yieldDrops and $t instanceof Container){
|
||||
if($t instanceof Chest){
|
||||
|
@ -1962,17 +1962,33 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Tile in a position, or null if not found
|
||||
* Returns the Tile in a position, or null if not found.
|
||||
*
|
||||
* Note: This method wraps getTileAt(). If you're guaranteed to be passing integers, and you're using this method
|
||||
* in performance-sensitive code, consider using getTileAt() instead of this method for better performance.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
public function getTile(Vector3 $pos){
|
||||
$chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false);
|
||||
public function getTile(Vector3 $pos) : ?Tile{
|
||||
return $this->getTileAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tile at the specified x,y,z coordinates, or null if it does not exist.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
public function getTileAt(int $x, int $y, int $z) : ?Tile{
|
||||
$chunk = $this->getChunk($x >> 4, $z >> 4);
|
||||
|
||||
if($chunk !== null){
|
||||
return $chunk->getTile($pos->x & 0x0f, $pos->y, $pos->z & 0x0f);
|
||||
return $chunk->getTile($x & 0x0f, $y, $z & 0x0f);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -136,7 +136,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
*/
|
||||
public function getPair() : ?Chest{
|
||||
if($this->isPaired()){
|
||||
$tile = $this->getLevel()->getTile(new Vector3($this->namedtag->getInt(self::TAG_PAIRX), $this->y, $this->namedtag->getInt(self::TAG_PAIRZ)));
|
||||
$tile = $this->getLevel()->getTileAt($this->namedtag->getInt(self::TAG_PAIRX), $this->y, $this->namedtag->getInt(self::TAG_PAIRZ));
|
||||
if($tile instanceof Chest){
|
||||
return $tile;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user