mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
remove position parameters from BlockFactory::get() and BlockFactory::fromFullBlock()
This commit is contained in:
parent
c9cd6ee038
commit
6a4ae4cb94
@ -51,7 +51,6 @@ use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\item\ToolTier;
|
||||
use pocketmine\world\Position;
|
||||
use function array_fill;
|
||||
use function array_filter;
|
||||
use function get_class;
|
||||
@ -830,13 +829,12 @@ class BlockFactory{
|
||||
/**
|
||||
* Returns a new Block instance with the specified ID, meta and position.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param Position $pos
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public static function get(int $id, int $meta = 0, ?Position $pos = null) : Block{
|
||||
public static function get(int $id, int $meta = 0) : Block{
|
||||
if($meta < 0 or $meta > 0xf){
|
||||
throw new \InvalidArgumentException("Block meta value $meta is out of bounds");
|
||||
}
|
||||
@ -856,15 +854,11 @@ class BlockFactory{
|
||||
$block = new UnknownBlock(new BID($id, $meta));
|
||||
}
|
||||
|
||||
if($pos !== null){
|
||||
$block->position($pos->getWorld(), $pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ());
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
public static function fromFullBlock(int $fullState, ?Position $pos = null) : Block{
|
||||
return self::get($fullState >> 4, $fullState & 0xf, $pos);
|
||||
public static function fromFullBlock(int $fullState) : Block{
|
||||
return self::get($fullState >> 4, $fullState & 0xf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,6 @@ use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\World;
|
||||
use function assert;
|
||||
use function atan2;
|
||||
@ -84,7 +83,7 @@ abstract class Projectile extends Entity{
|
||||
$blockData = null;
|
||||
|
||||
if($nbt->hasTag("tileX", IntTag::class) and $nbt->hasTag("tileY", IntTag::class) and $nbt->hasTag("tileZ", IntTag::class)){
|
||||
$blockPos = new Position($nbt->getInt("tileX"), $nbt->getInt("tileY"), $nbt->getInt("tileZ"), $this->getWorld());
|
||||
$blockPos = new Vector3($nbt->getInt("tileX"), $nbt->getInt("tileY"), $nbt->getInt("tileZ"));
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
@ -101,7 +100,8 @@ abstract class Projectile extends Entity{
|
||||
break;
|
||||
}
|
||||
|
||||
$this->blockHit = BlockFactory::get($blockId, $blockData, $blockPos);
|
||||
$this->blockHit = BlockFactory::get($blockId, $blockData);
|
||||
$this->blockHit->position($this->getWorld(), $blockPos->getFloorX(), $blockPos->getFloorY(), $blockPos->getFloorZ());
|
||||
}while(false);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,6 @@ class Explosion{
|
||||
}
|
||||
|
||||
$vector = new Vector3(0, 0, 0);
|
||||
$vBlock = new Position(0, 0, 0, $this->world);
|
||||
|
||||
$currentChunk = null;
|
||||
$currentSubChunk = null;
|
||||
@ -115,21 +114,23 @@ class Explosion{
|
||||
$x = (int) $pointerX;
|
||||
$y = (int) $pointerY;
|
||||
$z = (int) $pointerZ;
|
||||
$vBlock->x = $pointerX >= $x ? $x : $x - 1;
|
||||
$vBlock->y = $pointerY >= $y ? $y : $y - 1;
|
||||
$vBlock->z = $pointerZ >= $z ? $z : $z - 1;
|
||||
$vBlockX = $pointerX >= $x ? $x : $x - 1;
|
||||
$vBlockY = $pointerY >= $y ? $y : $y - 1;
|
||||
$vBlockZ = $pointerZ >= $z ? $z : $z - 1;
|
||||
|
||||
if(!$this->subChunkHandler->moveTo($vBlock->x, $vBlock->y, $vBlock->z, false)){
|
||||
if(!$this->subChunkHandler->moveTo($vBlockX, $vBlockY, $vBlockZ, false)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$state = $this->subChunkHandler->currentSubChunk->getFullBlock($vBlock->x & 0x0f, $vBlock->y & 0x0f, $vBlock->z & 0x0f);
|
||||
$state = $this->subChunkHandler->currentSubChunk->getFullBlock($vBlockX & 0x0f, $vBlockY & 0x0f, $vBlockZ & 0x0f);
|
||||
|
||||
if($state !== 0){
|
||||
$blastForce -= (BlockFactory::$blastResistance[$state] / 5 + 0.3) * $this->stepLen;
|
||||
if($blastForce > 0){
|
||||
if(!isset($this->affectedBlocks[$index = World::blockHash($vBlock->x, $vBlock->y, $vBlock->z)])){
|
||||
$this->affectedBlocks[$index] = BlockFactory::fromFullBlock($state, $vBlock);
|
||||
if(!isset($this->affectedBlocks[$index = World::blockHash($vBlockX, $vBlockY, $vBlockZ)])){
|
||||
$_block = BlockFactory::fromFullBlock($state);
|
||||
$_block->position($this->world, $vBlockX, $vBlockY, $vBlockZ);
|
||||
$this->affectedBlocks[$index] = $_block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -996,11 +996,8 @@ class World implements ChunkManager{
|
||||
|
||||
if(isset($this->randomTickBlocks[$state])){
|
||||
/** @var Block $block */
|
||||
$block = BlockFactory::fromFullBlock($state, $this->temporalPosition->setComponents(
|
||||
$chunkX * 16 + $x,
|
||||
($Y << 4) + $y,
|
||||
$chunkZ * 16 + $z
|
||||
));
|
||||
$block = BlockFactory::fromFullBlock($state);
|
||||
$block->position($this, $chunkX * 16 + $x, ($Y << 4) + $y, $chunkZ * 16 + $z);
|
||||
$block->onRandomTick();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user