mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Implement ICopper interface for blocks with common properties (#6390)
This commit is contained in:
parent
2ffc38c835
commit
accaa0acce
@ -24,7 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
use pocketmine\block\utils\ICopper;
|
||||
|
||||
class Copper extends Opaque{
|
||||
class Copper extends Opaque implements ICopper{
|
||||
use CopperTrait;
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
use pocketmine\block\utils\ICopper;
|
||||
|
||||
class CopperSlab extends Slab{
|
||||
class CopperSlab extends Slab implements ICopper{
|
||||
use CopperTrait;
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
use pocketmine\block\utils\ICopper;
|
||||
|
||||
class CopperStairs extends Stair{
|
||||
class CopperStairs extends Stair implements ICopper{
|
||||
use CopperTrait;
|
||||
}
|
||||
|
38
src/block/utils/ICopper.php
Normal file
38
src/block/utils/ICopper.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\utils;
|
||||
|
||||
/**
|
||||
* Represents copper blocks that have oxidized and waxed variations.
|
||||
*/
|
||||
interface ICopper{
|
||||
|
||||
public function getOxidation() : CopperOxidation;
|
||||
|
||||
public function setOxidation(CopperOxidation $oxidation) : ICopper;
|
||||
|
||||
public function isWaxed() : bool;
|
||||
|
||||
public function setWaxed(bool $waxed) : ICopper;
|
||||
}
|
@ -26,9 +26,6 @@ namespace pocketmine\data\bedrock\block\convert;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Button;
|
||||
use pocketmine\block\Candle;
|
||||
use pocketmine\block\Copper;
|
||||
use pocketmine\block\CopperSlab;
|
||||
use pocketmine\block\CopperStairs;
|
||||
use pocketmine\block\Crops;
|
||||
use pocketmine\block\DaylightSensor;
|
||||
use pocketmine\block\Door;
|
||||
@ -49,6 +46,7 @@ use pocketmine\block\Stair;
|
||||
use pocketmine\block\Stem;
|
||||
use pocketmine\block\Trapdoor;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\ICopper;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\block\Wall;
|
||||
@ -102,24 +100,24 @@ final class BlockStateDeserializerHelper{
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template TBlock of Copper|CopperSlab|CopperStairs
|
||||
* @phpstan-template TBlock of ICopper
|
||||
*
|
||||
* @phpstan-param TBlock $block
|
||||
* @phpstan-return TBlock
|
||||
*/
|
||||
public static function decodeCopper(Copper|CopperSlab|CopperStairs $block, CopperOxidation $oxidation) : Copper|CopperSlab|CopperStairs{
|
||||
public static function decodeCopper(ICopper $block, CopperOxidation $oxidation) : ICopper{
|
||||
$block->setOxidation($oxidation);
|
||||
$block->setWaxed(false);
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template TBlock of Copper|CopperSlab|CopperStairs
|
||||
* @phpstan-template TBlock of ICopper
|
||||
*
|
||||
* @phpstan-param TBlock $block
|
||||
* @phpstan-return TBlock
|
||||
*/
|
||||
public static function decodeWaxedCopper(Copper|CopperSlab|CopperStairs $block, CopperOxidation $oxidation) : Copper|CopperSlab|CopperStairs{
|
||||
public static function decodeWaxedCopper(ICopper $block, CopperOxidation $oxidation) : ICopper{
|
||||
$block->setOxidation($oxidation);
|
||||
$block->setWaxed(true);
|
||||
return $block;
|
||||
|
Loading…
x
Reference in New Issue
Block a user