Merge branch 'minor-next' into major-next

This commit is contained in:
Dylan K. Taylor 2023-09-07 20:10:31 +01:00
commit cd6b780d31
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
181 changed files with 2372 additions and 3251 deletions

View File

@ -152,9 +152,6 @@ jobs:
- name: Regenerate KnownTranslation APIs - name: Regenerate KnownTranslation APIs
run: php build/generate-known-translation-apis.php run: php build/generate-known-translation-apis.php
- name: Regenerate RuntimeEnum(De)serializer
run: php build/generate-runtime-enum-serializers.php
- name: Regenerate BedrockData available files constants - name: Regenerate BedrockData available files constants
run: php build/generate-bedrockdata-path-consts.php run: php build/generate-bedrockdata-path-consts.php

View File

@ -1,265 +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\build\generate_runtime_enum_serializers;
use pocketmine\block\utils\BellAttachmentType;
use pocketmine\block\utils\CopperOxidation;
use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\DirtType;
use pocketmine\block\utils\DripleafState;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\FroglightType;
use pocketmine\block\utils\LeverFacing;
use pocketmine\block\utils\MobHeadType;
use pocketmine\block\utils\MushroomBlockType;
use pocketmine\block\utils\SlabType;
use pocketmine\item\MedicineType;
use pocketmine\item\PotionType;
use pocketmine\item\SuspiciousStewType;
use function array_key_first;
use function array_keys;
use function array_map;
use function ceil;
use function count;
use function dirname;
use function file_put_contents;
use function implode;
use function ksort;
use function lcfirst;
use function log;
use function ob_get_clean;
use function ob_start;
use const SORT_STRING;
require dirname(__DIR__) . '/vendor/autoload.php';
/**
* @param string[] $memberNames
* @phpstan-param list<string> $memberNames
*
* @return string[]
* @phpstan-return list<string>
*/
function buildWriterFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string $functionName) : array{
$bits = getBitsRequired($memberNames);
$lines = [];
$lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$this->writeInt($bits, match(\$value){";
foreach($memberNames as $key => $memberName){
$lines[] = "\t\t$memberName => $key,";
}
$lines[] = "\t\tdefault => throw new \pocketmine\utils\AssumptionFailedError(\"All $virtualTypeName cases should be covered\")";
$lines[] = "\t});";
$lines[] = "}";
return $lines;
}
/**
* @param string[] $memberNames
* @phpstan-param list<string> $memberNames
*
* @return string[]
* @phpstan-return list<string>
*/
function buildReaderFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string $functionName) : array{
$bits = getBitsRequired($memberNames);
$lines = [];
$lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$value = match(\$this->readInt($bits)){";
foreach($memberNames as $key => $memberName){
$lines[] = "\t\t$key => $memberName,";
}
$lines[] = "\t\tdefault => throw new InvalidSerializedRuntimeDataException(\"Invalid serialized value for $virtualTypeName\")";
$lines[] = "\t};";
$lines[] = "}";
return $lines;
}
function buildInterfaceFunc(string $nativeTypeName, string $functionName) : string{
return "public function $functionName(\\$nativeTypeName &\$value) : void;";
}
/**
* @param string[] $memberNames
* @phpstan-param list<string> $memberNames
*
* @return string[]
* @phpstan-return list<string>
*/
function buildSizeCalculationFunc(string $nativeTypeName, string $functionName, array $memberNames) : array{
$lines = [];
$lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$this->addBits(" . getBitsRequired($memberNames) . ");";
$lines[] = "}";
return $lines;
}
/**
* @param mixed[] $members
*/
function getBitsRequired(array $members) : int{
return (int) ceil(log(count($members), 2));
}
/**
* @param object[] $members
* @phpstan-param array<string, object> $members
*
* @return string[]
* @phpstan-return list<string>
*/
function stringifyEnumMembers(array $members, string $enumClass) : array{
ksort($members, SORT_STRING);
return array_map(fn(string $enumCaseName) => "\\$enumClass::$enumCaseName()", array_keys($members));
}
$enumsUsed = [
BellAttachmentType::getAll(),
CopperOxidation::getAll(),
CoralType::getAll(),
DirtType::getAll(),
DripleafState::getAll(),
DyeColor::getAll(),
FroglightType::getAll(),
LeverFacing::getAll(),
MedicineType::getAll(),
MushroomBlockType::getAll(),
MobHeadType::getAll(),
SlabType::getAll(),
SuspiciousStewType::getAll(),
PotionType::getAll()
];
$readerFuncs = [
"" => [
"abstract protected function readInt(int \$bits) : int;"
]
];
$writerFuncs = [
"" => [
"abstract protected function writeInt(int \$bits, int \$value) : void;"
]
];
$interfaceFuncs = [];
$sizeCalculationFuncs = [
"" => [
"abstract protected function addBits(int \$bits) : void;"
]
];
foreach($enumsUsed as $enumMembers){
if(count($enumMembers) === 0){
throw new \InvalidArgumentException("Enum members cannot be empty");
}
$reflect = new \ReflectionClass($enumMembers[array_key_first($enumMembers)]);
$virtualTypeName = $reflect->getShortName();
$nativeTypeName = $reflect->getName();
$functionName = lcfirst($virtualTypeName);
$stringifiedMembers = stringifyEnumMembers($enumMembers, $nativeTypeName);
$writerFuncs[$functionName] = buildWriterFunc(
$virtualTypeName,
$nativeTypeName,
$stringifiedMembers,
$functionName
);
$readerFuncs[$functionName] = buildReaderFunc(
$virtualTypeName,
$nativeTypeName,
$stringifiedMembers,
$functionName
);
$interfaceFuncs[$functionName] = [buildInterfaceFunc(
$nativeTypeName,
$functionName
)];
$sizeCalculationFuncs[$functionName] = buildSizeCalculationFunc(
$nativeTypeName,
$functionName,
$stringifiedMembers
);
}
/**
* @param string[][] $functions
* @phpstan-param array<string, list<string>> $functions
*/
function printFunctions(array $functions, string $className, string $classType) : void{
ksort($functions, SORT_STRING);
ob_start();
echo <<<'HEADER'
<?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\data\runtime;
/**
* This class is auto-generated. Do not edit it manually.
* @see build/generate-runtime-enum-serializers.php
*/
HEADER;
echo "$classType $className{\n\n";
echo implode("\n\n", array_map(fn(array $functionLines) => "\t" . implode("\n\t", $functionLines), $functions));
echo "\n\n}\n";
file_put_contents(dirname(__DIR__) . '/src/data/runtime/' . $className . '.php', ob_get_clean());
}
printFunctions($writerFuncs, "RuntimeEnumSerializerTrait", "trait");
printFunctions($readerFuncs, "RuntimeEnumDeserializerTrait", "trait");
printFunctions($interfaceFuncs, "RuntimeEnumDescriber", "interface");
printFunctions($sizeCalculationFuncs, "RuntimeEnumSizeCalculatorTrait", "trait");
echo "Done. Don't forget to run CS fixup after generating code.\n";

View File

@ -78,7 +78,7 @@ class Anvil extends Transparent implements Fallable{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{

View File

@ -95,7 +95,7 @@ class Bamboo extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
private static function getOffsetSeed(int $x, int $y, int $z) : int{ private static function getOffsetSeed(int $x, int $y, int $z) : int{

View File

@ -26,7 +26,6 @@ namespace pocketmine\block;
use pocketmine\block\tile\Banner as TileBanner; use pocketmine\block\tile\Banner as TileBanner;
use pocketmine\block\utils\BannerPatternLayer; use pocketmine\block\utils\BannerPatternLayer;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\item\Banner as ItemBanner; use pocketmine\item\Banner as ItemBanner;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -48,11 +47,6 @@ abstract class BaseBanner extends Transparent{
*/ */
protected array $patterns = []; protected array $patterns = [];
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::BLACK();
parent::__construct($idInfo, $name, $typeInfo);
}
public function readStateFromWorld() : Block{ public function readStateFromWorld() : Block{
parent::readStateFromWorld(); parent::readStateFromWorld();
$tile = $this->position->getWorld()->getTile($this->position); $tile = $this->position->getWorld()->getTile($this->position);
@ -111,7 +105,7 @@ abstract class BaseBanner extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
private function canBeSupportedBy(Block $block) : bool{ private function canBeSupportedBy(Block $block) : bool{

View File

@ -131,6 +131,6 @@ abstract class BaseBigDripleaf extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
abstract class BaseCake extends Transparent implements FoodSource{ abstract class BaseCake extends Transparent implements FoodSource{
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\CoralTypeTrait; use pocketmine\block\utils\CoralTypeTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -33,11 +32,6 @@ use function mt_rand;
abstract class BaseCoral extends Transparent{ abstract class BaseCoral extends Transparent{
use CoralTypeTrait; use CoralTypeTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->coralType = CoralType::TUBE();
parent::__construct($idInfo, $name, $typeInfo);
}
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if(!$this->dead){ if(!$this->dead){
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200)); $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));
@ -78,6 +72,6 @@ abstract class BaseCoral extends Transparent{
protected function recalculateCollisionBoxes() : array{ return []; } protected function recalculateCollisionBoxes() : array{ return []; }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -103,7 +103,7 @@ abstract class BaseSign extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
abstract protected function getSupportingFace() : int; abstract protected function getSupportingFace() : int;
@ -172,13 +172,13 @@ abstract class BaseSign extends Transparent{
} }
$dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){ $dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){
ItemTypeIds::BONE_MEAL => DyeColor::WHITE(), ItemTypeIds::BONE_MEAL => DyeColor::WHITE,
ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE(), ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE,
ItemTypeIds::COCOA_BEANS => DyeColor::BROWN(), ItemTypeIds::COCOA_BEANS => DyeColor::BROWN,
default => null default => null
}; };
if($dyeColor !== null){ if($dyeColor !== null){
$color = $dyeColor->equals(DyeColor::BLACK()) ? new Color(0, 0, 0) : $dyeColor->getRgbValue(); $color = $dyeColor === DyeColor::BLACK ? new Color(0, 0, 0) : $dyeColor->getRgbValue();
if( if(
$color->toARGB() !== $this->text->getBaseColor()->toARGB() && $color->toARGB() !== $this->text->getBaseColor()->toARGB() &&
$this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item) $this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item)

View File

@ -48,11 +48,6 @@ class Bed extends Transparent{
protected bool $occupied = false; protected bool $occupied = false;
protected bool $head = false; protected bool $head = false;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::RED();
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->occupied); $w->bool($this->occupied);
@ -65,6 +60,8 @@ class Bed extends Transparent{
$tile = $this->position->getWorld()->getTile($this->position); $tile = $this->position->getWorld()->getTile($this->position);
if($tile instanceof TileBed){ if($tile instanceof TileBed){
$this->color = $tile->getColor(); $this->color = $tile->getColor();
}else{
$this->color = DyeColor::RED; //legacy pre-1.1 beds don't have tiles
} }
return $this; return $this;
@ -87,7 +84,7 @@ class Bed extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function isHeadPart() : bool{ public function isHeadPart() : bool{
@ -209,7 +206,7 @@ class Bed extends Transparent{
} }
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE()); return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
} }
public function getMaxStackSize() : int{ return 1; } public function getMaxStackSize() : int{ return 1; }

View File

@ -35,32 +35,26 @@ use pocketmine\math\Facing;
use pocketmine\math\RayTraceResult; use pocketmine\math\RayTraceResult;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
use pocketmine\world\sound\BellRingSound; use pocketmine\world\sound\BellRingSound;
final class Bell extends Transparent{ final class Bell extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
private BellAttachmentType $attachmentType; private BellAttachmentType $attachmentType = BellAttachmentType::FLOOR;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->attachmentType = BellAttachmentType::FLOOR();
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bellAttachmentType($this->attachmentType); $w->enum($this->attachmentType);
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
} }
protected function recalculateCollisionBoxes() : array{ protected function recalculateCollisionBoxes() : array{
if($this->attachmentType->equals(BellAttachmentType::FLOOR())){ if($this->attachmentType === BellAttachmentType::FLOOR){
return [ return [
AxisAlignedBB::one()->squash(Facing::axis($this->facing), 1 / 4)->trim(Facing::UP, 3 / 16) AxisAlignedBB::one()->squash(Facing::axis($this->facing), 1 / 4)->trim(Facing::UP, 3 / 16)
]; ];
} }
if($this->attachmentType->equals(BellAttachmentType::CEILING())){ if($this->attachmentType === BellAttachmentType::CEILING){
return [ return [
AxisAlignedBB::one()->contract(1 / 4, 0, 1 / 4)->trim(Facing::DOWN, 1 / 4) AxisAlignedBB::one()->contract(1 / 4, 0, 1 / 4)->trim(Facing::DOWN, 1 / 4)
]; ];
@ -72,12 +66,12 @@ final class Bell extends Transparent{
->trim(Facing::DOWN, 1 / 4); ->trim(Facing::DOWN, 1 / 4);
return [ return [
$this->attachmentType->equals(BellAttachmentType::ONE_WALL()) ? $box->trim($this->facing, 3 / 16) : $box $this->attachmentType === BellAttachmentType::ONE_WALL ? $box->trim($this->facing, 3 / 16) : $box
]; ];
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function getAttachmentType() : BellAttachmentType{ return $this->attachmentType; } public function getAttachmentType() : BellAttachmentType{ return $this->attachmentType; }
@ -89,7 +83,7 @@ final class Bell extends Transparent{
} }
private function canBeSupportedAt(Block $block, int $face) : bool{ private function canBeSupportedAt(Block $block, int $face) : bool{
return !$block->getAdjacentSupportType($face)->equals(SupportType::NONE()); return $block->getAdjacentSupportType($face) !== SupportType::NONE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
@ -100,15 +94,15 @@ final class Bell extends Transparent{
if($player !== null){ if($player !== null){
$this->setFacing(Facing::opposite($player->getHorizontalFacing())); $this->setFacing(Facing::opposite($player->getHorizontalFacing()));
} }
$this->setAttachmentType(BellAttachmentType::FLOOR()); $this->setAttachmentType(BellAttachmentType::FLOOR);
}elseif($face === Facing::DOWN){ }elseif($face === Facing::DOWN){
$this->setAttachmentType(BellAttachmentType::CEILING()); $this->setAttachmentType(BellAttachmentType::CEILING);
}else{ }else{
$this->setFacing($face); $this->setFacing($face);
$this->setAttachmentType( $this->setAttachmentType(
$this->canBeSupportedAt($blockReplace, $face) ? $this->canBeSupportedAt($blockReplace, $face) ?
BellAttachmentType::TWO_WALLS() : BellAttachmentType::TWO_WALLS :
BellAttachmentType::ONE_WALL() BellAttachmentType::ONE_WALL
); );
} }
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
@ -116,11 +110,10 @@ final class Bell extends Transparent{
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
foreach(match($this->attachmentType){ foreach(match($this->attachmentType){
BellAttachmentType::CEILING() => [Facing::UP], BellAttachmentType::CEILING => [Facing::UP],
BellAttachmentType::FLOOR() => [Facing::DOWN], BellAttachmentType::FLOOR => [Facing::DOWN],
BellAttachmentType::ONE_WALL() => [Facing::opposite($this->facing)], BellAttachmentType::ONE_WALL => [Facing::opposite($this->facing)],
BellAttachmentType::TWO_WALLS() => [$this->facing, Facing::opposite($this->facing)], BellAttachmentType::TWO_WALLS => [$this->facing, Facing::opposite($this->facing)]
default => throw new AssumptionFailedError("All cases of BellAttachmentType must be handled")
} as $supportBlockDirection){ } as $supportBlockDirection){
if(!$this->canBeSupportedAt($this, $supportBlockDirection)){ if(!$this->canBeSupportedAt($this, $supportBlockDirection)){
$this->position->getWorld()->useBreakOn($this->position); $this->position->getWorld()->useBreakOn($this->position);
@ -159,10 +152,9 @@ final class Bell extends Transparent{
private function isValidFaceToRing(int $faceHit) : bool{ private function isValidFaceToRing(int $faceHit) : bool{
return match($this->attachmentType){ return match($this->attachmentType){
BellAttachmentType::CEILING() => true, BellAttachmentType::CEILING => true,
BellAttachmentType::FLOOR() => Facing::axis($faceHit) === Facing::axis($this->facing), BellAttachmentType::FLOOR => Facing::axis($faceHit) === Facing::axis($this->facing),
BellAttachmentType::ONE_WALL(), BellAttachmentType::TWO_WALLS() => $faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true), BellAttachmentType::ONE_WALL, BellAttachmentType::TWO_WALLS => $faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true),
default => throw new AssumptionFailedError("All cases of BellAttachmentType must be handled")
}; };
} }
} }

View File

@ -30,22 +30,16 @@ use pocketmine\entity\projectile\Projectile;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\math\RayTraceResult; use pocketmine\math\RayTraceResult;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\world\sound\DripleafTiltDownSound; use pocketmine\world\sound\DripleafTiltDownSound;
use pocketmine\world\sound\DripleafTiltUpSound; use pocketmine\world\sound\DripleafTiltUpSound;
class BigDripleafHead extends BaseBigDripleaf{ class BigDripleafHead extends BaseBigDripleaf{
protected DripleafState $leafState; protected DripleafState $leafState = DripleafState::STABLE;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->leafState = DripleafState::STABLE();
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
parent::describeBlockOnlyState($w); parent::describeBlockOnlyState($w);
$w->dripleafState($this->leafState); $w->enum($this->leafState);
} }
protected function isHead() : bool{ protected function isHead() : bool{
@ -76,20 +70,20 @@ class BigDripleafHead extends BaseBigDripleaf{
private function getLeafTopOffset() : float{ private function getLeafTopOffset() : float{
return match($this->leafState){ return match($this->leafState){
DripleafState::STABLE(), DripleafState::UNSTABLE() => 1 / 16, DripleafState::STABLE, DripleafState::UNSTABLE => 1 / 16,
DripleafState::PARTIAL_TILT() => 3 / 16, DripleafState::PARTIAL_TILT => 3 / 16,
default => 0 default => 0
}; };
} }
public function onEntityInside(Entity $entity) : bool{ public function onEntityInside(Entity $entity) : bool{
if(!$entity instanceof Projectile && $this->leafState->equals(DripleafState::STABLE())){ if(!$entity instanceof Projectile && $this->leafState === DripleafState::STABLE){
//the entity must be standing on top of the leaf - do not collapse if the entity is standing underneath //the entity must be standing on top of the leaf - do not collapse if the entity is standing underneath
$intersection = AxisAlignedBB::one() $intersection = AxisAlignedBB::one()
->offset($this->position->x, $this->position->y, $this->position->z) ->offset($this->position->x, $this->position->y, $this->position->z)
->trim(Facing::DOWN, 1 - $this->getLeafTopOffset()); ->trim(Facing::DOWN, 1 - $this->getLeafTopOffset());
if($entity->getBoundingBox()->intersectsWith($intersection)){ if($entity->getBoundingBox()->intersectsWith($intersection)){
$this->setTiltAndScheduleTick(DripleafState::UNSTABLE()); $this->setTiltAndScheduleTick(DripleafState::UNSTABLE);
return false; return false;
} }
} }
@ -97,22 +91,21 @@ class BigDripleafHead extends BaseBigDripleaf{
} }
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{ public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
if(!$this->leafState->equals(DripleafState::FULL_TILT())){ if($this->leafState !== DripleafState::FULL_TILT){
$this->setTiltAndScheduleTick(DripleafState::FULL_TILT()); $this->setTiltAndScheduleTick(DripleafState::FULL_TILT);
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound()); $this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
} }
} }
public function onScheduledUpdate() : void{ public function onScheduledUpdate() : void{
if(!$this->leafState->equals(DripleafState::STABLE())){ if($this->leafState !== DripleafState::STABLE){
if($this->leafState->equals(DripleafState::FULL_TILT())){ if($this->leafState === DripleafState::FULL_TILT){
$this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE())); $this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE));
$this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound()); $this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound());
}else{ }else{
$this->setTiltAndScheduleTick(match($this->leafState->id()){ $this->setTiltAndScheduleTick(match($this->leafState){
DripleafState::UNSTABLE()->id() => DripleafState::PARTIAL_TILT(), DripleafState::UNSTABLE => DripleafState::PARTIAL_TILT,
DripleafState::PARTIAL_TILT()->id() => DripleafState::FULL_TILT(), DripleafState::PARTIAL_TILT => DripleafState::FULL_TILT,
default => throw new AssumptionFailedError("All types should be covered")
}); });
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound()); $this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
} }
@ -120,7 +113,7 @@ class BigDripleafHead extends BaseBigDripleaf{
} }
protected function recalculateCollisionBoxes() : array{ protected function recalculateCollisionBoxes() : array{
if(!$this->leafState->equals(DripleafState::FULL_TILT())){ if($this->leafState !== DripleafState::FULL_TILT){
return [ return [
AxisAlignedBB::one() AxisAlignedBB::one()
->trim(Facing::DOWN, 11 / 16) ->trim(Facing::DOWN, 11 / 16)

View File

@ -877,7 +877,7 @@ class Block{
* blocks placed on the given face can be supported by this block. * blocks placed on the given face can be supported by this block.
*/ */
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::FULL(); return SupportType::FULL;
} }
protected function getAdjacentSupportType(int $facing) : SupportType{ protected function getAdjacentSupportType(int $facing) : SupportType{

View File

@ -34,6 +34,7 @@ use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
use function array_key_exists; use function array_key_exists;
use function spl_object_id;
class BrewingStand extends Transparent{ class BrewingStand extends Transparent{
@ -61,18 +62,18 @@ class BrewingStand extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function hasSlot(BrewingStandSlot $slot) : bool{ public function hasSlot(BrewingStandSlot $slot) : bool{
return array_key_exists($slot->id(), $this->slots); return array_key_exists(spl_object_id($slot), $this->slots);
} }
public function setSlot(BrewingStandSlot $slot, bool $occupied) : self{ public function setSlot(BrewingStandSlot $slot, bool $occupied) : self{
if($occupied){ if($occupied){
$this->slots[$slot->id()] = $slot; $this->slots[spl_object_id($slot)] = $slot;
}else{ }else{
unset($this->slots[$slot->id()]); unset($this->slots[spl_object_id($slot)]);
} }
return $this; return $this;
} }
@ -89,7 +90,7 @@ class BrewingStand extends Transparent{
public function setSlots(array $slots) : self{ public function setSlots(array $slots) : self{
$this->slots = []; $this->slots = [];
foreach($slots as $slot){ foreach($slots as $slot){
$this->slots[$slot->id()] = $slot; $this->slots[spl_object_id($slot)] = $slot;
} }
return $this; return $this;
} }
@ -114,7 +115,7 @@ class BrewingStand extends Transparent{
} }
$changed = false; $changed = false;
foreach(BrewingStandSlot::getAll() as $slot){ foreach(BrewingStandSlot::cases() as $slot){
$occupied = !$brewing->getInventory()->isSlotEmpty($slot->getSlotNumber()); $occupied = !$brewing->getInventory()->isSlotEmpty($slot->getSlotNumber());
if($occupied !== $this->hasSlot($slot)){ if($occupied !== $this->hasSlot($slot)){
$this->setSlot($slot, $occupied); $this->setSlot($slot, $occupied);

View File

@ -69,7 +69,7 @@ class Cactus extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onEntityInside(Entity $entity) : bool{ public function onEntityInside(Entity $entity) : bool{

View File

@ -30,7 +30,7 @@ class CakeWithDyedCandle extends CakeWithCandle{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE(); $this->color = DyeColor::WHITE;
parent::__construct($idInfo, $name, $typeInfo); parent::__construct($idInfo, $name, $typeInfo);
} }

View File

@ -91,7 +91,7 @@ class Candle extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
protected function getCandleIfCompatibleType(Block $block) : ?Candle{ protected function getCandleIfCompatibleType(Block $block) : ?Candle{

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -35,11 +34,6 @@ use pocketmine\world\BlockTransaction;
class Carpet extends Flowable{ class Carpet extends Flowable{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
public function isSolid() : bool{ public function isSolid() : bool{
return true; return true;
} }

View File

@ -61,7 +61,7 @@ final class Cauldron extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return $facing === Facing::UP ? SupportType::EDGE() : SupportType::NONE(); return $facing === Facing::UP ? SupportType::EDGE : SupportType::NONE;
} }
/** /**
@ -83,7 +83,7 @@ final class Cauldron extends Transparent{
}elseif($item->getTypeId() === ItemTypeIds::POWDER_SNOW_BUCKET){ }elseif($item->getTypeId() === ItemTypeIds::POWDER_SNOW_BUCKET){
//TODO: powder snow cauldron //TODO: powder snow cauldron
}elseif($item instanceof Potion || $item instanceof SplashPotion){ //TODO: lingering potion }elseif($item instanceof Potion || $item instanceof SplashPotion){ //TODO: lingering potion
if($item->getType()->equals(PotionType::WATER())){ if($item->getType() === PotionType::WATER){
$this->fill(WaterCauldron::WATER_BOTTLE_FILL_AMOUNT, VanillaBlocks::WATER_CAULDRON(), $item, VanillaItems::GLASS_BOTTLE(), $returnedItems); $this->fill(WaterCauldron::WATER_BOTTLE_FILL_AMOUNT, VanillaBlocks::WATER_CAULDRON(), $item, VanillaItems::GLASS_BOTTLE(), $returnedItems);
}else{ }else{
$this->fill(PotionCauldron::POTION_FILL_AMOUNT, VanillaBlocks::POTION_CAULDRON()->setPotionItem($item), $item, VanillaItems::GLASS_BOTTLE(), $returnedItems); $this->fill(PotionCauldron::POTION_FILL_AMOUNT, VanillaBlocks::POTION_CAULDRON()->setPotionItem($item), $item, VanillaItems::GLASS_BOTTLE(), $returnedItems);

View File

@ -88,7 +88,7 @@ class CaveVines extends Flowable{
} }
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return $block->getAdjacentSupportType(Facing::UP)->equals(SupportType::FULL()) || $block->hasSameTypeId($this); return $block->getAdjacentSupportType(Facing::UP) === SupportType::FULL || $block->hasSameTypeId($this);
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
@ -176,6 +176,6 @@ class CaveVines extends Flowable{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -33,7 +33,7 @@ final class Chain extends Transparent{
use PillarRotationTrait; use PillarRotationTrait;
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return $this->axis === Axis::Y && Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE(); return $this->axis === Axis::Y && Facing::axis($facing) === Axis::Y ? SupportType::CENTER : SupportType::NONE;
} }
protected function recalculateCollisionBoxes() : array{ protected function recalculateCollisionBoxes() : array{

View File

@ -45,7 +45,7 @@ class Chest extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onPostPlace() : void{ public function onPostPlace() : void{

View File

@ -77,11 +77,11 @@ class CocoaBlock extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
private function canAttachTo(Block $block) : bool{ private function canAttachTo(Block $block) : bool{
return $block instanceof Wood && $block->getWoodType()->equals(WoodType::JUNGLE()); return $block instanceof Wood && $block->getWoodType() === WoodType::JUNGLE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
class Concrete extends Opaque{ class Concrete extends Opaque{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -25,7 +25,6 @@ namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\Fallable; use pocketmine\block\utils\Fallable;
use pocketmine\block\utils\FallableTrait; use pocketmine\block\utils\FallableTrait;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -36,11 +35,6 @@ class ConcretePowder extends Opaque implements Fallable{
onNearbyBlockChange as protected startFalling; onNearbyBlockChange as protected startFalling;
} }
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if(($water = $this->getAdjacentWater()) !== null){ if(($water = $this->getAdjacentWater()) !== null){
BlockEventHelper::form($this, VanillaBlocks::CONCRETE()->setColor($this->color), $water); BlockEventHelper::form($this, VanillaBlocks::CONCRETE()->setColor($this->color), $water);

View File

@ -23,14 +23,8 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\CopperOxidation;
use pocketmine\block\utils\CopperTrait; use pocketmine\block\utils\CopperTrait;
class CopperStairs extends Stair{ class CopperStairs extends Stair{
use CopperTrait; use CopperTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->oxidation = CopperOxidation::NONE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\CoralTypeTrait; use pocketmine\block\utils\CoralTypeTrait;
use pocketmine\item\Item; use pocketmine\item\Item;
use function mt_rand; use function mt_rand;
@ -32,11 +31,6 @@ use function mt_rand;
final class CoralBlock extends Opaque{ final class CoralBlock extends Opaque{
use CoralTypeTrait; use CoralTypeTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->coralType = CoralType::TUBE();
parent::__construct($idInfo, $name, $typeInfo);
}
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if(!$this->dead){ if(!$this->dead){
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200)); $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));

View File

@ -70,7 +70,7 @@ class DaylightSensor extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{

View File

@ -38,15 +38,10 @@ use pocketmine\world\sound\ItemUseOnBlockSound;
use pocketmine\world\sound\WaterSplashSound; use pocketmine\world\sound\WaterSplashSound;
class Dirt extends Opaque{ class Dirt extends Opaque{
protected DirtType $dirtType; protected DirtType $dirtType = DirtType::NORMAL;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->dirtType = DirtType::NORMAL();
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->dirtType($this->dirtType); $w->enum($this->dirtType);
} }
public function getDirtType() : DirtType{ return $this->dirtType; } public function getDirtType() : DirtType{ return $this->dirtType; }
@ -62,16 +57,16 @@ class Dirt extends Opaque{
if($face === Facing::UP && $item instanceof Hoe){ if($face === Facing::UP && $item instanceof Hoe){
$item->applyDamage(1); $item->applyDamage(1);
$newBlock = $this->dirtType->equals(DirtType::NORMAL()) ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT(); $newBlock = $this->dirtType === DirtType::NORMAL ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT();
$center = $this->position->add(0.5, 0.5, 0.5); $center = $this->position->add(0.5, 0.5, 0.5);
$world->addSound($center, new ItemUseOnBlockSound($newBlock)); $world->addSound($center, new ItemUseOnBlockSound($newBlock));
$world->setBlock($this->position, $newBlock); $world->setBlock($this->position, $newBlock);
if($this->dirtType->equals(DirtType::ROOTED())){ if($this->dirtType === DirtType::ROOTED){
$world->dropItem($center, VanillaBlocks::HANGING_ROOTS()->asItem()); $world->dropItem($center, VanillaBlocks::HANGING_ROOTS()->asItem());
} }
return true; return true;
}elseif($this->dirtType->equals(DirtType::ROOTED()) && $item instanceof Fertilizer){ }elseif($this->dirtType === DirtType::ROOTED && $item instanceof Fertilizer){
$down = $this->getSide(Facing::DOWN); $down = $this->getSide(Facing::DOWN);
if($down->getTypeId() !== BlockTypeIds::AIR){ if($down->getTypeId() !== BlockTypeIds::AIR){
return true; return true;
@ -80,7 +75,7 @@ class Dirt extends Opaque{
$item->pop(); $item->pop();
$world->setBlock($down->position, VanillaBlocks::HANGING_ROOTS()); $world->setBlock($down->position, VanillaBlocks::HANGING_ROOTS());
//TODO: bonemeal particles, growth sounds //TODO: bonemeal particles, growth sounds
}elseif(($item instanceof Potion || $item instanceof SplashPotion) && $item->getType()->equals(PotionType::WATER())){ }elseif(($item instanceof Potion || $item instanceof SplashPotion) && $item->getType() === PotionType::WATER){
$item->pop(); $item->pop();
$world->setBlock($this->position, VanillaBlocks::MUD()); $world->setBlock($this->position, VanillaBlocks::MUD());
$world->addSound($this->position, new WaterSplashSound(0.5)); $world->addSound($this->position, new WaterSplashSound(0.5));

View File

@ -102,7 +102,7 @@ class Door extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{

View File

@ -82,6 +82,6 @@ class DragonEgg extends Transparent implements Fallable{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -24,19 +24,13 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
class DyedCandle extends Candle{ class DyedCandle extends Candle{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
protected function getCandleIfCompatibleType(Block $block) : ?Candle{ protected function getCandleIfCompatibleType(Block $block) : ?Candle{
$result = parent::getCandleIfCompatibleType($block); $result = parent::getCandleIfCompatibleType($block);
//different coloured candles can't be combined in the same block //different coloured candles can't be combined in the same block
return $result instanceof DyedCandle && $result->color->equals($this->color) ? $result : null; return $result instanceof DyedCandle && $result->color === $this->color ? $result : null;
} }
} }

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
final class DyedShulkerBox extends ShulkerBox{ final class DyedShulkerBox extends ShulkerBox{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -41,7 +41,7 @@ class EnchantingTable extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{

View File

@ -49,7 +49,7 @@ class EnderChest extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{

View File

@ -42,7 +42,7 @@ class Fence extends Transparent{
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
$block = $this->getSide($facing); $block = $this->getSide($facing);
if($block instanceof static || $block instanceof FenceGate || $block->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){ if($block instanceof static || $block instanceof FenceGate || $block->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
$this->connections[$facing] = true; $this->connections[$facing] = true;
}else{ }else{
unset($this->connections[$facing]); unset($this->connections[$facing]);
@ -98,6 +98,6 @@ class Fence extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE(); return Facing::axis($facing) === Axis::Y ? SupportType::CENTER : SupportType::NONE;
} }
} }

View File

@ -72,7 +72,7 @@ class FenceGate extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
private function checkInWall() : bool{ private function checkInWall() : bool{

View File

@ -64,7 +64,7 @@ abstract class FillableCauldron extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return $facing === Facing::UP ? SupportType::EDGE() : SupportType::NONE(); return $facing === Facing::UP ? SupportType::EDGE : SupportType::NONE;
} }
protected function withFillLevel(int $fillLevel) : Block{ protected function withFillLevel(int $fillLevel) : Block{

View File

@ -60,7 +60,7 @@ class Fire extends BaseFire{
} }
private function canBeSupportedBy(Block $block) : bool{ private function canBeSupportedBy(Block $block) : bool{
return $block->getSupportType(Facing::UP)->equals(SupportType::FULL()); return $block->getSupportType(Facing::UP) === SupportType::FULL;
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{

View File

@ -48,6 +48,6 @@ abstract class Flowable extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -28,15 +28,10 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
final class Froglight extends SimplePillar{ final class Froglight extends SimplePillar{
private FroglightType $froglightType; private FroglightType $froglightType = FroglightType::OCHRE;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->froglightType = FroglightType::OCHRE();
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->froglightType($this->froglightType); $w->enum($this->froglightType);
} }
public function getFroglightType() : FroglightType{ return $this->froglightType; } public function getFroglightType() : FroglightType{ return $this->froglightType; }

View File

@ -24,15 +24,9 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait; use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
class GlazedTerracotta extends Opaque{ class GlazedTerracotta extends Opaque{
use ColoredTrait; use ColoredTrait;
use FacesOppositePlacingPlayerTrait; use FacesOppositePlacingPlayerTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::BLACK();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -95,7 +95,7 @@ class GlowLichen extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function canBeReplaced() : bool{ public function canBeReplaced() : bool{
@ -121,7 +121,7 @@ class GlowLichen extends Transparent{
$changed = false; $changed = false;
foreach($this->faces as $face){ foreach($this->faces as $face){
if(!$this->getAdjacentSupportType($face)->equals(SupportType::FULL())){ if($this->getAdjacentSupportType($face) !== SupportType::FULL){
unset($this->faces[$face]); unset($this->faces[$face]);
$changed = true; $changed = true;
} }
@ -156,7 +156,7 @@ class GlowLichen extends Transparent{
$supportBlock = $world->getBlock($replacePos->getSide($spreadFace)); $supportBlock = $world->getBlock($replacePos->getSide($spreadFace));
$supportFace = Facing::opposite($spreadFace); $supportFace = Facing::opposite($spreadFace);
if(!$supportBlock->getSupportType($supportFace)->equals(SupportType::FULL())){ if($supportBlock->getSupportType($supportFace) !== SupportType::FULL){
return false; return false;
} }
@ -268,7 +268,7 @@ class GlowLichen extends Transparent{
private function getAvailableFaces() : array{ private function getAvailableFaces() : array{
$faces = []; $faces = [];
foreach(Facing::ALL as $face){ foreach(Facing::ALL as $face){
if(!$this->hasFace($face) && $this->getAdjacentSupportType($face)->equals(SupportType::FULL())){ if(!$this->hasFace($face) && $this->getAdjacentSupportType($face) === SupportType::FULL){
$faces[$face] = $face; $faces[$face] = $face;
} }
} }

View File

@ -69,7 +69,7 @@ class Grass extends Opaque{
$b = $world->getBlockAt($x, $y, $z); $b = $world->getBlockAt($x, $y, $z);
if( if(
!($b instanceof Dirt) || !($b instanceof Dirt) ||
!$b->getDirtType()->equals(DirtType::NORMAL()) || $b->getDirtType() !== DirtType::NORMAL ||
$world->getFullLightAt($x, $y + 1, $z) < 4 || $world->getFullLightAt($x, $y + 1, $z) < 4 ||
$world->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2 $world->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
){ ){

View File

@ -68,9 +68,9 @@ class Hopper extends Transparent{
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return match($facing){ return match($facing){
Facing::UP => SupportType::FULL(), Facing::UP => SupportType::FULL,
Facing::DOWN => $this->facing === Facing::DOWN ? SupportType::CENTER() : SupportType::NONE(), Facing::DOWN => $this->facing === Facing::DOWN ? SupportType::CENTER : SupportType::NONE,
default => SupportType::NONE() default => SupportType::NONE
}; };
} }

View File

@ -164,7 +164,7 @@ class ItemFrame extends Flowable{
} }
private function canBeSupportedAt(Block $block, int $face) : bool{ private function canBeSupportedAt(Block $block, int $face) : bool{
return !$block->getAdjacentSupportType($face)->equals(SupportType::NONE()); return $block->getAdjacentSupportType($face) !== SupportType::NONE;
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{

View File

@ -66,7 +66,7 @@ class Ladder extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
@ -85,6 +85,6 @@ class Ladder extends Transparent{
} }
private function canBeSupportedAt(Block $block, int $face) : bool{ private function canBeSupportedAt(Block $block, int $face) : bool{
return $block->getAdjacentSupportType($face)->equals(SupportType::FULL()); return $block->getAdjacentSupportType($face) === SupportType::FULL;
} }
} }

View File

@ -73,7 +73,7 @@ class Lantern extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -33,7 +33,6 @@ use pocketmine\item\VanillaItems;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
use pocketmine\world\World; use pocketmine\world\World;
use function mt_rand; use function mt_rand;
@ -147,23 +146,22 @@ class Leaves extends Transparent{
if(FortuneDropHelper::bonusChanceDivisor($item, 20, 4)){ //Saplings if(FortuneDropHelper::bonusChanceDivisor($item, 20, 4)){ //Saplings
// TODO: according to the wiki, the jungle saplings have a different drop rate // TODO: according to the wiki, the jungle saplings have a different drop rate
$sapling = (match($this->leavesType){ $sapling = (match($this->leavesType){
LeavesType::ACACIA() => VanillaBlocks::ACACIA_SAPLING(), LeavesType::ACACIA => VanillaBlocks::ACACIA_SAPLING(),
LeavesType::BIRCH() => VanillaBlocks::BIRCH_SAPLING(), LeavesType::BIRCH => VanillaBlocks::BIRCH_SAPLING(),
LeavesType::DARK_OAK() => VanillaBlocks::DARK_OAK_SAPLING(), LeavesType::DARK_OAK => VanillaBlocks::DARK_OAK_SAPLING(),
LeavesType::JUNGLE() => VanillaBlocks::JUNGLE_SAPLING(), LeavesType::JUNGLE => VanillaBlocks::JUNGLE_SAPLING(),
LeavesType::OAK() => VanillaBlocks::OAK_SAPLING(), LeavesType::OAK => VanillaBlocks::OAK_SAPLING(),
LeavesType::SPRUCE() => VanillaBlocks::SPRUCE_SAPLING(), LeavesType::SPRUCE => VanillaBlocks::SPRUCE_SAPLING(),
LeavesType::MANGROVE(), //TODO: mangrove propagule LeavesType::MANGROVE, //TODO: mangrove propagule
LeavesType::AZALEA(), LeavesType::FLOWERING_AZALEA() => null, //TODO: azalea LeavesType::AZALEA, LeavesType::FLOWERING_AZALEA => null, //TODO: azalea
LeavesType::CHERRY() => null, //TODO: cherry LeavesType::CHERRY => null, //TODO: cherry
default => throw new AssumptionFailedError("Unreachable")
})?->asItem(); })?->asItem();
if($sapling !== null){ if($sapling !== null){
$drops[] = $sapling; $drops[] = $sapling;
} }
} }
if( if(
($this->leavesType->equals(LeavesType::OAK()) || $this->leavesType->equals(LeavesType::DARK_OAK())) && ($this->leavesType === LeavesType::OAK || $this->leavesType === LeavesType::DARK_OAK) &&
FortuneDropHelper::bonusChanceDivisor($item, 200, 20) FortuneDropHelper::bonusChanceDivisor($item, 200, 20)
){ //Apples ){ //Apples
$drops[] = VanillaItems::APPLE(); $drops[] = VanillaItems::APPLE();
@ -188,6 +186,6 @@ class Leaves extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -87,7 +87,7 @@ class Lectern extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function isProducingSignal() : bool{ return $this->producingSignal; } public function isProducingSignal() : bool{ return $this->producingSignal; }

View File

@ -36,16 +36,11 @@ use pocketmine\world\sound\RedstonePowerOffSound;
use pocketmine\world\sound\RedstonePowerOnSound; use pocketmine\world\sound\RedstonePowerOnSound;
class Lever extends Flowable{ class Lever extends Flowable{
protected LeverFacing $facing; protected LeverFacing $facing = LeverFacing::UP_AXIS_X;
protected bool $activated = false; protected bool $activated = false;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->facing = LeverFacing::UP_AXIS_X();
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->leverFacing($this->facing); $w->enum($this->facing);
$w->bool($this->activated); $w->bool($this->activated);
} }
@ -77,12 +72,12 @@ class Lever extends Flowable{
return $x; return $x;
}; };
$this->facing = match($face){ $this->facing = match($face){
Facing::DOWN => $selectUpDownPos(LeverFacing::DOWN_AXIS_X(), LeverFacing::DOWN_AXIS_Z()), Facing::DOWN => $selectUpDownPos(LeverFacing::DOWN_AXIS_X, LeverFacing::DOWN_AXIS_Z),
Facing::UP => $selectUpDownPos(LeverFacing::UP_AXIS_X(), LeverFacing::UP_AXIS_Z()), Facing::UP => $selectUpDownPos(LeverFacing::UP_AXIS_X, LeverFacing::UP_AXIS_Z),
Facing::NORTH => LeverFacing::NORTH(), Facing::NORTH => LeverFacing::NORTH,
Facing::SOUTH => LeverFacing::SOUTH(), Facing::SOUTH => LeverFacing::SOUTH,
Facing::WEST => LeverFacing::WEST(), Facing::WEST => LeverFacing::WEST,
Facing::EAST => LeverFacing::EAST(), Facing::EAST => LeverFacing::EAST,
default => throw new AssumptionFailedError("Bad facing value"), default => throw new AssumptionFailedError("Bad facing value"),
}; };

View File

@ -97,7 +97,7 @@ abstract class Liquid extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -39,18 +39,13 @@ class MobHead extends Flowable{
public const MIN_ROTATION = 0; public const MIN_ROTATION = 0;
public const MAX_ROTATION = 15; public const MAX_ROTATION = 15;
protected MobHeadType $mobHeadType; protected MobHeadType $mobHeadType = MobHeadType::SKELETON;
protected int $facing = Facing::NORTH; protected int $facing = Facing::NORTH;
protected int $rotation = self::MIN_ROTATION; //TODO: split this into floor skull and wall skull handling protected int $rotation = self::MIN_ROTATION; //TODO: split this into floor skull and wall skull handling
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->mobHeadType = MobHeadType::SKELETON(); //TODO: this should be a parameter
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->mobHeadType($this->mobHeadType); $w->enum($this->mobHeadType);
} }
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{

View File

@ -42,6 +42,6 @@ class MonsterSpawner extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -52,7 +52,7 @@ class Mycelium extends Opaque{
$z = mt_rand($this->position->z - 1, $this->position->z + 1); $z = mt_rand($this->position->z - 1, $this->position->z + 1);
$world = $this->position->getWorld(); $world = $this->position->getWorld();
$block = $world->getBlockAt($x, $y, $z); $block = $world->getBlockAt($x, $y, $z);
if($block instanceof Dirt && $block->getDirtType()->equals(DirtType::NORMAL())){ if($block instanceof Dirt && $block->getDirtType() === DirtType::NORMAL){
if($block->getSide(Facing::UP) instanceof Transparent){ if($block->getSide(Facing::UP) instanceof Transparent){
BlockEventHelper::spread($block, VanillaBlocks::MYCELIUM(), $this); BlockEventHelper::spread($block, VanillaBlocks::MYCELIUM(), $this);
} }

View File

@ -70,7 +70,7 @@ class NetherPortal extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function getDrops(Item $item) : array{ public function getDrops(Item $item) : array{

View File

@ -184,6 +184,6 @@ class NetherVines extends Flowable{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -60,7 +60,7 @@ abstract class PressurePlate extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
@ -71,7 +71,7 @@ abstract class PressurePlate extends Transparent{
} }
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE()); return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{

View File

@ -29,17 +29,12 @@ use pocketmine\item\Item;
use function mt_rand; use function mt_rand;
class RedMushroomBlock extends Opaque{ class RedMushroomBlock extends Opaque{
protected MushroomBlockType $mushroomBlockType; protected MushroomBlockType $mushroomBlockType = MushroomBlockType::ALL_CAP;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->mushroomBlockType = MushroomBlockType::ALL_CAP();
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
//these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative), //these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative),
//so this information needs to be kept in the type info //so this information needs to be kept in the type info
$w->mushroomBlockType($this->mushroomBlockType); $w->enum($this->mushroomBlockType);
} }
public function getMushroomBlockType() : MushroomBlockType{ return $this->mushroomBlockType; } public function getMushroomBlockType() : MushroomBlockType{ return $this->mushroomBlockType; }
@ -61,10 +56,10 @@ class RedMushroomBlock extends Opaque{
} }
public function getSilkTouchDrops(Item $item) : array{ public function getSilkTouchDrops(Item $item) : array{
return [(clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP())->asItem()]; return [(clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP)->asItem()];
} }
public function getPickedItem(bool $addUserData = false) : Item{ public function getPickedItem(bool $addUserData = false) : Item{
return (clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP())->asItem(); return (clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP)->asItem();
} }
} }

View File

@ -108,7 +108,7 @@ class RedstoneComparator extends Flowable{
} }
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE()); return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
} }
//TODO: redstone functionality //TODO: redstone functionality

View File

@ -94,7 +94,7 @@ class RedstoneRepeater extends Flowable{
} }
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE()); return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
} }
//TODO: redstone functionality //TODO: redstone functionality

View File

@ -78,7 +78,7 @@ class SeaPickle extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{ public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{

View File

@ -113,6 +113,6 @@ class ShulkerBox extends Opaque{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -34,19 +34,18 @@ use pocketmine\player\Player;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
class Slab extends Transparent{ class Slab extends Transparent{
protected SlabType $slabType; protected SlabType $slabType = SlabType::BOTTOM;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->slabType = SlabType::BOTTOM();
parent::__construct($idInfo, $name . " Slab", $typeInfo); parent::__construct($idInfo, $name . " Slab", $typeInfo);
} }
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->slabType($this->slabType); $w->enum($this->slabType);
} }
public function isTransparent() : bool{ public function isTransparent() : bool{
return !$this->slabType->equals(SlabType::DOUBLE()); return $this->slabType !== SlabType::DOUBLE;
} }
/** /**
@ -69,8 +68,8 @@ class Slab extends Transparent{
return true; return true;
} }
if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->hasSameTypeId($this)){ if($blockReplace instanceof Slab && $blockReplace->slabType !== SlabType::DOUBLE && $blockReplace->hasSameTypeId($this)){
if($blockReplace->slabType->equals(SlabType::TOP())){ //Trying to combine with top slab if($blockReplace->slabType === SlabType::TOP){ //Trying to combine with top slab
return $clickVector->y <= 0.5 || (!$isClickedBlock && $face === Facing::UP); return $clickVector->y <= 0.5 || (!$isClickedBlock && $face === Facing::UP);
}else{ }else{
return $clickVector->y >= 0.5 || (!$isClickedBlock && $face === Facing::DOWN); return $clickVector->y >= 0.5 || (!$isClickedBlock && $face === Facing::DOWN);
@ -81,14 +80,14 @@ class Slab extends Transparent{
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->hasSameTypeId($this) && ( if($blockReplace instanceof Slab && $blockReplace->slabType !== SlabType::DOUBLE && $blockReplace->hasSameTypeId($this) && (
($blockReplace->slabType->equals(SlabType::TOP()) && ($clickVector->y <= 0.5 || $face === Facing::UP)) || ($blockReplace->slabType === SlabType::TOP && ($clickVector->y <= 0.5 || $face === Facing::UP)) ||
($blockReplace->slabType->equals(SlabType::BOTTOM()) && ($clickVector->y >= 0.5 || $face === Facing::DOWN)) ($blockReplace->slabType === SlabType::BOTTOM && ($clickVector->y >= 0.5 || $face === Facing::DOWN))
)){ )){
//Clicked in empty half of existing slab //Clicked in empty half of existing slab
$this->slabType = SlabType::DOUBLE(); $this->slabType = SlabType::DOUBLE;
}else{ }else{
$this->slabType = (($face !== Facing::UP && $clickVector->y > 0.5) || $face === Facing::DOWN) ? SlabType::TOP() : SlabType::BOTTOM(); $this->slabType = (($face !== Facing::UP && $clickVector->y > 0.5) || $face === Facing::DOWN) ? SlabType::TOP : SlabType::BOTTOM;
} }
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
@ -98,22 +97,22 @@ class Slab extends Transparent{
* @return AxisAlignedBB[] * @return AxisAlignedBB[]
*/ */
protected function recalculateCollisionBoxes() : array{ protected function recalculateCollisionBoxes() : array{
if($this->slabType->equals(SlabType::DOUBLE())){ if($this->slabType === SlabType::DOUBLE){
return [AxisAlignedBB::one()]; return [AxisAlignedBB::one()];
} }
return [AxisAlignedBB::one()->trim($this->slabType->equals(SlabType::TOP()) ? Facing::DOWN : Facing::UP, 0.5)]; return [AxisAlignedBB::one()->trim($this->slabType === SlabType::TOP ? Facing::DOWN : Facing::UP, 0.5)];
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
if($this->slabType->equals(SlabType::DOUBLE())){ if($this->slabType === SlabType::DOUBLE){
return SupportType::FULL(); return SupportType::FULL;
}elseif(($facing === Facing::UP && $this->slabType->equals(SlabType::TOP())) || ($facing === Facing::DOWN && $this->slabType->equals(SlabType::BOTTOM()))){ }elseif(($facing === Facing::UP && $this->slabType === SlabType::TOP) || ($facing === Facing::DOWN && $this->slabType === SlabType::BOTTOM)){
return SupportType::FULL(); return SupportType::FULL;
} }
return SupportType::NONE(); return SupportType::NONE;
} }
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{
return [$this->asItem()->setCount($this->slabType->equals(SlabType::DOUBLE()) ? 2 : 1)]; return [$this->asItem()->setCount($this->slabType === SlabType::DOUBLE ? 2 : 1)];
} }
} }

View File

@ -161,7 +161,7 @@ class SmallDripleaf extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
protected function recalculateCollisionBoxes() : array{ protected function recalculateCollisionBoxes() : array{

View File

@ -75,13 +75,13 @@ class SnowLayer extends Flowable implements Fallable{
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
if(!$this->canBeReplaced()){ if(!$this->canBeReplaced()){
return SupportType::FULL(); return SupportType::FULL;
} }
return SupportType::NONE(); return SupportType::NONE;
} }
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return $block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::FULL()); return $block->getAdjacentSupportType(Facing::DOWN) === SupportType::FULL;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -33,7 +33,7 @@ use pocketmine\world\BlockTransaction;
final class SporeBlossom extends Flowable{ final class SporeBlossom extends Flowable{
private function canBeSupportedAt(Block $block) : bool{ private function canBeSupportedAt(Block $block) : bool{
return $block->getAdjacentSupportType(Facing::UP)->equals(SupportType::FULL()); return $block->getAdjacentSupportType(Facing::UP) === SupportType::FULL;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
final class StainedGlass extends Glass{ final class StainedGlass extends Glass{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
final class StainedGlassPane extends GlassPane{ final class StainedGlassPane extends GlassPane{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
final class StainedHardenedClay extends HardenedClay{ final class StainedHardenedClay extends HardenedClay{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
final class StainedHardenedGlass extends HardenedGlass{ final class StainedHardenedGlass extends HardenedGlass{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -24,13 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
final class StainedHardenedGlassPane extends HardenedGlassPane{ final class StainedHardenedGlassPane extends HardenedGlassPane{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
} }

View File

@ -39,12 +39,7 @@ class Stair extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
protected bool $upsideDown = false; protected bool $upsideDown = false;
protected StairShape $shape; protected StairShape $shape = StairShape::STRAIGHT;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->shape = StairShape::STRAIGHT();
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
@ -56,11 +51,11 @@ class Stair extends Transparent{
$clockwise = Facing::rotateY($this->facing, true); $clockwise = Facing::rotateY($this->facing, true);
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){ if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
$this->shape = $backFacing === $clockwise ? StairShape::OUTER_RIGHT() : StairShape::OUTER_LEFT(); $this->shape = $backFacing === $clockwise ? StairShape::OUTER_RIGHT : StairShape::OUTER_LEFT;
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){ }elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
$this->shape = $frontFacing === $clockwise ? StairShape::INNER_RIGHT() : StairShape::INNER_LEFT(); $this->shape = $frontFacing === $clockwise ? StairShape::INNER_RIGHT : StairShape::INNER_LEFT;
}else{ }else{
$this->shape = StairShape::STRAIGHT(); $this->shape = StairShape::STRAIGHT;
} }
return $this; return $this;
@ -92,14 +87,14 @@ class Stair extends Transparent{
->trim(Facing::opposite($topStepFace), 0.5) ->trim(Facing::opposite($topStepFace), 0.5)
->trim(Facing::opposite($this->facing), 0.5); ->trim(Facing::opposite($this->facing), 0.5);
if($this->shape->equals(StairShape::OUTER_LEFT()) || $this->shape->equals(StairShape::OUTER_RIGHT())){ if($this->shape === StairShape::OUTER_LEFT || $this->shape === StairShape::OUTER_RIGHT){
$topStep->trim(Facing::rotateY($this->facing, $this->shape->equals(StairShape::OUTER_LEFT())), 0.5); $topStep->trim(Facing::rotateY($this->facing, $this->shape === StairShape::OUTER_LEFT), 0.5);
}elseif($this->shape->equals(StairShape::INNER_LEFT()) || $this->shape->equals(StairShape::INNER_RIGHT())){ }elseif($this->shape === StairShape::INNER_LEFT || $this->shape === StairShape::INNER_RIGHT){
//add an extra cube //add an extra cube
$bbs[] = AxisAlignedBB::one() $bbs[] = AxisAlignedBB::one()
->trim(Facing::opposite($topStepFace), 0.5) ->trim(Facing::opposite($topStepFace), 0.5)
->trim($this->facing, 0.5) //avoid overlapping with main step ->trim($this->facing, 0.5) //avoid overlapping with main step
->trim(Facing::rotateY($this->facing, $this->shape->equals(StairShape::INNER_LEFT())), 0.5); ->trim(Facing::rotateY($this->facing, $this->shape === StairShape::INNER_LEFT), 0.5);
} }
$bbs[] = $topStep; $bbs[] = $topStep;
@ -111,13 +106,13 @@ class Stair extends Transparent{
if( if(
$facing === Facing::UP && $this->isUpsideDown() || $facing === Facing::UP && $this->isUpsideDown() ||
$facing === Facing::DOWN && !$this->isUpsideDown() || $facing === Facing::DOWN && !$this->isUpsideDown() ||
($facing === $this->facing && !$this->shape->equals(StairShape::OUTER_LEFT()) && !$this->shape->equals(StairShape::OUTER_RIGHT())) || ($facing === $this->facing && $this->shape !== StairShape::OUTER_LEFT && $this->shape !== StairShape::OUTER_RIGHT) ||
($facing === Facing::rotate($this->facing, Axis::Y, false) && $this->shape->equals(StairShape::INNER_LEFT())) || ($facing === Facing::rotate($this->facing, Axis::Y, false) && $this->shape === StairShape::INNER_LEFT) ||
($facing === Facing::rotate($this->facing, Axis::Y, true) && $this->shape->equals(StairShape::INNER_RIGHT())) ($facing === Facing::rotate($this->facing, Axis::Y, true) && $this->shape === StairShape::INNER_RIGHT)
){ ){
return SupportType::FULL(); return SupportType::FULL;
} }
return SupportType::NONE(); return SupportType::NONE;
} }
private function getPossibleCornerFacing(bool $oppositeFacing) : ?int{ private function getPossibleCornerFacing(bool $oppositeFacing) : ?int{

View File

@ -47,6 +47,6 @@ class Stonecutter extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -41,7 +41,7 @@ class Thin extends Transparent{
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
$side = $this->getSide($facing); $side = $this->getSide($facing);
if($side instanceof Thin || $side instanceof Wall || $side->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){ if($side instanceof Thin || $side instanceof Wall || $side->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
$this->connections[$facing] = true; $this->connections[$facing] = true;
}else{ }else{
unset($this->connections[$facing]); unset($this->connections[$facing]);
@ -90,6 +90,6 @@ class Thin extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
} }

View File

@ -84,6 +84,6 @@ class Torch extends Flowable{
private function canBeSupportedAt(Block $block, int $face) : bool{ private function canBeSupportedAt(Block $block, int $face) : bool{
return $face === Facing::DOWN ? return $face === Facing::DOWN ?
$block->getAdjacentSupportType($face)->hasCenterSupport() : $block->getAdjacentSupportType($face)->hasCenterSupport() :
$block->getAdjacentSupportType($face)->equals(SupportType::FULL()); $block->getAdjacentSupportType($face) === SupportType::FULL;
} }
} }

View File

@ -70,7 +70,7 @@ class Trapdoor extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return SupportType::NONE(); return SupportType::NONE;
} }
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -68,6 +68,7 @@ use pocketmine\utils\CloningRegistryTrait;
use pocketmine\world\sound\AmethystBlockChimeSound; use pocketmine\world\sound\AmethystBlockChimeSound;
use pocketmine\world\sound\BlockPunchSound; use pocketmine\world\sound\BlockPunchSound;
use function mb_strtolower; use function mb_strtolower;
use function strtolower;
/** /**
* This doc-block is generated automatically, do not modify it manually. * This doc-block is generated automatically, do not modify it manually.
@ -782,7 +783,7 @@ final class VanillaBlocks{
$railBreakInfo = new Info(new BlockBreakInfo(0.7)); $railBreakInfo = new Info(new BlockBreakInfo(0.7));
self::register("activator_rail", new ActivatorRail(new BID(Ids::ACTIVATOR_RAIL), "Activator Rail", $railBreakInfo)); self::register("activator_rail", new ActivatorRail(new BID(Ids::ACTIVATOR_RAIL), "Activator Rail", $railBreakInfo));
self::register("air", new Air(new BID(Ids::AIR), "Air", new Info(BreakInfo::indestructible(-1.0)))); self::register("air", new Air(new BID(Ids::AIR), "Air", new Info(BreakInfo::indestructible(-1.0))));
self::register("anvil", new Anvil(new BID(Ids::ANVIL), "Anvil", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD(), 6000.0)))); self::register("anvil", new Anvil(new BID(Ids::ANVIL), "Anvil", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 6000.0))));
self::register("bamboo", new Bamboo(new BID(Ids::BAMBOO), "Bamboo", new Info(new class(2.0 /* 1.0 in PC */, ToolType::AXE) extends BreakInfo{ self::register("bamboo", new Bamboo(new BID(Ids::BAMBOO), "Bamboo", new Info(new class(2.0 /* 1.0 in PC */, ToolType::AXE) extends BreakInfo{
public function getBreakTime(Item $item) : float{ public function getBreakTime(Item $item) : float{
if($item->getBlockToolType() === ToolType::SWORD){ if($item->getBlockToolType() === ToolType::SWORD){
@ -803,13 +804,13 @@ final class VanillaBlocks{
self::register("bedrock", new Bedrock(new BID(Ids::BEDROCK), "Bedrock", new Info(BreakInfo::indestructible()))); self::register("bedrock", new Bedrock(new BID(Ids::BEDROCK), "Bedrock", new Info(BreakInfo::indestructible())));
self::register("beetroots", new Beetroot(new BID(Ids::BEETROOTS), "Beetroot Block", new Info(BreakInfo::instant()))); self::register("beetroots", new Beetroot(new BID(Ids::BEETROOTS), "Beetroot Block", new Info(BreakInfo::instant())));
self::register("bell", new Bell(new BID(Ids::BELL, TileBell::class), "Bell", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD())))); self::register("bell", new Bell(new BID(Ids::BELL, TileBell::class), "Bell", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD))));
self::register("blue_ice", new BlueIce(new BID(Ids::BLUE_ICE), "Blue Ice", new Info(BreakInfo::pickaxe(2.8)))); self::register("blue_ice", new BlueIce(new BID(Ids::BLUE_ICE), "Blue Ice", new Info(BreakInfo::pickaxe(2.8))));
self::register("bone_block", new BoneBlock(new BID(Ids::BONE_BLOCK), "Bone Block", new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD())))); self::register("bone_block", new BoneBlock(new BID(Ids::BONE_BLOCK), "Bone Block", new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD))));
self::register("bookshelf", new Bookshelf(new BID(Ids::BOOKSHELF), "Bookshelf", new Info(BreakInfo::axe(1.5)))); self::register("bookshelf", new Bookshelf(new BID(Ids::BOOKSHELF), "Bookshelf", new Info(BreakInfo::axe(1.5))));
self::register("brewing_stand", new BrewingStand(new BID(Ids::BREWING_STAND, TileBrewingStand::class), "Brewing Stand", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD())))); self::register("brewing_stand", new BrewingStand(new BID(Ids::BREWING_STAND, TileBrewingStand::class), "Brewing Stand", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD))));
$bricksBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $bricksBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("brick_stairs", new Stair(new BID(Ids::BRICK_STAIRS), "Brick Stairs", $bricksBreakInfo)); self::register("brick_stairs", new Stair(new BID(Ids::BRICK_STAIRS), "Brick Stairs", $bricksBreakInfo));
self::register("bricks", new Opaque(new BID(Ids::BRICKS), "Bricks", $bricksBreakInfo)); self::register("bricks", new Opaque(new BID(Ids::BRICKS), "Bricks", $bricksBreakInfo));
@ -821,9 +822,9 @@ final class VanillaBlocks{
$chestBreakInfo = new Info(BreakInfo::axe(2.5)); $chestBreakInfo = new Info(BreakInfo::axe(2.5));
self::register("chest", new Chest(new BID(Ids::CHEST, TileChest::class), "Chest", $chestBreakInfo)); self::register("chest", new Chest(new BID(Ids::CHEST, TileChest::class), "Chest", $chestBreakInfo));
self::register("clay", new Clay(new BID(Ids::CLAY), "Clay Block", new Info(BreakInfo::shovel(0.6)))); self::register("clay", new Clay(new BID(Ids::CLAY), "Clay Block", new Info(BreakInfo::shovel(0.6))));
self::register("coal", new Coal(new BID(Ids::COAL), "Coal Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD(), 30.0)))); self::register("coal", new Coal(new BID(Ids::COAL), "Coal Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 30.0))));
$cobblestoneBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $cobblestoneBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("cobblestone", $cobblestone = new Opaque(new BID(Ids::COBBLESTONE), "Cobblestone", $cobblestoneBreakInfo)); self::register("cobblestone", $cobblestone = new Opaque(new BID(Ids::COBBLESTONE), "Cobblestone", $cobblestoneBreakInfo));
self::register("mossy_cobblestone", new Opaque(new BID(Ids::MOSSY_COBBLESTONE), "Mossy Cobblestone", $cobblestoneBreakInfo)); self::register("mossy_cobblestone", new Opaque(new BID(Ids::MOSSY_COBBLESTONE), "Mossy Cobblestone", $cobblestoneBreakInfo));
self::register("cobblestone_stairs", new Stair(new BID(Ids::COBBLESTONE_STAIRS), "Cobblestone Stairs", $cobblestoneBreakInfo)); self::register("cobblestone_stairs", new Stair(new BID(Ids::COBBLESTONE_STAIRS), "Cobblestone Stairs", $cobblestoneBreakInfo));
@ -831,12 +832,12 @@ final class VanillaBlocks{
self::register("cobweb", new Cobweb(new BID(Ids::COBWEB), "Cobweb", new Info(new BreakInfo(4.0, ToolType::SWORD | ToolType::SHEARS, 1)))); self::register("cobweb", new Cobweb(new BID(Ids::COBWEB), "Cobweb", new Info(new BreakInfo(4.0, ToolType::SWORD | ToolType::SHEARS, 1))));
self::register("cocoa_pod", new CocoaBlock(new BID(Ids::COCOA_POD), "Cocoa Block", new Info(BreakInfo::axe(0.2, null, 15.0)))); self::register("cocoa_pod", new CocoaBlock(new BID(Ids::COCOA_POD), "Cocoa Block", new Info(BreakInfo::axe(0.2, null, 15.0))));
self::register("coral_block", new CoralBlock(new BID(Ids::CORAL_BLOCK), "Coral Block", new Info(BreakInfo::pickaxe(7.0, ToolTier::WOOD())))); self::register("coral_block", new CoralBlock(new BID(Ids::CORAL_BLOCK), "Coral Block", new Info(BreakInfo::pickaxe(7.0, ToolTier::WOOD))));
self::register("daylight_sensor", new DaylightSensor(new BID(Ids::DAYLIGHT_SENSOR, TileDaylightSensor::class), "Daylight Sensor", new Info(BreakInfo::axe(0.2)))); self::register("daylight_sensor", new DaylightSensor(new BID(Ids::DAYLIGHT_SENSOR, TileDaylightSensor::class), "Daylight Sensor", new Info(BreakInfo::axe(0.2))));
self::register("dead_bush", new DeadBush(new BID(Ids::DEAD_BUSH), "Dead Bush", new Info(BreakInfo::instant(ToolType::SHEARS, 1), [Tags::POTTABLE_PLANTS]))); self::register("dead_bush", new DeadBush(new BID(Ids::DEAD_BUSH), "Dead Bush", new Info(BreakInfo::instant(ToolType::SHEARS, 1), [Tags::POTTABLE_PLANTS])));
self::register("detector_rail", new DetectorRail(new BID(Ids::DETECTOR_RAIL), "Detector Rail", $railBreakInfo)); self::register("detector_rail", new DetectorRail(new BID(Ids::DETECTOR_RAIL), "Detector Rail", $railBreakInfo));
self::register("diamond", new Opaque(new BID(Ids::DIAMOND), "Diamond Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::IRON(), 30.0)))); self::register("diamond", new Opaque(new BID(Ids::DIAMOND), "Diamond Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::IRON, 30.0))));
self::register("dirt", new Dirt(new BID(Ids::DIRT), "Dirt", new Info(BreakInfo::shovel(0.5), [Tags::DIRT]))); self::register("dirt", new Dirt(new BID(Ids::DIRT), "Dirt", new Info(BreakInfo::shovel(0.5), [Tags::DIRT])));
self::register("sunflower", new DoublePlant(new BID(Ids::SUNFLOWER), "Sunflower", new Info(BreakInfo::instant()))); self::register("sunflower", new DoublePlant(new BID(Ids::SUNFLOWER), "Sunflower", new Info(BreakInfo::instant())));
self::register("lilac", new DoublePlant(new BID(Ids::LILAC), "Lilac", new Info(BreakInfo::instant()))); self::register("lilac", new DoublePlant(new BID(Ids::LILAC), "Lilac", new Info(BreakInfo::instant())));
@ -845,19 +846,19 @@ final class VanillaBlocks{
self::register("pink_petals", new PinkPetals(new BID(Ids::PINK_PETALS), "Pink Petals", new Info(BreakInfo::instant()))); self::register("pink_petals", new PinkPetals(new BID(Ids::PINK_PETALS), "Pink Petals", new Info(BreakInfo::instant())));
self::register("double_tallgrass", new DoubleTallGrass(new BID(Ids::DOUBLE_TALLGRASS), "Double Tallgrass", new Info(BreakInfo::instant(ToolType::SHEARS, 1)))); self::register("double_tallgrass", new DoubleTallGrass(new BID(Ids::DOUBLE_TALLGRASS), "Double Tallgrass", new Info(BreakInfo::instant(ToolType::SHEARS, 1))));
self::register("large_fern", new DoubleTallGrass(new BID(Ids::LARGE_FERN), "Large Fern", new Info(BreakInfo::instant(ToolType::SHEARS, 1)))); self::register("large_fern", new DoubleTallGrass(new BID(Ids::LARGE_FERN), "Large Fern", new Info(BreakInfo::instant(ToolType::SHEARS, 1))));
self::register("dragon_egg", new DragonEgg(new BID(Ids::DRAGON_EGG), "Dragon Egg", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD())))); self::register("dragon_egg", new DragonEgg(new BID(Ids::DRAGON_EGG), "Dragon Egg", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD))));
self::register("dried_kelp", new DriedKelp(new BID(Ids::DRIED_KELP), "Dried Kelp Block", new Info(new BreakInfo(0.5, ToolType::NONE, 0, 12.5)))); self::register("dried_kelp", new DriedKelp(new BID(Ids::DRIED_KELP), "Dried Kelp Block", new Info(new BreakInfo(0.5, ToolType::NONE, 0, 12.5))));
self::register("emerald", new Opaque(new BID(Ids::EMERALD), "Emerald Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::IRON(), 30.0)))); self::register("emerald", new Opaque(new BID(Ids::EMERALD), "Emerald Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::IRON, 30.0))));
self::register("enchanting_table", new EnchantingTable(new BID(Ids::ENCHANTING_TABLE, TileEnchantingTable::class), "Enchanting Table", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD(), 6000.0)))); self::register("enchanting_table", new EnchantingTable(new BID(Ids::ENCHANTING_TABLE, TileEnchantingTable::class), "Enchanting Table", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 6000.0))));
self::register("end_portal_frame", new EndPortalFrame(new BID(Ids::END_PORTAL_FRAME), "End Portal Frame", new Info(BreakInfo::indestructible()))); self::register("end_portal_frame", new EndPortalFrame(new BID(Ids::END_PORTAL_FRAME), "End Portal Frame", new Info(BreakInfo::indestructible())));
self::register("end_rod", new EndRod(new BID(Ids::END_ROD), "End Rod", new Info(BreakInfo::instant()))); self::register("end_rod", new EndRod(new BID(Ids::END_ROD), "End Rod", new Info(BreakInfo::instant())));
self::register("end_stone", new Opaque(new BID(Ids::END_STONE), "End Stone", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD(), 45.0)))); self::register("end_stone", new Opaque(new BID(Ids::END_STONE), "End Stone", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 45.0))));
$endBrickBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD(), 4.0)); $endBrickBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD, 4.0));
self::register("end_stone_bricks", new Opaque(new BID(Ids::END_STONE_BRICKS), "End Stone Bricks", $endBrickBreakInfo)); self::register("end_stone_bricks", new Opaque(new BID(Ids::END_STONE_BRICKS), "End Stone Bricks", $endBrickBreakInfo));
self::register("end_stone_brick_stairs", new Stair(new BID(Ids::END_STONE_BRICK_STAIRS), "End Stone Brick Stairs", $endBrickBreakInfo)); self::register("end_stone_brick_stairs", new Stair(new BID(Ids::END_STONE_BRICK_STAIRS), "End Stone Brick Stairs", $endBrickBreakInfo));
self::register("ender_chest", new EnderChest(new BID(Ids::ENDER_CHEST, TileEnderChest::class), "Ender Chest", new Info(BreakInfo::pickaxe(22.5, ToolTier::WOOD(), 3000.0)))); self::register("ender_chest", new EnderChest(new BID(Ids::ENDER_CHEST, TileEnderChest::class), "Ender Chest", new Info(BreakInfo::pickaxe(22.5, ToolTier::WOOD, 3000.0))));
self::register("farmland", new Farmland(new BID(Ids::FARMLAND), "Farmland", new Info(BreakInfo::shovel(0.6), [Tags::DIRT]))); self::register("farmland", new Farmland(new BID(Ids::FARMLAND), "Farmland", new Info(BreakInfo::shovel(0.6), [Tags::DIRT])));
self::register("fire", new Fire(new BID(Ids::FIRE), "Fire Block", new Info(BreakInfo::instant(), [Tags::FIRE]))); self::register("fire", new Fire(new BID(Ids::FIRE), "Fire Block", new Info(BreakInfo::instant(), [Tags::FIRE])));
@ -876,31 +877,31 @@ final class VanillaBlocks{
self::register("white_tulip", new Flower(new BID(Ids::WHITE_TULIP), "White Tulip", $flowerTypeInfo)); self::register("white_tulip", new Flower(new BID(Ids::WHITE_TULIP), "White Tulip", $flowerTypeInfo));
self::register("flower_pot", new FlowerPot(new BID(Ids::FLOWER_POT, TileFlowerPot::class), "Flower Pot", new Info(BreakInfo::instant()))); self::register("flower_pot", new FlowerPot(new BID(Ids::FLOWER_POT, TileFlowerPot::class), "Flower Pot", new Info(BreakInfo::instant())));
self::register("frosted_ice", new FrostedIce(new BID(Ids::FROSTED_ICE), "Frosted Ice", new Info(BreakInfo::pickaxe(2.5)))); self::register("frosted_ice", new FrostedIce(new BID(Ids::FROSTED_ICE), "Frosted Ice", new Info(BreakInfo::pickaxe(2.5))));
self::register("furnace", new Furnace(new BID(Ids::FURNACE, TileNormalFurnace::class), "Furnace", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD())), FurnaceType::FURNACE())); self::register("furnace", new Furnace(new BID(Ids::FURNACE, TileNormalFurnace::class), "Furnace", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD)), FurnaceType::FURNACE));
self::register("blast_furnace", new Furnace(new BID(Ids::BLAST_FURNACE, TileBlastFurnace::class), "Blast Furnace", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD())), FurnaceType::BLAST_FURNACE())); self::register("blast_furnace", new Furnace(new BID(Ids::BLAST_FURNACE, TileBlastFurnace::class), "Blast Furnace", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD)), FurnaceType::BLAST_FURNACE));
self::register("smoker", new Furnace(new BID(Ids::SMOKER, TileSmoker::class), "Smoker", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD())), FurnaceType::SMOKER())); self::register("smoker", new Furnace(new BID(Ids::SMOKER, TileSmoker::class), "Smoker", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD)), FurnaceType::SMOKER));
$glassBreakInfo = new Info(new BreakInfo(0.3)); $glassBreakInfo = new Info(new BreakInfo(0.3));
self::register("glass", new Glass(new BID(Ids::GLASS), "Glass", $glassBreakInfo)); self::register("glass", new Glass(new BID(Ids::GLASS), "Glass", $glassBreakInfo));
self::register("glass_pane", new GlassPane(new BID(Ids::GLASS_PANE), "Glass Pane", $glassBreakInfo)); self::register("glass_pane", new GlassPane(new BID(Ids::GLASS_PANE), "Glass Pane", $glassBreakInfo));
self::register("glowing_obsidian", new GlowingObsidian(new BID(Ids::GLOWING_OBSIDIAN), "Glowing Obsidian", new Info(BreakInfo::pickaxe(10.0, ToolTier::DIAMOND(), 50.0)))); self::register("glowing_obsidian", new GlowingObsidian(new BID(Ids::GLOWING_OBSIDIAN), "Glowing Obsidian", new Info(BreakInfo::pickaxe(10.0, ToolTier::DIAMOND, 50.0))));
self::register("glowstone", new Glowstone(new BID(Ids::GLOWSTONE), "Glowstone", new Info(BreakInfo::pickaxe(0.3)))); self::register("glowstone", new Glowstone(new BID(Ids::GLOWSTONE), "Glowstone", new Info(BreakInfo::pickaxe(0.3))));
self::register("glow_lichen", new GlowLichen(new BID(Ids::GLOW_LICHEN), "Glow Lichen", new Info(BreakInfo::axe(0.2, null, 0.2)))); self::register("glow_lichen", new GlowLichen(new BID(Ids::GLOW_LICHEN), "Glow Lichen", new Info(BreakInfo::axe(0.2, null, 0.2))));
self::register("gold", new Opaque(new BID(Ids::GOLD), "Gold Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::IRON(), 30.0)))); self::register("gold", new Opaque(new BID(Ids::GOLD), "Gold Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::IRON, 30.0))));
$grassBreakInfo = BreakInfo::shovel(0.6); $grassBreakInfo = BreakInfo::shovel(0.6);
self::register("grass", new Grass(new BID(Ids::GRASS), "Grass", new Info($grassBreakInfo, [Tags::DIRT]))); self::register("grass", new Grass(new BID(Ids::GRASS), "Grass", new Info($grassBreakInfo, [Tags::DIRT])));
self::register("grass_path", new GrassPath(new BID(Ids::GRASS_PATH), "Grass Path", new Info($grassBreakInfo))); self::register("grass_path", new GrassPath(new BID(Ids::GRASS_PATH), "Grass Path", new Info($grassBreakInfo)));
self::register("gravel", new Gravel(new BID(Ids::GRAVEL), "Gravel", new Info(BreakInfo::shovel(0.6)))); self::register("gravel", new Gravel(new BID(Ids::GRAVEL), "Gravel", new Info(BreakInfo::shovel(0.6))));
$hardenedClayBreakInfo = new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD(), 21.0)); $hardenedClayBreakInfo = new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD, 21.0));
self::register("hardened_clay", new HardenedClay(new BID(Ids::HARDENED_CLAY), "Hardened Clay", $hardenedClayBreakInfo)); self::register("hardened_clay", new HardenedClay(new BID(Ids::HARDENED_CLAY), "Hardened Clay", $hardenedClayBreakInfo));
$hardenedGlassBreakInfo = new Info(new BreakInfo(10.0)); $hardenedGlassBreakInfo = new Info(new BreakInfo(10.0));
self::register("hardened_glass", new HardenedGlass(new BID(Ids::HARDENED_GLASS), "Hardened Glass", $hardenedGlassBreakInfo)); self::register("hardened_glass", new HardenedGlass(new BID(Ids::HARDENED_GLASS), "Hardened Glass", $hardenedGlassBreakInfo));
self::register("hardened_glass_pane", new HardenedGlassPane(new BID(Ids::HARDENED_GLASS_PANE), "Hardened Glass Pane", $hardenedGlassBreakInfo)); self::register("hardened_glass_pane", new HardenedGlassPane(new BID(Ids::HARDENED_GLASS_PANE), "Hardened Glass Pane", $hardenedGlassBreakInfo));
self::register("hay_bale", new HayBale(new BID(Ids::HAY_BALE), "Hay Bale", new Info(new BreakInfo(0.5)))); self::register("hay_bale", new HayBale(new BID(Ids::HAY_BALE), "Hay Bale", new Info(new BreakInfo(0.5))));
self::register("hopper", new Hopper(new BID(Ids::HOPPER, TileHopper::class), "Hopper", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD(), 15.0)))); self::register("hopper", new Hopper(new BID(Ids::HOPPER, TileHopper::class), "Hopper", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 15.0))));
self::register("ice", new Ice(new BID(Ids::ICE), "Ice", new Info(BreakInfo::pickaxe(0.5)))); self::register("ice", new Ice(new BID(Ids::ICE), "Ice", new Info(BreakInfo::pickaxe(0.5))));
$updateBlockBreakInfo = new Info(new BreakInfo(1.0)); $updateBlockBreakInfo = new Info(new BreakInfo(1.0));
@ -908,10 +909,10 @@ final class VanillaBlocks{
self::register("info_update2", new Opaque(new BID(Ids::INFO_UPDATE2), "ate!upd", $updateBlockBreakInfo)); self::register("info_update2", new Opaque(new BID(Ids::INFO_UPDATE2), "ate!upd", $updateBlockBreakInfo));
self::register("invisible_bedrock", new Transparent(new BID(Ids::INVISIBLE_BEDROCK), "Invisible Bedrock", new Info(BreakInfo::indestructible()))); self::register("invisible_bedrock", new Transparent(new BID(Ids::INVISIBLE_BEDROCK), "Invisible Bedrock", new Info(BreakInfo::indestructible())));
$ironBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::STONE(), 30.0)); $ironBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::STONE, 30.0));
self::register("iron", new Opaque(new BID(Ids::IRON), "Iron Block", $ironBreakInfo)); self::register("iron", new Opaque(new BID(Ids::IRON), "Iron Block", $ironBreakInfo));
self::register("iron_bars", new Thin(new BID(Ids::IRON_BARS), "Iron Bars", $ironBreakInfo)); self::register("iron_bars", new Thin(new BID(Ids::IRON_BARS), "Iron Bars", $ironBreakInfo));
$ironDoorBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD(), 25.0)); $ironDoorBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 25.0));
self::register("iron_door", new Door(new BID(Ids::IRON_DOOR), "Iron Door", $ironDoorBreakInfo)); self::register("iron_door", new Door(new BID(Ids::IRON_DOOR), "Iron Door", $ironDoorBreakInfo));
self::register("iron_trapdoor", new Trapdoor(new BID(Ids::IRON_TRAPDOOR), "Iron Trapdoor", $ironDoorBreakInfo)); self::register("iron_trapdoor", new Trapdoor(new BID(Ids::IRON_TRAPDOOR), "Iron Trapdoor", $ironDoorBreakInfo));
@ -922,21 +923,21 @@ final class VanillaBlocks{
self::register("jukebox", new Jukebox(new BID(Ids::JUKEBOX, TileJukebox::class), "Jukebox", new Info(BreakInfo::axe(0.8)))); //TODO: in PC the hardness is 2.0, not 0.8, unsure if this is a MCPE bug or not self::register("jukebox", new Jukebox(new BID(Ids::JUKEBOX, TileJukebox::class), "Jukebox", new Info(BreakInfo::axe(0.8)))); //TODO: in PC the hardness is 2.0, not 0.8, unsure if this is a MCPE bug or not
self::register("ladder", new Ladder(new BID(Ids::LADDER), "Ladder", new Info(BreakInfo::axe(0.4)))); self::register("ladder", new Ladder(new BID(Ids::LADDER), "Ladder", new Info(BreakInfo::axe(0.4))));
$lanternBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD())); $lanternBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD));
self::register("lantern", new Lantern(new BID(Ids::LANTERN), "Lantern", $lanternBreakInfo, 15)); self::register("lantern", new Lantern(new BID(Ids::LANTERN), "Lantern", $lanternBreakInfo, 15));
self::register("soul_lantern", new Lantern(new BID(Ids::SOUL_LANTERN), "Soul Lantern", $lanternBreakInfo, 10)); self::register("soul_lantern", new Lantern(new BID(Ids::SOUL_LANTERN), "Soul Lantern", $lanternBreakInfo, 10));
self::register("lapis_lazuli", new Opaque(new BID(Ids::LAPIS_LAZULI), "Lapis Lazuli Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE())))); self::register("lapis_lazuli", new Opaque(new BID(Ids::LAPIS_LAZULI), "Lapis Lazuli Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE))));
self::register("lava", new Lava(new BID(Ids::LAVA), "Lava", new Info(BreakInfo::indestructible(500.0)))); self::register("lava", new Lava(new BID(Ids::LAVA), "Lava", new Info(BreakInfo::indestructible(500.0))));
self::register("lectern", new Lectern(new BID(Ids::LECTERN, TileLectern::class), "Lectern", new Info(BreakInfo::axe(2.0)))); self::register("lectern", new Lectern(new BID(Ids::LECTERN, TileLectern::class), "Lectern", new Info(BreakInfo::axe(2.0))));
self::register("lever", new Lever(new BID(Ids::LEVER), "Lever", new Info(new BreakInfo(0.5)))); self::register("lever", new Lever(new BID(Ids::LEVER), "Lever", new Info(new BreakInfo(0.5))));
self::register("magma", new Magma(new BID(Ids::MAGMA), "Magma Block", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD())))); self::register("magma", new Magma(new BID(Ids::MAGMA), "Magma Block", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD))));
self::register("melon", new Melon(new BID(Ids::MELON), "Melon Block", new Info(BreakInfo::axe(1.0)))); self::register("melon", new Melon(new BID(Ids::MELON), "Melon Block", new Info(BreakInfo::axe(1.0))));
self::register("melon_stem", new MelonStem(new BID(Ids::MELON_STEM), "Melon Stem", new Info(BreakInfo::instant()))); self::register("melon_stem", new MelonStem(new BID(Ids::MELON_STEM), "Melon Stem", new Info(BreakInfo::instant())));
self::register("monster_spawner", new MonsterSpawner(new BID(Ids::MONSTER_SPAWNER, TileMonsterSpawner::class), "Monster Spawner", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD())))); self::register("monster_spawner", new MonsterSpawner(new BID(Ids::MONSTER_SPAWNER, TileMonsterSpawner::class), "Monster Spawner", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD))));
self::register("mycelium", new Mycelium(new BID(Ids::MYCELIUM), "Mycelium", new Info(BreakInfo::shovel(0.6), [Tags::DIRT]))); self::register("mycelium", new Mycelium(new BID(Ids::MYCELIUM), "Mycelium", new Info(BreakInfo::shovel(0.6), [Tags::DIRT])));
$netherBrickBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $netherBrickBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("nether_bricks", new Opaque(new BID(Ids::NETHER_BRICKS), "Nether Bricks", $netherBrickBreakInfo)); self::register("nether_bricks", new Opaque(new BID(Ids::NETHER_BRICKS), "Nether Bricks", $netherBrickBreakInfo));
self::register("red_nether_bricks", new Opaque(new BID(Ids::RED_NETHER_BRICKS), "Red Nether Bricks", $netherBrickBreakInfo)); self::register("red_nether_bricks", new Opaque(new BID(Ids::RED_NETHER_BRICKS), "Red Nether Bricks", $netherBrickBreakInfo));
self::register("nether_brick_fence", new Fence(new BID(Ids::NETHER_BRICK_FENCE), "Nether Brick Fence", $netherBrickBreakInfo)); self::register("nether_brick_fence", new Fence(new BID(Ids::NETHER_BRICK_FENCE), "Nether Brick Fence", $netherBrickBreakInfo));
@ -946,18 +947,18 @@ final class VanillaBlocks{
self::register("cracked_nether_bricks", new Opaque(new BID(Ids::CRACKED_NETHER_BRICKS), "Cracked Nether Bricks", $netherBrickBreakInfo)); self::register("cracked_nether_bricks", new Opaque(new BID(Ids::CRACKED_NETHER_BRICKS), "Cracked Nether Bricks", $netherBrickBreakInfo));
self::register("nether_portal", new NetherPortal(new BID(Ids::NETHER_PORTAL), "Nether Portal", new Info(BreakInfo::indestructible(0.0)))); self::register("nether_portal", new NetherPortal(new BID(Ids::NETHER_PORTAL), "Nether Portal", new Info(BreakInfo::indestructible(0.0))));
self::register("nether_reactor_core", new NetherReactor(new BID(Ids::NETHER_REACTOR_CORE), "Nether Reactor Core", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD())))); self::register("nether_reactor_core", new NetherReactor(new BID(Ids::NETHER_REACTOR_CORE), "Nether Reactor Core", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD))));
self::register("nether_wart_block", new Opaque(new BID(Ids::NETHER_WART_BLOCK), "Nether Wart Block", new Info(new BreakInfo(1.0, ToolType::HOE)))); self::register("nether_wart_block", new Opaque(new BID(Ids::NETHER_WART_BLOCK), "Nether Wart Block", new Info(new BreakInfo(1.0, ToolType::HOE))));
self::register("nether_wart", new NetherWartPlant(new BID(Ids::NETHER_WART), "Nether Wart", new Info(BreakInfo::instant()))); self::register("nether_wart", new NetherWartPlant(new BID(Ids::NETHER_WART), "Nether Wart", new Info(BreakInfo::instant())));
self::register("netherrack", new Netherrack(new BID(Ids::NETHERRACK), "Netherrack", new Info(BreakInfo::pickaxe(0.4, ToolTier::WOOD())))); self::register("netherrack", new Netherrack(new BID(Ids::NETHERRACK), "Netherrack", new Info(BreakInfo::pickaxe(0.4, ToolTier::WOOD))));
self::register("note_block", new Note(new BID(Ids::NOTE_BLOCK, TileNote::class), "Note Block", new Info(BreakInfo::axe(0.8)))); self::register("note_block", new Note(new BID(Ids::NOTE_BLOCK, TileNote::class), "Note Block", new Info(BreakInfo::axe(0.8))));
self::register("obsidian", new Opaque(new BID(Ids::OBSIDIAN), "Obsidian", new Info(BreakInfo::pickaxe(35.0 /* 50 in PC */, ToolTier::DIAMOND(), 6000.0)))); self::register("obsidian", new Opaque(new BID(Ids::OBSIDIAN), "Obsidian", new Info(BreakInfo::pickaxe(35.0 /* 50 in PC */, ToolTier::DIAMOND, 6000.0))));
self::register("packed_ice", new PackedIce(new BID(Ids::PACKED_ICE), "Packed Ice", new Info(BreakInfo::pickaxe(0.5)))); self::register("packed_ice", new PackedIce(new BID(Ids::PACKED_ICE), "Packed Ice", new Info(BreakInfo::pickaxe(0.5))));
self::register("podzol", new Podzol(new BID(Ids::PODZOL), "Podzol", new Info(BreakInfo::shovel(0.5), [Tags::DIRT]))); self::register("podzol", new Podzol(new BID(Ids::PODZOL), "Podzol", new Info(BreakInfo::shovel(0.5), [Tags::DIRT])));
self::register("potatoes", new Potato(new BID(Ids::POTATOES), "Potato Block", new Info(BreakInfo::instant()))); self::register("potatoes", new Potato(new BID(Ids::POTATOES), "Potato Block", new Info(BreakInfo::instant())));
self::register("powered_rail", new PoweredRail(new BID(Ids::POWERED_RAIL), "Powered Rail", $railBreakInfo)); self::register("powered_rail", new PoweredRail(new BID(Ids::POWERED_RAIL), "Powered Rail", $railBreakInfo));
$prismarineBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0)); $prismarineBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
self::register("prismarine", new Opaque(new BID(Ids::PRISMARINE), "Prismarine", $prismarineBreakInfo)); self::register("prismarine", new Opaque(new BID(Ids::PRISMARINE), "Prismarine", $prismarineBreakInfo));
self::register("dark_prismarine", new Opaque(new BID(Ids::DARK_PRISMARINE), "Dark Prismarine", $prismarineBreakInfo)); self::register("dark_prismarine", new Opaque(new BID(Ids::DARK_PRISMARINE), "Dark Prismarine", $prismarineBreakInfo));
self::register("prismarine_bricks", new Opaque(new BID(Ids::PRISMARINE_BRICKS), "Prismarine Bricks", $prismarineBreakInfo)); self::register("prismarine_bricks", new Opaque(new BID(Ids::PRISMARINE_BRICKS), "Prismarine Bricks", $prismarineBreakInfo));
@ -972,12 +973,12 @@ final class VanillaBlocks{
self::register("pumpkin_stem", new PumpkinStem(new BID(Ids::PUMPKIN_STEM), "Pumpkin Stem", new Info(BreakInfo::instant()))); self::register("pumpkin_stem", new PumpkinStem(new BID(Ids::PUMPKIN_STEM), "Pumpkin Stem", new Info(BreakInfo::instant())));
$purpurBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0)); $purpurBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
self::register("purpur", new Opaque(new BID(Ids::PURPUR), "Purpur Block", $purpurBreakInfo)); self::register("purpur", new Opaque(new BID(Ids::PURPUR), "Purpur Block", $purpurBreakInfo));
self::register("purpur_pillar", new SimplePillar(new BID(Ids::PURPUR_PILLAR), "Purpur Pillar", $purpurBreakInfo)); self::register("purpur_pillar", new SimplePillar(new BID(Ids::PURPUR_PILLAR), "Purpur Pillar", $purpurBreakInfo));
self::register("purpur_stairs", new Stair(new BID(Ids::PURPUR_STAIRS), "Purpur Stairs", $purpurBreakInfo)); self::register("purpur_stairs", new Stair(new BID(Ids::PURPUR_STAIRS), "Purpur Stairs", $purpurBreakInfo));
$quartzBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD())); $quartzBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD));
self::register("quartz", new Opaque(new BID(Ids::QUARTZ), "Quartz Block", $quartzBreakInfo)); self::register("quartz", new Opaque(new BID(Ids::QUARTZ), "Quartz Block", $quartzBreakInfo));
self::register("chiseled_quartz", new SimplePillar(new BID(Ids::CHISELED_QUARTZ), "Chiseled Quartz Block", $quartzBreakInfo)); self::register("chiseled_quartz", new SimplePillar(new BID(Ids::CHISELED_QUARTZ), "Chiseled Quartz Block", $quartzBreakInfo));
self::register("quartz_pillar", new SimplePillar(new BID(Ids::QUARTZ_PILLAR), "Quartz Pillar", $quartzBreakInfo)); self::register("quartz_pillar", new SimplePillar(new BID(Ids::QUARTZ_PILLAR), "Quartz Pillar", $quartzBreakInfo));
@ -989,7 +990,7 @@ final class VanillaBlocks{
self::register("rail", new Rail(new BID(Ids::RAIL), "Rail", $railBreakInfo)); self::register("rail", new Rail(new BID(Ids::RAIL), "Rail", $railBreakInfo));
self::register("red_mushroom", new RedMushroom(new BID(Ids::RED_MUSHROOM), "Red Mushroom", new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS]))); self::register("red_mushroom", new RedMushroom(new BID(Ids::RED_MUSHROOM), "Red Mushroom", new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS])));
self::register("redstone", new Redstone(new BID(Ids::REDSTONE), "Redstone Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD(), 30.0)))); self::register("redstone", new Redstone(new BID(Ids::REDSTONE), "Redstone Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 30.0))));
self::register("redstone_comparator", new RedstoneComparator(new BID(Ids::REDSTONE_COMPARATOR, TileComparator::class), "Redstone Comparator", new Info(BreakInfo::instant()))); self::register("redstone_comparator", new RedstoneComparator(new BID(Ids::REDSTONE_COMPARATOR, TileComparator::class), "Redstone Comparator", new Info(BreakInfo::instant())));
self::register("redstone_lamp", new RedstoneLamp(new BID(Ids::REDSTONE_LAMP), "Redstone Lamp", new Info(new BreakInfo(0.3)))); self::register("redstone_lamp", new RedstoneLamp(new BID(Ids::REDSTONE_LAMP), "Redstone Lamp", new Info(new BreakInfo(0.3))));
self::register("redstone_repeater", new RedstoneRepeater(new BID(Ids::REDSTONE_REPEATER), "Redstone Repeater", new Info(BreakInfo::instant()))); self::register("redstone_repeater", new RedstoneRepeater(new BID(Ids::REDSTONE_REPEATER), "Redstone Repeater", new Info(BreakInfo::instant())));
@ -1005,14 +1006,14 @@ final class VanillaBlocks{
self::register("sea_pickle", new SeaPickle(new BID(Ids::SEA_PICKLE), "Sea Pickle", new Info(BreakInfo::instant()))); self::register("sea_pickle", new SeaPickle(new BID(Ids::SEA_PICKLE), "Sea Pickle", new Info(BreakInfo::instant())));
self::register("mob_head", new MobHead(new BID(Ids::MOB_HEAD, TileMobHead::class), "Mob Head", new Info(new BreakInfo(1.0), enchantmentTags: [EnchantmentTags::MASK]))); self::register("mob_head", new MobHead(new BID(Ids::MOB_HEAD, TileMobHead::class), "Mob Head", new Info(new BreakInfo(1.0), enchantmentTags: [EnchantmentTags::MASK])));
self::register("slime", new Slime(new BID(Ids::SLIME), "Slime Block", new Info(BreakInfo::instant()))); self::register("slime", new Slime(new BID(Ids::SLIME), "Slime Block", new Info(BreakInfo::instant())));
self::register("snow", new Snow(new BID(Ids::SNOW), "Snow Block", new Info(BreakInfo::shovel(0.2, ToolTier::WOOD())))); self::register("snow", new Snow(new BID(Ids::SNOW), "Snow Block", new Info(BreakInfo::shovel(0.2, ToolTier::WOOD))));
self::register("snow_layer", new SnowLayer(new BID(Ids::SNOW_LAYER), "Snow Layer", new Info(BreakInfo::shovel(0.1, ToolTier::WOOD())))); self::register("snow_layer", new SnowLayer(new BID(Ids::SNOW_LAYER), "Snow Layer", new Info(BreakInfo::shovel(0.1, ToolTier::WOOD))));
self::register("soul_sand", new SoulSand(new BID(Ids::SOUL_SAND), "Soul Sand", new Info(BreakInfo::shovel(0.5)))); self::register("soul_sand", new SoulSand(new BID(Ids::SOUL_SAND), "Soul Sand", new Info(BreakInfo::shovel(0.5))));
self::register("sponge", new Sponge(new BID(Ids::SPONGE), "Sponge", new Info(new BreakInfo(0.6, ToolType::HOE)))); self::register("sponge", new Sponge(new BID(Ids::SPONGE), "Sponge", new Info(new BreakInfo(0.6, ToolType::HOE))));
$shulkerBoxBreakInfo = new Info(BreakInfo::pickaxe(2)); $shulkerBoxBreakInfo = new Info(BreakInfo::pickaxe(2));
self::register("shulker_box", new ShulkerBox(new BID(Ids::SHULKER_BOX, TileShulkerBox::class), "Shulker Box", $shulkerBoxBreakInfo)); self::register("shulker_box", new ShulkerBox(new BID(Ids::SHULKER_BOX, TileShulkerBox::class), "Shulker Box", $shulkerBoxBreakInfo));
$stoneBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0)); $stoneBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
self::register( self::register(
"stone", "stone",
$stone = new class(new BID(Ids::STONE), "Stone", $stoneBreakInfo) extends Opaque{ $stone = new class(new BID(Ids::STONE), "Stone", $stoneBreakInfo) extends Opaque{
@ -1057,10 +1058,10 @@ final class VanillaBlocks{
self::register("mossy_stone_brick_stairs", new Stair(new BID(Ids::MOSSY_STONE_BRICK_STAIRS), "Mossy Stone Brick Stairs", $stoneBreakInfo)); self::register("mossy_stone_brick_stairs", new Stair(new BID(Ids::MOSSY_STONE_BRICK_STAIRS), "Mossy Stone Brick Stairs", $stoneBreakInfo));
self::register("stone_button", new StoneButton(new BID(Ids::STONE_BUTTON), "Stone Button", new Info(BreakInfo::pickaxe(0.5)))); self::register("stone_button", new StoneButton(new BID(Ids::STONE_BUTTON), "Stone Button", new Info(BreakInfo::pickaxe(0.5))));
self::register("stonecutter", new Stonecutter(new BID(Ids::STONECUTTER), "Stonecutter", new Info(BreakInfo::pickaxe(3.5)))); self::register("stonecutter", new Stonecutter(new BID(Ids::STONECUTTER), "Stonecutter", new Info(BreakInfo::pickaxe(3.5))));
self::register("stone_pressure_plate", new StonePressurePlate(new BID(Ids::STONE_PRESSURE_PLATE), "Stone Pressure Plate", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD())))); self::register("stone_pressure_plate", new StonePressurePlate(new BID(Ids::STONE_PRESSURE_PLATE), "Stone Pressure Plate", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD))));
//TODO: in the future this won't be the same for all the types //TODO: in the future this won't be the same for all the types
$stoneSlabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $stoneSlabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("brick_slab", new Slab(new BID(Ids::BRICK_SLAB), "Brick", $stoneSlabBreakInfo)); self::register("brick_slab", new Slab(new BID(Ids::BRICK_SLAB), "Brick", $stoneSlabBreakInfo));
self::register("cobblestone_slab", new Slab(new BID(Ids::COBBLESTONE_SLAB), "Cobblestone", $stoneSlabBreakInfo)); self::register("cobblestone_slab", new Slab(new BID(Ids::COBBLESTONE_SLAB), "Cobblestone", $stoneSlabBreakInfo));
@ -1092,7 +1093,7 @@ final class VanillaBlocks{
self::register("smooth_quartz_slab", new Slab(new BID(Ids::SMOOTH_QUARTZ_SLAB), "Smooth Quartz", $stoneSlabBreakInfo)); self::register("smooth_quartz_slab", new Slab(new BID(Ids::SMOOTH_QUARTZ_SLAB), "Smooth Quartz", $stoneSlabBreakInfo));
self::register("stone_slab", new Slab(new BID(Ids::STONE_SLAB), "Stone", $stoneSlabBreakInfo)); self::register("stone_slab", new Slab(new BID(Ids::STONE_SLAB), "Stone", $stoneSlabBreakInfo));
self::register("legacy_stonecutter", new Opaque(new BID(Ids::LEGACY_STONECUTTER), "Legacy Stonecutter", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD())))); self::register("legacy_stonecutter", new Opaque(new BID(Ids::LEGACY_STONECUTTER), "Legacy Stonecutter", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD))));
self::register("sugarcane", new Sugarcane(new BID(Ids::SUGARCANE), "Sugarcane", new Info(BreakInfo::instant()))); self::register("sugarcane", new Sugarcane(new BID(Ids::SUGARCANE), "Sugarcane", new Info(BreakInfo::instant())));
self::register("sweet_berry_bush", new SweetBerryBush(new BID(Ids::SWEET_BERRY_BUSH), "Sweet Berry Bush", new Info(BreakInfo::instant()))); self::register("sweet_berry_bush", new SweetBerryBush(new BID(Ids::SWEET_BERRY_BUSH), "Sweet Berry Bush", new Info(BreakInfo::instant())));
self::register("tnt", new TNT(new BID(Ids::TNT), "TNT", new Info(BreakInfo::instant()))); self::register("tnt", new TNT(new BID(Ids::TNT), "TNT", new Info(BreakInfo::instant())));
@ -1113,7 +1114,7 @@ final class VanillaBlocks{
self::register("water", new Water(new BID(Ids::WATER), "Water", new Info(BreakInfo::indestructible(500.0)))); self::register("water", new Water(new BID(Ids::WATER), "Water", new Info(BreakInfo::indestructible(500.0))));
self::register("lily_pad", new WaterLily(new BID(Ids::LILY_PAD), "Lily Pad", new Info(BreakInfo::instant()))); self::register("lily_pad", new WaterLily(new BID(Ids::LILY_PAD), "Lily Pad", new Info(BreakInfo::instant())));
$weightedPressurePlateBreakInfo = new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD())); $weightedPressurePlateBreakInfo = new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD));
self::register("weighted_pressure_plate_heavy", new WeightedPressurePlateHeavy( self::register("weighted_pressure_plate_heavy", new WeightedPressurePlateHeavy(
new BID(Ids::WEIGHTED_PRESSURE_PLATE_HEAVY), new BID(Ids::WEIGHTED_PRESSURE_PLATE_HEAVY),
"Weighted Pressure Plate Heavy", "Weighted Pressure Plate Heavy",
@ -1140,16 +1141,16 @@ final class VanillaBlocks{
}); });
$saplingTypeInfo = new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS]); $saplingTypeInfo = new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS]);
foreach(SaplingType::getAll() as $saplingType){ foreach(SaplingType::cases() as $saplingType){
$name = $saplingType->getDisplayName(); $name = $saplingType->getDisplayName();
self::register($saplingType->name() . "_sapling", new Sapling(WoodLikeBlockIdHelper::getSaplingIdentifier($saplingType), $name . " Sapling", $saplingTypeInfo, $saplingType)); self::register(strtolower($saplingType->name) . "_sapling", new Sapling(WoodLikeBlockIdHelper::getSaplingIdentifier($saplingType), $name . " Sapling", $saplingTypeInfo, $saplingType));
} }
foreach(LeavesType::getAll() as $leavesType){ foreach(LeavesType::cases() as $leavesType){
$name = $leavesType->getDisplayName(); $name = $leavesType->getDisplayName();
self::register($leavesType->name() . "_leaves", new Leaves(WoodLikeBlockIdHelper::getLeavesIdentifier($leavesType), $name . " Leaves", $leavesBreakInfo, $leavesType)); self::register(strtolower($leavesType->name) . "_leaves", new Leaves(WoodLikeBlockIdHelper::getLeavesIdentifier($leavesType), $name . " Leaves", $leavesBreakInfo, $leavesType));
} }
$sandstoneBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD())); $sandstoneBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD));
self::register("red_sandstone_stairs", new Stair(new BID(Ids::RED_SANDSTONE_STAIRS), "Red Sandstone Stairs", $sandstoneBreakInfo)); self::register("red_sandstone_stairs", new Stair(new BID(Ids::RED_SANDSTONE_STAIRS), "Red Sandstone Stairs", $sandstoneBreakInfo));
self::register("smooth_red_sandstone_stairs", new Stair(new BID(Ids::SMOOTH_RED_SANDSTONE_STAIRS), "Smooth Red Sandstone Stairs", $sandstoneBreakInfo)); self::register("smooth_red_sandstone_stairs", new Stair(new BID(Ids::SMOOTH_RED_SANDSTONE_STAIRS), "Smooth Red Sandstone Stairs", $sandstoneBreakInfo));
self::register("red_sandstone", new Opaque(new BID(Ids::RED_SANDSTONE), "Red Sandstone", $sandstoneBreakInfo)); self::register("red_sandstone", new Opaque(new BID(Ids::RED_SANDSTONE), "Red Sandstone", $sandstoneBreakInfo));
@ -1164,7 +1165,7 @@ final class VanillaBlocks{
self::register("cut_sandstone", new Opaque(new BID(Ids::CUT_SANDSTONE), "Cut Sandstone", $sandstoneBreakInfo)); self::register("cut_sandstone", new Opaque(new BID(Ids::CUT_SANDSTONE), "Cut Sandstone", $sandstoneBreakInfo));
self::register("smooth_sandstone", new Opaque(new BID(Ids::SMOOTH_SANDSTONE), "Smooth Sandstone", $sandstoneBreakInfo)); self::register("smooth_sandstone", new Opaque(new BID(Ids::SMOOTH_SANDSTONE), "Smooth Sandstone", $sandstoneBreakInfo));
self::register("glazed_terracotta", new GlazedTerracotta(new BID(Ids::GLAZED_TERRACOTTA), "Glazed Terracotta", new Info(BreakInfo::pickaxe(1.4, ToolTier::WOOD())))); self::register("glazed_terracotta", new GlazedTerracotta(new BID(Ids::GLAZED_TERRACOTTA), "Glazed Terracotta", new Info(BreakInfo::pickaxe(1.4, ToolTier::WOOD))));
self::register("dyed_shulker_box", new DyedShulkerBox(new BID(Ids::DYED_SHULKER_BOX, TileShulkerBox::class), "Dyed Shulker Box", $shulkerBoxBreakInfo)); self::register("dyed_shulker_box", new DyedShulkerBox(new BID(Ids::DYED_SHULKER_BOX, TileShulkerBox::class), "Dyed Shulker Box", $shulkerBoxBreakInfo));
self::register("stained_glass", new StainedGlass(new BID(Ids::STAINED_GLASS), "Stained Glass", $glassBreakInfo)); self::register("stained_glass", new StainedGlass(new BID(Ids::STAINED_GLASS), "Stained Glass", $glassBreakInfo));
self::register("stained_glass_pane", new StainedGlassPane(new BID(Ids::STAINED_GLASS_PANE), "Stained Glass Pane", $glassBreakInfo)); self::register("stained_glass_pane", new StainedGlassPane(new BID(Ids::STAINED_GLASS_PANE), "Stained Glass Pane", $glassBreakInfo));
@ -1172,7 +1173,7 @@ final class VanillaBlocks{
self::register("stained_hardened_glass", new StainedHardenedGlass(new BID(Ids::STAINED_HARDENED_GLASS), "Stained Hardened Glass", $hardenedGlassBreakInfo)); self::register("stained_hardened_glass", new StainedHardenedGlass(new BID(Ids::STAINED_HARDENED_GLASS), "Stained Hardened Glass", $hardenedGlassBreakInfo));
self::register("stained_hardened_glass_pane", new StainedHardenedGlassPane(new BID(Ids::STAINED_HARDENED_GLASS_PANE), "Stained Hardened Glass Pane", $hardenedGlassBreakInfo)); self::register("stained_hardened_glass_pane", new StainedHardenedGlassPane(new BID(Ids::STAINED_HARDENED_GLASS_PANE), "Stained Hardened Glass Pane", $hardenedGlassBreakInfo));
self::register("carpet", new Carpet(new BID(Ids::CARPET), "Carpet", new Info(new BreakInfo(0.1)))); self::register("carpet", new Carpet(new BID(Ids::CARPET), "Carpet", new Info(new BreakInfo(0.1))));
self::register("concrete", new Concrete(new BID(Ids::CONCRETE), "Concrete", new Info(BreakInfo::pickaxe(1.8, ToolTier::WOOD())))); self::register("concrete", new Concrete(new BID(Ids::CONCRETE), "Concrete", new Info(BreakInfo::pickaxe(1.8, ToolTier::WOOD))));
self::register("concrete_powder", new ConcretePowder(new BID(Ids::CONCRETE_POWDER), "Concrete Powder", new Info(BreakInfo::shovel(0.5)))); self::register("concrete_powder", new ConcretePowder(new BID(Ids::CONCRETE_POWDER), "Concrete Powder", new Info(BreakInfo::shovel(0.5))));
self::register("wool", new Wool(new BID(Ids::WOOL), "Wool", new Info(new class(0.8, ToolType::SHEARS) extends BreakInfo{ self::register("wool", new Wool(new BID(Ids::WOOL), "Wool", new Info(new class(0.8, ToolType::SHEARS) extends BreakInfo{
public function getBreakTime(Item $item) : float{ public function getBreakTime(Item $item) : float{
@ -1186,7 +1187,7 @@ final class VanillaBlocks{
}))); })));
//TODO: in the future these won't all have the same hardness; they only do now because of the old metadata crap //TODO: in the future these won't all have the same hardness; they only do now because of the old metadata crap
$wallBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $wallBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("cobblestone_wall", new Wall(new BID(Ids::COBBLESTONE_WALL), "Cobblestone Wall", $wallBreakInfo)); self::register("cobblestone_wall", new Wall(new BID(Ids::COBBLESTONE_WALL), "Cobblestone Wall", $wallBreakInfo));
self::register("andesite_wall", new Wall(new BID(Ids::ANDESITE_WALL), "Andesite Wall", $wallBreakInfo)); self::register("andesite_wall", new Wall(new BID(Ids::ANDESITE_WALL), "Andesite Wall", $wallBreakInfo));
self::register("brick_wall", new Wall(new BID(Ids::BRICK_WALL), "Brick Wall", $wallBreakInfo)); self::register("brick_wall", new Wall(new BID(Ids::BRICK_WALL), "Brick Wall", $wallBreakInfo));
@ -1204,7 +1205,7 @@ final class VanillaBlocks{
self::registerElements(); self::registerElements();
$chemistryTableBreakInfo = new Info(BreakInfo::pickaxe(2.5, ToolTier::WOOD())); $chemistryTableBreakInfo = new Info(BreakInfo::pickaxe(2.5, ToolTier::WOOD));
self::register("compound_creator", new ChemistryTable(new BID(Ids::COMPOUND_CREATOR), "Compound Creator", $chemistryTableBreakInfo)); self::register("compound_creator", new ChemistryTable(new BID(Ids::COMPOUND_CREATOR), "Compound Creator", $chemistryTableBreakInfo));
self::register("element_constructor", new ChemistryTable(new BID(Ids::ELEMENT_CONSTRUCTOR), "Element Constructor", $chemistryTableBreakInfo)); self::register("element_constructor", new ChemistryTable(new BID(Ids::ELEMENT_CONSTRUCTOR), "Element Constructor", $chemistryTableBreakInfo));
self::register("lab_table", new ChemistryTable(new BID(Ids::LAB_TABLE), "Lab Table", $chemistryTableBreakInfo)); self::register("lab_table", new ChemistryTable(new BID(Ids::LAB_TABLE), "Lab Table", $chemistryTableBreakInfo));
@ -1262,9 +1263,9 @@ final class VanillaBlocks{
$woodenButtonBreakInfo = new Info(BreakInfo::axe(0.5)); $woodenButtonBreakInfo = new Info(BreakInfo::axe(0.5));
$woodenPressurePlateBreakInfo = new Info(BreakInfo::axe(0.5)); $woodenPressurePlateBreakInfo = new Info(BreakInfo::axe(0.5));
foreach(WoodType::getAll() as $woodType){ foreach(WoodType::cases() as $woodType){
$name = $woodType->getDisplayName(); $name = $woodType->getDisplayName();
$idName = fn(string $suffix) => $woodType->name() . "_" . $suffix; $idName = fn(string $suffix) => strtolower($woodType->name) . "_" . $suffix;
self::register($idName(mb_strtolower($woodType->getStandardLogSuffix() ?? "log", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getLogIdentifier($woodType), $name . " " . ($woodType->getStandardLogSuffix() ?? "Log"), $logBreakInfo, $woodType)); self::register($idName(mb_strtolower($woodType->getStandardLogSuffix() ?? "log", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getLogIdentifier($woodType), $name . " " . ($woodType->getStandardLogSuffix() ?? "Log"), $logBreakInfo, $woodType));
self::register($idName(mb_strtolower($woodType->getAllSidedLogSuffix() ?? "wood", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getAllSidedLogIdentifier($woodType), $name . " " . ($woodType->getAllSidedLogSuffix() ?? "Wood"), $logBreakInfo, $woodType)); self::register($idName(mb_strtolower($woodType->getAllSidedLogSuffix() ?? "wood", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getAllSidedLogIdentifier($woodType), $name . " " . ($woodType->getAllSidedLogSuffix() ?? "Wood"), $logBreakInfo, $woodType));
@ -1427,26 +1428,26 @@ final class VanillaBlocks{
private static function registerOres() : void{ private static function registerOres() : void{
$stoneOreBreakInfo = fn(ToolTier $toolTier) => new Info(BreakInfo::pickaxe(3.0, $toolTier)); $stoneOreBreakInfo = fn(ToolTier $toolTier) => new Info(BreakInfo::pickaxe(3.0, $toolTier));
self::register("coal_ore", new CoalOre(new BID(Ids::COAL_ORE), "Coal Ore", $stoneOreBreakInfo(ToolTier::WOOD()))); self::register("coal_ore", new CoalOre(new BID(Ids::COAL_ORE), "Coal Ore", $stoneOreBreakInfo(ToolTier::WOOD)));
self::register("copper_ore", new CopperOre(new BID(Ids::COPPER_ORE), "Copper Ore", $stoneOreBreakInfo(ToolTier::STONE()))); self::register("copper_ore", new CopperOre(new BID(Ids::COPPER_ORE), "Copper Ore", $stoneOreBreakInfo(ToolTier::STONE)));
self::register("diamond_ore", new DiamondOre(new BID(Ids::DIAMOND_ORE), "Diamond Ore", $stoneOreBreakInfo(ToolTier::IRON()))); self::register("diamond_ore", new DiamondOre(new BID(Ids::DIAMOND_ORE), "Diamond Ore", $stoneOreBreakInfo(ToolTier::IRON)));
self::register("emerald_ore", new EmeraldOre(new BID(Ids::EMERALD_ORE), "Emerald Ore", $stoneOreBreakInfo(ToolTier::IRON()))); self::register("emerald_ore", new EmeraldOre(new BID(Ids::EMERALD_ORE), "Emerald Ore", $stoneOreBreakInfo(ToolTier::IRON)));
self::register("gold_ore", new GoldOre(new BID(Ids::GOLD_ORE), "Gold Ore", $stoneOreBreakInfo(ToolTier::IRON()))); self::register("gold_ore", new GoldOre(new BID(Ids::GOLD_ORE), "Gold Ore", $stoneOreBreakInfo(ToolTier::IRON)));
self::register("iron_ore", new IronOre(new BID(Ids::IRON_ORE), "Iron Ore", $stoneOreBreakInfo(ToolTier::STONE()))); self::register("iron_ore", new IronOre(new BID(Ids::IRON_ORE), "Iron Ore", $stoneOreBreakInfo(ToolTier::STONE)));
self::register("lapis_lazuli_ore", new LapisOre(new BID(Ids::LAPIS_LAZULI_ORE), "Lapis Lazuli Ore", $stoneOreBreakInfo(ToolTier::STONE()))); self::register("lapis_lazuli_ore", new LapisOre(new BID(Ids::LAPIS_LAZULI_ORE), "Lapis Lazuli Ore", $stoneOreBreakInfo(ToolTier::STONE)));
self::register("redstone_ore", new RedstoneOre(new BID(Ids::REDSTONE_ORE), "Redstone Ore", $stoneOreBreakInfo(ToolTier::IRON()))); self::register("redstone_ore", new RedstoneOre(new BID(Ids::REDSTONE_ORE), "Redstone Ore", $stoneOreBreakInfo(ToolTier::IRON)));
$deepslateOreBreakInfo = fn(ToolTier $toolTier) => new Info(BreakInfo::pickaxe(4.5, $toolTier)); $deepslateOreBreakInfo = fn(ToolTier $toolTier) => new Info(BreakInfo::pickaxe(4.5, $toolTier));
self::register("deepslate_coal_ore", new CoalOre(new BID(Ids::DEEPSLATE_COAL_ORE), "Deepslate Coal Ore", $deepslateOreBreakInfo(ToolTier::WOOD()))); self::register("deepslate_coal_ore", new CoalOre(new BID(Ids::DEEPSLATE_COAL_ORE), "Deepslate Coal Ore", $deepslateOreBreakInfo(ToolTier::WOOD)));
self::register("deepslate_copper_ore", new CopperOre(new BID(Ids::DEEPSLATE_COPPER_ORE), "Deepslate Copper Ore", $deepslateOreBreakInfo(ToolTier::STONE()))); self::register("deepslate_copper_ore", new CopperOre(new BID(Ids::DEEPSLATE_COPPER_ORE), "Deepslate Copper Ore", $deepslateOreBreakInfo(ToolTier::STONE)));
self::register("deepslate_diamond_ore", new DiamondOre(new BID(Ids::DEEPSLATE_DIAMOND_ORE), "Deepslate Diamond Ore", $deepslateOreBreakInfo(ToolTier::IRON()))); self::register("deepslate_diamond_ore", new DiamondOre(new BID(Ids::DEEPSLATE_DIAMOND_ORE), "Deepslate Diamond Ore", $deepslateOreBreakInfo(ToolTier::IRON)));
self::register("deepslate_emerald_ore", new EmeraldOre(new BID(Ids::DEEPSLATE_EMERALD_ORE), "Deepslate Emerald Ore", $deepslateOreBreakInfo(ToolTier::IRON()))); self::register("deepslate_emerald_ore", new EmeraldOre(new BID(Ids::DEEPSLATE_EMERALD_ORE), "Deepslate Emerald Ore", $deepslateOreBreakInfo(ToolTier::IRON)));
self::register("deepslate_gold_ore", new GoldOre(new BID(Ids::DEEPSLATE_GOLD_ORE), "Deepslate Gold Ore", $deepslateOreBreakInfo(ToolTier::IRON()))); self::register("deepslate_gold_ore", new GoldOre(new BID(Ids::DEEPSLATE_GOLD_ORE), "Deepslate Gold Ore", $deepslateOreBreakInfo(ToolTier::IRON)));
self::register("deepslate_iron_ore", new IronOre(new BID(Ids::DEEPSLATE_IRON_ORE), "Deepslate Iron Ore", $deepslateOreBreakInfo(ToolTier::STONE()))); self::register("deepslate_iron_ore", new IronOre(new BID(Ids::DEEPSLATE_IRON_ORE), "Deepslate Iron Ore", $deepslateOreBreakInfo(ToolTier::STONE)));
self::register("deepslate_lapis_lazuli_ore", new LapisOre(new BID(Ids::DEEPSLATE_LAPIS_LAZULI_ORE), "Deepslate Lapis Lazuli Ore", $deepslateOreBreakInfo(ToolTier::STONE()))); self::register("deepslate_lapis_lazuli_ore", new LapisOre(new BID(Ids::DEEPSLATE_LAPIS_LAZULI_ORE), "Deepslate Lapis Lazuli Ore", $deepslateOreBreakInfo(ToolTier::STONE)));
self::register("deepslate_redstone_ore", new RedstoneOre(new BID(Ids::DEEPSLATE_REDSTONE_ORE), "Deepslate Redstone Ore", $deepslateOreBreakInfo(ToolTier::IRON()))); self::register("deepslate_redstone_ore", new RedstoneOre(new BID(Ids::DEEPSLATE_REDSTONE_ORE), "Deepslate Redstone Ore", $deepslateOreBreakInfo(ToolTier::IRON)));
$netherrackOreBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD())); $netherrackOreBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD));
self::register("nether_quartz_ore", new NetherQuartzOre(new BID(Ids::NETHER_QUARTZ_ORE), "Nether Quartz Ore", $netherrackOreBreakInfo)); self::register("nether_quartz_ore", new NetherQuartzOre(new BID(Ids::NETHER_QUARTZ_ORE), "Nether Quartz Ore", $netherrackOreBreakInfo));
self::register("nether_gold_ore", new NetherGoldOre(new BID(Ids::NETHER_GOLD_ORE), "Nether Gold Ore", $netherrackOreBreakInfo)); self::register("nether_gold_ore", new NetherGoldOre(new BID(Ids::NETHER_GOLD_ORE), "Nether Gold Ore", $netherrackOreBreakInfo));
} }
@ -1478,20 +1479,20 @@ final class VanillaBlocks{
private static function registerBlocksR16() : void{ private static function registerBlocksR16() : void{
//for some reason, slabs have weird hardness like the legacy ones //for some reason, slabs have weird hardness like the legacy ones
$slabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $slabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("ancient_debris", new Opaque(new BID(Ids::ANCIENT_DEBRIS), "Ancient Debris", new Info(BreakInfo::pickaxe(30, ToolTier::DIAMOND(), 3600.0)))); self::register("ancient_debris", new Opaque(new BID(Ids::ANCIENT_DEBRIS), "Ancient Debris", new Info(BreakInfo::pickaxe(30, ToolTier::DIAMOND, 3600.0))));
$netheriteBreakInfo = new Info(BreakInfo::pickaxe(50, ToolTier::DIAMOND(), 3600.0)); $netheriteBreakInfo = new Info(BreakInfo::pickaxe(50, ToolTier::DIAMOND, 3600.0));
self::register("netherite", new class(new BID(Ids::NETHERITE), "Netherite Block", $netheriteBreakInfo) extends Opaque{ self::register("netherite", new class(new BID(Ids::NETHERITE), "Netherite Block", $netheriteBreakInfo) extends Opaque{
public function isFireProofAsItem() : bool{ return true; } public function isFireProofAsItem() : bool{ return true; }
}); });
$basaltBreakInfo = new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD(), 21.0)); $basaltBreakInfo = new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD, 21.0));
self::register("basalt", new SimplePillar(new BID(Ids::BASALT), "Basalt", $basaltBreakInfo)); self::register("basalt", new SimplePillar(new BID(Ids::BASALT), "Basalt", $basaltBreakInfo));
self::register("polished_basalt", new SimplePillar(new BID(Ids::POLISHED_BASALT), "Polished Basalt", $basaltBreakInfo)); self::register("polished_basalt", new SimplePillar(new BID(Ids::POLISHED_BASALT), "Polished Basalt", $basaltBreakInfo));
self::register("smooth_basalt", new Opaque(new BID(Ids::SMOOTH_BASALT), "Smooth Basalt", $basaltBreakInfo)); self::register("smooth_basalt", new Opaque(new BID(Ids::SMOOTH_BASALT), "Smooth Basalt", $basaltBreakInfo));
$blackstoneBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0)); $blackstoneBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
self::register("blackstone", new Opaque(new BID(Ids::BLACKSTONE), "Blackstone", $blackstoneBreakInfo)); self::register("blackstone", new Opaque(new BID(Ids::BLACKSTONE), "Blackstone", $blackstoneBreakInfo));
self::register("blackstone_slab", new Slab(new BID(Ids::BLACKSTONE_SLAB), "Blackstone", $slabBreakInfo)); self::register("blackstone_slab", new Slab(new BID(Ids::BLACKSTONE_SLAB), "Blackstone", $slabBreakInfo));
self::register("blackstone_stairs", new Stair(new BID(Ids::BLACKSTONE_STAIRS), "Blackstone Stairs", $blackstoneBreakInfo)); self::register("blackstone_stairs", new Stair(new BID(Ids::BLACKSTONE_STAIRS), "Blackstone Stairs", $blackstoneBreakInfo));
@ -1503,7 +1504,7 @@ final class VanillaBlocks{
$prefix = fn(string $thing) => "Polished Blackstone" . ($thing !== "" ? " $thing" : ""); $prefix = fn(string $thing) => "Polished Blackstone" . ($thing !== "" ? " $thing" : "");
self::register("polished_blackstone", new Opaque(new BID(Ids::POLISHED_BLACKSTONE), $prefix(""), $blackstoneBreakInfo)); self::register("polished_blackstone", new Opaque(new BID(Ids::POLISHED_BLACKSTONE), $prefix(""), $blackstoneBreakInfo));
self::register("polished_blackstone_button", new StoneButton(new BID(Ids::POLISHED_BLACKSTONE_BUTTON), $prefix("Button"), new Info(BreakInfo::pickaxe(0.5)))); self::register("polished_blackstone_button", new StoneButton(new BID(Ids::POLISHED_BLACKSTONE_BUTTON), $prefix("Button"), new Info(BreakInfo::pickaxe(0.5))));
self::register("polished_blackstone_pressure_plate", new StonePressurePlate(new BID(Ids::POLISHED_BLACKSTONE_PRESSURE_PLATE), $prefix("Pressure Plate"), new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD())), 20)); self::register("polished_blackstone_pressure_plate", new StonePressurePlate(new BID(Ids::POLISHED_BLACKSTONE_PRESSURE_PLATE), $prefix("Pressure Plate"), new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD)), 20));
self::register("polished_blackstone_slab", new Slab(new BID(Ids::POLISHED_BLACKSTONE_SLAB), $prefix(""), $slabBreakInfo)); self::register("polished_blackstone_slab", new Slab(new BID(Ids::POLISHED_BLACKSTONE_SLAB), $prefix(""), $slabBreakInfo));
self::register("polished_blackstone_stairs", new Stair(new BID(Ids::POLISHED_BLACKSTONE_STAIRS), $prefix("Stairs"), $blackstoneBreakInfo)); self::register("polished_blackstone_stairs", new Stair(new BID(Ids::POLISHED_BLACKSTONE_STAIRS), $prefix("Stairs"), $blackstoneBreakInfo));
self::register("polished_blackstone_wall", new Wall(new BID(Ids::POLISHED_BLACKSTONE_WALL), $prefix("Wall"), $blackstoneBreakInfo)); self::register("polished_blackstone_wall", new Wall(new BID(Ids::POLISHED_BLACKSTONE_WALL), $prefix("Wall"), $blackstoneBreakInfo));
@ -1527,33 +1528,33 @@ final class VanillaBlocks{
}); });
self::register("warped_wart_block", new Opaque(new BID(Ids::WARPED_WART_BLOCK), "Warped Wart Block", new Info(new BreakInfo(1.0, ToolType::HOE)))); self::register("warped_wart_block", new Opaque(new BID(Ids::WARPED_WART_BLOCK), "Warped Wart Block", new Info(new BreakInfo(1.0, ToolType::HOE))));
self::register("crying_obsidian", new class(new BID(Ids::CRYING_OBSIDIAN), "Crying Obsidian", new Info(BreakInfo::pickaxe(35.0 /* 50 in Java */, ToolTier::DIAMOND(), 6000.0))) extends Opaque{ self::register("crying_obsidian", new class(new BID(Ids::CRYING_OBSIDIAN), "Crying Obsidian", new Info(BreakInfo::pickaxe(35.0 /* 50 in Java */, ToolTier::DIAMOND, 6000.0))) extends Opaque{
public function getLightLevel() : int{ return 10;} public function getLightLevel() : int{ return 10;}
}); });
self::register("twisting_vines", new NetherVines(new BID(Ids::TWISTING_VINES), "Twisting Vines", new Info(BreakInfo::instant()), Facing::UP)); self::register("twisting_vines", new NetherVines(new BID(Ids::TWISTING_VINES), "Twisting Vines", new Info(BreakInfo::instant()), Facing::UP));
self::register("weeping_vines", new NetherVines(new BID(Ids::WEEPING_VINES), "Weeping Vines", new Info(BreakInfo::instant()), Facing::DOWN)); self::register("weeping_vines", new NetherVines(new BID(Ids::WEEPING_VINES), "Weeping Vines", new Info(BreakInfo::instant()), Facing::DOWN));
self::register("chain", new Chain(new BID(Ids::CHAIN), "Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD())))); self::register("chain", new Chain(new BID(Ids::CHAIN), "Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD))));
} }
private static function registerBlocksR17() : void{ private static function registerBlocksR17() : void{
//in java this can be acquired using any tool - seems to be a parity issue in bedrock //in java this can be acquired using any tool - seems to be a parity issue in bedrock
self::register("amethyst", new class(new BID(Ids::AMETHYST), "Amethyst", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD()))) extends Opaque{ self::register("amethyst", new class(new BID(Ids::AMETHYST), "Amethyst", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD))) extends Opaque{
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{ public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
$this->position->getWorld()->addSound($this->position, new AmethystBlockChimeSound()); $this->position->getWorld()->addSound($this->position, new AmethystBlockChimeSound());
$this->position->getWorld()->addSound($this->position, new BlockPunchSound($this)); $this->position->getWorld()->addSound($this->position, new BlockPunchSound($this));
} }
}); });
self::register("calcite", new Opaque(new BID(Ids::CALCITE), "Calcite", new Info(BreakInfo::pickaxe(0.75, ToolTier::WOOD())))); self::register("calcite", new Opaque(new BID(Ids::CALCITE), "Calcite", new Info(BreakInfo::pickaxe(0.75, ToolTier::WOOD))));
self::register("tuff", new Opaque(new BID(Ids::TUFF), "Tuff", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0)))); self::register("tuff", new Opaque(new BID(Ids::TUFF), "Tuff", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0))));
self::register("raw_copper", new Opaque(new BID(Ids::RAW_COPPER), "Raw Copper Block", new Info(BreakInfo::pickaxe(5, ToolTier::STONE(), 30.0)))); self::register("raw_copper", new Opaque(new BID(Ids::RAW_COPPER), "Raw Copper Block", new Info(BreakInfo::pickaxe(5, ToolTier::STONE, 30.0))));
self::register("raw_gold", new Opaque(new BID(Ids::RAW_GOLD), "Raw Gold Block", new Info(BreakInfo::pickaxe(5, ToolTier::IRON(), 30.0)))); self::register("raw_gold", new Opaque(new BID(Ids::RAW_GOLD), "Raw Gold Block", new Info(BreakInfo::pickaxe(5, ToolTier::IRON, 30.0))));
self::register("raw_iron", new Opaque(new BID(Ids::RAW_IRON), "Raw Iron Block", new Info(BreakInfo::pickaxe(5, ToolTier::STONE(), 30.0)))); self::register("raw_iron", new Opaque(new BID(Ids::RAW_IRON), "Raw Iron Block", new Info(BreakInfo::pickaxe(5, ToolTier::STONE, 30.0))));
$deepslateBreakInfo = new Info(BreakInfo::pickaxe(3, ToolTier::WOOD(), 18.0)); $deepslateBreakInfo = new Info(BreakInfo::pickaxe(3, ToolTier::WOOD, 18.0));
self::register("deepslate", new class(new BID(Ids::DEEPSLATE), "Deepslate", $deepslateBreakInfo) extends SimplePillar{ self::register("deepslate", new class(new BID(Ids::DEEPSLATE), "Deepslate", $deepslateBreakInfo) extends SimplePillar{
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{
return [VanillaBlocks::COBBLED_DEEPSLATE()->asItem()]; return [VanillaBlocks::COBBLED_DEEPSLATE()->asItem()];
@ -1565,29 +1566,29 @@ final class VanillaBlocks{
}); });
//TODO: parity issue here - in Java this has a hardness of 3.0, but in bedrock it's 3.5 //TODO: parity issue here - in Java this has a hardness of 3.0, but in bedrock it's 3.5
self::register("chiseled_deepslate", new Opaque(new BID(Ids::CHISELED_DEEPSLATE), "Chiseled Deepslate", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD(), 18.0)))); self::register("chiseled_deepslate", new Opaque(new BID(Ids::CHISELED_DEEPSLATE), "Chiseled Deepslate", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0))));
$deepslateBrickBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD(), 18.0)); $deepslateBrickBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
self::register("deepslate_bricks", new Opaque(new BID(Ids::DEEPSLATE_BRICKS), "Deepslate Bricks", $deepslateBrickBreakInfo)); self::register("deepslate_bricks", new Opaque(new BID(Ids::DEEPSLATE_BRICKS), "Deepslate Bricks", $deepslateBrickBreakInfo));
self::register("deepslate_brick_slab", new Slab(new BID(Ids::DEEPSLATE_BRICK_SLAB), "Deepslate Brick", $deepslateBrickBreakInfo)); self::register("deepslate_brick_slab", new Slab(new BID(Ids::DEEPSLATE_BRICK_SLAB), "Deepslate Brick", $deepslateBrickBreakInfo));
self::register("deepslate_brick_stairs", new Stair(new BID(Ids::DEEPSLATE_BRICK_STAIRS), "Deepslate Brick Stairs", $deepslateBrickBreakInfo)); self::register("deepslate_brick_stairs", new Stair(new BID(Ids::DEEPSLATE_BRICK_STAIRS), "Deepslate Brick Stairs", $deepslateBrickBreakInfo));
self::register("deepslate_brick_wall", new Wall(new BID(Ids::DEEPSLATE_BRICK_WALL), "Deepslate Brick Wall", $deepslateBrickBreakInfo)); self::register("deepslate_brick_wall", new Wall(new BID(Ids::DEEPSLATE_BRICK_WALL), "Deepslate Brick Wall", $deepslateBrickBreakInfo));
self::register("cracked_deepslate_bricks", new Opaque(new BID(Ids::CRACKED_DEEPSLATE_BRICKS), "Cracked Deepslate Bricks", $deepslateBrickBreakInfo)); self::register("cracked_deepslate_bricks", new Opaque(new BID(Ids::CRACKED_DEEPSLATE_BRICKS), "Cracked Deepslate Bricks", $deepslateBrickBreakInfo));
$deepslateTilesBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD(), 18.0)); $deepslateTilesBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
self::register("deepslate_tiles", new Opaque(new BID(Ids::DEEPSLATE_TILES), "Deepslate Tiles", $deepslateTilesBreakInfo)); self::register("deepslate_tiles", new Opaque(new BID(Ids::DEEPSLATE_TILES), "Deepslate Tiles", $deepslateTilesBreakInfo));
self::register("deepslate_tile_slab", new Slab(new BID(Ids::DEEPSLATE_TILE_SLAB), "Deepslate Tile", $deepslateTilesBreakInfo)); self::register("deepslate_tile_slab", new Slab(new BID(Ids::DEEPSLATE_TILE_SLAB), "Deepslate Tile", $deepslateTilesBreakInfo));
self::register("deepslate_tile_stairs", new Stair(new BID(Ids::DEEPSLATE_TILE_STAIRS), "Deepslate Tile Stairs", $deepslateTilesBreakInfo)); self::register("deepslate_tile_stairs", new Stair(new BID(Ids::DEEPSLATE_TILE_STAIRS), "Deepslate Tile Stairs", $deepslateTilesBreakInfo));
self::register("deepslate_tile_wall", new Wall(new BID(Ids::DEEPSLATE_TILE_WALL), "Deepslate Tile Wall", $deepslateTilesBreakInfo)); self::register("deepslate_tile_wall", new Wall(new BID(Ids::DEEPSLATE_TILE_WALL), "Deepslate Tile Wall", $deepslateTilesBreakInfo));
self::register("cracked_deepslate_tiles", new Opaque(new BID(Ids::CRACKED_DEEPSLATE_TILES), "Cracked Deepslate Tiles", $deepslateTilesBreakInfo)); self::register("cracked_deepslate_tiles", new Opaque(new BID(Ids::CRACKED_DEEPSLATE_TILES), "Cracked Deepslate Tiles", $deepslateTilesBreakInfo));
$cobbledDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD(), 18.0)); $cobbledDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
self::register("cobbled_deepslate", new Opaque(new BID(Ids::COBBLED_DEEPSLATE), "Cobbled Deepslate", $cobbledDeepslateBreakInfo)); self::register("cobbled_deepslate", new Opaque(new BID(Ids::COBBLED_DEEPSLATE), "Cobbled Deepslate", $cobbledDeepslateBreakInfo));
self::register("cobbled_deepslate_slab", new Slab(new BID(Ids::COBBLED_DEEPSLATE_SLAB), "Cobbled Deepslate", $cobbledDeepslateBreakInfo)); self::register("cobbled_deepslate_slab", new Slab(new BID(Ids::COBBLED_DEEPSLATE_SLAB), "Cobbled Deepslate", $cobbledDeepslateBreakInfo));
self::register("cobbled_deepslate_stairs", new Stair(new BID(Ids::COBBLED_DEEPSLATE_STAIRS), "Cobbled Deepslate Stairs", $cobbledDeepslateBreakInfo)); self::register("cobbled_deepslate_stairs", new Stair(new BID(Ids::COBBLED_DEEPSLATE_STAIRS), "Cobbled Deepslate Stairs", $cobbledDeepslateBreakInfo));
self::register("cobbled_deepslate_wall", new Wall(new BID(Ids::COBBLED_DEEPSLATE_WALL), "Cobbled Deepslate Wall", $cobbledDeepslateBreakInfo)); self::register("cobbled_deepslate_wall", new Wall(new BID(Ids::COBBLED_DEEPSLATE_WALL), "Cobbled Deepslate Wall", $cobbledDeepslateBreakInfo));
$polishedDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD(), 18.0)); $polishedDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
self::register("polished_deepslate", new Opaque(new BID(Ids::POLISHED_DEEPSLATE), "Polished Deepslate", $polishedDeepslateBreakInfo)); self::register("polished_deepslate", new Opaque(new BID(Ids::POLISHED_DEEPSLATE), "Polished Deepslate", $polishedDeepslateBreakInfo));
self::register("polished_deepslate_slab", new Slab(new BID(Ids::POLISHED_DEEPSLATE_SLAB), "Polished Deepslate", $polishedDeepslateBreakInfo)); self::register("polished_deepslate_slab", new Slab(new BID(Ids::POLISHED_DEEPSLATE_SLAB), "Polished Deepslate", $polishedDeepslateBreakInfo));
self::register("polished_deepslate_stairs", new Stair(new BID(Ids::POLISHED_DEEPSLATE_STAIRS), "Polished Deepslate Stairs", $polishedDeepslateBreakInfo)); self::register("polished_deepslate_stairs", new Stair(new BID(Ids::POLISHED_DEEPSLATE_STAIRS), "Polished Deepslate Stairs", $polishedDeepslateBreakInfo));
@ -1596,7 +1597,7 @@ final class VanillaBlocks{
self::register("tinted_glass", new TintedGlass(new BID(Ids::TINTED_GLASS), "Tinted Glass", new Info(new BreakInfo(0.3)))); self::register("tinted_glass", new TintedGlass(new BID(Ids::TINTED_GLASS), "Tinted Glass", new Info(new BreakInfo(0.3))));
//blast resistance should be 30 if we were matched with java :( //blast resistance should be 30 if we were matched with java :(
$copperBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE(), 18.0)); $copperBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE, 18.0));
self::register("lightning_rod", new LightningRod(new BID(Ids::LIGHTNING_ROD), "Lightning Rod", $copperBreakInfo)); self::register("lightning_rod", new LightningRod(new BID(Ids::LIGHTNING_ROD), "Lightning Rod", $copperBreakInfo));
self::register("copper", new Copper(new BID(Ids::COPPER), "Copper Block", $copperBreakInfo)); self::register("copper", new Copper(new BID(Ids::COPPER), "Copper Block", $copperBreakInfo));
@ -1630,7 +1631,7 @@ final class VanillaBlocks{
self::register("mud", new Opaque(new BID(Ids::MUD), "Mud", new Info(BreakInfo::shovel(0.5), [Tags::MUD]))); self::register("mud", new Opaque(new BID(Ids::MUD), "Mud", new Info(BreakInfo::shovel(0.5), [Tags::MUD])));
self::register("packed_mud", new Opaque(new BID(Ids::PACKED_MUD), "Packed Mud", new Info(BreakInfo::pickaxe(1.0, null, 15.0)))); self::register("packed_mud", new Opaque(new BID(Ids::PACKED_MUD), "Packed Mud", new Info(BreakInfo::pickaxe(1.0, null, 15.0))));
$mudBricksBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD(), 30.0)); $mudBricksBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
self::register("mud_bricks", new Opaque(new BID(Ids::MUD_BRICKS), "Mud Bricks", $mudBricksBreakInfo)); self::register("mud_bricks", new Opaque(new BID(Ids::MUD_BRICKS), "Mud Bricks", $mudBricksBreakInfo));
self::register("mud_brick_slab", new Slab(new BID(Ids::MUD_BRICK_SLAB), "Mud Brick", $mudBricksBreakInfo)); self::register("mud_brick_slab", new Slab(new BID(Ids::MUD_BRICK_SLAB), "Mud Brick", $mudBricksBreakInfo));
@ -1639,7 +1640,7 @@ final class VanillaBlocks{
} }
private static function registerCauldronBlocks() : void{ private static function registerCauldronBlocks() : void{
$cauldronBreakInfo = new Info(BreakInfo::pickaxe(2, ToolTier::WOOD())); $cauldronBreakInfo = new Info(BreakInfo::pickaxe(2, ToolTier::WOOD));
self::register("cauldron", new Cauldron(new BID(Ids::CAULDRON, TileCauldron::class), "Cauldron", $cauldronBreakInfo)); self::register("cauldron", new Cauldron(new BID(Ids::CAULDRON, TileCauldron::class), "Cauldron", $cauldronBreakInfo));
self::register("water_cauldron", new WaterCauldron(new BID(Ids::WATER_CAULDRON, TileCauldron::class), "Water Cauldron", $cauldronBreakInfo)); self::register("water_cauldron", new WaterCauldron(new BID(Ids::WATER_CAULDRON, TileCauldron::class), "Water Cauldron", $cauldronBreakInfo));

View File

@ -101,9 +101,9 @@ class Wall extends Transparent{
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
$block = $this->getSide($facing); $block = $this->getSide($facing);
if($block instanceof static || $block instanceof FenceGate || $block instanceof Thin || $block->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){ if($block instanceof static || $block instanceof FenceGate || $block instanceof Thin || $block->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
if(!isset($this->connections[$facing])){ if(!isset($this->connections[$facing])){
$this->connections[$facing] = WallConnectionType::SHORT(); $this->connections[$facing] = WallConnectionType::SHORT;
$changed++; $changed++;
} }
}elseif(isset($this->connections[$facing])){ }elseif(isset($this->connections[$facing])){
@ -152,6 +152,6 @@ class Wall extends Transparent{
} }
public function getSupportType(int $facing) : SupportType{ public function getSupportType(int $facing) : SupportType{
return Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE(); return Facing::axis($facing) === Axis::Y ? SupportType::CENTER : SupportType::NONE;
} }
} }

View File

@ -110,10 +110,10 @@ final class WaterCauldron extends FillableCauldron{
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
$world = $this->position->getWorld(); $world = $this->position->getWorld();
if(($dyeColor = match($item->getTypeId()){ if(($dyeColor = match($item->getTypeId()){
ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE(), ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE,
ItemTypeIds::INK_SAC => DyeColor::BLACK(), ItemTypeIds::INK_SAC => DyeColor::BLACK,
ItemTypeIds::COCOA_BEANS => DyeColor::BROWN(), ItemTypeIds::COCOA_BEANS => DyeColor::BROWN,
ItemTypeIds::BONE_MEAL => DyeColor::WHITE(), ItemTypeIds::BONE_MEAL => DyeColor::WHITE,
ItemTypeIds::DYE => $item instanceof Dye ? $item->getColor() : null, ItemTypeIds::DYE => $item instanceof Dye ? $item->getColor() : null,
default => null default => null
}) !== null && ($newColor = $dyeColor->getRgbValue())->toRGBA() !== $this->customWaterColor?->toRGBA() }) !== null && ($newColor = $dyeColor->getRgbValue())->toRGBA() !== $this->customWaterColor?->toRGBA()
@ -123,7 +123,7 @@ final class WaterCauldron extends FillableCauldron{
$item->pop(); $item->pop();
}elseif($item instanceof Potion || $item instanceof SplashPotion){ //TODO: lingering potion }elseif($item instanceof Potion || $item instanceof SplashPotion){ //TODO: lingering potion
if($item->getType()->equals(PotionType::WATER())){ if($item->getType() === PotionType::WATER){
$this->setCustomWaterColor(null)->addFillLevels(self::WATER_BOTTLE_FILL_AMOUNT, $item, VanillaItems::GLASS_BOTTLE(), $returnedItems); $this->setCustomWaterColor(null)->addFillLevels(self::WATER_BOTTLE_FILL_AMOUNT, $item, VanillaItems::GLASS_BOTTLE(), $returnedItems);
}else{ }else{
$this->mix($item, VanillaItems::GLASS_BOTTLE(), $returnedItems); $this->mix($item, VanillaItems::GLASS_BOTTLE(), $returnedItems);
@ -170,7 +170,7 @@ final class WaterCauldron extends FillableCauldron{
match($item->getTypeId()){ match($item->getTypeId()){
ItemTypeIds::WATER_BUCKET => $this->setCustomWaterColor(null)->addFillLevels(self::MAX_FILL_LEVEL, $item, VanillaItems::BUCKET(), $returnedItems), ItemTypeIds::WATER_BUCKET => $this->setCustomWaterColor(null)->addFillLevels(self::MAX_FILL_LEVEL, $item, VanillaItems::BUCKET(), $returnedItems),
ItemTypeIds::BUCKET => $this->removeFillLevels(self::MAX_FILL_LEVEL, $item, VanillaItems::WATER_BUCKET(), $returnedItems), ItemTypeIds::BUCKET => $this->removeFillLevels(self::MAX_FILL_LEVEL, $item, VanillaItems::WATER_BUCKET(), $returnedItems),
ItemTypeIds::GLASS_BOTTLE => $this->removeFillLevels(self::WATER_BOTTLE_FILL_AMOUNT, $item, VanillaItems::POTION()->setType(PotionType::WATER()), $returnedItems), ItemTypeIds::GLASS_BOTTLE => $this->removeFillLevels(self::WATER_BOTTLE_FILL_AMOUNT, $item, VanillaItems::POTION()->setType(PotionType::WATER), $returnedItems),
ItemTypeIds::LAVA_BUCKET, ItemTypeIds::POWDER_SNOW_BUCKET => $this->mix($item, VanillaItems::BUCKET(), $returnedItems), ItemTypeIds::LAVA_BUCKET, ItemTypeIds::POWDER_SNOW_BUCKET => $this->mix($item, VanillaItems::BUCKET(), $returnedItems),
default => null default => null
}; };

View File

@ -48,110 +48,103 @@ use pocketmine\utils\AssumptionFailedError;
final class WoodLikeBlockIdHelper{ final class WoodLikeBlockIdHelper{
public static function getPlanksIdentifier(WoodType $type) : BID{ public static function getPlanksIdentifier(WoodType $type) : BID{
return new BID(match($type->id()){ return new BID(match($type){
WoodType::OAK()->id() => Ids::OAK_PLANKS, WoodType::OAK => Ids::OAK_PLANKS,
WoodType::SPRUCE()->id() => Ids::SPRUCE_PLANKS, WoodType::SPRUCE => Ids::SPRUCE_PLANKS,
WoodType::BIRCH()->id() => Ids::BIRCH_PLANKS, WoodType::BIRCH => Ids::BIRCH_PLANKS,
WoodType::JUNGLE()->id() => Ids::JUNGLE_PLANKS, WoodType::JUNGLE => Ids::JUNGLE_PLANKS,
WoodType::ACACIA()->id() => Ids::ACACIA_PLANKS, WoodType::ACACIA => Ids::ACACIA_PLANKS,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_PLANKS, WoodType::DARK_OAK => Ids::DARK_OAK_PLANKS,
WoodType::MANGROVE()->id() => Ids::MANGROVE_PLANKS, WoodType::MANGROVE => Ids::MANGROVE_PLANKS,
WoodType::CRIMSON()->id() => Ids::CRIMSON_PLANKS, WoodType::CRIMSON => Ids::CRIMSON_PLANKS,
WoodType::WARPED()->id() => Ids::WARPED_PLANKS, WoodType::WARPED => Ids::WARPED_PLANKS,
WoodType::CHERRY()->id() => Ids::CHERRY_PLANKS, WoodType::CHERRY => Ids::CHERRY_PLANKS,
default => throw new AssumptionFailedError("All tree types should be covered")
}); });
} }
public static function getFenceIdentifier(WoodType $type) : BID{ public static function getFenceIdentifier(WoodType $type) : BID{
return new BID(match($type->id()){ return new BID(match($type){
WoodType::OAK()->id() => Ids::OAK_FENCE, WoodType::OAK => Ids::OAK_FENCE,
WoodType::SPRUCE()->id() => Ids::SPRUCE_FENCE, WoodType::SPRUCE => Ids::SPRUCE_FENCE,
WoodType::BIRCH()->id() => Ids::BIRCH_FENCE, WoodType::BIRCH => Ids::BIRCH_FENCE,
WoodType::JUNGLE()->id() => Ids::JUNGLE_FENCE, WoodType::JUNGLE => Ids::JUNGLE_FENCE,
WoodType::ACACIA()->id() => Ids::ACACIA_FENCE, WoodType::ACACIA => Ids::ACACIA_FENCE,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_FENCE, WoodType::DARK_OAK => Ids::DARK_OAK_FENCE,
WoodType::MANGROVE()->id() => Ids::MANGROVE_FENCE, WoodType::MANGROVE => Ids::MANGROVE_FENCE,
WoodType::CRIMSON()->id() => Ids::CRIMSON_FENCE, WoodType::CRIMSON => Ids::CRIMSON_FENCE,
WoodType::WARPED()->id() => Ids::WARPED_FENCE, WoodType::WARPED => Ids::WARPED_FENCE,
WoodType::CHERRY()->id() => Ids::CHERRY_FENCE, WoodType::CHERRY => Ids::CHERRY_FENCE,
default => throw new AssumptionFailedError("All tree types should be covered")
}); });
} }
public static function getSlabIdentifier(WoodType $type) : BID{ public static function getSlabIdentifier(WoodType $type) : BID{
return new BID(match($type->id()){ return new BID(match($type){
WoodType::OAK()->id() => Ids::OAK_SLAB, WoodType::OAK => Ids::OAK_SLAB,
WoodType::SPRUCE()->id() => Ids::SPRUCE_SLAB, WoodType::SPRUCE => Ids::SPRUCE_SLAB,
WoodType::BIRCH()->id() => Ids::BIRCH_SLAB, WoodType::BIRCH => Ids::BIRCH_SLAB,
WoodType::JUNGLE()->id() => Ids::JUNGLE_SLAB, WoodType::JUNGLE => Ids::JUNGLE_SLAB,
WoodType::ACACIA()->id() => Ids::ACACIA_SLAB, WoodType::ACACIA => Ids::ACACIA_SLAB,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_SLAB, WoodType::DARK_OAK => Ids::DARK_OAK_SLAB,
WoodType::MANGROVE()->id() => Ids::MANGROVE_SLAB, WoodType::MANGROVE => Ids::MANGROVE_SLAB,
WoodType::CRIMSON()->id() => Ids::CRIMSON_SLAB, WoodType::CRIMSON => Ids::CRIMSON_SLAB,
WoodType::WARPED()->id() => Ids::WARPED_SLAB, WoodType::WARPED => Ids::WARPED_SLAB,
WoodType::CHERRY()->id() => Ids::CHERRY_SLAB, WoodType::CHERRY => Ids::CHERRY_SLAB,
default => throw new AssumptionFailedError("All tree types should be covered")
}); });
} }
public static function getLogIdentifier(WoodType $treeType) : BID{ public static function getLogIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_LOG, WoodType::OAK => Ids::OAK_LOG,
WoodType::SPRUCE()->id() => Ids::SPRUCE_LOG, WoodType::SPRUCE => Ids::SPRUCE_LOG,
WoodType::BIRCH()->id() => Ids::BIRCH_LOG, WoodType::BIRCH => Ids::BIRCH_LOG,
WoodType::JUNGLE()->id() => Ids::JUNGLE_LOG, WoodType::JUNGLE => Ids::JUNGLE_LOG,
WoodType::ACACIA()->id() => Ids::ACACIA_LOG, WoodType::ACACIA => Ids::ACACIA_LOG,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_LOG, WoodType::DARK_OAK => Ids::DARK_OAK_LOG,
WoodType::MANGROVE()->id() => Ids::MANGROVE_LOG, WoodType::MANGROVE => Ids::MANGROVE_LOG,
WoodType::CRIMSON()->id() => Ids::CRIMSON_STEM, WoodType::CRIMSON => Ids::CRIMSON_STEM,
WoodType::WARPED()->id() => Ids::WARPED_STEM, WoodType::WARPED => Ids::WARPED_STEM,
WoodType::CHERRY()->id() => Ids::CHERRY_LOG, WoodType::CHERRY => Ids::CHERRY_LOG,
default => throw new AssumptionFailedError("All tree types should be covered")
}); });
} }
public static function getAllSidedLogIdentifier(WoodType $treeType) : BID{ public static function getAllSidedLogIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_WOOD, WoodType::OAK => Ids::OAK_WOOD,
WoodType::SPRUCE()->id() => Ids::SPRUCE_WOOD, WoodType::SPRUCE => Ids::SPRUCE_WOOD,
WoodType::BIRCH()->id() => Ids::BIRCH_WOOD, WoodType::BIRCH => Ids::BIRCH_WOOD,
WoodType::JUNGLE()->id() => Ids::JUNGLE_WOOD, WoodType::JUNGLE => Ids::JUNGLE_WOOD,
WoodType::ACACIA()->id() => Ids::ACACIA_WOOD, WoodType::ACACIA => Ids::ACACIA_WOOD,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_WOOD, WoodType::DARK_OAK => Ids::DARK_OAK_WOOD,
WoodType::MANGROVE()->id() => Ids::MANGROVE_WOOD, WoodType::MANGROVE => Ids::MANGROVE_WOOD,
WoodType::CRIMSON()->id() => Ids::CRIMSON_HYPHAE, WoodType::CRIMSON => Ids::CRIMSON_HYPHAE,
WoodType::WARPED()->id() => Ids::WARPED_HYPHAE, WoodType::WARPED => Ids::WARPED_HYPHAE,
WoodType::CHERRY()->id() => Ids::CHERRY_WOOD, WoodType::CHERRY => Ids::CHERRY_WOOD,
default => throw new AssumptionFailedError("All tree types should be covered")
}); });
} }
public static function getLeavesIdentifier(LeavesType $leavesType) : BID{ public static function getLeavesIdentifier(LeavesType $leavesType) : BID{
return new BID(match($leavesType->id()){ return new BID(match($leavesType){
LeavesType::OAK()->id() => Ids::OAK_LEAVES, LeavesType::OAK => Ids::OAK_LEAVES,
LeavesType::SPRUCE()->id() => Ids::SPRUCE_LEAVES, LeavesType::SPRUCE => Ids::SPRUCE_LEAVES,
LeavesType::BIRCH()->id() => Ids::BIRCH_LEAVES, LeavesType::BIRCH => Ids::BIRCH_LEAVES,
LeavesType::JUNGLE()->id() => Ids::JUNGLE_LEAVES, LeavesType::JUNGLE => Ids::JUNGLE_LEAVES,
LeavesType::ACACIA()->id() => Ids::ACACIA_LEAVES, LeavesType::ACACIA => Ids::ACACIA_LEAVES,
LeavesType::DARK_OAK()->id() => Ids::DARK_OAK_LEAVES, LeavesType::DARK_OAK => Ids::DARK_OAK_LEAVES,
LeavesType::MANGROVE()->id() => Ids::MANGROVE_LEAVES, LeavesType::MANGROVE => Ids::MANGROVE_LEAVES,
LeavesType::AZALEA()->id() => Ids::AZALEA_LEAVES, LeavesType::AZALEA => Ids::AZALEA_LEAVES,
LeavesType::FLOWERING_AZALEA()->id() => Ids::FLOWERING_AZALEA_LEAVES, LeavesType::FLOWERING_AZALEA => Ids::FLOWERING_AZALEA_LEAVES,
LeavesType::CHERRY()->id() => Ids::CHERRY_LEAVES, LeavesType::CHERRY => Ids::CHERRY_LEAVES,
default => throw new AssumptionFailedError("All leaves types should be covered")
}); });
} }
public static function getSaplingIdentifier(SaplingType $treeType) : BID{ public static function getSaplingIdentifier(SaplingType $treeType) : BID{
return new BID(match($treeType->id()){ return new BID(match($treeType){
SaplingType::OAK()->id() => Ids::OAK_SAPLING, SaplingType::OAK => Ids::OAK_SAPLING,
SaplingType::SPRUCE()->id() => Ids::SPRUCE_SAPLING, SaplingType::SPRUCE => Ids::SPRUCE_SAPLING,
SaplingType::BIRCH()->id() => Ids::BIRCH_SAPLING, SaplingType::BIRCH => Ids::BIRCH_SAPLING,
SaplingType::JUNGLE()->id() => Ids::JUNGLE_SAPLING, SaplingType::JUNGLE => Ids::JUNGLE_SAPLING,
SaplingType::ACACIA()->id() => Ids::ACACIA_SAPLING, SaplingType::ACACIA => Ids::ACACIA_SAPLING,
SaplingType::DARK_OAK()->id() => Ids::DARK_OAK_SAPLING, SaplingType::DARK_OAK => Ids::DARK_OAK_SAPLING,
default => throw new AssumptionFailedError("All tree types should be covered")
}); });
} }
@ -160,62 +153,62 @@ final class WoodLikeBlockIdHelper{
* @phpstan-return array{BID, BID, \Closure() : \pocketmine\item\Item} * @phpstan-return array{BID, BID, \Closure() : \pocketmine\item\Item}
*/ */
public static function getSignInfo(WoodType $treeType) : array{ public static function getSignInfo(WoodType $treeType) : array{
switch($treeType->id()){ switch($treeType){
case WoodType::OAK()->id(): case WoodType::OAK:
return [ return [
new BID(Ids::OAK_SIGN, TileSign::class), new BID(Ids::OAK_SIGN, TileSign::class),
new BID(Ids::OAK_WALL_SIGN, TileSign::class), new BID(Ids::OAK_WALL_SIGN, TileSign::class),
fn() => VanillaItems::OAK_SIGN() fn() => VanillaItems::OAK_SIGN()
]; ];
case WoodType::SPRUCE()->id(): case WoodType::SPRUCE:
return [ return [
new BID(Ids::SPRUCE_SIGN, TileSign::class), new BID(Ids::SPRUCE_SIGN, TileSign::class),
new BID(Ids::SPRUCE_WALL_SIGN, TileSign::class), new BID(Ids::SPRUCE_WALL_SIGN, TileSign::class),
fn() => VanillaItems::SPRUCE_SIGN() fn() => VanillaItems::SPRUCE_SIGN()
]; ];
case WoodType::BIRCH()->id(): case WoodType::BIRCH:
return [ return [
new BID(Ids::BIRCH_SIGN, TileSign::class), new BID(Ids::BIRCH_SIGN, TileSign::class),
new BID(Ids::BIRCH_WALL_SIGN, TileSign::class), new BID(Ids::BIRCH_WALL_SIGN, TileSign::class),
fn() => VanillaItems::BIRCH_SIGN() fn() => VanillaItems::BIRCH_SIGN()
]; ];
case WoodType::JUNGLE()->id(): case WoodType::JUNGLE:
return [ return [
new BID(Ids::JUNGLE_SIGN, TileSign::class), new BID(Ids::JUNGLE_SIGN, TileSign::class),
new BID(Ids::JUNGLE_WALL_SIGN, TileSign::class), new BID(Ids::JUNGLE_WALL_SIGN, TileSign::class),
fn() => VanillaItems::JUNGLE_SIGN() fn() => VanillaItems::JUNGLE_SIGN()
]; ];
case WoodType::ACACIA()->id(): case WoodType::ACACIA:
return [ return [
new BID(Ids::ACACIA_SIGN, TileSign::class), new BID(Ids::ACACIA_SIGN, TileSign::class),
new BID(Ids::ACACIA_WALL_SIGN, TileSign::class), new BID(Ids::ACACIA_WALL_SIGN, TileSign::class),
fn() => VanillaItems::ACACIA_SIGN() fn() => VanillaItems::ACACIA_SIGN()
]; ];
case WoodType::DARK_OAK()->id(): case WoodType::DARK_OAK:
return [ return [
new BID(Ids::DARK_OAK_SIGN, TileSign::class), new BID(Ids::DARK_OAK_SIGN, TileSign::class),
new BID(Ids::DARK_OAK_WALL_SIGN, TileSign::class), new BID(Ids::DARK_OAK_WALL_SIGN, TileSign::class),
fn() => VanillaItems::DARK_OAK_SIGN() fn() => VanillaItems::DARK_OAK_SIGN()
]; ];
case WoodType::MANGROVE()->id(): case WoodType::MANGROVE:
return [ return [
new BID(Ids::MANGROVE_SIGN, TileSign::class), new BID(Ids::MANGROVE_SIGN, TileSign::class),
new BID(Ids::MANGROVE_WALL_SIGN, TileSign::class), new BID(Ids::MANGROVE_WALL_SIGN, TileSign::class),
fn() => VanillaItems::MANGROVE_SIGN() fn() => VanillaItems::MANGROVE_SIGN()
]; ];
case WoodType::CRIMSON()->id(): case WoodType::CRIMSON:
return [ return [
new BID(Ids::CRIMSON_SIGN, TileSign::class), new BID(Ids::CRIMSON_SIGN, TileSign::class),
new BID(Ids::CRIMSON_WALL_SIGN, TileSign::class), new BID(Ids::CRIMSON_WALL_SIGN, TileSign::class),
fn() => VanillaItems::CRIMSON_SIGN() fn() => VanillaItems::CRIMSON_SIGN()
]; ];
case WoodType::WARPED()->id(): case WoodType::WARPED:
return [ return [
new BID(Ids::WARPED_SIGN, TileSign::class), new BID(Ids::WARPED_SIGN, TileSign::class),
new BID(Ids::WARPED_WALL_SIGN, TileSign::class), new BID(Ids::WARPED_WALL_SIGN, TileSign::class),
fn() => VanillaItems::WARPED_SIGN() fn() => VanillaItems::WARPED_SIGN()
]; ];
case WoodType::CHERRY()->id(): case WoodType::CHERRY:
return [ return [
new BID(Ids::CHERRY_SIGN, TileSign::class), new BID(Ids::CHERRY_SIGN, TileSign::class),
new BID(Ids::CHERRY_WALL_SIGN, TileSign::class), new BID(Ids::CHERRY_WALL_SIGN, TileSign::class),
@ -226,98 +219,92 @@ final class WoodLikeBlockIdHelper{
} }
public static function getTrapdoorIdentifier(WoodType $treeType) : BlockIdentifier{ public static function getTrapdoorIdentifier(WoodType $treeType) : BlockIdentifier{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_TRAPDOOR, WoodType::OAK => Ids::OAK_TRAPDOOR,
WoodType::SPRUCE()->id() => Ids::SPRUCE_TRAPDOOR, WoodType::SPRUCE => Ids::SPRUCE_TRAPDOOR,
WoodType::BIRCH()->id() => Ids::BIRCH_TRAPDOOR, WoodType::BIRCH => Ids::BIRCH_TRAPDOOR,
WoodType::JUNGLE()->id() => Ids::JUNGLE_TRAPDOOR, WoodType::JUNGLE => Ids::JUNGLE_TRAPDOOR,
WoodType::ACACIA()->id() => Ids::ACACIA_TRAPDOOR, WoodType::ACACIA => Ids::ACACIA_TRAPDOOR,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_TRAPDOOR, WoodType::DARK_OAK => Ids::DARK_OAK_TRAPDOOR,
WoodType::MANGROVE()->id() => Ids::MANGROVE_TRAPDOOR, WoodType::MANGROVE => Ids::MANGROVE_TRAPDOOR,
WoodType::CRIMSON()->id() => Ids::CRIMSON_TRAPDOOR, WoodType::CRIMSON => Ids::CRIMSON_TRAPDOOR,
WoodType::WARPED()->id() => Ids::WARPED_TRAPDOOR, WoodType::WARPED => Ids::WARPED_TRAPDOOR,
WoodType::CHERRY()->id() => Ids::CHERRY_TRAPDOOR, WoodType::CHERRY => Ids::CHERRY_TRAPDOOR,
default => throw new AssumptionFailedError("All wood types should be covered")
}); });
} }
public static function getButtonIdentifier(WoodType $treeType) : BlockIdentifier{ public static function getButtonIdentifier(WoodType $treeType) : BlockIdentifier{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_BUTTON, WoodType::OAK => Ids::OAK_BUTTON,
WoodType::SPRUCE()->id() => Ids::SPRUCE_BUTTON, WoodType::SPRUCE => Ids::SPRUCE_BUTTON,
WoodType::BIRCH()->id() => Ids::BIRCH_BUTTON, WoodType::BIRCH => Ids::BIRCH_BUTTON,
WoodType::JUNGLE()->id() => Ids::JUNGLE_BUTTON, WoodType::JUNGLE => Ids::JUNGLE_BUTTON,
WoodType::ACACIA()->id() => Ids::ACACIA_BUTTON, WoodType::ACACIA => Ids::ACACIA_BUTTON,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_BUTTON, WoodType::DARK_OAK => Ids::DARK_OAK_BUTTON,
WoodType::MANGROVE()->id() => Ids::MANGROVE_BUTTON, WoodType::MANGROVE => Ids::MANGROVE_BUTTON,
WoodType::CRIMSON()->id() => Ids::CRIMSON_BUTTON, WoodType::CRIMSON => Ids::CRIMSON_BUTTON,
WoodType::WARPED()->id() => Ids::WARPED_BUTTON, WoodType::WARPED => Ids::WARPED_BUTTON,
WoodType::CHERRY()->id() => Ids::CHERRY_BUTTON, WoodType::CHERRY => Ids::CHERRY_BUTTON,
default => throw new AssumptionFailedError("All wood types should be covered")
}); });
} }
public static function getPressurePlateIdentifier(WoodType $treeType) : BlockIdentifier{ public static function getPressurePlateIdentifier(WoodType $treeType) : BlockIdentifier{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_PRESSURE_PLATE, WoodType::OAK => Ids::OAK_PRESSURE_PLATE,
WoodType::SPRUCE()->id() => Ids::SPRUCE_PRESSURE_PLATE, WoodType::SPRUCE => Ids::SPRUCE_PRESSURE_PLATE,
WoodType::BIRCH()->id() => Ids::BIRCH_PRESSURE_PLATE, WoodType::BIRCH => Ids::BIRCH_PRESSURE_PLATE,
WoodType::JUNGLE()->id() => Ids::JUNGLE_PRESSURE_PLATE, WoodType::JUNGLE => Ids::JUNGLE_PRESSURE_PLATE,
WoodType::ACACIA()->id() => Ids::ACACIA_PRESSURE_PLATE, WoodType::ACACIA => Ids::ACACIA_PRESSURE_PLATE,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_PRESSURE_PLATE, WoodType::DARK_OAK => Ids::DARK_OAK_PRESSURE_PLATE,
WoodType::MANGROVE()->id() => Ids::MANGROVE_PRESSURE_PLATE, WoodType::MANGROVE => Ids::MANGROVE_PRESSURE_PLATE,
WoodType::CRIMSON()->id() => Ids::CRIMSON_PRESSURE_PLATE, WoodType::CRIMSON => Ids::CRIMSON_PRESSURE_PLATE,
WoodType::WARPED()->id() => Ids::WARPED_PRESSURE_PLATE, WoodType::WARPED => Ids::WARPED_PRESSURE_PLATE,
WoodType::CHERRY()->id() => Ids::CHERRY_PRESSURE_PLATE, WoodType::CHERRY => Ids::CHERRY_PRESSURE_PLATE,
default => throw new AssumptionFailedError("All wood types should be covered")
}); });
} }
public static function getDoorIdentifier(WoodType $treeType) : BlockIdentifier{ public static function getDoorIdentifier(WoodType $treeType) : BlockIdentifier{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_DOOR, WoodType::OAK => Ids::OAK_DOOR,
WoodType::SPRUCE()->id() => Ids::SPRUCE_DOOR, WoodType::SPRUCE => Ids::SPRUCE_DOOR,
WoodType::BIRCH()->id() => Ids::BIRCH_DOOR, WoodType::BIRCH => Ids::BIRCH_DOOR,
WoodType::JUNGLE()->id() => Ids::JUNGLE_DOOR, WoodType::JUNGLE => Ids::JUNGLE_DOOR,
WoodType::ACACIA()->id() => Ids::ACACIA_DOOR, WoodType::ACACIA => Ids::ACACIA_DOOR,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_DOOR, WoodType::DARK_OAK => Ids::DARK_OAK_DOOR,
WoodType::MANGROVE()->id() => Ids::MANGROVE_DOOR, WoodType::MANGROVE => Ids::MANGROVE_DOOR,
WoodType::CRIMSON()->id() => Ids::CRIMSON_DOOR, WoodType::CRIMSON => Ids::CRIMSON_DOOR,
WoodType::WARPED()->id() => Ids::WARPED_DOOR, WoodType::WARPED => Ids::WARPED_DOOR,
WoodType::CHERRY()->id() => Ids::CHERRY_DOOR, WoodType::CHERRY => Ids::CHERRY_DOOR,
default => throw new AssumptionFailedError("All wood types should be covered")
}); });
} }
public static function getFenceGateIdentifier(WoodType $treeType) : BlockIdentifier{ public static function getFenceGateIdentifier(WoodType $treeType) : BlockIdentifier{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_FENCE_GATE, WoodType::OAK => Ids::OAK_FENCE_GATE,
WoodType::SPRUCE()->id() => Ids::SPRUCE_FENCE_GATE, WoodType::SPRUCE => Ids::SPRUCE_FENCE_GATE,
WoodType::BIRCH()->id() => Ids::BIRCH_FENCE_GATE, WoodType::BIRCH => Ids::BIRCH_FENCE_GATE,
WoodType::JUNGLE()->id() => Ids::JUNGLE_FENCE_GATE, WoodType::JUNGLE => Ids::JUNGLE_FENCE_GATE,
WoodType::ACACIA()->id() => Ids::ACACIA_FENCE_GATE, WoodType::ACACIA => Ids::ACACIA_FENCE_GATE,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_FENCE_GATE, WoodType::DARK_OAK => Ids::DARK_OAK_FENCE_GATE,
WoodType::MANGROVE()->id() => Ids::MANGROVE_FENCE_GATE, WoodType::MANGROVE => Ids::MANGROVE_FENCE_GATE,
WoodType::CRIMSON()->id() => Ids::CRIMSON_FENCE_GATE, WoodType::CRIMSON => Ids::CRIMSON_FENCE_GATE,
WoodType::WARPED()->id() => Ids::WARPED_FENCE_GATE, WoodType::WARPED => Ids::WARPED_FENCE_GATE,
WoodType::CHERRY()->id() => Ids::CHERRY_FENCE_GATE, WoodType::CHERRY => Ids::CHERRY_FENCE_GATE,
default => throw new AssumptionFailedError("All wood types should be covered")
}); });
} }
public static function getStairsIdentifier(WoodType $treeType) : BlockIdentifier{ public static function getStairsIdentifier(WoodType $treeType) : BlockIdentifier{
return new BID(match($treeType->id()){ return new BID(match($treeType){
WoodType::OAK()->id() => Ids::OAK_STAIRS, WoodType::OAK => Ids::OAK_STAIRS,
WoodType::SPRUCE()->id() => Ids::SPRUCE_STAIRS, WoodType::SPRUCE => Ids::SPRUCE_STAIRS,
WoodType::BIRCH()->id() => Ids::BIRCH_STAIRS, WoodType::BIRCH => Ids::BIRCH_STAIRS,
WoodType::JUNGLE()->id() => Ids::JUNGLE_STAIRS, WoodType::JUNGLE => Ids::JUNGLE_STAIRS,
WoodType::ACACIA()->id() => Ids::ACACIA_STAIRS, WoodType::ACACIA => Ids::ACACIA_STAIRS,
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_STAIRS, WoodType::DARK_OAK => Ids::DARK_OAK_STAIRS,
WoodType::MANGROVE()->id() => Ids::MANGROVE_STAIRS, WoodType::MANGROVE => Ids::MANGROVE_STAIRS,
WoodType::CRIMSON()->id() => Ids::CRIMSON_STAIRS, WoodType::CRIMSON => Ids::CRIMSON_STAIRS,
WoodType::WARPED()->id() => Ids::WARPED_STAIRS, WoodType::WARPED => Ids::WARPED_STAIRS,
WoodType::CHERRY()->id() => Ids::CHERRY_STAIRS, WoodType::CHERRY => Ids::CHERRY_STAIRS,
default => throw new AssumptionFailedError("All wood types should be covered")
}); });
} }
} }

View File

@ -24,16 +24,10 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\ColoredTrait; use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
class Wool extends Opaque{ class Wool extends Opaque{
use ColoredTrait; use ColoredTrait;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
$this->color = DyeColor::WHITE();
parent::__construct($idInfo, $name, $typeInfo);
}
public function getFlameEncouragement() : int{ public function getFlameEncouragement() : int{
return 30; return 30;
} }

View File

@ -27,11 +27,9 @@ use pocketmine\block\utils\BannerPatternLayer;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\data\bedrock\BannerPatternTypeIdMap; use pocketmine\data\bedrock\BannerPatternTypeIdMap;
use pocketmine\data\bedrock\DyeColorIdMap; use pocketmine\data\bedrock\DyeColorIdMap;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
use pocketmine\world\World;
/** /**
* @deprecated * @deprecated
@ -44,7 +42,7 @@ class Banner extends Spawnable{
public const TAG_PATTERN_COLOR = "Color"; public const TAG_PATTERN_COLOR = "Color";
public const TAG_PATTERN_NAME = "Pattern"; public const TAG_PATTERN_NAME = "Pattern";
private DyeColor $baseColor; private DyeColor $baseColor = DyeColor::BLACK;
/** /**
* @var BannerPatternLayer[] * @var BannerPatternLayer[]
@ -52,11 +50,6 @@ class Banner extends Spawnable{
*/ */
private array $patterns = []; private array $patterns = [];
public function __construct(World $world, Vector3 $pos){
$this->baseColor = DyeColor::BLACK();
parent::__construct($world, $pos);
}
public function readSaveData(CompoundTag $nbt) : void{ public function readSaveData(CompoundTag $nbt) : void{
$colorIdMap = DyeColorIdMap::getInstance(); $colorIdMap = DyeColorIdMap::getInstance();
if( if(
@ -65,7 +58,7 @@ class Banner extends Spawnable{
){ ){
$this->baseColor = $baseColor; $this->baseColor = $baseColor;
}else{ }else{
$this->baseColor = DyeColor::BLACK(); //TODO: this should be an error $this->baseColor = DyeColor::BLACK; //TODO: this should be an error
} }
$patternTypeIdMap = BannerPatternTypeIdMap::getInstance(); $patternTypeIdMap = BannerPatternTypeIdMap::getInstance();
@ -74,7 +67,7 @@ class Banner extends Spawnable{
if($patterns !== null){ if($patterns !== null){
/** @var CompoundTag $pattern */ /** @var CompoundTag $pattern */
foreach($patterns as $pattern){ foreach($patterns as $pattern){
$patternColor = $colorIdMap->fromInvertedId($pattern->getInt(self::TAG_PATTERN_COLOR)) ?? DyeColor::BLACK(); //TODO: missing pattern colour should be an error $patternColor = $colorIdMap->fromInvertedId($pattern->getInt(self::TAG_PATTERN_COLOR)) ?? DyeColor::BLACK; //TODO: missing pattern colour should be an error
$patternType = $patternTypeIdMap->fromId($pattern->getString(self::TAG_PATTERN_NAME)); $patternType = $patternTypeIdMap->fromId($pattern->getString(self::TAG_PATTERN_NAME));
if($patternType === null){ if($patternType === null){
continue; //TODO: this should be an error, but right now we don't have the setup to deal with it continue; //TODO: this should be an error, but right now we don't have the setup to deal with it

View File

@ -25,20 +25,13 @@ namespace pocketmine\block\tile;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\data\bedrock\DyeColorIdMap; use pocketmine\data\bedrock\DyeColorIdMap;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\world\World;
class Bed extends Spawnable{ class Bed extends Spawnable{
public const TAG_COLOR = "color"; public const TAG_COLOR = "color";
private DyeColor $color; private DyeColor $color = DyeColor::RED;
public function __construct(World $world, Vector3 $pos){
$this->color = DyeColor::RED();
parent::__construct($world, $pos);
}
public function getColor() : DyeColor{ public function getColor() : DyeColor{
return $this->color; return $this->color;
@ -55,7 +48,7 @@ class Bed extends Spawnable{
){ ){
$this->color = $color; $this->color = $color;
}else{ }else{
$this->color = DyeColor::RED(); //TODO: this should be an error, but we don't have the systems to handle it yet $this->color = DyeColor::RED; //TODO: this should be an error, but we don't have the systems to handle it yet
} }
} }

View File

@ -27,6 +27,6 @@ use pocketmine\crafting\FurnaceType;
class BlastFurnace extends Furnace{ class BlastFurnace extends Furnace{
public function getFurnaceType() : FurnaceType{ public function getFurnaceType() : FurnaceType{
return FurnaceType::BLAST_FURNACE(); return FurnaceType::BLAST_FURNACE;
} }
} }

View File

@ -26,10 +26,8 @@ namespace pocketmine\block\tile;
use pocketmine\block\utils\MobHeadType; use pocketmine\block\utils\MobHeadType;
use pocketmine\data\bedrock\MobHeadTypeIdMap; use pocketmine\data\bedrock\MobHeadTypeIdMap;
use pocketmine\data\SavedDataLoadingException; use pocketmine\data\SavedDataLoadingException;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\world\World;
/** /**
* @deprecated * @deprecated
@ -42,14 +40,9 @@ class MobHead extends Spawnable{
private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte
private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int
private MobHeadType $mobHeadType; private MobHeadType $mobHeadType = MobHeadType::SKELETON;
private int $rotation = 0; private int $rotation = 0;
public function __construct(World $world, Vector3 $pos){
$this->mobHeadType = MobHeadType::SKELETON();
parent::__construct($world, $pos);
}
public function readSaveData(CompoundTag $nbt) : void{ public function readSaveData(CompoundTag $nbt) : void{
if(($skullTypeTag = $nbt->getTag(self::TAG_SKULL_TYPE)) instanceof ByteTag){ if(($skullTypeTag = $nbt->getTag(self::TAG_SKULL_TYPE)) instanceof ByteTag){
$mobHeadType = MobHeadTypeIdMap::getInstance()->fromId($skullTypeTag->getValue()); $mobHeadType = MobHeadTypeIdMap::getInstance()->fromId($skullTypeTag->getValue());

View File

@ -27,6 +27,6 @@ use pocketmine\crafting\FurnaceType;
class NormalFurnace extends Furnace{ class NormalFurnace extends Furnace{
public function getFurnaceType() : FurnaceType{ public function getFurnaceType() : FurnaceType{
return FurnaceType::FURNACE(); return FurnaceType::FURNACE;
} }
} }

View File

@ -27,6 +27,6 @@ use pocketmine\crafting\FurnaceType;
class Smoker extends Furnace{ class Smoker extends Furnace{
public function getFurnaceType() : FurnaceType{ public function getFurnaceType() : FurnaceType{
return FurnaceType::SMOKER(); return FurnaceType::SMOKER;
} }
} }

View File

@ -23,13 +23,11 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static BannerPatternType BORDER() * @method static BannerPatternType BORDER()
* @method static BannerPatternType BRICKS() * @method static BannerPatternType BRICKS()
@ -70,49 +68,45 @@ use pocketmine\utils\EnumTrait;
* @method static BannerPatternType TRIANGLE_BOTTOM() * @method static BannerPatternType TRIANGLE_BOTTOM()
* @method static BannerPatternType TRIANGLE_TOP() * @method static BannerPatternType TRIANGLE_TOP()
*/ */
final class BannerPatternType{ enum BannerPatternType{
use EnumTrait; use LegacyEnumShimTrait;
protected static function setup() : void{ case BORDER;
self::registerAll( case BRICKS;
new self("border"), case CIRCLE;
new self("bricks"), case CREEPER;
new self("circle"), case CROSS;
new self("creeper"), case CURLY_BORDER;
new self("cross"), case DIAGONAL_LEFT;
new self("curly_border"), case DIAGONAL_RIGHT;
new self("diagonal_left"), case DIAGONAL_UP_LEFT;
new self("diagonal_right"), case DIAGONAL_UP_RIGHT;
new self("diagonal_up_left"), case FLOWER;
new self("diagonal_up_right"), case GRADIENT;
new self("flower"), case GRADIENT_UP;
new self("gradient"), case HALF_HORIZONTAL;
new self("gradient_up"), case HALF_HORIZONTAL_BOTTOM;
new self("half_horizontal"), case HALF_VERTICAL;
new self("half_horizontal_bottom"), case HALF_VERTICAL_RIGHT;
new self("half_vertical"), case MOJANG;
new self("half_vertical_right"), case RHOMBUS;
new self("mojang"), case SKULL;
new self("rhombus"), case SMALL_STRIPES;
new self("skull"), case SQUARE_BOTTOM_LEFT;
new self("small_stripes"), case SQUARE_BOTTOM_RIGHT;
new self("square_bottom_left"), case SQUARE_TOP_LEFT;
new self("square_bottom_right"), case SQUARE_TOP_RIGHT;
new self("square_top_left"), case STRAIGHT_CROSS;
new self("square_top_right"), case STRIPE_BOTTOM;
new self("straight_cross"), case STRIPE_CENTER;
new self("stripe_bottom"), case STRIPE_DOWNLEFT;
new self("stripe_center"), case STRIPE_DOWNRIGHT;
new self("stripe_downleft"), case STRIPE_LEFT;
new self("stripe_downright"), case STRIPE_MIDDLE;
new self("stripe_left"), case STRIPE_RIGHT;
new self("stripe_middle"), case STRIPE_TOP;
new self("stripe_right"), case TRIANGLE_BOTTOM;
new self("stripe_top"), case TRIANGLE_TOP;
new self("triangle_bottom"), case TRIANGLES_BOTTOM;
new self("triangle_top"), case TRIANGLES_TOP;
new self("triangles_bottom"),
new self("triangles_top")
);
}
} }

View File

@ -23,28 +23,22 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static BellAttachmentType CEILING() * @method static BellAttachmentType CEILING()
* @method static BellAttachmentType FLOOR() * @method static BellAttachmentType FLOOR()
* @method static BellAttachmentType ONE_WALL() * @method static BellAttachmentType ONE_WALL()
* @method static BellAttachmentType TWO_WALLS() * @method static BellAttachmentType TWO_WALLS()
*/ */
final class BellAttachmentType{ enum BellAttachmentType{
use EnumTrait; use LegacyEnumShimTrait;
protected static function setup() : void{ case CEILING;
self::registerAll( case FLOOR;
new self("ceiling"), case ONE_WALL;
new self("floor"), case TWO_WALLS;
new self("one_wall"),
new self("two_walls")
);
}
} }

View File

@ -24,37 +24,31 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\inventory\BrewingStandInventory; use pocketmine\block\inventory\BrewingStandInventory;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static BrewingStandSlot EAST() * @method static BrewingStandSlot EAST()
* @method static BrewingStandSlot NORTHWEST() * @method static BrewingStandSlot NORTHWEST()
* @method static BrewingStandSlot SOUTHWEST() * @method static BrewingStandSlot SOUTHWEST()
*/ */
final class BrewingStandSlot{ enum BrewingStandSlot{
use EnumTrait { use LegacyEnumShimTrait;
__construct as Enum___construct;
}
protected static function setup() : void{ case EAST;
self::registerAll( case NORTHWEST;
new self("east", BrewingStandInventory::SLOT_BOTTLE_LEFT), case SOUTHWEST;
new self("northwest", BrewingStandInventory::SLOT_BOTTLE_MIDDLE),
new self("southwest", BrewingStandInventory::SLOT_BOTTLE_RIGHT)
);
}
private function __construct(string $enumName, private int $slotNumber){
$this->Enum___construct($enumName);
}
/** /**
* Returns the brewing stand inventory slot number associated with this visual slot. * Returns the brewing stand inventory slot number associated with this visual slot.
*/ */
public function getSlotNumber() : int{ return $this->slotNumber; } public function getSlotNumber() : int{
return match($this){
self::EAST => BrewingStandInventory::SLOT_BOTTLE_LEFT,
self::NORTHWEST => BrewingStandInventory::SLOT_BOTTLE_MIDDLE,
self::SOUTHWEST => BrewingStandInventory::SLOT_BOTTLE_RIGHT
};
}
} }

View File

@ -28,11 +28,11 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
trait ColoredTrait{ trait ColoredTrait{
/** @var DyeColor */ /** @var DyeColor */
private $color; private $color = DyeColor::WHITE;
/** @see Block::describeBlockItemState() */ /** @see Block::describeBlockItemState() */
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color); $w->enum($this->color);
} }
public function getColor() : DyeColor{ return $this->color; } public function getColor() : DyeColor{ return $this->color; }

View File

@ -23,57 +23,30 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static CopperOxidation EXPOSED() * @method static CopperOxidation EXPOSED()
* @method static CopperOxidation NONE() * @method static CopperOxidation NONE()
* @method static CopperOxidation OXIDIZED() * @method static CopperOxidation OXIDIZED()
* @method static CopperOxidation WEATHERED() * @method static CopperOxidation WEATHERED()
*/ */
final class CopperOxidation{ enum CopperOxidation : int{
use EnumTrait { use LegacyEnumShimTrait;
__construct as Enum___construct;
register as Enum_register;
}
protected static function setup() : void{ case NONE = 0;
self::registerAll( case EXPOSED = 1;
new self("none", 0), case WEATHERED = 2;
new self("exposed", 1), case OXIDIZED = 3;
new self("weathered", 2),
new self("oxidized", 3)
);
}
protected static function register(self $member) : void{
self::Enum_register($member);
self::$levelMap[$member->value] = $member;
}
/**
* @var self[]
* @phpstan-var array<int, self>
*/
private static array $levelMap = [];
private function __construct(
string $name,
private int $value
){
$this->Enum___construct($name);
}
public function getPrevious() : ?self{ public function getPrevious() : ?self{
return self::$levelMap[$this->value - 1] ?? null; return self::tryFrom($this->value - 1);
} }
public function getNext() : ?self{ public function getNext() : ?self{
return self::$levelMap[$this->value + 1] ?? null; return self::tryFrom($this->value + 1);
} }
} }

View File

@ -23,8 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\BlockIdentifier;
use pocketmine\block\BlockTypeInfo;
use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Axe; use pocketmine\item\Axe;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -36,16 +34,11 @@ use pocketmine\world\sound\CopperWaxRemoveSound;
use pocketmine\world\sound\ScrapeSound; use pocketmine\world\sound\ScrapeSound;
trait CopperTrait{ trait CopperTrait{
private CopperOxidation $oxidation; private CopperOxidation $oxidation = CopperOxidation::NONE;
private bool $waxed = false; private bool $waxed = false;
public function __construct(BlockIdentifier $identifier, string $name, BlockTypeInfo $typeInfo){
$this->oxidation = CopperOxidation::NONE();
parent::__construct($identifier, $name, $typeInfo);
}
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->copperOxidation($this->oxidation); $w->enum($this->oxidation);
$w->bool($this->waxed); $w->bool($this->waxed);
} }

View File

@ -23,13 +23,11 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static CoralType BRAIN() * @method static CoralType BRAIN()
* @method static CoralType BUBBLE() * @method static CoralType BUBBLE()
@ -37,27 +35,22 @@ use pocketmine\utils\EnumTrait;
* @method static CoralType HORN() * @method static CoralType HORN()
* @method static CoralType TUBE() * @method static CoralType TUBE()
*/ */
final class CoralType{ enum CoralType{
use EnumTrait { use LegacyEnumShimTrait;
__construct as Enum___construct;
}
protected static function setup() : void{ case TUBE;
self::registerAll( case BRAIN;
new self("tube", "Tube"), case BUBBLE;
new self("brain", "Brain"), case FIRE;
new self("bubble", "Bubble"), case HORN;
new self("fire", "Fire"),
new self("horn", "Horn"),
);
}
private function __construct( public function getDisplayName() : string{
string $name, return match($this){
private string $displayName self::TUBE => "Tube",
){ self::BRAIN => "Brain",
$this->Enum___construct($name); self::BUBBLE => "Bubble",
self::FIRE => "Fire",
self::HORN => "Horn",
};
} }
public function getDisplayName() : string{ return $this->displayName; }
} }

View File

@ -27,12 +27,12 @@ use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\data\runtime\RuntimeDataDescriber;
trait CoralTypeTrait{ trait CoralTypeTrait{
protected CoralType $coralType; protected CoralType $coralType = CoralType::TUBE;
protected bool $dead = false; protected bool $dead = false;
/** @see Block::describeBlockItemState() */ /** @see Block::describeBlockItemState() */
public function describeBlockItemState(RuntimeDataDescriber $w) : void{ public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->coralType($this->coralType); $w->enum($this->coralType);
$w->bool($this->dead); $w->bool($this->dead);
} }

View File

@ -23,26 +23,20 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static DirtType COARSE() * @method static DirtType COARSE()
* @method static DirtType NORMAL() * @method static DirtType NORMAL()
* @method static DirtType ROOTED() * @method static DirtType ROOTED()
*/ */
final class DirtType{ enum DirtType{
use EnumTrait; use LegacyEnumShimTrait;
protected static function setup() : void{ case NORMAL;
self::registerAll( case COARSE;
new self("normal"), case ROOTED;
new self("coarse"),
new self("rooted")
);
}
} }

View File

@ -23,43 +23,30 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static DripleafState FULL_TILT() * @method static DripleafState FULL_TILT()
* @method static DripleafState PARTIAL_TILT() * @method static DripleafState PARTIAL_TILT()
* @method static DripleafState STABLE() * @method static DripleafState STABLE()
* @method static DripleafState UNSTABLE() * @method static DripleafState UNSTABLE()
*/ */
final class DripleafState{ enum DripleafState{
use EnumTrait { use LegacyEnumShimTrait;
register as Enum_register;
__construct as Enum___construct;
}
protected static function setup() : void{ case STABLE;
self::registerAll( case UNSTABLE;
new self("stable", null), case PARTIAL_TILT;
new self("unstable", 10), case FULL_TILT;
new self("partial_tilt", 10),
new self("full_tilt", 100)
);
}
private function __construct(
string $enumName,
private ?int $scheduledUpdateDelayTicks
){
$this->Enum___construct($enumName);
}
public function getScheduledUpdateDelayTicks() : ?int{ public function getScheduledUpdateDelayTicks() : ?int{
return $this->scheduledUpdateDelayTicks; return match($this){
self::STABLE => null,
self::UNSTABLE, self::PARTIAL_TILT => 10,
self::FULL_TILT => 100,
};
} }
} }

View File

@ -24,13 +24,12 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\color\Color; use pocketmine\color\Color;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static DyeColor BLACK() * @method static DyeColor BLACK()
* @method static DyeColor BLUE() * @method static DyeColor BLUE()
@ -48,46 +47,70 @@ use pocketmine\utils\EnumTrait;
* @method static DyeColor RED() * @method static DyeColor RED()
* @method static DyeColor WHITE() * @method static DyeColor WHITE()
* @method static DyeColor YELLOW() * @method static DyeColor YELLOW()
*
* @phpstan-type TMetadata array{0: string, 1: Color}
*/ */
final class DyeColor{ enum DyeColor{
use EnumTrait { use LegacyEnumShimTrait;
__construct as Enum___construct;
case WHITE;
case ORANGE;
case MAGENTA;
case LIGHT_BLUE;
case YELLOW;
case LIME;
case PINK;
case GRAY;
case LIGHT_GRAY;
case CYAN;
case PURPLE;
case BLUE;
case BROWN;
case GREEN;
case RED;
case BLACK;
/**
* This function exists only to permit the use of named arguments and to make the code easier to read in PhpStorm.
*
* @phpstan-return TMetadata
*/
private static function meta(string $displayName, Color $rgbValue) : array{
return [$displayName, $rgbValue];
} }
protected static function setup() : void{ /**
self::registerAll( * @phpstan-return TMetadata
new DyeColor("white", "White", new Color(0xf0, 0xf0, 0xf0)), */
new DyeColor("orange", "Orange", new Color(0xf9, 0x80, 0x1d)), private function getMetadata() : array{
new DyeColor("magenta", "Magenta", new Color(0xc7, 0x4e, 0xbd)), /** @phpstan-var array<int, TMetadata> $cache */
new DyeColor("light_blue", "Light Blue", new Color(0x3a, 0xb3, 0xda)), static $cache = [];
new DyeColor("yellow", "Yellow", new Color(0xfe, 0xd8, 0x3d)),
new DyeColor("lime", "Lime", new Color(0x80, 0xc7, 0x1f)),
new DyeColor("pink", "Pink", new Color(0xf3, 0x8b, 0xaa)),
new DyeColor("gray", "Gray", new Color(0x47, 0x4f, 0x52)),
new DyeColor("light_gray", "Light Gray", new Color(0x9d, 0x9d, 0x97)),
new DyeColor("cyan", "Cyan", new Color(0x16, 0x9c, 0x9c)),
new DyeColor("purple", "Purple", new Color(0x89, 0x32, 0xb8)),
new DyeColor("blue", "Blue", new Color(0x3c, 0x44, 0xaa)),
new DyeColor("brown", "Brown", new Color(0x83, 0x54, 0x32)),
new DyeColor("green", "Green", new Color(0x5e, 0x7c, 0x16)),
new DyeColor("red", "Red", new Color(0xb0, 0x2e, 0x26)),
new DyeColor("black", "Black", new Color(0x1d, 0x1d, 0x21))
);
}
private function __construct( return $cache[spl_object_id($this)] ??= match($this){
string $enumName, self::WHITE => self::meta("White", new Color(0xf0, 0xf0, 0xf0)),
private string $displayName, self::ORANGE => self::meta("Orange", new Color(0xf9, 0x80, 0x1d)),
private Color $rgbValue self::MAGENTA => self::meta("Magenta", new Color(0xc7, 0x4e, 0xbd)),
){ self::LIGHT_BLUE => self::meta("Light Blue", new Color(0x3a, 0xb3, 0xda)),
$this->Enum___construct($enumName); self::YELLOW => self::meta("Yellow", new Color(0xfe, 0xd8, 0x3d)),
self::LIME => self::meta("Lime", new Color(0x80, 0xc7, 0x1f)),
self::PINK => self::meta("Pink", new Color(0xf3, 0x8b, 0xaa)),
self::GRAY => self::meta("Gray", new Color(0x47, 0x4f, 0x52)),
self::LIGHT_GRAY => self::meta("Light Gray", new Color(0x9d, 0x9d, 0x97)),
self::CYAN => self::meta("Cyan", new Color(0x16, 0x9c, 0x9c)),
self::PURPLE => self::meta("Purple", new Color(0x89, 0x32, 0xb8)),
self::BLUE => self::meta("Blue", new Color(0x3c, 0x44, 0xaa)),
self::BROWN => self::meta("Brown", new Color(0x83, 0x54, 0x32)),
self::GREEN => self::meta("Green", new Color(0x5e, 0x7c, 0x16)),
self::RED => self::meta("Red", new Color(0xb0, 0x2e, 0x26)),
self::BLACK => self::meta("Black", new Color(0x1d, 0x1d, 0x21)),
};
} }
public function getDisplayName() : string{ public function getDisplayName() : string{
return $this->displayName; return $this->getMetadata()[0];
} }
public function getRgbValue() : Color{ public function getRgbValue() : Color{
return $this->rgbValue; return $this->getMetadata()[1];
} }
} }

View File

@ -23,26 +23,20 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\utils\EnumTrait; use pocketmine\utils\LegacyEnumShimTrait;
/** /**
* This doc-block is generated automatically, do not modify it manually. * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* This must be regenerated whenever registry members are added, removed or changed. * These are retained for backwards compatibility only.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* *
* @method static FroglightType OCHRE() * @method static FroglightType OCHRE()
* @method static FroglightType PEARLESCENT() * @method static FroglightType PEARLESCENT()
* @method static FroglightType VERDANT() * @method static FroglightType VERDANT()
*/ */
final class FroglightType{ enum FroglightType{
use EnumTrait; use LegacyEnumShimTrait;
protected static function setup() : void{ case OCHRE;
self::registerAll( case PEARLESCENT;
new self("ochre"), case VERDANT;
new self("pearlescent"),
new self("verdant")
);
}
} }

Some files were not shown because too many files have changed in this diff Show More