mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 15:19:56 +00:00
Removed unnecessary methods Block->canBeActivated() and Item->canBeActivated() (needless extra confusion)
This commit is contained in:
parent
036663e0b5
commit
6ae24c5c19
@ -44,10 +44,6 @@ class Anvil extends Fallable{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,6 @@ class Bed extends Transparent{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 0.2;
|
return 0.2;
|
||||||
}
|
}
|
||||||
|
@ -472,15 +472,6 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* AKA: Block->isActivable
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function canBeActivated(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasEntityCollision(){
|
public function hasEntityCollision(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,6 @@ class BurningFurnace extends Solid{
|
|||||||
return "Burning Furnace";
|
return "Burning Furnace";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 3.5;
|
return 3.5;
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,6 @@ class Cake extends Transparent implements FoodSource{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,6 @@ class Chest extends Transparent{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 2.5;
|
return 2.5;
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,6 @@ use pocketmine\Server;
|
|||||||
|
|
||||||
abstract class Crops extends Flowable{
|
abstract class Crops extends Flowable{
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
if($block->getSide(Vector3::SIDE_DOWN)->getId() === Block::FARMLAND){
|
if($block->getSide(Vector3::SIDE_DOWN)->getId() === Block::FARMLAND){
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
@ -35,10 +35,6 @@ class Dirt extends Solid{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,6 @@ use pocketmine\Player;
|
|||||||
|
|
||||||
abstract class Door extends Transparent{
|
abstract class Door extends Transparent{
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isSolid(){
|
public function isSolid(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -64,10 +64,6 @@ class EnchantingTable extends Transparent{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,6 @@ class FenceGate extends Transparent{
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getToolType(){
|
public function getToolType(){
|
||||||
return Tool::TYPE_AXE;
|
return Tool::TYPE_AXE;
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,6 @@ class FlowerPot extends Flowable{
|
|||||||
return "Flower Pot Block";
|
return "Flower Pot Block";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(): bool{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function recalculateBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + 0.3125,
|
$this->x + 0.3125,
|
||||||
|
@ -41,10 +41,6 @@ class Grass extends Solid{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return "Grass";
|
return "Grass";
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,6 @@ class ItemFrame extends Flowable{
|
|||||||
return "Item Frame";
|
return "Item Frame";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
$tile = $this->level->getTile($this);
|
$tile = $this->level->getTile($this);
|
||||||
if(!($tile instanceof TileItemFrame)){
|
if(!($tile instanceof TileItemFrame)){
|
||||||
|
@ -43,10 +43,6 @@ class Sapling extends Flowable{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
static $names = [
|
static $names = [
|
||||||
0 => "Oak Sapling",
|
0 => "Oak Sapling",
|
||||||
|
@ -49,10 +49,6 @@ class TNT extends Solid{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if($item->getId() === Item::FLINT_STEEL){
|
if($item->getId() === Item::FLINT_STEEL){
|
||||||
$item->useOn($this);
|
$item->useOn($this);
|
||||||
|
@ -52,10 +52,6 @@ class Trapdoor extends Transparent{
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function recalculateBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
$damage = $this->getDamage();
|
$damage = $this->getDamage();
|
||||||
|
@ -38,10 +38,6 @@ class WoodDoor extends Door{
|
|||||||
return "Wood Door Block";
|
return "Wood Door Block";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,6 @@ class Workbench extends Solid{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHardness(){
|
public function getHardness(){
|
||||||
return 2.5;
|
return 2.5;
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,6 @@ class Bucket extends Item{
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$targetBlock = Block::get($this->meta);
|
$targetBlock = Block::get($this->meta);
|
||||||
|
|
||||||
|
@ -34,10 +34,6 @@ class FlintSteel extends Tool{
|
|||||||
parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel");
|
parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($block->getId() === self::AIR and ($target instanceof Solid)){
|
if($block->getId() === self::AIR and ($target instanceof Solid)){
|
||||||
$level->setBlock($block, new Fire(), true);
|
$level->setBlock($block, new Fire(), true);
|
||||||
|
@ -93,10 +93,6 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function init(){
|
public static function init(){
|
||||||
if(self::$list === null){
|
if(self::$list === null){
|
||||||
self::$list = new \SplFixedArray(65536);
|
self::$list = new \SplFixedArray(65536);
|
||||||
|
@ -32,10 +32,6 @@ class Painting extends Item{
|
|||||||
parent::__construct(self::PAINTING, 0, $count, "Painting");
|
parent::__construct(self::PAINTING, 0, $count, "Painting");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($target->isTransparent() === false and $face > 1 and $block->isSolid() === false){
|
if($target->isTransparent() === false and $face > 1 and $block->isSolid() === false){
|
||||||
$faces = [
|
$faces = [
|
||||||
|
@ -38,10 +38,6 @@ class SpawnEgg extends Item{
|
|||||||
parent::__construct(self::SPAWN_EGG, $meta, $count, "Spawn Egg");
|
parent::__construct(self::SPAWN_EGG, $meta, $count, "Spawn Egg");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeActivated(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
|
@ -1757,11 +1757,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->server->getPluginManager()->callEvent($ev);
|
$this->server->getPluginManager()->callEvent($ev);
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$target->onUpdate(self::BLOCK_UPDATE_TOUCH);
|
$target->onUpdate(self::BLOCK_UPDATE_TOUCH);
|
||||||
if(!$player->isSneaking() and $target->canBeActivated() === true and $target->onActivate($item, $player) === true){
|
if(!$player->isSneaking() and $target->onActivate($item, $player) === true){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$player->isSneaking() and $item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)){
|
if(!$player->isSneaking() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)){
|
||||||
if($item->getCount() <= 0){
|
if($item->getCount() <= 0){
|
||||||
$item = Item::get(Item::AIR, 0, 0);
|
$item = Item::get(Item::AIR, 0, 0);
|
||||||
|
|
||||||
@ -1771,7 +1771,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}elseif($target->canBeActivated() === true and $target->onActivate($item, $player) === true){
|
}elseif($target->onActivate($item, $player) === true){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user