mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Merge branch 'minor-next' into major-next
This commit is contained in:
commit
e51903d7ea
@ -52,6 +52,9 @@ class CakeWithCandle extends BaseCake{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||||
|
if($this->lit && $face !== Facing::UP){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($this->onInteractCandle($item, $face, $clickVector, $player, $returnedItems)){
|
if($this->onInteractCandle($item, $face, $clickVector, $player, $returnedItems)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -266,6 +266,7 @@ final class ItemSerializerDeserializerRegistrar{
|
|||||||
$this->map1to1Item(Ids::HONEY_BOTTLE, Items::HONEY_BOTTLE());
|
$this->map1to1Item(Ids::HONEY_BOTTLE, Items::HONEY_BOTTLE());
|
||||||
$this->map1to1Item(Ids::HONEYCOMB, Items::HONEYCOMB());
|
$this->map1to1Item(Ids::HONEYCOMB, Items::HONEYCOMB());
|
||||||
$this->map1to1Item(Ids::HOST_ARMOR_TRIM_SMITHING_TEMPLATE, Items::HOST_ARMOR_TRIM_SMITHING_TEMPLATE());
|
$this->map1to1Item(Ids::HOST_ARMOR_TRIM_SMITHING_TEMPLATE, Items::HOST_ARMOR_TRIM_SMITHING_TEMPLATE());
|
||||||
|
$this->map1to1Item(Ids::ICE_BOMB, Items::ICE_BOMB());
|
||||||
$this->map1to1Item(Ids::INK_SAC, Items::INK_SAC());
|
$this->map1to1Item(Ids::INK_SAC, Items::INK_SAC());
|
||||||
$this->map1to1Item(Ids::IRON_AXE, Items::IRON_AXE());
|
$this->map1to1Item(Ids::IRON_AXE, Items::IRON_AXE());
|
||||||
$this->map1to1Item(Ids::IRON_BOOTS, Items::IRON_BOOTS());
|
$this->map1to1Item(Ids::IRON_BOOTS, Items::IRON_BOOTS());
|
||||||
|
@ -43,6 +43,7 @@ use pocketmine\entity\projectile\Arrow;
|
|||||||
use pocketmine\entity\projectile\Egg;
|
use pocketmine\entity\projectile\Egg;
|
||||||
use pocketmine\entity\projectile\EnderPearl;
|
use pocketmine\entity\projectile\EnderPearl;
|
||||||
use pocketmine\entity\projectile\ExperienceBottle;
|
use pocketmine\entity\projectile\ExperienceBottle;
|
||||||
|
use pocketmine\entity\projectile\IceBomb;
|
||||||
use pocketmine\entity\projectile\Snowball;
|
use pocketmine\entity\projectile\Snowball;
|
||||||
use pocketmine\entity\projectile\SplashPotion;
|
use pocketmine\entity\projectile\SplashPotion;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
@ -120,6 +121,10 @@ final class EntityFactory{
|
|||||||
return new FallingBlock(Helper::parseLocation($nbt, $world), FallingBlock::parseBlockNBT(RuntimeBlockStateRegistry::getInstance(), $nbt), $nbt);
|
return new FallingBlock(Helper::parseLocation($nbt, $world), FallingBlock::parseBlockNBT(RuntimeBlockStateRegistry::getInstance(), $nbt), $nbt);
|
||||||
}, ['FallingSand', 'minecraft:falling_block']);
|
}, ['FallingSand', 'minecraft:falling_block']);
|
||||||
|
|
||||||
|
$this->register(IceBomb::class, function(World $world, CompoundTag $nbt) : IceBomb{
|
||||||
|
return new IceBomb(Helper::parseLocation($nbt, $world), null, $nbt);
|
||||||
|
}, ['minecraft:ice_bomb']);
|
||||||
|
|
||||||
$this->register(ItemEntity::class, function(World $world, CompoundTag $nbt) : ItemEntity{
|
$this->register(ItemEntity::class, function(World $world, CompoundTag $nbt) : ItemEntity{
|
||||||
$itemTag = $nbt->getCompoundTag(ItemEntity::TAG_ITEM);
|
$itemTag = $nbt->getCompoundTag(ItemEntity::TAG_ITEM);
|
||||||
if($itemTag === null){
|
if($itemTag === null){
|
||||||
|
86
src/entity/projectile/IceBomb.php
Normal file
86
src/entity/projectile/IceBomb.php
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\entity\projectile;
|
||||||
|
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\block\BlockTypeIds;
|
||||||
|
use pocketmine\block\VanillaBlocks;
|
||||||
|
use pocketmine\event\entity\ProjectileHitEvent;
|
||||||
|
use pocketmine\item\VanillaItems;
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\RayTraceResult;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
||||||
|
use pocketmine\world\particle\ItemBreakParticle;
|
||||||
|
use pocketmine\world\sound\IceBombHitSound;
|
||||||
|
|
||||||
|
class IceBomb extends Throwable{
|
||||||
|
public static function getNetworkTypeId() : string{ return EntityIds::ICE_BOMB; }
|
||||||
|
|
||||||
|
public function getResultDamage() : int{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function calculateInterceptWithBlock(Block $block, Vector3 $start, Vector3 $end) : ?RayTraceResult{
|
||||||
|
if($block->getTypeId() === BlockTypeIds::WATER){
|
||||||
|
$pos = $block->getPosition();
|
||||||
|
|
||||||
|
return AxisAlignedBB::one()->offset($pos->x, $pos->y, $pos->z)->calculateIntercept($start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::calculateInterceptWithBlock($block, $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function onHit(ProjectileHitEvent $event) : void{
|
||||||
|
$world = $this->getWorld();
|
||||||
|
$pos = $this->location;
|
||||||
|
|
||||||
|
$world->addSound($pos, new IceBombHitSound());
|
||||||
|
$itemBreakParticle = new ItemBreakParticle(VanillaItems::ICE_BOMB());
|
||||||
|
for($i = 0; $i < 6; ++$i){
|
||||||
|
$world->addParticle($pos, $itemBreakParticle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
|
||||||
|
parent::onHitBlock($blockHit, $hitResult);
|
||||||
|
|
||||||
|
$pos = $blockHit->getPosition();
|
||||||
|
$world = $pos->getWorld();
|
||||||
|
$posX = $pos->getFloorX();
|
||||||
|
$posY = $pos->getFloorY();
|
||||||
|
$posZ = $pos->getFloorZ();
|
||||||
|
|
||||||
|
$ice = VanillaBlocks::ICE();
|
||||||
|
for($x = $posX - 1; $x <= $posX + 1; $x++){
|
||||||
|
for($y = $posY - 1; $y <= $posY + 1; $y++){
|
||||||
|
for($z = $posZ - 1; $z <= $posZ + 1; $z++){
|
||||||
|
if($world->getBlockAt($x, $y, $z)->getTypeId() === BlockTypeIds::WATER){
|
||||||
|
$world->setBlockAt($x, $y, $z, $ice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
src/item/IceBomb.php
Normal file
48
src/item/IceBomb.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\item;
|
||||||
|
|
||||||
|
use pocketmine\entity\Location;
|
||||||
|
use pocketmine\entity\projectile\IceBomb as IceBombEntity;
|
||||||
|
use pocketmine\entity\projectile\Throwable;
|
||||||
|
use pocketmine\player\Player;
|
||||||
|
|
||||||
|
class IceBomb extends ProjectileItem{
|
||||||
|
|
||||||
|
public function getMaxStackSize() : int{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createEntity(Location $location, Player $thrower) : Throwable{
|
||||||
|
return new IceBombEntity($location, $thrower);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThrowForce() : float{
|
||||||
|
return 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCooldownTicks() : int{
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
}
|
@ -326,8 +326,9 @@ final class ItemTypeIds{
|
|||||||
public const NAME_TAG = 20287;
|
public const NAME_TAG = 20287;
|
||||||
public const GOAT_HORN = 20288;
|
public const GOAT_HORN = 20288;
|
||||||
public const END_CRYSTAL = 20289;
|
public const END_CRYSTAL = 20289;
|
||||||
|
public const ICE_BOMB = 20290;
|
||||||
|
|
||||||
public const FIRST_UNUSED_ITEM_ID = 20290;
|
public const FIRST_UNUSED_ITEM_ID = 20291;
|
||||||
|
|
||||||
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
|
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
|
||||||
|
|
||||||
|
@ -1378,6 +1378,7 @@ final class StringToItemParser extends StringToTParser{
|
|||||||
$result->register("honey_bottle", fn() => Items::HONEY_BOTTLE());
|
$result->register("honey_bottle", fn() => Items::HONEY_BOTTLE());
|
||||||
$result->register("host_armor_trim_smithing_template", fn() => Items::HOST_ARMOR_TRIM_SMITHING_TEMPLATE());
|
$result->register("host_armor_trim_smithing_template", fn() => Items::HOST_ARMOR_TRIM_SMITHING_TEMPLATE());
|
||||||
$result->register("honeycomb", fn() => Items::HONEYCOMB());
|
$result->register("honeycomb", fn() => Items::HONEYCOMB());
|
||||||
|
$result->register("ice_bomb", fn() => Items::ICE_BOMB());
|
||||||
$result->register("ink_sac", fn() => Items::INK_SAC());
|
$result->register("ink_sac", fn() => Items::INK_SAC());
|
||||||
$result->register("iron_axe", fn() => Items::IRON_AXE());
|
$result->register("iron_axe", fn() => Items::IRON_AXE());
|
||||||
$result->register("iron_boots", fn() => Items::IRON_BOOTS());
|
$result->register("iron_boots", fn() => Items::IRON_BOOTS());
|
||||||
|
@ -192,6 +192,7 @@ use function strtolower;
|
|||||||
* @method static Item HONEYCOMB()
|
* @method static Item HONEYCOMB()
|
||||||
* @method static HoneyBottle HONEY_BOTTLE()
|
* @method static HoneyBottle HONEY_BOTTLE()
|
||||||
* @method static Item HOST_ARMOR_TRIM_SMITHING_TEMPLATE()
|
* @method static Item HOST_ARMOR_TRIM_SMITHING_TEMPLATE()
|
||||||
|
* @method static IceBomb ICE_BOMB()
|
||||||
* @method static Item INK_SAC()
|
* @method static Item INK_SAC()
|
||||||
* @method static Axe IRON_AXE()
|
* @method static Axe IRON_AXE()
|
||||||
* @method static Armor IRON_BOOTS()
|
* @method static Armor IRON_BOOTS()
|
||||||
@ -504,6 +505,7 @@ final class VanillaItems{
|
|||||||
self::register("heart_of_the_sea", fn(IID $id) => new Item($id, "Heart of the Sea"));
|
self::register("heart_of_the_sea", fn(IID $id) => new Item($id, "Heart of the Sea"));
|
||||||
self::register("honey_bottle", fn(IID $id) => new HoneyBottle($id, "Honey Bottle"));
|
self::register("honey_bottle", fn(IID $id) => new HoneyBottle($id, "Honey Bottle"));
|
||||||
self::register("honeycomb", fn(IID $id) => new Item($id, "Honeycomb"));
|
self::register("honeycomb", fn(IID $id) => new Item($id, "Honeycomb"));
|
||||||
|
self::register("ice_bomb", fn(IID $id) => new IceBomb($id, "Ice Bomb"));
|
||||||
self::register("ink_sac", fn(IID $id) => new Item($id, "Ink Sac"));
|
self::register("ink_sac", fn(IID $id) => new Item($id, "Ink Sac"));
|
||||||
self::register("iron_ingot", fn(IID $id) => new Item($id, "Iron Ingot"));
|
self::register("iron_ingot", fn(IID $id) => new Item($id, "Iron Ingot"));
|
||||||
self::register("iron_nugget", fn(IID $id) => new Item($id, "Iron Nugget"));
|
self::register("iron_nugget", fn(IID $id) => new Item($id, "Iron Nugget"));
|
||||||
|
@ -592,7 +592,6 @@ class InventoryManager{
|
|||||||
$info = $this->trackItemStack($entry, $slot, $itemStack, null);
|
$info = $this->trackItemStack($entry, $slot, $itemStack, null);
|
||||||
$contents[] = new ItemStackWrapper($info->getStackId(), $itemStack);
|
$contents[] = new ItemStackWrapper($info->getStackId(), $itemStack);
|
||||||
}
|
}
|
||||||
$clearSlotWrapper = new ItemStackWrapper(0, ItemStack::null());
|
|
||||||
if($entry->complexSlotMap !== null){
|
if($entry->complexSlotMap !== null){
|
||||||
foreach($contents as $slotId => $info){
|
foreach($contents as $slotId => $info){
|
||||||
$packetSlot = $entry->complexSlotMap->mapCoreToNet($slotId) ?? null;
|
$packetSlot = $entry->complexSlotMap->mapCoreToNet($slotId) ?? null;
|
||||||
|
@ -26,8 +26,12 @@ namespace pocketmine\scheduler;
|
|||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
|
|
||||||
abstract class Task{
|
abstract class Task{
|
||||||
|
/** @phpstan-var TaskHandler<static>|null */
|
||||||
private ?TaskHandler $taskHandler = null;
|
private ?TaskHandler $taskHandler = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-return TaskHandler<static>|null
|
||||||
|
*/
|
||||||
final public function getHandler() : ?TaskHandler{
|
final public function getHandler() : ?TaskHandler{
|
||||||
return $this->taskHandler;
|
return $this->taskHandler;
|
||||||
}
|
}
|
||||||
@ -36,6 +40,9 @@ abstract class Task{
|
|||||||
return Utils::getNiceClassName($this);
|
return Utils::getNiceClassName($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param TaskHandler<static>|null $taskHandler
|
||||||
|
*/
|
||||||
final public function setHandler(?TaskHandler $taskHandler) : void{
|
final public function setHandler(?TaskHandler $taskHandler) : void{
|
||||||
if($this->taskHandler === null || $taskHandler === null){
|
if($this->taskHandler === null || $taskHandler === null){
|
||||||
$this->taskHandler = $taskHandler;
|
$this->taskHandler = $taskHandler;
|
||||||
|
@ -26,6 +26,9 @@ namespace pocketmine\scheduler;
|
|||||||
use pocketmine\timings\Timings;
|
use pocketmine\timings\Timings;
|
||||||
use pocketmine\timings\TimingsHandler;
|
use pocketmine\timings\TimingsHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template TTask of Task
|
||||||
|
*/
|
||||||
class TaskHandler{
|
class TaskHandler{
|
||||||
protected int $nextRun;
|
protected int $nextRun;
|
||||||
|
|
||||||
@ -36,6 +39,9 @@ class TaskHandler{
|
|||||||
private string $taskName;
|
private string $taskName;
|
||||||
private string $ownerName;
|
private string $ownerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param TTask $task
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected Task $task,
|
protected Task $task,
|
||||||
protected int $delay = -1,
|
protected int $delay = -1,
|
||||||
@ -66,6 +72,9 @@ class TaskHandler{
|
|||||||
$this->nextRun = $ticks;
|
$this->nextRun = $ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-return TTask
|
||||||
|
*/
|
||||||
public function getTask() : Task{
|
public function getTask() : Task{
|
||||||
return $this->task;
|
return $this->task;
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,12 @@ use pocketmine\utils\ReversePriorityQueue;
|
|||||||
class TaskScheduler{
|
class TaskScheduler{
|
||||||
private bool $enabled = true;
|
private bool $enabled = true;
|
||||||
|
|
||||||
/** @phpstan-var ReversePriorityQueue<int, TaskHandler> */
|
/** @phpstan-var ReversePriorityQueue<int, TaskHandler<covariant Task>> */
|
||||||
protected ReversePriorityQueue $queue;
|
protected ReversePriorityQueue $queue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ObjectSet|TaskHandler[]
|
* @var ObjectSet|TaskHandler[]
|
||||||
* @phpstan-var ObjectSet<TaskHandler>
|
* @phpstan-var ObjectSet<TaskHandler<covariant Task>>
|
||||||
*/
|
*/
|
||||||
protected ObjectSet $tasks;
|
protected ObjectSet $tasks;
|
||||||
|
|
||||||
@ -51,18 +51,42 @@ class TaskScheduler{
|
|||||||
$this->tasks = new ObjectSet();
|
$this->tasks = new ObjectSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TTask of Task
|
||||||
|
* @phpstan-param TTask $task
|
||||||
|
*
|
||||||
|
* @phpstan-return TaskHandler<TTask>
|
||||||
|
*/
|
||||||
public function scheduleTask(Task $task) : TaskHandler{
|
public function scheduleTask(Task $task) : TaskHandler{
|
||||||
return $this->addTask($task, -1, -1);
|
return $this->addTask($task, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TTask of Task
|
||||||
|
* @phpstan-param TTask $task
|
||||||
|
*
|
||||||
|
* @phpstan-return TaskHandler<TTask>
|
||||||
|
*/
|
||||||
public function scheduleDelayedTask(Task $task, int $delay) : TaskHandler{
|
public function scheduleDelayedTask(Task $task, int $delay) : TaskHandler{
|
||||||
return $this->addTask($task, $delay, -1);
|
return $this->addTask($task, $delay, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TTask of Task
|
||||||
|
* @phpstan-param TTask $task
|
||||||
|
*
|
||||||
|
* @phpstan-return TaskHandler<TTask>
|
||||||
|
*/
|
||||||
public function scheduleRepeatingTask(Task $task, int $period) : TaskHandler{
|
public function scheduleRepeatingTask(Task $task, int $period) : TaskHandler{
|
||||||
return $this->addTask($task, -1, $period);
|
return $this->addTask($task, -1, $period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TTask of Task
|
||||||
|
* @phpstan-param TTask $task
|
||||||
|
*
|
||||||
|
* @phpstan-return TaskHandler<TTask>
|
||||||
|
*/
|
||||||
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period) : TaskHandler{
|
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period) : TaskHandler{
|
||||||
return $this->addTask($task, $delay, $period);
|
return $this->addTask($task, $delay, $period);
|
||||||
}
|
}
|
||||||
@ -77,10 +101,19 @@ class TaskScheduler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param TaskHandler<covariant Task> $task
|
||||||
|
*/
|
||||||
public function isQueued(TaskHandler $task) : bool{
|
public function isQueued(TaskHandler $task) : bool{
|
||||||
return $this->tasks->contains($task);
|
return $this->tasks->contains($task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TTask of Task
|
||||||
|
* @phpstan-param TTask $task
|
||||||
|
*
|
||||||
|
* @phpstan-return TaskHandler<TTask>
|
||||||
|
*/
|
||||||
private function addTask(Task $task, int $delay, int $period) : TaskHandler{
|
private function addTask(Task $task, int $delay, int $period) : TaskHandler{
|
||||||
if(!$this->enabled){
|
if(!$this->enabled){
|
||||||
throw new \LogicException("Tried to schedule task to disabled scheduler");
|
throw new \LogicException("Tried to schedule task to disabled scheduler");
|
||||||
@ -99,6 +132,11 @@ class TaskScheduler{
|
|||||||
return $this->handle(new TaskHandler($task, $delay, $period, $this->owner));
|
return $this->handle(new TaskHandler($task, $delay, $period, $this->owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TTask of Task
|
||||||
|
* @phpstan-param TaskHandler<TTask> $handler
|
||||||
|
* @phpstan-return TaskHandler<TTask>
|
||||||
|
*/
|
||||||
private function handle(TaskHandler $handler) : TaskHandler{
|
private function handle(TaskHandler $handler) : TaskHandler{
|
||||||
if($handler->isDelayed()){
|
if($handler->isDelayed()){
|
||||||
$nextRun = $this->currentTick + $handler->getDelay();
|
$nextRun = $this->currentTick + $handler->getDelay();
|
||||||
@ -128,7 +166,7 @@ class TaskScheduler{
|
|||||||
}
|
}
|
||||||
$this->currentTick = $currentTick;
|
$this->currentTick = $currentTick;
|
||||||
while($this->isReady($this->currentTick)){
|
while($this->isReady($this->currentTick)){
|
||||||
/** @var TaskHandler $task */
|
/** @phpstan-var TaskHandler<covariant Task> $task */
|
||||||
$task = $this->queue->extract();
|
$task = $this->queue->extract();
|
||||||
if($task->isCancelled()){
|
if($task->isCancelled()){
|
||||||
$this->tasks->remove($task);
|
$this->tasks->remove($task);
|
||||||
|
@ -30,6 +30,7 @@ use pocketmine\network\mcpe\protocol\ClientboundPacket;
|
|||||||
use pocketmine\network\mcpe\protocol\ServerboundPacket;
|
use pocketmine\network\mcpe\protocol\ServerboundPacket;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use pocketmine\scheduler\AsyncTask;
|
use pocketmine\scheduler\AsyncTask;
|
||||||
|
use pocketmine\scheduler\Task;
|
||||||
use pocketmine\scheduler\TaskHandler;
|
use pocketmine\scheduler\TaskHandler;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function str_starts_with;
|
use function str_starts_with;
|
||||||
@ -192,6 +193,10 @@ abstract class Timings{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template TTask of Task
|
||||||
|
* @phpstan-param TaskHandler<TTask> $task
|
||||||
|
*/
|
||||||
public static function getScheduledTaskTimings(TaskHandler $task, int $period) : TimingsHandler{
|
public static function getScheduledTaskTimings(TaskHandler $task, int $period) : TimingsHandler{
|
||||||
self::init();
|
self::init();
|
||||||
$name = "Task: " . $task->getTaskName();
|
$name = "Task: " . $task->getTaskName();
|
||||||
|
34
src/world/sound/IceBombHitSound.php
Normal file
34
src/world/sound/IceBombHitSound.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\world\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||||
|
|
||||||
|
final class IceBombHitSound implements Sound{
|
||||||
|
public function encode(Vector3 $pos) : array{
|
||||||
|
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::ICEBOMB_HIT, $pos, false)];
|
||||||
|
}
|
||||||
|
}
|
@ -801,7 +801,7 @@ parameters:
|
|||||||
path: ../../../src/scheduler/BulkCurlTask.php
|
path: ../../../src/scheduler/BulkCurlTask.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot call method getNextRun\\(\\) on array\\<string, int\\|pocketmine\\\\scheduler\\\\TaskHandler\\>\\|int\\|pocketmine\\\\scheduler\\\\TaskHandler\\.$#"
|
message: "#^Cannot call method getNextRun\\(\\) on array\\<string, int\\|pocketmine\\\\scheduler\\\\TaskHandler\\<covariant pocketmine\\\\scheduler\\\\Task\\>\\>\\|int\\|pocketmine\\\\scheduler\\\\TaskHandler\\<covariant pocketmine\\\\scheduler\\\\Task\\>\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/scheduler/TaskScheduler.php
|
path: ../../../src/scheduler/TaskScheduler.php
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user