Skip to content

Commit

Permalink
Update to the new version of PM
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Dec 10, 2021
1 parent 6f5d6ea commit e270b48
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ipad54/composter/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class Main extends PluginBase
{

protected function onLoad()
protected function onLoad() : void
{
BlockFactory::getInstance()->register(new Composter(new BID(IDS::COMPOSTER, 0, ItemIds::COMPOSTER)));
}
Expand Down
18 changes: 9 additions & 9 deletions src/ipad54/composter/block/Composter.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player
{
if ($this->fill >= 8) {
$this->fill = 0;
$this->pos->getWorld()->setBlock($this->pos, $this);
$this->pos->getWorld()->addSound($this->pos, new ComposteEmptySound());
$this->pos->getWorld()->dropItem($this->pos, VanillaItems::BONE_MEAL());
$this->position->getWorld()->setBlock($this->position, $this);
$this->position->getWorld()->addSound($this->position, new ComposteEmptySound());
$this->position->getWorld()->dropItem($this->position, VanillaItems::BONE_MEAL());
return true;
}
if (isset($this->ingridients[$item->getId()]) && $this->fill < 7) {
Expand All @@ -116,7 +116,7 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player
$this->incrimentFill(true);
return true;
}
$this->pos->getWorld()->addSound($this->pos, new ComposteFillSound());
$this->position->getWorld()->addSound($this->position, new ComposteFillSound());
}
return true;
}
Expand All @@ -128,12 +128,12 @@ public function incrimentFill(bool $playsound = false): bool
return false;
}
if (++$this->fill >= 7) {
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 25);
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, 25);
} else {
$this->pos->getWorld()->setBlock($this->pos, $this);
$this->position->getWorld()->setBlock($this->position, $this);
}
if ($playsound) {
$this->pos->getWorld()->addSound($this->pos, new ComposteFillSuccessSound());
$this->position->getWorld()->addSound($this->position, new ComposteFillSuccessSound());
}
return true;
}
Expand All @@ -142,8 +142,8 @@ public function onScheduledUpdate(): void
{
if ($this->fill == 7) {
++$this->fill;
$this->pos->getWorld()->setBlock($this->pos, $this);
$this->pos->getWorld()->addSound($this->pos, new ComposteReadySound());
$this->position->getWorld()->setBlock($this->position, $this);
$this->position->getWorld()->addSound($this->position, new ComposteReadySound());
}
}
}
3 changes: 2 additions & 1 deletion src/ipad54/composter/sound/ComposteEmptySound.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\ClientboundPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
use pocketmine\world\sound\Sound;

class ComposteEmptySound implements Sound
Expand All @@ -15,6 +16,6 @@ class ComposteEmptySound implements Sound

public function encode(?Vector3 $pos): array
{
return [LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BLOCK_COMPOSTER_EMPTY, $pos)];
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_COMPOSTER_EMPTY, $pos, false)];
}
}
3 changes: 2 additions & 1 deletion src/ipad54/composter/sound/ComposteFillSound.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
use pocketmine\world\sound\Sound;

class ComposteFillSound implements Sound
{

public function encode(?Vector3 $pos): array
{
return [LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BLOCK_COMPOSTER_FILL, $pos)];
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_COMPOSTER_FILL, $pos, false)];
}
}
3 changes: 2 additions & 1 deletion src/ipad54/composter/sound/ComposteFillSuccessSound.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
use pocketmine\world\sound\Sound;

class ComposteFillSuccessSound implements Sound
{

public function encode(?Vector3 $pos): array
{
return [LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BLOCK_COMPOSTER_FILL_SUCCESS, $pos)];
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_COMPOSTER_FILL_SUCCESS, $pos, false)];
}
}
3 changes: 2 additions & 1 deletion src/ipad54/composter/sound/ComposteReadySound.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
use pocketmine\world\sound\Sound;

class ComposteReadySound implements Sound
{

public function encode(?Vector3 $pos): array
{
return [LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BLOCK_COMPOSTER_READY, $pos)];
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_COMPOSTER_READY, $pos, false)];
}
}

1 comment on commit e270b48

@JaxkDev
Copy link

@JaxkDev JaxkDev commented on e270b48 Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @ipad54,

I have manually added the ‘Vanilla Mechanics’ category to your plugin, this is a new category for plugins that add vanilla mechanics…

This comment is posted here because this is the last commit when the released build was created.

Please sign in to comment.