mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-10 20:08:01 +00:00
partial sea pickle implementation
This commit is contained in:
parent
3c283aa700
commit
a8fa8572e1
@ -227,6 +227,7 @@ class BlockFactory{
|
|||||||
self::register(new SandstoneStairs(new BID(Block::RED_SANDSTONE_STAIRS), "Red Sandstone Stairs"));
|
self::register(new SandstoneStairs(new BID(Block::RED_SANDSTONE_STAIRS), "Red Sandstone Stairs"));
|
||||||
self::register(new SandstoneStairs(new BID(Block::SANDSTONE_STAIRS), "Sandstone Stairs"));
|
self::register(new SandstoneStairs(new BID(Block::SANDSTONE_STAIRS), "Sandstone Stairs"));
|
||||||
self::register(new SeaLantern(new BID(Block::SEALANTERN), "Sea Lantern"));
|
self::register(new SeaLantern(new BID(Block::SEALANTERN), "Sea Lantern"));
|
||||||
|
self::register(new SeaPickle(new BID(Block::SEA_PICKLE), "Sea Pickle"));
|
||||||
self::register(new Skull(new BID(Block::MOB_HEAD_BLOCK, 0, null, \pocketmine\tile\Skull::class), "Mob Head"));
|
self::register(new Skull(new BID(Block::MOB_HEAD_BLOCK, 0, null, \pocketmine\tile\Skull::class), "Mob Head"));
|
||||||
self::register(new SmoothStone(new BID(Block::STONE, Stone::NORMAL), "Stone"));
|
self::register(new SmoothStone(new BID(Block::STONE, Stone::NORMAL), "Stone"));
|
||||||
self::register(new Snow(new BID(Block::SNOW), "Snow Block"));
|
self::register(new Snow(new BID(Block::SNOW), "Snow Block"));
|
||||||
|
84
src/pocketmine/block/SeaPickle.php
Normal file
84
src/pocketmine/block/SeaPickle.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?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\item\Item;
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
class SeaPickle extends Transparent{
|
||||||
|
/** @var int */
|
||||||
|
protected $count = 1;
|
||||||
|
/** @var bool */
|
||||||
|
protected $underwater = false;
|
||||||
|
|
||||||
|
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||||
|
$this->count = ($stateMeta & 0x03) + 1;
|
||||||
|
$this->underwater = ($stateMeta & 0x04) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function writeStateToMeta() : int{
|
||||||
|
return ($this->count - 1) | ($this->underwater ? 0 : 0x04);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStateBitmask() : int{
|
||||||
|
return 0b111;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness() : float{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSolid() : bool{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLightLevel() : int{
|
||||||
|
return $this->underwater ? ($this->count + 1) * 3 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
||||||
|
//TODO: proper placement logic (needs a supporting face below)
|
||||||
|
return ($blockReplace instanceof SeaPickle and $blockReplace->count < 4) or parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
$this->underwater = false; //TODO: implement this once we have new water logic in place
|
||||||
|
if($blockReplace instanceof SeaPickle and $blockReplace->count < 4){
|
||||||
|
$this->count = $blockReplace->count + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
//TODO: bonemeal logic (requires coral)
|
||||||
|
return parent::onInteract($item, $face, $clickVector, $player);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user