From d679fb7546fb78f725510667af5bc965aac8e863 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 28 Feb 2019 17:35:30 +0000 Subject: [PATCH] Block: Rename onActivate() -> onInteract() --- src/pocketmine/block/Anvil.php | 2 +- src/pocketmine/block/Bed.php | 2 +- src/pocketmine/block/Block.php | 4 ++-- src/pocketmine/block/Button.php | 2 +- src/pocketmine/block/Cake.php | 2 +- src/pocketmine/block/Chest.php | 2 +- src/pocketmine/block/CoarseDirt.php | 2 +- src/pocketmine/block/CocoaBlock.php | 2 +- src/pocketmine/block/CraftingTable.php | 2 +- src/pocketmine/block/Crops.php | 2 +- src/pocketmine/block/DaylightSensor.php | 2 +- src/pocketmine/block/Dirt.php | 2 +- src/pocketmine/block/Door.php | 2 +- src/pocketmine/block/DragonEgg.php | 2 +- src/pocketmine/block/EnchantingTable.php | 2 +- src/pocketmine/block/EnderChest.php | 2 +- src/pocketmine/block/FenceGate.php | 2 +- src/pocketmine/block/FlowerPot.php | 2 +- src/pocketmine/block/Furnace.php | 2 +- src/pocketmine/block/Grass.php | 2 +- src/pocketmine/block/ItemFrame.php | 2 +- src/pocketmine/block/Lever.php | 2 +- src/pocketmine/block/RedstoneOre.php | 2 +- src/pocketmine/block/RedstoneRepeater.php | 2 +- src/pocketmine/block/Sapling.php | 2 +- src/pocketmine/block/Sugarcane.php | 2 +- src/pocketmine/block/TNT.php | 2 +- src/pocketmine/block/Trapdoor.php | 2 +- src/pocketmine/level/Level.php | 4 ++-- 29 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index 23ad43911..ae433ee9e 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -77,7 +77,7 @@ class Anvil extends Transparent implements Fallable{ return AxisAlignedBB::one()->squash(Facing::axis(Facing::rotateY($this->facing, false)), 1 / 8); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $player->addWindow(new AnvilInventory($this)); } diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index da51227e7..7f4caee1e 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -138,7 +138,7 @@ class Bed extends Transparent{ return null; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player !== null){ $other = $this->getOtherHalf(); if($other === null){ diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 36926fd1b..8ae99f582 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -367,7 +367,7 @@ class Block extends Position implements BlockIds, Metadatable{ } /** - * Do actions when activated by Item. Returns if it has done anything + * Do actions when interacted by Item. Returns if it has done anything * * @param Item $item * @param int $face @@ -376,7 +376,7 @@ class Block extends Position implements BlockIds, Metadatable{ * * @return bool */ - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ return false; } diff --git a/src/pocketmine/block/Button.php b/src/pocketmine/block/Button.php index 1ff248414..a2d8cc3c6 100644 --- a/src/pocketmine/block/Button.php +++ b/src/pocketmine/block/Button.php @@ -59,7 +59,7 @@ abstract class Button extends Flowable{ abstract protected function getActivationTime() : int; - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if(!$this->powered){ $this->powered = true; $this->level->setBlock($this, $this); diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index 335f0f644..ec6e32fdb 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -84,7 +84,7 @@ class Cake extends Transparent implements FoodSource{ return false; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player !== null){ $player->consumeObject($this); return true; diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index be2f38ea1..678564d4a 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -91,7 +91,7 @@ class Chest extends Transparent{ return false; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $chest = $this->getLevel()->getTile($this); diff --git a/src/pocketmine/block/CoarseDirt.php b/src/pocketmine/block/CoarseDirt.php index 23b16f716..67d606bb1 100644 --- a/src/pocketmine/block/CoarseDirt.php +++ b/src/pocketmine/block/CoarseDirt.php @@ -31,7 +31,7 @@ use pocketmine\Player; class CoarseDirt extends Dirt{ - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($face === Facing::UP and $item instanceof Hoe){ $item->applyDamage(1); $this->getLevel()->setBlock($this, BlockFactory::get(Block::DIRT)); diff --git a/src/pocketmine/block/CocoaBlock.php b/src/pocketmine/block/CocoaBlock.php index 0046d27aa..1c74c16e8 100644 --- a/src/pocketmine/block/CocoaBlock.php +++ b/src/pocketmine/block/CocoaBlock.php @@ -85,7 +85,7 @@ class CocoaBlock extends Transparent{ return false; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($this->age < 2 and $item instanceof Fertilizer){ $this->age++; $this->level->setBlock($this, $this); diff --git a/src/pocketmine/block/CraftingTable.php b/src/pocketmine/block/CraftingTable.php index 369deab4e..0042bcb1c 100644 --- a/src/pocketmine/block/CraftingTable.php +++ b/src/pocketmine/block/CraftingTable.php @@ -38,7 +38,7 @@ class CraftingTable extends Solid{ return BlockToolType::TYPE_AXE; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $player->setCraftingGrid(new CraftingGrid($player, CraftingGrid::SIZE_BIG)); } diff --git a/src/pocketmine/block/Crops.php b/src/pocketmine/block/Crops.php index 2586d9109..771968daa 100644 --- a/src/pocketmine/block/Crops.php +++ b/src/pocketmine/block/Crops.php @@ -57,7 +57,7 @@ abstract class Crops extends Flowable{ } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($this->age < 7 and $item instanceof Fertilizer){ $block = clone $this; $block->age += mt_rand(2, 5); diff --git a/src/pocketmine/block/DaylightSensor.php b/src/pocketmine/block/DaylightSensor.php index a379c5f14..41e53794a 100644 --- a/src/pocketmine/block/DaylightSensor.php +++ b/src/pocketmine/block/DaylightSensor.php @@ -91,7 +91,7 @@ class DaylightSensor extends Transparent{ return AxisAlignedBB::one()->trim(Facing::UP, 0.5); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->inverted = !$this->inverted; $this->level->setBlock($this, $this); return true; diff --git a/src/pocketmine/block/Dirt.php b/src/pocketmine/block/Dirt.php index c19c9ff66..c74f42e57 100644 --- a/src/pocketmine/block/Dirt.php +++ b/src/pocketmine/block/Dirt.php @@ -41,7 +41,7 @@ class Dirt extends Solid{ return BlockToolType::TYPE_SHOVEL; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($face === Facing::UP and $item instanceof Hoe){ $item->applyDamage(1); $this->getLevel()->setBlock($this, BlockFactory::get(Block::FARMLAND)); diff --git a/src/pocketmine/block/Door.php b/src/pocketmine/block/Door.php index 39e56e5f8..8e588fd59 100644 --- a/src/pocketmine/block/Door.php +++ b/src/pocketmine/block/Door.php @@ -134,7 +134,7 @@ abstract class Door extends Transparent{ return false; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->open = !$this->open; $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); diff --git a/src/pocketmine/block/DragonEgg.php b/src/pocketmine/block/DragonEgg.php index 887968166..cf9c53457 100644 --- a/src/pocketmine/block/DragonEgg.php +++ b/src/pocketmine/block/DragonEgg.php @@ -58,7 +58,7 @@ class DragonEgg extends Transparent implements Fallable{ return null; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->teleport(); return true; } diff --git a/src/pocketmine/block/EnchantingTable.php b/src/pocketmine/block/EnchantingTable.php index c2454f657..e8b884c33 100644 --- a/src/pocketmine/block/EnchantingTable.php +++ b/src/pocketmine/block/EnchantingTable.php @@ -53,7 +53,7 @@ class EnchantingTable extends Transparent{ return AxisAlignedBB::one()->trim(Facing::UP, 0.25); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ //TODO lock diff --git a/src/pocketmine/block/EnderChest.php b/src/pocketmine/block/EnderChest.php index 6630ffcb0..4235fa984 100644 --- a/src/pocketmine/block/EnderChest.php +++ b/src/pocketmine/block/EnderChest.php @@ -82,7 +82,7 @@ class EnderChest extends Transparent{ return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $enderChest = $this->getLevel()->getTile($this); if($enderChest instanceof TileEnderChest and $this->getSide(Facing::UP)->isTransparent()){ diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index b26152064..564c9d610 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -96,7 +96,7 @@ class FenceGate extends Transparent{ } } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->open = !$this->open; if($this->open and $player !== null){ $playerFacing = $player->getHorizontalFacing(); diff --git a/src/pocketmine/block/FlowerPot.php b/src/pocketmine/block/FlowerPot.php index 7a7b8ad76..33de6c9ad 100644 --- a/src/pocketmine/block/FlowerPot.php +++ b/src/pocketmine/block/FlowerPot.php @@ -125,7 +125,7 @@ class FlowerPot extends Flowable{ } } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $plant = $item->getBlock(); if(!$this->canAddPlant($plant)){ return false; diff --git a/src/pocketmine/block/Furnace.php b/src/pocketmine/block/Furnace.php index a407aa75d..c5921cb03 100644 --- a/src/pocketmine/block/Furnace.php +++ b/src/pocketmine/block/Furnace.php @@ -95,7 +95,7 @@ class Furnace extends Solid{ return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $furnace = $this->getLevel()->getTile($this); if($furnace instanceof TileFurnace and $furnace->canOpenWith($item->getCustomName())){ diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index 493efc620..b3d4992b5 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -91,7 +91,7 @@ class Grass extends Solid{ } } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($face !== Facing::UP){ return false; } diff --git a/src/pocketmine/block/ItemFrame.php b/src/pocketmine/block/ItemFrame.php index 430ee3a1a..5c8279d00 100644 --- a/src/pocketmine/block/ItemFrame.php +++ b/src/pocketmine/block/ItemFrame.php @@ -142,7 +142,7 @@ class ItemFrame extends Flowable{ $this->itemDropChance = $itemDropChance; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($this->framedItem !== null){ $this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS; }elseif(!$item->isNull()){ diff --git a/src/pocketmine/block/Lever.php b/src/pocketmine/block/Lever.php index 458fb8932..3b3b01af3 100644 --- a/src/pocketmine/block/Lever.php +++ b/src/pocketmine/block/Lever.php @@ -109,7 +109,7 @@ class Lever extends Flowable{ } } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->powered = !$this->powered; $this->level->setBlock($this, $this); $this->level->broadcastLevelSoundEvent( diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 3ab072028..66c2f085e 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -75,7 +75,7 @@ class RedstoneOre extends Solid{ return $this->getLevel()->setBlock($this, $this, false); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if(!$this->lit){ $this->lit = true; $this->getLevel()->setBlock($this, $this); //no return here - this shouldn't prevent block placement diff --git a/src/pocketmine/block/RedstoneRepeater.php b/src/pocketmine/block/RedstoneRepeater.php index ab16eead2..651607d0e 100644 --- a/src/pocketmine/block/RedstoneRepeater.php +++ b/src/pocketmine/block/RedstoneRepeater.php @@ -94,7 +94,7 @@ class RedstoneRepeater extends Flowable{ return false; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if(++$this->delay > 4){ $this->delay = 1; } diff --git a/src/pocketmine/block/Sapling.php b/src/pocketmine/block/Sapling.php index 0b725ffab..0fa70f3ce 100644 --- a/src/pocketmine/block/Sapling.php +++ b/src/pocketmine/block/Sapling.php @@ -66,7 +66,7 @@ class Sapling extends Flowable{ return false; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($item instanceof Fertilizer){ Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->treeType); diff --git a/src/pocketmine/block/Sugarcane.php b/src/pocketmine/block/Sugarcane.php index 6a0281213..ef4baba17 100644 --- a/src/pocketmine/block/Sugarcane.php +++ b/src/pocketmine/block/Sugarcane.php @@ -48,7 +48,7 @@ class Sugarcane extends Flowable{ return 0b1111; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($item instanceof Fertilizer){ if($this->getSide(Facing::DOWN)->getId() !== self::SUGARCANE_BLOCK){ for($y = 1; $y < 3; ++$y){ diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index 4b71e5b56..4d499da07 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -44,7 +44,7 @@ class TNT extends Solid{ return 0; } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($item instanceof FlintSteel or $item->hasEnchantment(Enchantment::FIRE_ASPECT())){ if($item instanceof Durable){ $item->applyDamage(1); diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index 1cc736894..c815b85ee 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -77,7 +77,7 @@ class Trapdoor extends Transparent{ return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->open = !$this->open; $this->level->setBlock($this, $this); $this->level->addSound($this, new DoorSound()); diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 7d4f06a89..effddbf69 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1822,7 +1822,7 @@ class Level implements ChunkManager, Metadatable{ $ev = new PlayerInteractEvent($player, $item, $blockClicked, $clickVector, $face, PlayerInteractEvent::RIGHT_CLICK_BLOCK); $ev->call(); if(!$ev->isCancelled()){ - if(!$player->isSneaking() and $blockClicked->onActivate($item, $face, $clickVector, $player)){ + if(!$player->isSneaking() and $blockClicked->onInteract($item, $face, $clickVector, $player)){ return true; } @@ -1835,7 +1835,7 @@ class Level implements ChunkManager, Metadatable{ }else{ return false; } - }elseif($blockClicked->onActivate($item, $face, $clickVector, $player)){ + }elseif($blockClicked->onInteract($item, $face, $clickVector, $player)){ return true; }