mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Compare commits
101 Commits
5.31.0
...
block-posi
Author | SHA1 | Date | |
---|---|---|---|
897816c6bb | |||
f93333227c | |||
6d2329128a | |||
07045dd424 | |||
c5b0df4578 | |||
5e9dbace90 | |||
8245fa35f6 | |||
241e356780 | |||
39662bdc3b | |||
224fa09327 | |||
205aabe11f | |||
3091e1325f | |||
779e80a961 | |||
007673cb96 | |||
0dae786a21 | |||
02d181d0c8 | |||
2fc6bbe84e | |||
002383be89 | |||
00bdb6be73 | |||
c3c917bb05 | |||
a078f653f4 | |||
ed33983792 | |||
15eaf67a0c | |||
d72941c36c | |||
e51903d7ea | |||
3e9a96b43a | |||
9fce27eaa8 | |||
7208733d62 | |||
c61434d87b | |||
dcc258706f | |||
820e2d4a2f | |||
0fb1415f7f | |||
a6534ecbbb | |||
330bcd2423 | |||
e71b9e8dc6 | |||
9e2d91bae6 | |||
b6f55b78a9 | |||
ab5176baf9 | |||
ef6fce4091 | |||
cc335889f3 | |||
80b7f6aba4 | |||
82c5a3160c | |||
85de28d6c3 | |||
1ef854f2d1 | |||
082af9978c | |||
e8620ef94d | |||
83a91634c3 | |||
3c73bd22dd | |||
0e1824451b | |||
6c5ae634fd | |||
041944ed16 | |||
603527c6e8 | |||
1ac08ea73b | |||
c9e8d382c5 | |||
12179aa03a | |||
e781c64540 | |||
644693ffee | |||
6b66cbfb1c | |||
4d337add7c | |||
9d75c45bf5 | |||
c7a537abbb | |||
54694df48c | |||
15aae721cd | |||
d565be93a8 | |||
e32a90be72 | |||
d4d7d02067 | |||
a45e143e81 | |||
05981d2669 | |||
fa9bba470c | |||
361626d236 | |||
16d8522245 | |||
a4f3476190 | |||
e96e68d221 | |||
f1a6d71cc1 | |||
89f42c80d4 | |||
cd6b780d31 | |||
ed61a68013 | |||
4dc9d696d0 | |||
258038c9a9 | |||
5c915a3dfe | |||
8c594fd126 | |||
9fd6653f36 | |||
32d67080e5 | |||
ed9d057ca2 | |||
5ec0e0f20b | |||
cb251069dd | |||
e0ad39b70a | |||
9997b614bc | |||
89f8f421a6 | |||
c4ff6d7757 | |||
3c0e7ae492 | |||
b944205f60 | |||
2ab3393568 | |||
1e1b95e1b8 | |||
62465fa676 | |||
aac5944396 | |||
74cfd687d7 | |||
f2f30143b0 | |||
d98adf127f | |||
280bf60830 | |||
1ffa945fbf |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
||||
[submodule "tests/plugins/DevTools"]
|
||||
path = tests/plugins/DevTools
|
||||
url = https://github.com/pmmp/DevTools.git
|
||||
[submodule "build/php"]
|
||||
path = build/php
|
||||
url = https://github.com/pmmp/php-build-scripts.git
|
||||
|
@ -5,7 +5,6 @@ $finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__ . '/build')
|
||||
->in(__DIR__ . '/tests')
|
||||
->in(__DIR__ . '/tools')
|
||||
->notPath('plugins/DevTools')
|
||||
->notName('PocketMine.php');
|
||||
|
||||
return (new PhpCsFixer\Config)
|
||||
|
@ -78,7 +78,6 @@
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"make-devtools": "@php -dphar.readonly=0 tests/plugins/DevTools/src/ConsoleScript.php --make ./ --relative tests/plugins/DevTools --out plugins/DevTools.phar",
|
||||
"make-server": [
|
||||
"@composer install --no-dev --classmap-authoritative --ignore-platform-reqs",
|
||||
"@php -dphar.readonly=0 build/server-phar.php"
|
||||
|
@ -10,8 +10,6 @@ includes:
|
||||
- vendor/phpstan/phpstan-strict-rules/rules.neon
|
||||
|
||||
rules:
|
||||
- pocketmine\phpstan\rules\DeprecatedLegacyEnumAccessRule
|
||||
- pocketmine\phpstan\rules\DisallowEnumComparisonRule
|
||||
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
|
||||
- pocketmine\phpstan\rules\UnsafeForeachArrayOfStringRule
|
||||
# - pocketmine\phpstan\rules\ThreadedSupportedTypesRule
|
||||
|
@ -79,6 +79,7 @@ use pocketmine\player\PlayerDataLoadException;
|
||||
use pocketmine\player\PlayerDataProvider;
|
||||
use pocketmine\player\PlayerDataSaveException;
|
||||
use pocketmine\player\PlayerInfo;
|
||||
use pocketmine\plugin\FolderPluginLoader;
|
||||
use pocketmine\plugin\PharPluginLoader;
|
||||
use pocketmine\plugin\PluginEnableOrder;
|
||||
use pocketmine\plugin\PluginGraylist;
|
||||
@ -344,6 +345,10 @@ class Server{
|
||||
return $this->maxPlayers;
|
||||
}
|
||||
|
||||
public function setMaxPlayers(int $maxPlayers) : void{
|
||||
$this->maxPlayers = $maxPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the server requires that players be authenticated to Xbox Live. If true, connecting players who
|
||||
* are not logged into Xbox Live will be disconnected.
|
||||
@ -1022,6 +1027,7 @@ class Server{
|
||||
$this->pluginManager = new PluginManager($this, $this->configGroup->getPropertyBool(Yml::PLUGINS_LEGACY_DATA_DIR, true) ? null : Path::join($this->dataPath, "plugin_data"), $pluginGraylist);
|
||||
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
|
||||
$this->pluginManager->registerInterface(new ScriptPluginLoader());
|
||||
$this->pluginManager->registerInterface(new FolderPluginLoader($this->autoloader));
|
||||
|
||||
$providerManager = new WorldProviderManager();
|
||||
if(
|
||||
|
@ -116,7 +116,7 @@ class Bamboo extends Transparent{
|
||||
}
|
||||
|
||||
public function getModelPositionOffset() : ?Vector3{
|
||||
$seed = self::getOffsetSeed($this->position->getFloorX(), 0, $this->position->getFloorZ());
|
||||
$seed = self::getOffsetSeed($this->position->x, 0, $this->position->z);
|
||||
$retX = (($seed % 12) + 1) / 16;
|
||||
$retZ = ((($seed >> 8) % 12) + 1) / 16;
|
||||
return new Vector3($retX, 0, $retZ);
|
||||
@ -135,7 +135,7 @@ class Bamboo extends Transparent{
|
||||
private function seekToTop() : Bamboo{
|
||||
$world = $this->position->getWorld();
|
||||
$top = $this;
|
||||
while(($next = $world->getBlock($top->position->up())) instanceof Bamboo && $next->hasSameTypeId($this)){
|
||||
while(($next = $world->getBlock($top->position->getSide(Facing::UP))) instanceof Bamboo && $next->hasSameTypeId($this)){
|
||||
$top = $next;
|
||||
}
|
||||
return $top;
|
||||
@ -144,7 +144,7 @@ class Bamboo extends Transparent{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($item instanceof Fertilizer){
|
||||
$top = $this->seekToTop();
|
||||
if($top->grow(self::getMaxHeight($top->position->getFloorX(), $top->position->getFloorZ()), mt_rand(1, 2), $player)){
|
||||
if($top->grow(self::getMaxHeight($top->position->x, $top->position->z), mt_rand(1, 2), $player)){
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
@ -159,12 +159,12 @@ class Bamboo extends Transparent{
|
||||
|
||||
private function grow(int $maxHeight, int $growAmount, ?Player $player) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$world->getBlock($this->position->up())->canBeReplaced()){
|
||||
if(!$world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$height = 1;
|
||||
while($world->getBlock($this->position->subtract(0, $height, 0))->hasSameTypeId($this)){
|
||||
while($world->getBlock($this->position->getSide(Facing::DOWN, $height))->hasSameTypeId($this)){
|
||||
if(++$height >= $maxHeight){
|
||||
return false;
|
||||
}
|
||||
@ -201,7 +201,7 @@ class Bamboo extends Transparent{
|
||||
|
||||
$tx = new BlockTransaction($world);
|
||||
foreach($newBlocks as $idx => $newBlock){
|
||||
$tx->addBlock($this->position->subtract(0, $idx - $growAmount, 0), $newBlock);
|
||||
$tx->addBlock($this->position->getSide(Facing::DOWN, $idx - $growAmount), $newBlock);
|
||||
}
|
||||
|
||||
$ev = new StructureGrowEvent($this, $tx, $player);
|
||||
@ -221,10 +221,10 @@ class Bamboo extends Transparent{
|
||||
$world = $this->position->getWorld();
|
||||
if($this->ready){
|
||||
$this->ready = false;
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow(self::getMaxHeight($this->position->getFloorX(), $this->position->getFloorZ()), 1, null)){
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow(self::getMaxHeight($this->position->x, $this->position->z), 1, null)){
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
}elseif($world->getBlock($this->position->up())->canBeReplaced()){
|
||||
}elseif($world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){
|
||||
$this->ready = true;
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ final class BambooSapling extends Flowable{
|
||||
|
||||
private function grow(?Player $player) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$world->getBlock($this->position->up())->canBeReplaced()){
|
||||
if(!$world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$tx = new BlockTransaction($world);
|
||||
$bamboo = VanillaBlocks::BAMBOO();
|
||||
$tx->addBlock($this->position, $bamboo)
|
||||
->addBlock($this->position->up(), (clone $bamboo)->setLeafSize(Bamboo::SMALL_LEAVES));
|
||||
->addBlock($this->position->getSide(Facing::UP), (clone $bamboo)->setLeafSize(Bamboo::SMALL_LEAVES));
|
||||
|
||||
$ev = new StructureGrowEvent($this, $tx, $player);
|
||||
$ev->call();
|
||||
@ -102,7 +102,7 @@ final class BambooSapling extends Flowable{
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow(null)){
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
}elseif($world->getBlock($this->position->up())->canBeReplaced()){
|
||||
}elseif($world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){
|
||||
$this->ready = true;
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
|
@ -99,10 +99,10 @@ abstract class BaseBigDripleaf extends Transparent{
|
||||
return false;
|
||||
}
|
||||
$pos = $head->position;
|
||||
$up = $pos->up();
|
||||
$up = $pos->getSide(Facing::UP);
|
||||
$world = $pos->getWorld();
|
||||
if(
|
||||
!$world->isInWorld($up->getFloorX(), $up->getFloorY(), $up->getFloorZ()) ||
|
||||
!$world->isInWorld($up->x, $up->y, $up->z) ||
|
||||
$world->getBlock($up)->getTypeId() !== BlockTypeIds::AIR
|
||||
){
|
||||
return false;
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\CoralTypeTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use function mt_rand;
|
||||
|
||||
abstract class BaseCoral extends Transparent{
|
||||
@ -55,11 +56,9 @@ abstract class BaseCoral extends Transparent{
|
||||
public function isSolid() : bool{ return false; }
|
||||
|
||||
protected function isCoveredWithWater() : bool{
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
$hasWater = false;
|
||||
foreach($this->position->sides() as $vector3){
|
||||
if($world->getBlock($vector3) instanceof Water){
|
||||
foreach(Facing::ALL as $side){
|
||||
if($this->getSide($side) instanceof Water){
|
||||
$hasWater = true;
|
||||
break;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ abstract class BaseSign extends Transparent{
|
||||
|
||||
private function changeSignGlowingState(bool $glowing, Player $player, Item $item) : bool{
|
||||
if($this->text->isGlowing() !== $glowing && $this->doSignChange(new SignText($this->text->getLines(), $this->text->getBaseColor(), $glowing), $player, $item)){
|
||||
$this->position->getWorld()->addSound($this->position, new InkSacUseSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new InkSacUseSound());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -183,7 +183,7 @@ abstract class BaseSign extends Transparent{
|
||||
$color->toARGB() !== $this->text->getBaseColor()->toARGB() &&
|
||||
$this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item)
|
||||
){
|
||||
$this->position->getWorld()->addSound($this->position, new DyeUseSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new DyeUseSound());
|
||||
return true;
|
||||
}
|
||||
}elseif(match($item->getTypeId()){
|
||||
|
@ -128,7 +128,7 @@ class Bed extends Transparent{
|
||||
$player->sendMessage(TextFormat::GRAY . "This bed is incomplete");
|
||||
|
||||
return true;
|
||||
}elseif($playerPos->distanceSquared($this->position) > 4 && $playerPos->distanceSquared($other->position) > 4){
|
||||
}elseif($playerPos->distanceSquared($this->position->center()) > 4 && $playerPos->distanceSquared($other->position->center()) > 4){
|
||||
$player->sendMessage(KnownTranslationFactory::tile_bed_tooFar()->prefix(TextFormat::GRAY));
|
||||
return true;
|
||||
}
|
||||
|
@ -143,10 +143,10 @@ final class Bell extends Transparent{
|
||||
|
||||
public function ring(int $faceHit) : void{
|
||||
$world = $this->position->getWorld();
|
||||
$world->addSound($this->position, new BellRingSound());
|
||||
$world->addSound($this->position->center(), new BellRingSound());
|
||||
$tile = $world->getTile($this->position);
|
||||
if($tile instanceof TileBell){
|
||||
$world->broadcastPacketToViewers($this->position, $tile->createFakeUpdatePacket($faceHit));
|
||||
$world->broadcastPacketOnBlock($this->position, $tile->createFakeUpdatePacket($faceHit));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ class BigDripleafHead extends BaseBigDripleaf{
|
||||
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
||||
if($this->leafState !== DripleafState::FULL_TILT){
|
||||
$this->setTiltAndScheduleTick(DripleafState::FULL_TILT);
|
||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new DripleafTiltDownSound());
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,13 +101,13 @@ class BigDripleafHead extends BaseBigDripleaf{
|
||||
if($this->leafState !== DripleafState::STABLE){
|
||||
if($this->leafState === DripleafState::FULL_TILT){
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE));
|
||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new DripleafTiltUpSound());
|
||||
}else{
|
||||
$this->setTiltAndScheduleTick(match($this->leafState){
|
||||
DripleafState::UNSTABLE => DripleafState::PARTIAL_TILT,
|
||||
DripleafState::PARTIAL_TILT => DripleafState::FULL_TILT,
|
||||
});
|
||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new DripleafTiltDownSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class Block{
|
||||
protected BlockIdentifier $idInfo;
|
||||
protected string $fallbackName;
|
||||
protected BlockTypeInfo $typeInfo;
|
||||
protected Position $position;
|
||||
protected BlockPosition $position;
|
||||
|
||||
/** @var AxisAlignedBB[]|null */
|
||||
protected ?array $collisionBoxes = null;
|
||||
@ -107,7 +107,7 @@ class Block{
|
||||
$this->idInfo = $idInfo;
|
||||
$this->fallbackName = $name;
|
||||
$this->typeInfo = $typeInfo;
|
||||
$this->position = new Position(0, 0, 0, null);
|
||||
$this->position = new BlockPosition(0, 0, 0, null);
|
||||
|
||||
$calculator = new RuntimeDataSizeCalculator();
|
||||
$this->describeBlockItemState($calculator);
|
||||
@ -377,7 +377,7 @@ class Block{
|
||||
*/
|
||||
public function writeStateToWorld() : void{
|
||||
$world = $this->position->getWorld();
|
||||
$chunk = $world->getOrLoadChunkAtPosition($this->position);
|
||||
$chunk = $world->loadChunk($this->position->x >> Chunk::COORD_BIT_SIZE, $this->position->z >> Chunk::COORD_BIT_SIZE);
|
||||
if($chunk === null){
|
||||
throw new AssumptionFailedError("World::setBlock() should have loaded the chunk before calling this method");
|
||||
}
|
||||
@ -398,7 +398,7 @@ class Block{
|
||||
* @var Tile $tile
|
||||
* @see Tile::__construct()
|
||||
*/
|
||||
$tile = new $tileType($world, $this->position->asVector3());
|
||||
$tile = new $tileType($this->position);
|
||||
$world->addTile($tile);
|
||||
}
|
||||
}
|
||||
@ -608,7 +608,7 @@ class Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
final public function getPosition() : Position{
|
||||
final public function getPosition() : BlockPosition{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
@ -616,7 +616,7 @@ class Block{
|
||||
* @internal
|
||||
*/
|
||||
final public function position(World $world, int $x, int $y, int $z) : void{
|
||||
$this->position = new Position($x, $y, $z, $world);
|
||||
$this->position = new BlockPosition($x, $y, $z, $world);
|
||||
$this->collisionBoxes = null;
|
||||
}
|
||||
|
||||
@ -912,9 +912,9 @@ class Block{
|
||||
if($this->collisionBoxes === null){
|
||||
$this->collisionBoxes = $this->recalculateCollisionBoxes();
|
||||
$extraOffset = $this->getModelPositionOffset();
|
||||
$offset = $extraOffset !== null ? $this->position->addVector($extraOffset) : $this->position;
|
||||
[$dx, $dy, $dz] = $extraOffset !== null ? [$extraOffset->x, $extraOffset->y, $extraOffset->z] : [0, 0, 0];
|
||||
foreach($this->collisionBoxes as $bb){
|
||||
$bb->offset($offset->x, $offset->y, $offset->z);
|
||||
$bb->offset($this->position->x + $dx, $this->position->y + $dy, $this->position->z + $dz);
|
||||
}
|
||||
}
|
||||
|
||||
|
110
src/block/BlockPosition.php
Normal file
110
src/block/BlockPosition.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\World;
|
||||
use function iterator_to_array;
|
||||
|
||||
final class BlockPosition implements \Stringable{
|
||||
|
||||
public function __construct(
|
||||
public readonly int $x,
|
||||
public readonly int $y,
|
||||
public readonly int $z,
|
||||
private ?World $world //TODO: make this non-nullable (requires Blocks not to reference positions)
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the position's world if valid. Throws an error if the world is unexpectedly invalid.
|
||||
*
|
||||
* @throws AssumptionFailedError
|
||||
*/
|
||||
public function getWorld() : World{
|
||||
if($this->world === null || !$this->world->isLoaded()){
|
||||
throw new AssumptionFailedError("Position world is null or has been unloaded");
|
||||
}
|
||||
|
||||
return $this->world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this object has a valid reference to a loaded world
|
||||
*/
|
||||
public function isValid() : bool{
|
||||
if($this->world !== null && !$this->world->isLoaded()){
|
||||
$this->world = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->world !== null;
|
||||
}
|
||||
|
||||
public function asVector3() : Vector3{
|
||||
return new Vector3($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function center() : Vector3{
|
||||
return new Vector3($this->x + 0.5, $this->y + 0.5, $this->z + 0.5);
|
||||
}
|
||||
|
||||
public static function fromVector3(Vector3 $vector3, World $world) : self{
|
||||
return new self($vector3->getFloorX(), $vector3->getFloorY(), $vector3->getFloorZ(), $world);
|
||||
}
|
||||
|
||||
public function getSide(int $side, int $step = 1) : BlockPosition{
|
||||
$offset = Facing::OFFSET[$side] ?? throw new \InvalidArgumentException("Invalid side $side");
|
||||
|
||||
[$dx, $dy, $dz] = $offset;
|
||||
return new BlockPosition($this->x + ($dx * $step), $this->y + ($dy * $step), $this->z + ($dz * $step), $this->world);
|
||||
}
|
||||
|
||||
public function add(int $x, int $y, int $z) : BlockPosition{
|
||||
return new BlockPosition($this->x + $x, $this->y + $y, $this->z + $z, $this->world);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-return \Generator<int, self, void, void>
|
||||
*/
|
||||
public function getAllSides() : \Generator{
|
||||
foreach(Facing::ALL as $facing){
|
||||
yield $this->getSide($facing);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-return list<self>
|
||||
*/
|
||||
public function getAllSidesArray() : array{
|
||||
return iterator_to_array($this->getAllSides(), preserve_keys: false);
|
||||
}
|
||||
|
||||
public function __toString() : string{
|
||||
$worldName = $this->world?->getFolderName() ?? "???";
|
||||
return "BlockPosition(x=$this->x,y=$this->y,z=$this->z,world={$worldName}";
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ abstract class Button extends Flowable{
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->scheduleDelayedBlockUpdate($this->position, $this->getActivationTime());
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new RedstonePowerOnSound());
|
||||
$world->addSound($this->position->center(), new RedstonePowerOnSound());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -78,7 +78,7 @@ abstract class Button extends Flowable{
|
||||
$this->pressed = false;
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new RedstonePowerOffSound());
|
||||
$world->addSound($this->position->center(), new RedstonePowerOffSound());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,6 @@ class CakeWithCandle extends BaseCake{
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
parent::onConsume($consumer);
|
||||
$this->position->getWorld()->dropItem($this->position->add(0.5, 0.5, 0.5), $this->getCandle()->asItem());
|
||||
$this->position->getWorld()->dropItem($this->position->center(), $this->getCandle()->asItem());
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ class Campfire extends Transparent{
|
||||
if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
|
||||
$item->pop();
|
||||
$this->ignite();
|
||||
$this->position->getWorld()->addSound($this->position, new BlazeShootSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new BlazeShootSound());
|
||||
return true;
|
||||
}elseif($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){
|
||||
if($item instanceof Durable){
|
||||
@ -205,7 +205,7 @@ class Campfire extends Transparent{
|
||||
$ingredient->setCount(1);
|
||||
if(count($this->inventory->addItem($ingredient)) === 0){
|
||||
$item->pop();
|
||||
$this->position->getWorld()->addSound($this->position, new ItemFrameAddItemSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new ItemFrameAddItemSound());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -259,26 +259,26 @@ class Campfire extends Transparent{
|
||||
|
||||
$this->inventory->setItem($slot, VanillaItems::AIR());
|
||||
$this->setCookingTime($slot, 0);
|
||||
$this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $ev->getResult());
|
||||
$this->position->getWorld()->dropItem($this->position->asVector3()->add(0.5, 1, 0.5), $ev->getResult());
|
||||
}
|
||||
}
|
||||
if(count($items) > 0){
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
}
|
||||
if(mt_rand(1, 6) === 1){
|
||||
$this->position->getWorld()->addSound($this->position, $furnaceType->getCookSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), $furnaceType->getCookSound());
|
||||
}
|
||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS);
|
||||
}
|
||||
}
|
||||
|
||||
private function extinguish() : void{
|
||||
$this->position->getWorld()->addSound($this->position, new FireExtinguishSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new FireExtinguishSound());
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLit(false));
|
||||
}
|
||||
|
||||
private function ignite() : void{
|
||||
$this->position->getWorld()->addSound($this->position, new FlintSteelSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new FlintSteelSound());
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLit(true));
|
||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ final class Cauldron extends Transparent{
|
||||
*/
|
||||
private function fill(int $amount, FillableCauldron $result, Item $usedItem, Item $returnedItem, array &$returnedItems) : void{
|
||||
$this->position->getWorld()->setBlock($this->position, $result->setFillLevel($amount));
|
||||
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), $result->getFillSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), $result->getFillSound());
|
||||
|
||||
$usedItem->pop();
|
||||
$returnedItems[] = $returnedItem;
|
||||
@ -95,10 +95,10 @@ final class Cauldron extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){
|
||||
if($this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::WATER){
|
||||
$cauldron = VanillaBlocks::WATER_CAULDRON()->setFillLevel(FillableCauldron::MAX_FILL_LEVEL);
|
||||
$world->setBlock($this->position, $cauldron);
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), $cauldron->getFillSound());
|
||||
$world->addSound($this->position->center(), $cauldron->getFillSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ class CaveVines extends Flowable{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($this->berries){
|
||||
$this->position->getWorld()->dropItem($this->position, $this->asItem());
|
||||
$this->position->getWorld()->addSound($this->position, new GlowBerriesPickSound());
|
||||
$this->position->getWorld()->dropItem($this->position->center(), $this->asItem());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new GlowBerriesPickSound());
|
||||
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setBerries(false));
|
||||
return true;
|
||||
@ -117,7 +117,7 @@ class CaveVines extends Flowable{
|
||||
if($this->age < self::MAX_AGE && mt_rand(1, 10) === 1){
|
||||
$growthPos = $this->position->getSide(Facing::DOWN);
|
||||
$world = $growthPos->getWorld();
|
||||
if($world->isInWorld($growthPos->getFloorX(), $growthPos->getFloorY(), $growthPos->getFloorZ())){
|
||||
if($world->isInWorld($growthPos->x, $growthPos->y, $growthPos->z)){
|
||||
$block = $world->getBlock($growthPos);
|
||||
if($block->getTypeId() === BlockTypeIds::AIR){
|
||||
$newState = VanillaBlocks::CAVE_VINES()
|
||||
|
@ -27,15 +27,12 @@ use pocketmine\block\utils\AgeableTrait;
|
||||
use pocketmine\block\utils\StaticSupportTrait;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\ChorusFlowerDieSound;
|
||||
use pocketmine\world\sound\ChorusFlowerGrowSound;
|
||||
use pocketmine\world\World;
|
||||
use function array_rand;
|
||||
use function min;
|
||||
use function mt_rand;
|
||||
@ -54,24 +51,22 @@ final class ChorusFlower extends Flowable{
|
||||
}
|
||||
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
$position = $block->position;
|
||||
$world = $position->getWorld();
|
||||
$down = $world->getBlock($position->down());
|
||||
$down = $block->getSide(Facing::DOWN);
|
||||
|
||||
if($down->getTypeId() === BlockTypeIds::END_STONE || $down->getTypeId() === BlockTypeIds::CHORUS_PLANT){
|
||||
return true;
|
||||
}
|
||||
|
||||
$plantAdjacent = false;
|
||||
foreach($position->sidesAroundAxis(Axis::Y) as $sidePosition){
|
||||
$block = $world->getBlock($sidePosition);
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
$sideBlock = $block->getSide($side);
|
||||
|
||||
if($block->getTypeId() === BlockTypeIds::CHORUS_PLANT){
|
||||
if($sideBlock->getTypeId() === BlockTypeIds::CHORUS_PLANT){
|
||||
if($plantAdjacent){ //at most one plant may be horizontally adjacent
|
||||
return false;
|
||||
}
|
||||
$plantAdjacent = true;
|
||||
}elseif($block->getTypeId() !== BlockTypeIds::AIR){
|
||||
}elseif($sideBlock->getTypeId() !== BlockTypeIds::AIR){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -92,7 +87,7 @@ final class ChorusFlower extends Flowable{
|
||||
$stemHeight = 0;
|
||||
$endStoneBelow = false;
|
||||
for($yOffset = 0; $yOffset < self::MAX_STEM_HEIGHT; $yOffset++, $stemHeight++){
|
||||
$down = $world->getBlock($this->position->down($yOffset + 1));
|
||||
$down = $this->getSide(Facing::DOWN, $yOffset + 1);
|
||||
|
||||
if($down->getTypeId() !== BlockTypeIds::CHORUS_PLANT){
|
||||
if($down->getTypeId() === BlockTypeIds::END_STONE){
|
||||
@ -105,12 +100,13 @@ final class ChorusFlower extends Flowable{
|
||||
return [$stemHeight, $endStoneBelow];
|
||||
}
|
||||
|
||||
private function allHorizontalBlocksEmpty(World $world, Vector3 $position, ?int $except) : bool{
|
||||
foreach($position->sidesAroundAxis(Axis::Y) as $facing => $sidePosition){
|
||||
private function allHorizontalBlocksEmpty(BlockPosition $position, ?int $except) : bool{
|
||||
$world = $position->getWorld();
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
if($facing === $except){
|
||||
continue;
|
||||
}
|
||||
if($world->getBlock($sidePosition)->getTypeId() !== BlockTypeIds::AIR){
|
||||
if($world->getBlock($position->getSide($facing))->getTypeId() !== BlockTypeIds::AIR){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -121,7 +117,7 @@ final class ChorusFlower extends Flowable{
|
||||
private function canGrowUpwards(int $stemHeight, bool $endStoneBelow) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
$up = $this->position->up();
|
||||
$up = $this->position->getSide(Facing::UP);
|
||||
if(
|
||||
//the space above must be empty and writable
|
||||
!$world->isInWorld($up->x, $up->y, $up->z) ||
|
||||
@ -129,7 +125,7 @@ final class ChorusFlower extends Flowable{
|
||||
(
|
||||
//the space above that must be empty, but doesn't need to be writable
|
||||
$world->isInWorld($up->x, $up->y + 1, $up->z) &&
|
||||
$world->getBlock($up->up())->getTypeId() !== BlockTypeIds::AIR
|
||||
$world->getBlock($up->getSide(Facing::UP))->getTypeId() !== BlockTypeIds::AIR
|
||||
)
|
||||
){
|
||||
return false;
|
||||
@ -145,7 +141,7 @@ final class ChorusFlower extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
return $this->allHorizontalBlocksEmpty($world, $up, null);
|
||||
return $this->allHorizontalBlocksEmpty($up, null);
|
||||
}
|
||||
|
||||
private function grow(int $facing, int $ageChange, ?BlockTransaction $tx) : BlockTransaction{
|
||||
@ -183,8 +179,8 @@ final class ChorusFlower extends Flowable{
|
||||
$sidePosition = $this->position->getSide($facing);
|
||||
if(
|
||||
$world->getBlock($sidePosition)->getTypeId() === BlockTypeIds::AIR &&
|
||||
$world->getBlock($sidePosition->down())->getTypeId() === BlockTypeIds::AIR &&
|
||||
$this->allHorizontalBlocksEmpty($world, $sidePosition, Facing::opposite($facing))
|
||||
$world->getBlock($sidePosition->getSide(Facing::DOWN))->getTypeId() === BlockTypeIds::AIR &&
|
||||
$this->allHorizontalBlocksEmpty($sidePosition, Facing::opposite($facing))
|
||||
){
|
||||
$tx = $this->grow($facing, 1, $tx);
|
||||
}
|
||||
@ -196,10 +192,10 @@ final class ChorusFlower extends Flowable{
|
||||
$ev = new StructureGrowEvent($this, $tx, null);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled() && $tx->apply()){
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ChorusFlowerGrowSound());
|
||||
$world->addSound($this->position->center(), new ChorusFlowerGrowSound());
|
||||
}
|
||||
}else{
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ChorusFlowerDieSound());
|
||||
$world->addSound($this->position->center(), new ChorusFlowerDieSound());
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setAge(self::MAX_AGE));
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\StaticSupportTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use function mt_rand;
|
||||
@ -51,21 +50,18 @@ final class ChorusPlant extends Flowable{
|
||||
}
|
||||
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
$position = $block->position;
|
||||
$world = $position->getWorld();
|
||||
$down = $block->getSide(Facing::DOWN);
|
||||
$verticalAir = $down->getTypeId() === BlockTypeIds::AIR || $block->getSide(Facing::UP)->getTypeId() === BlockTypeIds::AIR;
|
||||
|
||||
$down = $world->getBlock($position->down());
|
||||
$verticalAir = $down->getTypeId() === BlockTypeIds::AIR || $world->getBlock($position->up())->getTypeId() === BlockTypeIds::AIR;
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$sideBlock = $block->getSide($facing);
|
||||
|
||||
foreach($position->sidesAroundAxis(Axis::Y) as $sidePosition){
|
||||
$block = $world->getBlock($sidePosition);
|
||||
|
||||
if($block->getTypeId() === BlockTypeIds::CHORUS_PLANT){
|
||||
if($sideBlock->getTypeId() === BlockTypeIds::CHORUS_PLANT){
|
||||
if(!$verticalAir){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->canBeSupportedBy($block->getSide(Facing::DOWN))){
|
||||
if($this->canBeSupportedBy($sideBlock->getSide(Facing::DOWN))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\CoralTypeTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use function mt_rand;
|
||||
|
||||
final class CoralBlock extends Opaque{
|
||||
@ -39,11 +40,9 @@ final class CoralBlock extends Opaque{
|
||||
|
||||
public function onScheduledUpdate() : void{
|
||||
if(!$this->dead){
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
$hasWater = false;
|
||||
foreach($this->position->sides() as $vector3){
|
||||
if($world->getBlock($vector3) instanceof Water){
|
||||
foreach(Facing::ALL as $facing){
|
||||
if($this->getSide($facing) instanceof Water){
|
||||
$hasWater = true;
|
||||
break;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class Dirt extends Opaque{
|
||||
$item->applyDamage(1);
|
||||
|
||||
$newBlock = $this->dirtType === DirtType::NORMAL ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT();
|
||||
$center = $this->position->add(0.5, 0.5, 0.5);
|
||||
$center = $this->position->center();
|
||||
$world->addSound($center, new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
if($this->dirtType === DirtType::ROOTED){
|
||||
@ -83,7 +83,7 @@ class Dirt extends Opaque{
|
||||
}elseif(($item instanceof Potion || $item instanceof SplashPotion) && $item->getType() === PotionType::WATER){
|
||||
$item->pop();
|
||||
$world->setBlock($this->position, VanillaBlocks::MUD());
|
||||
$world->addSound($this->position, new WaterSplashSound(0.5));
|
||||
$world->addSound($this->position->center(), new WaterSplashSound(0.5));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class Door extends Transparent{
|
||||
}
|
||||
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->addSound($this->position, new DoorSound());
|
||||
$world->addSound($this->position->center(), new DoorSound());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -66,16 +66,17 @@ class DragonEgg extends Transparent implements Fallable{
|
||||
$this->position->z + mt_rand(-16, 16)
|
||||
);
|
||||
if($block instanceof Air){
|
||||
$ev = new BlockTeleportEvent($this, $block->position);
|
||||
//TODO: this needs migrating to BlockPosition, but having World in there presents some issues
|
||||
$ev = new BlockTeleportEvent($this, $block->position->asVector3());
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
break;
|
||||
}
|
||||
|
||||
$blockPos = $ev->getTo();
|
||||
$world->addParticle($this->position, new DragonEggTeleportParticle($this->position->x - $blockPos->x, $this->position->y - $blockPos->y, $this->position->z - $blockPos->z));
|
||||
$world->addParticle($this->position->center(), new DragonEggTeleportParticle($this->position->x - $blockPos->getFloorX(), $this->position->y - $blockPos->getFloorY(), $this->position->z - $blockPos->getFloorZ()));
|
||||
$world->setBlock($this->position, VanillaBlocks::AIR());
|
||||
$world->setBlock($blockPos, $this);
|
||||
$world->setBlockAt($blockPos->getFloorX(), $blockPos->getFloorY(), $blockPos->getFloorZ(), $this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -161,9 +161,9 @@ class Farmland extends Transparent{
|
||||
protected function canHydrate() : bool{
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
$startX = $this->position->getFloorX() - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2);
|
||||
$startY = $this->position->getFloorY();
|
||||
$startZ = $this->position->getFloorZ() - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2);
|
||||
$startX = $this->position->x - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2);
|
||||
$startY = $this->position->y;
|
||||
$startZ = $this->position->z - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2);
|
||||
|
||||
if($this->waterPositionIndex !== self::WATER_POSITION_INDEX_UNKNOWN){
|
||||
$raw = $this->waterPositionIndex;
|
||||
|
@ -111,7 +111,7 @@ class FenceGate extends Transparent{
|
||||
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->addSound($this->position, new DoorSound());
|
||||
$world->addSound($this->position->center(), new DoorSound());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ abstract class FillableCauldron extends Transparent{
|
||||
return;
|
||||
}
|
||||
$this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->fillLevel + $amount));
|
||||
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), $this->getFillSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), $this->getFillSound());
|
||||
|
||||
$usedItem->pop();
|
||||
$returnedItems[] = $returnedItem;
|
||||
@ -94,7 +94,7 @@ abstract class FillableCauldron extends Transparent{
|
||||
}
|
||||
|
||||
$this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->fillLevel - $amount));
|
||||
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), $this->getEmptySound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), $this->getEmptySound());
|
||||
|
||||
$usedItem->pop();
|
||||
$returnedItems[] = $returnedItem;
|
||||
|
@ -161,7 +161,7 @@ class Fire extends BaseFire{
|
||||
$ageDivisor = $this->age + 30;
|
||||
|
||||
for($y = -1; $y <= 4; ++$y){
|
||||
$targetY = $y + (int) $this->position->y;
|
||||
$targetY = $y + $this->position->y;
|
||||
if($targetY < World::Y_MIN || $targetY >= World::Y_MAX){
|
||||
continue;
|
||||
}
|
||||
@ -169,12 +169,12 @@ class Fire extends BaseFire{
|
||||
$randomBound = 100 + ($y > 1 ? ($y - 1) * 100 : 0);
|
||||
|
||||
for($z = -1; $z <= 1; ++$z){
|
||||
$targetZ = $z + (int) $this->position->z;
|
||||
$targetZ = $z + $this->position->z;
|
||||
for($x = -1; $x <= 1; ++$x){
|
||||
if($x === 0 && $y === 0 && $z === 0){
|
||||
continue;
|
||||
}
|
||||
$targetX = $x + (int) $this->position->x;
|
||||
$targetX = $x + $this->position->x;
|
||||
if(!$world->isInWorld($targetX, $targetY, $targetZ)){
|
||||
continue;
|
||||
}
|
||||
@ -190,9 +190,10 @@ class Fire extends BaseFire{
|
||||
//TODO: fire can't spread if it's raining in any horizontally adjacent block, or the current one
|
||||
|
||||
$encouragement = 0;
|
||||
foreach($block->position->sides() as $vector3){
|
||||
if($world->isInWorld($vector3->x, $vector3->y, $vector3->z)){
|
||||
$encouragement = max($encouragement, $world->getBlockAt($vector3->x, $vector3->y, $vector3->z)->getFlameEncouragement());
|
||||
foreach(Facing::ALL as $facing){
|
||||
$sidePos = $block->position->getSide($facing);
|
||||
if($world->isInWorld($sidePos->x, $sidePos->y, $sidePos->z)){
|
||||
$encouragement = max($encouragement, $world->getBlockAt($sidePos->x, $sidePos->y, $sidePos->z)->getFlameEncouragement());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ final class FloorCoralFan extends BaseCoral{
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$playerBlockPos = $player->getPosition()->floor();
|
||||
$directionVector = $blockReplace->position->subtractVector($playerBlockPos)->normalize();
|
||||
$directionVector = $blockReplace->position->asVector3()->subtractVector($playerBlockPos)->normalize();
|
||||
$angle = rad2deg(atan2($directionVector->getZ(), $directionVector->getX()));
|
||||
|
||||
if($angle <= 45 || 315 <= $angle || (135 <= $angle && $angle <= 225)){
|
||||
|
@ -111,7 +111,7 @@ class FlowerPot extends Flowable{
|
||||
$removedItems = $player->getInventory()->addItem(...$removedItems);
|
||||
}
|
||||
foreach($removedItems as $drops){
|
||||
$world->dropItem($this->position->add(0.5, 0.5, 0.5), $drops);
|
||||
$world->dropItem($this->position->center(), $drops);
|
||||
}
|
||||
|
||||
$this->setPlant(null);
|
||||
|
@ -73,7 +73,7 @@ class Furnace extends Opaque{
|
||||
$furnace = $world->getTile($this->position);
|
||||
if($furnace instanceof TileFurnace && $furnace->onUpdate()){
|
||||
if(mt_rand(1, 60) === 1){ //in vanilla this is between 1 and 5 seconds; try to average about 3
|
||||
$world->addSound($this->position, $furnace->getFurnaceType()->getCookSound());
|
||||
$world->addSound($this->position->center(), $furnace->getFurnaceType()->getCookSound());
|
||||
}
|
||||
$world->scheduleDelayedBlockUpdate($this->position, 1); //TODO: check this
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\World;
|
||||
use function count;
|
||||
use function shuffle;
|
||||
|
||||
@ -84,7 +83,8 @@ class GlowLichen extends Transparent{
|
||||
return $result->setFace($spreadFace, true);
|
||||
}
|
||||
|
||||
private function spread(World $world, Vector3 $replacePos, int $spreadFace) : bool{
|
||||
private function spread(BlockPosition $replacePos, int $spreadFace) : bool{
|
||||
$world = $replacePos->getWorld();
|
||||
$supportBlock = $world->getBlock($replacePos->getSide($spreadFace));
|
||||
$supportFace = Facing::opposite($spreadFace);
|
||||
|
||||
@ -117,12 +117,10 @@ class GlowLichen extends Transparent{
|
||||
}
|
||||
|
||||
private function spreadAroundSupport(int $sourceFace) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
$supportPos = $this->position->getSide($sourceFace);
|
||||
foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
|
||||
$replacePos = $supportPos->getSide($spreadFace);
|
||||
if($this->spread($world, $replacePos, Facing::opposite($spreadFace))){
|
||||
if($this->spread($replacePos, Facing::opposite($spreadFace))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -131,11 +129,9 @@ class GlowLichen extends Transparent{
|
||||
}
|
||||
|
||||
private function spreadAdjacentToSupport(int $sourceFace) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
|
||||
$replacePos = $this->position->getSide($spreadFace);
|
||||
if($this->spread($world, $replacePos, $sourceFace)){
|
||||
if($this->spread($replacePos, $sourceFace)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -144,7 +140,7 @@ class GlowLichen extends Transparent{
|
||||
|
||||
private function spreadWithinSelf(int $sourceFace) : bool{
|
||||
foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
|
||||
if(!$this->hasFace($spreadFace) && $this->spread($this->position->getWorld(), $this->position, $spreadFace)){
|
||||
if(!$this->hasFace($spreadFace) && $this->spread($this->position, $spreadFace)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class Grass extends Opaque{
|
||||
$world = $this->position->getWorld();
|
||||
if($item instanceof Fertilizer){
|
||||
$item->pop();
|
||||
TallGrassObject::growGrass($world, $this->position, new Random(mt_rand()), 8, 2);
|
||||
TallGrassObject::growGrass($world, $this->position->center(), new Random(mt_rand()), 8, 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -96,14 +96,14 @@ class Grass extends Opaque{
|
||||
if($item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::FARMLAND();
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
$world->addSound($this->position->center(), new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Shovel){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::GRASS_PATH();
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
$world->addSound($this->position->center(), new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
|
||||
return true;
|
||||
|
@ -135,11 +135,11 @@ class ItemFrame extends Flowable{
|
||||
if($this->framedItem !== null){
|
||||
$this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS;
|
||||
|
||||
$this->position->getWorld()->addSound($this->position, new ItemFrameRotateItemSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new ItemFrameRotateItemSound());
|
||||
}elseif(!$item->isNull()){
|
||||
$this->framedItem = $item->pop();
|
||||
|
||||
$this->position->getWorld()->addSound($this->position, new ItemFrameAddItemSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new ItemFrameAddItemSound());
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
@ -155,8 +155,8 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
$world = $this->position->getWorld();
|
||||
if(Utils::getRandomFloat() <= $this->itemDropChance){
|
||||
$world->dropItem($this->position->add(0.5, 0.5, 0.5), clone $this->framedItem);
|
||||
$world->addSound($this->position, new ItemFrameRemoveItemSound());
|
||||
$world->dropItem($this->position->center(), clone $this->framedItem);
|
||||
$world->addSound($this->position->center(), new ItemFrameRemoveItemSound());
|
||||
}
|
||||
$this->setFramedItem(null);
|
||||
$world->setBlock($this->position, $this);
|
||||
|
@ -61,7 +61,7 @@ class Jukebox extends Opaque{
|
||||
|
||||
public function ejectRecord() : void{
|
||||
if($this->record !== null){
|
||||
$this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $this->record);
|
||||
$this->position->getWorld()->dropItem($this->position->asVector3()->add(0.5, 1, 0.5), $this->record);
|
||||
$this->record = null;
|
||||
$this->stopSound();
|
||||
}
|
||||
@ -76,12 +76,12 @@ class Jukebox extends Opaque{
|
||||
|
||||
public function startSound() : void{
|
||||
if($this->record !== null){
|
||||
$this->position->getWorld()->addSound($this->position, new RecordSound($this->record->getRecordType()));
|
||||
$this->position->getWorld()->addSound($this->position->center(), new RecordSound($this->record->getRecordType()));
|
||||
}
|
||||
}
|
||||
|
||||
public function stopSound() : void{
|
||||
$this->position->getWorld()->addSound($this->position, new RecordStopSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new RecordStopSound());
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
|
@ -51,7 +51,7 @@ class Ladder extends Transparent{
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
if($entity instanceof Living && $entity->getPosition()->floor()->distanceSquared($this->position) < 1){ //entity coordinates must be inside block
|
||||
if($entity instanceof Living && $entity->getPosition()->floor()->distanceSquared($this->position->asVector3()) < 1){ //entity coordinates must be inside block
|
||||
$entity->resetFallDistance();
|
||||
$entity->onGround = true;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class Leaves extends Transparent{
|
||||
* @phpstan-param array<int, true> $visited
|
||||
* @phpstan-param-out array<int, true> $visited
|
||||
*/
|
||||
protected function findLog(Vector3 $pos, array &$visited = [], int $distance = 0) : bool{
|
||||
protected function findLog(BlockPosition $pos, array &$visited = [], int $distance = 0) : bool{
|
||||
$index = World::blockHash($pos->x, $pos->y, $pos->z);
|
||||
if(isset($visited[$index])){
|
||||
return false;
|
||||
|
@ -123,7 +123,7 @@ class Lectern extends Transparent{
|
||||
if($this->book === null && $item instanceof WritableBookBase){
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this->setBook($item));
|
||||
$world->addSound($this->position, new LecternPlaceBookSound());
|
||||
$world->addSound($this->position->center(), new LecternPlaceBookSound());
|
||||
$item->pop();
|
||||
}
|
||||
return true;
|
||||
@ -132,7 +132,7 @@ class Lectern extends Transparent{
|
||||
public function onAttack(Item $item, int $face, ?Player $player = null) : bool{
|
||||
if($this->book !== null){
|
||||
$world = $this->position->getWorld();
|
||||
$world->dropItem($this->position->up(), $this->book);
|
||||
$world->dropItem($this->position->getSide(Facing::UP)->center(), $this->book);
|
||||
$world->setBlock($this->position, $this->setBook(null));
|
||||
}
|
||||
return false;
|
||||
|
@ -95,7 +95,7 @@ class Lever extends Flowable{
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->addSound(
|
||||
$this->position->add(0.5, 0.5, 0.5),
|
||||
$this->position->center(),
|
||||
$this->activated ? new RedstonePowerOnSound() : new RedstonePowerOffSound()
|
||||
);
|
||||
return true;
|
||||
|
@ -165,9 +165,9 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
$vX = $vY = $vZ = 0;
|
||||
|
||||
$x = $this->position->getFloorX();
|
||||
$y = $this->position->getFloorY();
|
||||
$z = $this->position->getFloorZ();
|
||||
$x = $this->position->x;
|
||||
$y = $this->position->y;
|
||||
$z = $this->position->z;
|
||||
|
||||
$decay = $this->getEffectiveFlowDecay($this);
|
||||
|
||||
@ -259,9 +259,9 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
$world = $this->position->getWorld();
|
||||
|
||||
$x = $this->position->getFloorX();
|
||||
$y = $this->position->getFloorY();
|
||||
$z = $this->position->getFloorZ();
|
||||
$x = $this->position->x;
|
||||
$y = $this->position->y;
|
||||
$z = $this->position->z;
|
||||
|
||||
if(!$this->isSource()){
|
||||
$smallestFlowDecay = -100;
|
||||
@ -368,7 +368,7 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
protected function liquidCollide(Block $cause, Block $result) : bool{
|
||||
if(BlockEventHelper::form($this, $result, $cause)){
|
||||
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new FizzSound(2.6 + (Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.8));
|
||||
$this->position->getWorld()->addSound($this->position->center(), new FizzSound(2.6 + (Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.8));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class NetherVines extends Flowable{
|
||||
|
||||
for($i = 1; $i <= $growthAmount; $i++){
|
||||
$growthPos = $pos->getSide($this->growthFace, $i);
|
||||
if(!$world->isInWorld($growthPos->getFloorX(), $growthPos->getFloorY(), $growthPos->getFloorZ()) || !$world->getBlock($growthPos)->canBeReplaced()){
|
||||
if(!$world->isInWorld($growthPos->x, $growthPos->y, $growthPos->z) || !$world->getBlock($growthPos)->canBeReplaced()){
|
||||
break;
|
||||
}
|
||||
$tx->addBlock($growthPos, (clone $top)->setAge(min(++$age, self::MAX_AGE)));
|
||||
|
@ -89,7 +89,7 @@ class PinkPetals extends Flowable{
|
||||
if($this->count < self::MAX_COUNT){
|
||||
$grew = BlockEventHelper::grow($this, (clone $this)->setCount($this->count + 1), $player);
|
||||
}else{
|
||||
$this->position->getWorld()->dropItem($this->position->add(0, 0.5, 0), $this->asItem());
|
||||
$this->position->getWorld()->dropItem($this->position->center(), $this->asItem());
|
||||
$grew = true;
|
||||
}
|
||||
if($grew){
|
||||
|
@ -73,7 +73,7 @@ final class PitcherCrop extends Flowable{
|
||||
|
||||
$tx = new BlockTransaction($this->position->getWorld());
|
||||
$tx->addBlock($this->position, VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(false));
|
||||
$tx->addBlock($this->position->up(), VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(true));
|
||||
$tx->addBlock($this->position->getSide(Facing::UP), VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(true));
|
||||
|
||||
$ev = new StructureGrowEvent($this, $tx, $player);
|
||||
$ev->call();
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\tile\Cauldron as TileCauldron;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemTypeIds;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\CauldronEmptyPotionSound;
|
||||
@ -107,10 +108,10 @@ final class PotionCauldron extends FillableCauldron{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){
|
||||
if($this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::WATER){
|
||||
$cauldron = VanillaBlocks::WATER_CAULDRON()->setFillLevel(FillableCauldron::MAX_FILL_LEVEL);
|
||||
$world->setBlock($this->position, $cauldron);
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), $cauldron->getFillSound());
|
||||
$world->addSound($this->position->center(), $cauldron->getFillSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ abstract class PressurePlate extends Transparent{
|
||||
if($newState !== null){
|
||||
$world->setBlock($this->position, $newState);
|
||||
if($pressedChange !== null){
|
||||
$world->addSound($this->position, $pressedChange ?
|
||||
$world->addSound($this->position->center(), $pressedChange ?
|
||||
new PressurePlateActivateSound($this) :
|
||||
new PressurePlateDeactivateSound($this)
|
||||
);
|
||||
|
@ -38,7 +38,7 @@ class Pumpkin extends Opaque{
|
||||
$item->applyDamage(1);
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, VanillaBlocks::CARVED_PUMPKIN()->setFacing($face));
|
||||
$world->dropItem($this->position->add(0.5, 0.5, 0.5), VanillaItems::PUMPKIN_SEEDS()->setCount(1));
|
||||
$world->dropItem($this->position->center(), VanillaItems::PUMPKIN_SEEDS()->setCount(1));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -81,7 +81,7 @@ class Sapling extends Flowable{
|
||||
|
||||
public function onRandomTick() : void{
|
||||
$world = $this->position->getWorld();
|
||||
if($world->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 && mt_rand(1, 7) === 1){
|
||||
if($world->getFullLightAt($this->position->x, $this->position->y, $this->position->z) >= 8 && mt_rand(1, 7) === 1){
|
||||
if($this->ready){
|
||||
$this->grow(null);
|
||||
}else{
|
||||
@ -94,7 +94,7 @@ class Sapling extends Flowable{
|
||||
private function grow(?Player $player) : bool{
|
||||
$random = new Random(mt_rand());
|
||||
$tree = TreeFactory::get($random, $this->saplingType->getTreeType());
|
||||
$transaction = $tree?->getBlockTransaction($this->position->getWorld(), $this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ(), $random);
|
||||
$transaction = $tree?->getBlockTransaction($this->position->getWorld(), $this->position->x, $this->position->y, $this->position->z, $random);
|
||||
if($transaction === null){
|
||||
return false;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\Position;
|
||||
use function mt_rand;
|
||||
|
||||
class SmallDripleaf extends Transparent{
|
||||
@ -98,9 +97,9 @@ class SmallDripleaf extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
private function canGrowTo(Position $pos) : bool{
|
||||
private function canGrowTo(BlockPosition $pos) : bool{
|
||||
$world = $pos->getWorld();
|
||||
if(!$world->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())){
|
||||
if(!$world->isInWorld($pos->x, $pos->y, $pos->z)){
|
||||
return false;
|
||||
}
|
||||
$block = $world->getBlock($pos);
|
||||
|
@ -32,7 +32,6 @@ use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class Sugarcane extends Flowable{
|
||||
use AgeableTrait;
|
||||
@ -42,16 +41,16 @@ class Sugarcane extends Flowable{
|
||||
|
||||
public const MAX_AGE = 15;
|
||||
|
||||
private function seekToBottom() : Position{
|
||||
private function seekToBottom() : BlockPosition{
|
||||
$world = $this->position->getWorld();
|
||||
$bottom = $this->position;
|
||||
while(($next = $world->getBlock($bottom->down()))->hasSameTypeId($this)){
|
||||
while(($next = $world->getBlock($bottom->getSide(Facing::DOWN)))->hasSameTypeId($this)){
|
||||
$bottom = $next->position;
|
||||
}
|
||||
return $bottom;
|
||||
}
|
||||
|
||||
private function grow(Position $pos, ?Player $player = null) : bool{
|
||||
private function grow(BlockPosition $pos, ?Player $player = null) : bool{
|
||||
$grew = false;
|
||||
$world = $pos->getWorld();
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
|
@ -81,8 +81,9 @@ class SweetBerryBush extends Flowable{
|
||||
}
|
||||
}elseif(($dropAmount = $this->getBerryDropAmount()) > 0){
|
||||
$world->setBlock($this->position, $this->setAge(self::STAGE_BUSH_NO_BERRIES));
|
||||
$world->dropItem($this->position, $this->asItem()->setCount($dropAmount));
|
||||
$world->addSound($this->position, new SweetBerriesPickSound());
|
||||
$posV3 = $this->position->center();
|
||||
$world->dropItem($posV3, $this->asItem()->setCount($dropAmount));
|
||||
$world->addSound($posV3, new SweetBerriesPickSound());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -100,7 +100,7 @@ class TNT extends Opaque{
|
||||
|
||||
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
|
||||
|
||||
$tnt = new PrimedTNT(Location::fromObject($this->position->add(0.5, 0, 0.5), $world));
|
||||
$tnt = new PrimedTNT(Location::fromObject($this->position->asVector3()->add(0.5, 0, 0.5), $world));
|
||||
$tnt->setFuse($fuse);
|
||||
$tnt->setWorksUnderwater($this->worksUnderwater);
|
||||
$tnt->setMotion(new Vector3(-sin($mot) * 0.02, 0.2, -cos($mot) * 0.02));
|
||||
|
@ -88,7 +88,7 @@ class Trapdoor extends Transparent{
|
||||
$this->open = !$this->open;
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->addSound($this->position, new DoorSound());
|
||||
$world->addSound($this->position->center(), new DoorSound());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -783,8 +783,8 @@ use function strtolower;
|
||||
* @method static Water WATER()
|
||||
* @method static WaterCauldron WATER_CAULDRON()
|
||||
* @method static NetherVines WEEPING_VINES()
|
||||
* @method static WeightedPressurePlateHeavy WEIGHTED_PRESSURE_PLATE_HEAVY()
|
||||
* @method static WeightedPressurePlateLight WEIGHTED_PRESSURE_PLATE_LIGHT()
|
||||
* @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_HEAVY()
|
||||
* @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_LIGHT()
|
||||
* @method static Wheat WHEAT()
|
||||
* @method static Flower WHITE_TULIP()
|
||||
* @method static WitherRose WITHER_ROSE()
|
||||
@ -1180,14 +1180,14 @@ final class VanillaBlocks{
|
||||
self::register("lily_pad", fn(BID $id) => new WaterLily($id, "Lily Pad", new Info(BreakInfo::instant())));
|
||||
|
||||
$weightedPressurePlateBreakInfo = new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD));
|
||||
self::register("weighted_pressure_plate_heavy", fn(BID $id) => new WeightedPressurePlateHeavy(
|
||||
self::register("weighted_pressure_plate_heavy", fn(BID $id) => new WeightedPressurePlate(
|
||||
$id,
|
||||
"Weighted Pressure Plate Heavy",
|
||||
$weightedPressurePlateBreakInfo,
|
||||
deactivationDelayTicks: 10,
|
||||
signalStrengthFactor: 0.1
|
||||
));
|
||||
self::register("weighted_pressure_plate_light", fn(BID $id) => new WeightedPressurePlateLight(
|
||||
self::register("weighted_pressure_plate_light", fn(BID $id) => new WeightedPressurePlate(
|
||||
$id,
|
||||
"Weighted Pressure Plate Light",
|
||||
$weightedPressurePlateBreakInfo,
|
||||
|
@ -36,6 +36,7 @@ use pocketmine\item\Potion;
|
||||
use pocketmine\item\PotionType;
|
||||
use pocketmine\item\SplashPotion;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\CauldronAddDyeSound;
|
||||
@ -119,7 +120,7 @@ final class WaterCauldron extends FillableCauldron{
|
||||
}) !== null && ($newColor = $dyeColor->getRgbValue())->toRGBA() !== $this->customWaterColor?->toRGBA()
|
||||
){
|
||||
$world->setBlock($this->position, $this->setCustomWaterColor($this->customWaterColor === null ? $newColor : Color::mix($this->customWaterColor, $newColor)));
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronAddDyeSound());
|
||||
$world->addSound($this->position->center(), new CauldronAddDyeSound());
|
||||
|
||||
$item->pop();
|
||||
}elseif($item instanceof Potion || $item instanceof SplashPotion){ //TODO: lingering potion
|
||||
@ -139,12 +140,12 @@ final class WaterCauldron extends FillableCauldron{
|
||||
} && $item->getCustomColor()?->toRGBA() !== $this->customWaterColor->toRGBA()){
|
||||
$item->setCustomColor($this->customWaterColor);
|
||||
$world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::DYE_ARMOR_USE_AMOUNT));
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronDyeItemSound());
|
||||
$world->addSound($this->position->center(), new CauldronDyeItemSound());
|
||||
}
|
||||
}elseif($item->getCustomColor() !== null){
|
||||
$item->clearCustomColor();
|
||||
$world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::CLEAN_ARMOR_USE_AMOUNT));
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronCleanItemSound());
|
||||
$world->addSound($this->position->center(), new CauldronCleanItemSound());
|
||||
}
|
||||
}elseif($item instanceof Banner){
|
||||
$patterns = $item->getPatterns();
|
||||
@ -153,7 +154,7 @@ final class WaterCauldron extends FillableCauldron{
|
||||
$item->setPatterns($patterns);
|
||||
|
||||
$world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::CLEAN_BANNER_USE_AMOUNT));
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronCleanItemSound());
|
||||
$world->addSound($this->position->center(), new CauldronCleanItemSound());
|
||||
}
|
||||
}elseif(ItemTypeIds::toBlockTypeId($item->getTypeId()) === BlockTypeIds::DYED_SHULKER_BOX){
|
||||
if($this->customWaterColor === null){
|
||||
@ -164,7 +165,7 @@ final class WaterCauldron extends FillableCauldron{
|
||||
$returnedItems[] = $newItem;
|
||||
|
||||
$world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::CLEAN_SHULKER_BOX_USE_AMOUNT));
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronCleanItemSound());
|
||||
$world->addSound($this->position->center(), new CauldronCleanItemSound());
|
||||
}
|
||||
}else{
|
||||
match($item->getTypeId()){
|
||||
@ -195,13 +196,13 @@ final class WaterCauldron extends FillableCauldron{
|
||||
public function onNearbyBlockChange() : void{
|
||||
$hasCustomWaterColor = $this->customWaterColor !== null;
|
||||
if($this->getFillLevel() < self::MAX_FILL_LEVEL || $hasCustomWaterColor){
|
||||
$world = $this->position->getWorld();
|
||||
if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){
|
||||
if($this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::WATER){
|
||||
if($hasCustomWaterColor){
|
||||
//TODO: particles
|
||||
}
|
||||
$world = $this->position->getWorld();
|
||||
$world->setBlock($this->position, $this->setCustomWaterColor(null)->setFillLevel(FillableCauldron::MAX_FILL_LEVEL));
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), $this->getFillSound());
|
||||
$world->addSound($this->position->center(), $this->getFillSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class WeightedPressurePlateHeavy extends WeightedPressurePlate{
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class WeightedPressurePlateLight extends WeightedPressurePlate{
|
||||
|
||||
}
|
@ -67,7 +67,7 @@ class Wood extends Opaque{
|
||||
$item->applyDamage(1);
|
||||
$this->stripped = true;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
$this->position->getWorld()->addSound($this->position, new ItemUseOnBlockSound($this));
|
||||
$this->position->getWorld()->addSound($this->position->center(), new ItemUseOnBlockSound($this));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -50,7 +50,7 @@ trait AnimatedBlockInventoryTrait{
|
||||
if($this->holder->isValid() && $this->getViewerCount() === 1){
|
||||
//TODO: this crap really shouldn't be managed by the inventory
|
||||
$this->animateBlock(true);
|
||||
$this->holder->getWorld()->addSound($this->holder->add(0.5, 0.5, 0.5), $this->getOpenSound());
|
||||
$this->holder->getWorld()->addSound($this->holder->center(), $this->getOpenSound());
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ trait AnimatedBlockInventoryTrait{
|
||||
if($this->holder->isValid() && $this->getViewerCount() === 1){
|
||||
//TODO: this crap really shouldn't be managed by the inventory
|
||||
$this->animateBlock(false);
|
||||
$this->holder->getWorld()->addSound($this->holder->add(0.5, 0.5, 0.5), $this->getCloseSound());
|
||||
$this->holder->getWorld()->addSound($this->holder->center(), $this->getCloseSound());
|
||||
}
|
||||
parent::onClose($who);
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class AnvilInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
@ -33,7 +33,7 @@ class AnvilInventory extends SimpleInventory implements BlockInventory, Temporar
|
||||
public const SLOT_INPUT = 0;
|
||||
public const SLOT_MATERIAL = 1;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(2);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\Barrel;
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\sound\BarrelCloseSound;
|
||||
use pocketmine\world\sound\BarrelOpenSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
@ -33,7 +33,7 @@ use pocketmine\world\sound\Sound;
|
||||
class BarrelInventory extends SimpleInventory implements BlockInventory{
|
||||
use AnimatedBlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(27);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\block\BlockPosition;
|
||||
|
||||
interface BlockInventory{
|
||||
public function getHolder() : Position;
|
||||
public function getHolder() : BlockPosition;
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\block\BlockPosition;
|
||||
|
||||
trait BlockInventoryTrait{
|
||||
protected Position $holder;
|
||||
protected BlockPosition $holder;
|
||||
|
||||
public function getHolder() : Position{
|
||||
public function getHolder() : BlockPosition{
|
||||
return $this->holder;
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class BrewingStandInventory extends SimpleInventory implements BlockInventory{
|
||||
use BlockInventoryTrait;
|
||||
@ -35,7 +35,7 @@ class BrewingStandInventory extends SimpleInventory implements BlockInventory{
|
||||
public const SLOT_BOTTLE_RIGHT = 3;
|
||||
public const SLOT_FUEL = 4;
|
||||
|
||||
public function __construct(Position $holder, int $size = 5){
|
||||
public function __construct(BlockPosition $holder, int $size = 5){
|
||||
$this->holder = $holder;
|
||||
parent::__construct($size);
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class CampfireInventory extends SimpleInventory implements BlockInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(4);
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
final class CartographyTableInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(2);
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition;
|
||||
use pocketmine\world\sound\ChestCloseSound;
|
||||
use pocketmine\world\sound\ChestOpenSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
@ -34,7 +34,7 @@ use pocketmine\world\sound\Sound;
|
||||
class ChestInventory extends SimpleInventory implements BlockInventory{
|
||||
use AnimatedBlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(27);
|
||||
}
|
||||
@ -51,6 +51,6 @@ class ChestInventory extends SimpleInventory implements BlockInventory{
|
||||
$holder = $this->getHolder();
|
||||
|
||||
//event ID is always 1 for a chest
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0));
|
||||
$holder->getWorld()->broadcastPacketOnBlock($holder, BlockEventPacket::create(new ProtocolBlockPosition($holder->x, $holder->y, $holder->z), 1, $isOpen ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\crafting\CraftingGrid;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
final class CraftingTableInventory extends CraftingGrid implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(CraftingGrid::SIZE_BIG);
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\event\player\PlayerEnchantingOptionsRequestEvent;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\item\enchantment\EnchantingHelper as Helper;
|
||||
use pocketmine\item\enchantment\EnchantingOption;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\world\Position;
|
||||
use function array_values;
|
||||
use function count;
|
||||
|
||||
@ -45,7 +45,7 @@ class EnchantInventory extends SimpleInventory implements BlockInventory, Tempor
|
||||
*/
|
||||
private array $options = [];
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(2);
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\tile\EnderChest;
|
||||
use pocketmine\inventory\DelegateInventory;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\PlayerEnderInventory;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\sound\EnderChestCloseSound;
|
||||
use pocketmine\world\sound\EnderChestOpenSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
@ -44,7 +44,7 @@ class EnderChestInventory extends DelegateInventory implements BlockInventory{
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
Position $holder,
|
||||
BlockPosition $holder,
|
||||
private PlayerEnderInventory $inventory
|
||||
){
|
||||
parent::__construct($inventory);
|
||||
@ -75,7 +75,7 @@ class EnderChestInventory extends DelegateInventory implements BlockInventory{
|
||||
$holder = $this->getHolder();
|
||||
|
||||
//event ID is always 1 for a chest
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0));
|
||||
$holder->getWorld()->broadcastPacketOnBlock($holder, BlockEventPacket::create(new ProtocolBlockPosition($holder->x, $holder->y, $holder->z), 1, $isOpen ? 1 : 0));
|
||||
}
|
||||
|
||||
public function onClose(Player $who) : void{
|
||||
|
@ -23,10 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\crafting\FurnaceType;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class FurnaceInventory extends SimpleInventory implements BlockInventory{
|
||||
use BlockInventoryTrait;
|
||||
@ -36,7 +36,7 @@ class FurnaceInventory extends SimpleInventory implements BlockInventory{
|
||||
public const SLOT_RESULT = 2;
|
||||
|
||||
public function __construct(
|
||||
Position $holder,
|
||||
BlockPosition $holder,
|
||||
private FurnaceType $furnaceType
|
||||
){
|
||||
$this->holder = $holder;
|
||||
|
@ -23,13 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class HopperInventory extends SimpleInventory implements BlockInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder, int $size = 5){
|
||||
public function __construct(BlockPosition $holder, int $size = 5){
|
||||
$this->holder = $holder;
|
||||
parent::__construct($size);
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
final class LoomInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
@ -34,7 +34,7 @@ final class LoomInventory extends SimpleInventory implements BlockInventory, Tem
|
||||
public const SLOT_DYE = 1;
|
||||
public const SLOT_PATTERN = 2;
|
||||
|
||||
public function __construct(Position $holder, int $size = 3){
|
||||
public function __construct(BlockPosition $holder, int $size = 3){
|
||||
$this->holder = $holder;
|
||||
parent::__construct($size);
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\BlockTypeIds;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemTypeIds;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition;
|
||||
use pocketmine\world\sound\ShulkerBoxCloseSound;
|
||||
use pocketmine\world\sound\ShulkerBoxOpenSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
@ -37,7 +37,7 @@ use pocketmine\world\sound\Sound;
|
||||
class ShulkerBoxInventory extends SimpleInventory implements BlockInventory{
|
||||
use AnimatedBlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(27);
|
||||
}
|
||||
@ -62,6 +62,6 @@ class ShulkerBoxInventory extends SimpleInventory implements BlockInventory{
|
||||
$holder = $this->getHolder();
|
||||
|
||||
//event ID is always 1 for a chest
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0));
|
||||
$holder->getWorld()->broadcastPacketOnBlock($holder, BlockEventPacket::create(new ProtocolBlockPosition($holder->x, $holder->y, $holder->z), 1, $isOpen ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
final class SmithingTableInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(3);
|
||||
}
|
||||
|
@ -23,16 +23,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class StonecutterInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public const SLOT_INPUT = 0;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
public function __construct(BlockPosition $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(1);
|
||||
}
|
||||
|
@ -23,10 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\inventory\BarrelInventory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Barrel extends Spawnable implements Container, Nameable{
|
||||
use NameableTrait;
|
||||
@ -34,8 +33,8 @@ class Barrel extends Spawnable implements Container, Nameable{
|
||||
|
||||
protected BarrelInventory $inventory;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new BarrelInventory($this->position);
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,6 @@ final class Bell extends Spawnable{
|
||||
default => throw new AssumptionFailedError("Unreachable")
|
||||
});
|
||||
$nbt->setInt(self::TAG_TICKS, 0);
|
||||
return BlockActorDataPacket::create(BlockPosition::fromVector3($this->position), new CacheableNbt($nbt));
|
||||
return BlockActorDataPacket::create(new BlockPosition($this->position->x, $this->position->y, $this->position->z), new CacheableNbt($nbt));
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\inventory\BrewingStandInventory;
|
||||
use pocketmine\crafting\BrewingRecipe;
|
||||
use pocketmine\event\block\BrewingFuelUseEvent;
|
||||
@ -31,12 +32,10 @@ use pocketmine\inventory\CallbackInventoryListener;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\PotionFinishBrewingSound;
|
||||
use pocketmine\world\World;
|
||||
use function array_map;
|
||||
use function count;
|
||||
|
||||
@ -60,11 +59,11 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
||||
private int $maxFuelTime = 0;
|
||||
private int $remainingFuelTime = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new BrewingStandInventory($this->position);
|
||||
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(static function(Inventory $unused) use ($world, $pos) : void{
|
||||
$world->scheduleDelayedBlockUpdate($pos, 1);
|
||||
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(static function(Inventory $unused) use ($position) : void{
|
||||
$position->getWorld()->scheduleDelayedBlockUpdate($position, 1);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -215,7 +214,7 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
|
||||
if($anythingBrewed){
|
||||
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new PotionFinishBrewingSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new PotionFinishBrewingSound());
|
||||
}
|
||||
|
||||
$ingredient->pop();
|
||||
|
@ -23,16 +23,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\Campfire as BlockCampfire;
|
||||
use pocketmine\block\inventory\CampfireInventory;
|
||||
use pocketmine\inventory\CallbackInventoryListener;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Campfire extends Spawnable implements Container{
|
||||
use ContainerTrait;
|
||||
@ -51,14 +50,15 @@ class Campfire extends Spawnable implements Container{
|
||||
/** @var array<int, int> */
|
||||
private array $cookingTimes = [];
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new CampfireInventory($this->position);
|
||||
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(
|
||||
static function(Inventory $unused) use ($world, $pos) : void{
|
||||
$block = $world->getBlock($pos);
|
||||
static function(Inventory $unused) use ($position) : void{
|
||||
$world = $position->getWorld();
|
||||
$block = $world->getBlock($position);
|
||||
if($block instanceof BlockCampfire){
|
||||
$world->setBlock($pos, $block);
|
||||
$world->setBlock($position, $block);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
@ -23,13 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\inventory\ChestInventory;
|
||||
use pocketmine\block\inventory\DoubleChestInventory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\World;
|
||||
use function abs;
|
||||
|
||||
class Chest extends Spawnable implements Container, Nameable{
|
||||
@ -50,8 +50,8 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
private ?int $pairX = null;
|
||||
private ?int $pairZ = null;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new ChestInventory($this->position);
|
||||
}
|
||||
|
||||
|
@ -23,18 +23,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\utils\ChiseledBookshelfSlot;
|
||||
use pocketmine\data\bedrock\item\SavedItemData;
|
||||
use pocketmine\data\bedrock\item\SavedItemStackData;
|
||||
use pocketmine\data\SavedDataLoadingException;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\world\World;
|
||||
use function count;
|
||||
|
||||
class ChiseledBookshelf extends Tile implements Container{
|
||||
@ -46,8 +45,8 @@ class ChiseledBookshelf extends Tile implements Container{
|
||||
|
||||
private ?ChiseledBookshelfSlot $lastInteractedSlot = null;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new SimpleInventory(count(ChiseledBookshelfSlot::cases()));
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\data\bedrock\item\SavedItemStackData;
|
||||
use pocketmine\data\SavedDataLoadingException;
|
||||
use pocketmine\inventory\Inventory;
|
||||
@ -31,7 +32,6 @@ use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
/**
|
||||
* This trait implements most methods in the {@link Container} interface. It should only be used by Tiles.
|
||||
@ -90,9 +90,9 @@ trait ContainerTrait{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Position::asPosition()
|
||||
* @see Tile::getPosition()
|
||||
*/
|
||||
abstract protected function getPosition() : Position;
|
||||
abstract protected function getPosition() : BlockPosition;
|
||||
|
||||
/**
|
||||
* @see Tile::onBlockDestroyedHook()
|
||||
@ -102,7 +102,7 @@ trait ContainerTrait{
|
||||
$pos = $this->getPosition();
|
||||
|
||||
$world = $pos->getWorld();
|
||||
$dropPos = $pos->add(0.5, 0.5, 0.5);
|
||||
$dropPos = $pos->center();
|
||||
foreach($inv->getContents() as $k => $item){
|
||||
$world->dropItem($dropPos, $item);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\Furnace as BlockFurnace;
|
||||
use pocketmine\block\inventory\FurnaceInventory;
|
||||
use pocketmine\crafting\FurnaceRecipe;
|
||||
@ -32,11 +33,9 @@ use pocketmine\event\inventory\FurnaceSmeltEvent;
|
||||
use pocketmine\inventory\CallbackInventoryListener;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\World;
|
||||
use function array_map;
|
||||
use function max;
|
||||
|
||||
@ -53,12 +52,12 @@ abstract class Furnace extends Spawnable implements Container, Nameable{
|
||||
private int $cookTime = 0;
|
||||
private int $maxFuelTime = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new FurnaceInventory($this->position, $this->getFurnaceType());
|
||||
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(
|
||||
static function(Inventory $unused) use ($world, $pos) : void{
|
||||
$world->scheduleDelayedBlockUpdate($pos, 1);
|
||||
static function(Inventory $unused) use ($position) : void{
|
||||
$position->getWorld()->scheduleDelayedBlockUpdate($position, 1);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -23,10 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\inventory\HopperInventory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Hopper extends Spawnable implements Container, Nameable{
|
||||
|
||||
@ -38,8 +37,8 @@ class Hopper extends Spawnable implements Container, Nameable{
|
||||
private HopperInventory $inventory;
|
||||
private int $transferCooldown = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new HopperInventory($this->position);
|
||||
}
|
||||
|
||||
|
@ -23,13 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||
use pocketmine\world\World;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@ -44,9 +43,9 @@ class ItemFrame extends Spawnable{
|
||||
private int $itemRotation = 0;
|
||||
private float $itemDropChance = 1.0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
public function __construct(BlockPosition $position){
|
||||
$this->item = VanillaItems::AIR();
|
||||
parent::__construct($world, $pos);
|
||||
parent::__construct($position);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
|
@ -65,6 +65,6 @@ class Jukebox extends Spawnable{
|
||||
}
|
||||
|
||||
protected function onBlockDestroyedHook() : void{
|
||||
$this->position->getWorld()->addSound($this->position, new RecordStopSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new RecordStopSound());
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\inventory\ShulkerBoxInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class ShulkerBox extends Spawnable implements Container, Nameable{
|
||||
use NameableTrait {
|
||||
@ -42,8 +41,8 @@ class ShulkerBox extends Spawnable implements Container, Nameable{
|
||||
|
||||
protected ShulkerBoxInventory $inventory;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
public function __construct(BlockPosition $position){
|
||||
parent::__construct($position);
|
||||
$this->inventory = new ShulkerBoxInventory($this->position);
|
||||
}
|
||||
|
||||
|
@ -23,15 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\block\utils\SignText;
|
||||
use pocketmine\color\Color;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\world\World;
|
||||
use function array_pad;
|
||||
use function array_slice;
|
||||
use function explode;
|
||||
@ -72,9 +71,9 @@ class Sign extends Spawnable{
|
||||
|
||||
protected ?int $editorEntityRuntimeId = null;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
public function __construct(BlockPosition $position){
|
||||
$this->text = new SignText();
|
||||
parent::__construct($world, $pos);
|
||||
parent::__construct($position);
|
||||
}
|
||||
|
||||
private function readTextTag(CompoundTag $nbt, bool $lightingBugResolved) : void{
|
||||
|
@ -28,15 +28,13 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\timings\TimingsHandler;
|
||||
use pocketmine\VersionInfo;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\World;
|
||||
use function get_class;
|
||||
|
||||
abstract class Tile{
|
||||
@ -46,12 +44,12 @@ abstract class Tile{
|
||||
public const TAG_Y = "y";
|
||||
public const TAG_Z = "z";
|
||||
|
||||
protected Position $position;
|
||||
public bool $closed = false;
|
||||
protected TimingsHandler $timings;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->position = Position::fromObject($pos, $world);
|
||||
public function __construct(
|
||||
protected BlockPosition $position,
|
||||
){
|
||||
$this->timings = Timings::getTileEntityTimings($this);
|
||||
}
|
||||
|
||||
@ -70,9 +68,9 @@ abstract class Tile{
|
||||
public function saveNBT() : CompoundTag{
|
||||
$nbt = CompoundTag::create()
|
||||
->setString(self::TAG_ID, TileFactory::getInstance()->getSaveId(get_class($this)))
|
||||
->setInt(self::TAG_X, $this->position->getFloorX())
|
||||
->setInt(self::TAG_Y, $this->position->getFloorY())
|
||||
->setInt(self::TAG_Z, $this->position->getFloorZ())
|
||||
->setInt(self::TAG_X, $this->position->x)
|
||||
->setInt(self::TAG_Y, $this->position->y)
|
||||
->setInt(self::TAG_Z, $this->position->z)
|
||||
->setLong(VersionInfo::TAG_WORLD_DATA_VERSION, VersionInfo::WORLD_DATA_VERSION);
|
||||
$this->writeSaveData($nbt);
|
||||
|
||||
@ -99,7 +97,7 @@ abstract class Tile{
|
||||
return $this->position->getWorld()->getBlock($this->position);
|
||||
}
|
||||
|
||||
public function getPosition() : Position{
|
||||
public function getPosition() : BlockPosition{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\BlockPosition;
|
||||
use pocketmine\data\SavedDataLoadingException;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
@ -130,7 +130,7 @@ final class TileFactory{
|
||||
* @var Tile $tile
|
||||
* @see Tile::__construct()
|
||||
*/
|
||||
$tile = new $class($world, new Vector3($nbt->getInt(Tile::TAG_X), $nbt->getInt(Tile::TAG_Y), $nbt->getInt(Tile::TAG_Z)));
|
||||
$tile = new $class(new BlockPosition($nbt->getInt(Tile::TAG_X), $nbt->getInt(Tile::TAG_Y), $nbt->getInt(Tile::TAG_Z), $world));
|
||||
$tile->readSaveData($nbt);
|
||||
}catch(NbtException $e){
|
||||
throw new SavedDataLoadingException($e->getMessage(), 0, $e);
|
||||
|
@ -34,7 +34,7 @@ trait AmethystTrait{
|
||||
* @see Block::onProjectileHit()
|
||||
*/
|
||||
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
||||
$this->position->getWorld()->addSound($this->position, new AmethystBlockChimeSound());
|
||||
$this->position->getWorld()->addSound($this->position, new BlockPunchSound($this));
|
||||
$this->position->getWorld()->addSound($this->position->center(), new AmethystBlockChimeSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new BlockPunchSound($this));
|
||||
}
|
||||
}
|
||||
|
@ -23,54 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\utils\LegacyEnumShimTrait;
|
||||
|
||||
/**
|
||||
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||
* These are retained for backwards compatibility only.
|
||||
*
|
||||
* @method static BannerPatternType BORDER()
|
||||
* @method static BannerPatternType BRICKS()
|
||||
* @method static BannerPatternType CIRCLE()
|
||||
* @method static BannerPatternType CREEPER()
|
||||
* @method static BannerPatternType CROSS()
|
||||
* @method static BannerPatternType CURLY_BORDER()
|
||||
* @method static BannerPatternType DIAGONAL_LEFT()
|
||||
* @method static BannerPatternType DIAGONAL_RIGHT()
|
||||
* @method static BannerPatternType DIAGONAL_UP_LEFT()
|
||||
* @method static BannerPatternType DIAGONAL_UP_RIGHT()
|
||||
* @method static BannerPatternType FLOWER()
|
||||
* @method static BannerPatternType GRADIENT()
|
||||
* @method static BannerPatternType GRADIENT_UP()
|
||||
* @method static BannerPatternType HALF_HORIZONTAL()
|
||||
* @method static BannerPatternType HALF_HORIZONTAL_BOTTOM()
|
||||
* @method static BannerPatternType HALF_VERTICAL()
|
||||
* @method static BannerPatternType HALF_VERTICAL_RIGHT()
|
||||
* @method static BannerPatternType MOJANG()
|
||||
* @method static BannerPatternType RHOMBUS()
|
||||
* @method static BannerPatternType SKULL()
|
||||
* @method static BannerPatternType SMALL_STRIPES()
|
||||
* @method static BannerPatternType SQUARE_BOTTOM_LEFT()
|
||||
* @method static BannerPatternType SQUARE_BOTTOM_RIGHT()
|
||||
* @method static BannerPatternType SQUARE_TOP_LEFT()
|
||||
* @method static BannerPatternType SQUARE_TOP_RIGHT()
|
||||
* @method static BannerPatternType STRAIGHT_CROSS()
|
||||
* @method static BannerPatternType STRIPE_BOTTOM()
|
||||
* @method static BannerPatternType STRIPE_CENTER()
|
||||
* @method static BannerPatternType STRIPE_DOWNLEFT()
|
||||
* @method static BannerPatternType STRIPE_DOWNRIGHT()
|
||||
* @method static BannerPatternType STRIPE_LEFT()
|
||||
* @method static BannerPatternType STRIPE_MIDDLE()
|
||||
* @method static BannerPatternType STRIPE_RIGHT()
|
||||
* @method static BannerPatternType STRIPE_TOP()
|
||||
* @method static BannerPatternType TRIANGLES_BOTTOM()
|
||||
* @method static BannerPatternType TRIANGLES_TOP()
|
||||
* @method static BannerPatternType TRIANGLE_BOTTOM()
|
||||
* @method static BannerPatternType TRIANGLE_TOP()
|
||||
*/
|
||||
enum BannerPatternType{
|
||||
use LegacyEnumShimTrait;
|
||||
|
||||
case BORDER;
|
||||
case BRICKS;
|
||||
case CIRCLE;
|
||||
|
@ -23,20 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\utils\LegacyEnumShimTrait;
|
||||
|
||||
/**
|
||||
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||
* These are retained for backwards compatibility only.
|
||||
*
|
||||
* @method static BellAttachmentType CEILING()
|
||||
* @method static BellAttachmentType FLOOR()
|
||||
* @method static BellAttachmentType ONE_WALL()
|
||||
* @method static BellAttachmentType TWO_WALLS()
|
||||
*/
|
||||
enum BellAttachmentType{
|
||||
use LegacyEnumShimTrait;
|
||||
|
||||
case CEILING;
|
||||
case FLOOR;
|
||||
case ONE_WALL;
|
||||
|
@ -24,19 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\block\inventory\BrewingStandInventory;
|
||||
use pocketmine\utils\LegacyEnumShimTrait;
|
||||
|
||||
/**
|
||||
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||
* These are retained for backwards compatibility only.
|
||||
*
|
||||
* @method static BrewingStandSlot EAST()
|
||||
* @method static BrewingStandSlot NORTHWEST()
|
||||
* @method static BrewingStandSlot SOUTHWEST()
|
||||
*/
|
||||
enum BrewingStandSlot{
|
||||
use LegacyEnumShimTrait;
|
||||
|
||||
case EAST;
|
||||
case NORTHWEST;
|
||||
case SOUTHWEST;
|
||||
|
@ -54,9 +54,9 @@ trait CandleTrait{
|
||||
}elseif($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
|
||||
$item->pop();
|
||||
//TODO: not sure if this is intentional, but it's what Bedrock currently does as of 1.20.10
|
||||
$this->position->getWorld()->addSound($this->position, new BlazeShootSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new BlazeShootSound());
|
||||
}
|
||||
$this->position->getWorld()->addSound($this->position, new FlintSteelSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new FlintSteelSound());
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLit(true));
|
||||
|
||||
return true;
|
||||
@ -65,7 +65,7 @@ trait CandleTrait{
|
||||
if(!$this->lit){
|
||||
return true;
|
||||
}
|
||||
$this->position->getWorld()->addSound($this->position, new FireExtinguishSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new FireExtinguishSound());
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLit(false));
|
||||
|
||||
return true;
|
||||
|
@ -23,20 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\utils\LegacyEnumShimTrait;
|
||||
|
||||
/**
|
||||
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||
* These are retained for backwards compatibility only.
|
||||
*
|
||||
* @method static CopperOxidation EXPOSED()
|
||||
* @method static CopperOxidation NONE()
|
||||
* @method static CopperOxidation OXIDIZED()
|
||||
* @method static CopperOxidation WEATHERED()
|
||||
*/
|
||||
enum CopperOxidation : int{
|
||||
use LegacyEnumShimTrait;
|
||||
|
||||
case NONE = 0;
|
||||
case EXPOSED = 1;
|
||||
case WEATHERED = 2;
|
||||
|
@ -63,7 +63,7 @@ trait CopperTrait{
|
||||
$this->waxed = true;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
//TODO: orange particles are supposed to appear when applying wax
|
||||
$this->position->getWorld()->addSound($this->position, new CopperWaxApplySound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new CopperWaxApplySound());
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
@ -73,7 +73,7 @@ trait CopperTrait{
|
||||
$this->waxed = false;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
//TODO: white particles are supposed to appear when removing wax
|
||||
$this->position->getWorld()->addSound($this->position, new CopperWaxRemoveSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new CopperWaxRemoveSound());
|
||||
$item->applyDamage(1);
|
||||
return true;
|
||||
}
|
||||
@ -83,7 +83,7 @@ trait CopperTrait{
|
||||
$this->oxidation = $previousOxidation;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
//TODO: turquoise particles are supposed to appear when removing oxidation
|
||||
$this->position->getWorld()->addSound($this->position, new ScrapeSound());
|
||||
$this->position->getWorld()->addSound($this->position->center(), new ScrapeSound());
|
||||
$item->applyDamage(1);
|
||||
return true;
|
||||
}
|
||||
|
@ -23,21 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\utils\LegacyEnumShimTrait;
|
||||
|
||||
/**
|
||||
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||
* These are retained for backwards compatibility only.
|
||||
*
|
||||
* @method static CoralType BRAIN()
|
||||
* @method static CoralType BUBBLE()
|
||||
* @method static CoralType FIRE()
|
||||
* @method static CoralType HORN()
|
||||
* @method static CoralType TUBE()
|
||||
*/
|
||||
enum CoralType{
|
||||
use LegacyEnumShimTrait;
|
||||
|
||||
case TUBE;
|
||||
case BRAIN;
|
||||
case BUBBLE;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user