Fixed getAxis()/setAxis() not being seen by static analysers for some blocks

when using VanillaBlocks::CHISELED_QUARTZ(), VanillaBlocks::PURPUR_PILLAR() or VanillaBlocks::QUARTZ_PILLAR(), static analysis was unable to detect getAxis() and setAxis(), because these blocks were implemented using anonymous classes.
This commit is contained in:
Dylan K. Taylor 2021-02-06 20:39:23 +00:00
parent 9887138ac1
commit 7c1f0ecb8b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 40 additions and 12 deletions

View File

@ -266,20 +266,14 @@ class BlockFactory{
$purpurBreakInfo = new BlockBreakInfo(1.5, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 30.0);
$this->register(new Opaque(new BID(Ids::PURPUR_BLOCK, Meta::PURPUR_NORMAL), "Purpur Block", $purpurBreakInfo));
$this->register(new class(new BID(Ids::PURPUR_BLOCK, Meta::PURPUR_PILLAR), "Purpur Pillar", $purpurBreakInfo) extends Opaque{
use PillarRotationInMetadataTrait;
});
$this->register(new SimplePillar(new BID(Ids::PURPUR_BLOCK, Meta::PURPUR_PILLAR), "Purpur Pillar", $purpurBreakInfo));
$this->register(new Stair(new BID(Ids::PURPUR_STAIRS), "Purpur Stairs", $purpurBreakInfo));
$quartzBreakInfo = new BlockBreakInfo(0.8, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel());
$this->register(new Opaque(new BID(Ids::QUARTZ_BLOCK, Meta::QUARTZ_NORMAL), "Quartz Block", $quartzBreakInfo));
$this->register(new Stair(new BID(Ids::QUARTZ_STAIRS), "Quartz Stairs", $quartzBreakInfo));
$this->register(new class(new BID(Ids::QUARTZ_BLOCK, Meta::QUARTZ_CHISELED), "Chiseled Quartz Block", $quartzBreakInfo) extends Opaque{
use PillarRotationInMetadataTrait;
});
$this->register(new class(new BID(Ids::QUARTZ_BLOCK, Meta::QUARTZ_PILLAR), "Quartz Pillar", $quartzBreakInfo) extends Opaque{
use PillarRotationInMetadataTrait;
});
$this->register(new SimplePillar(new BID(Ids::QUARTZ_BLOCK, Meta::QUARTZ_CHISELED), "Chiseled Quartz Block", $quartzBreakInfo));
$this->register(new SimplePillar(new BID(Ids::QUARTZ_BLOCK, Meta::QUARTZ_PILLAR), "Quartz Pillar", $quartzBreakInfo));
$this->register(new Opaque(new BID(Ids::QUARTZ_BLOCK, Meta::QUARTZ_SMOOTH), "Smooth Quartz Block", $quartzBreakInfo)); //TODO: this has axis rotation in 1.9, unsure if a bug (https://bugs.mojang.com/browse/MCPE-39074)
$this->register(new Stair(new BID(Ids::SMOOTH_QUARTZ_STAIRS), "Smooth Quartz Stairs", $quartzBreakInfo));

View File

@ -0,0 +1,34 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\PillarRotationInMetadataTrait;
/**
* @internal This class provides a general base for pillar-like blocks. It **should not** be used for contract binding
* in APIs, because not all pillar-like blocks extend this class.
*/
class SimplePillar extends Opaque{
use PillarRotationInMetadataTrait;
}

View File

@ -110,7 +110,7 @@ use function assert;
* @method static CarvedPumpkin CARVED_PUMPKIN()
* @method static ChemicalHeat CHEMICAL_HEAT()
* @method static Chest CHEST()
* @method static Opaque CHISELED_QUARTZ()
* @method static SimplePillar CHISELED_QUARTZ()
* @method static Opaque CHISELED_RED_SANDSTONE()
* @method static Opaque CHISELED_SANDSTONE()
* @method static Opaque CHISELED_STONE_BRICKS()
@ -513,11 +513,11 @@ use function assert;
* @method static GlassPane PURPLE_STAINED_GLASS_PANE()
* @method static Torch PURPLE_TORCH()
* @method static Opaque PURPUR()
* @method static Opaque PURPUR_PILLAR()
* @method static SimplePillar PURPUR_PILLAR()
* @method static Slab PURPUR_SLAB()
* @method static Stair PURPUR_STAIRS()
* @method static Opaque QUARTZ()
* @method static Opaque QUARTZ_PILLAR()
* @method static SimplePillar QUARTZ_PILLAR()
* @method static Slab QUARTZ_SLAB()
* @method static Stair QUARTZ_STAIRS()
* @method static Rail RAIL()