Item: Remove redundant Level parameter from onActivate()

there are three other sources this could be gotten from, an arbitrary level doesn't make sense.
This commit is contained in:
Dylan K. Taylor 2018-01-25 10:15:36 +00:00
parent 3842ee15cf
commit 6c8a1a5b80
6 changed files with 9 additions and 8 deletions

View File

@ -51,7 +51,7 @@ class Bucket extends Item implements Consumable{
return 0; return 0;
} }
public function onActivate(Level $level, Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{ public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
$resultBlock = BlockFactory::get($this->meta); $resultBlock = BlockFactory::get($this->meta);
if($resultBlock instanceof Air){ if($resultBlock instanceof Air){

View File

@ -36,8 +36,10 @@ class FlintSteel extends Tool{
parent::__construct(self::FLINT_STEEL, $meta, "Flint and Steel"); parent::__construct(self::FLINT_STEEL, $meta, "Flint and Steel");
} }
public function onActivate(Level $level, Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{ public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
if($blockReplace->getId() === self::AIR and ($blockClicked instanceof Solid)){ if($blockReplace->getId() === self::AIR and ($blockClicked instanceof Solid)){
$level = $player->getLevel();
assert($level !== null);
$level->setBlock($blockReplace, BlockFactory::get(Block::FIRE), true); $level->setBlock($blockReplace, BlockFactory::get(Block::FIRE), true);
$level->broadcastLevelSoundEvent($blockReplace->add(0.5, 0.5, 0.5), LevelSoundEventPacket::SOUND_IGNITE); $level->broadcastLevelSoundEvent($blockReplace->add(0.5, 0.5, 0.5), LevelSoundEventPacket::SOUND_IGNITE);

View File

@ -792,7 +792,6 @@ class Item implements ItemIds, \JsonSerializable{
/** /**
* Called when a player uses this item on a block. * Called when a player uses this item on a block.
* *
* @param Level $level
* @param Player $player * @param Player $player
* @param Block $blockReplace * @param Block $blockReplace
* @param Block $blockClicked * @param Block $blockClicked
@ -801,7 +800,7 @@ class Item implements ItemIds, \JsonSerializable{
* *
* @return bool * @return bool
*/ */
public function onActivate(Level $level, Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{ public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
return false; return false;
} }

View File

@ -33,7 +33,7 @@ class Painting extends Item{
parent::__construct(self::PAINTING, $meta, "Painting"); parent::__construct(self::PAINTING, $meta, "Painting");
} }
public function onActivate(Level $level, Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{ public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
if($blockClicked->isTransparent() === false and $face > 1 and $blockReplace->isSolid() === false){ if($blockClicked->isTransparent() === false and $face > 1 and $blockReplace->isSolid() === false){
$faces = [ $faces = [
2 => 1, 2 => 1,

View File

@ -34,14 +34,14 @@ class SpawnEgg extends Item{
parent::__construct(self::SPAWN_EGG, $meta, "Spawn Egg"); parent::__construct(self::SPAWN_EGG, $meta, "Spawn Egg");
} }
public function onActivate(Level $level, Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{ public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
$nbt = Entity::createBaseNBT($blockReplace->add(0.5, 0, 0.5), null, lcg_value() * 360, 0); $nbt = Entity::createBaseNBT($blockReplace->add(0.5, 0, 0.5), null, lcg_value() * 360, 0);
if($this->hasCustomName()){ if($this->hasCustomName()){
$nbt->setString("CustomName", $this->getCustomName()); $nbt->setString("CustomName", $this->getCustomName());
} }
$entity = Entity::createEntity($this->meta, $level, $nbt); $entity = Entity::createEntity($this->meta, $player->getLevel(), $nbt);
if($entity instanceof Entity){ if($entity instanceof Entity){
--$this->count; --$this->count;

View File

@ -1854,7 +1854,7 @@ class Level implements ChunkManager, Metadatable{
return true; return true;
} }
if(!$player->isSneaking() and $item->onActivate($this, $player, $blockReplace, $blockClicked, $face, $clickVector)){ if(!$player->isSneaking() and $item->onActivate($player, $blockReplace, $blockClicked, $face, $clickVector)){
return true; return true;
} }
}else{ }else{