Protect Item->count

This commit is contained in:
Dylan K. Taylor
2018-10-07 14:34:04 +01:00
parent 82c718cff0
commit 139aaa5577
8 changed files with 8 additions and 8 deletions

View File

@ -180,7 +180,7 @@ class Item implements ItemIds, \JsonSerializable{
/** @var CompoundTag|null */
private $cachedNBT = null;
/** @var int */
public $count = 1;
protected $count = 1;
/** @var string */
protected $name;

View File

@ -93,7 +93,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

@ -55,7 +55,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

@ -40,7 +40,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;
}