avoid direct mutation of Item->count field, use Item->pop() instead

I think this change was already applied on the master branch, but I don't remember for sure.
This commit is contained in:
Dylan K. Taylor 2020-02-23 17:37:25 +00:00
parent 50fcdd6e7e
commit 2d7f37ac47
7 changed files with 7 additions and 7 deletions

View File

@ -55,7 +55,7 @@ abstract class Crops extends Flowable{
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
}
$item->count--;
$item->pop();
return true;
}

View File

@ -99,7 +99,7 @@ class Grass extends Solid{
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
$item->count--;
$item->pop();
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
return true;

View File

@ -72,7 +72,7 @@ class Sapling extends Flowable{
//TODO: change log type
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->getVariant());
$item->count--;
$item->pop();
return true;
}

View File

@ -62,7 +62,7 @@ class Sugarcane extends Flowable{
$this->getLevel()->setBlock($this, $this, true);
}
$item->count--;
$item->pop();
return true;
}

View File

@ -96,7 +96,7 @@ class PaintingItem extends Item{
$entity = Entity::createEntity("Painting", $blockReplace->getLevel(), $nbt);
if($entity instanceof Entity){
--$this->count;
$this->pop();
$entity->spawnToAll();
$player->getLevel()->broadcastLevelEvent($blockReplace->add(0.5, 0.5, 0.5), LevelEventPacket::EVENT_SOUND_ITEMFRAME_PLACE); //item frame and painting have the same sound

View File

@ -54,7 +54,7 @@ abstract class ProjectileItem extends Item{
$projectile->setMotion($projectile->getMotion()->multiply($this->getThrowForce()));
}
$this->count--;
$this->pop();
if($projectile instanceof Projectile){
$projectileEv = new ProjectileLaunchEvent($projectile);

View File

@ -44,7 +44,7 @@ class SpawnEgg extends Item{
$entity = Entity::createEntity($this->meta, $player->getLevel(), $nbt);
if($entity instanceof Entity){
--$this->count;
$this->pop();
$entity->spawnToAll();
return true;
}