Block: Rename onActivate() -> onInteract()

This commit is contained in:
Dylan K. Taylor 2019-02-28 17:35:30 +00:00
parent c9eb642afd
commit d679fb7546
29 changed files with 31 additions and 31 deletions

View File

@ -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));
}

View File

@ -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){

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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));
}

View File

@ -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);

View File

@ -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;

View File

@ -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));

View File

@ -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);

View File

@ -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;
}

View File

@ -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

View File

@ -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()){

View File

@ -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();

View File

@ -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;

View File

@ -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())){

View File

@ -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;
}

View File

@ -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()){

View File

@ -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(

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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){

View File

@ -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);

View File

@ -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());

View File

@ -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;
}