mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Implemented Bottle o' Enchanting
This commit is contained in:
parent
486edf0e55
commit
ad09e8c8d0
@ -35,6 +35,7 @@ use pocketmine\entity\object\PaintingMotive;
|
||||
use pocketmine\entity\projectile\Arrow;
|
||||
use pocketmine\entity\projectile\Egg;
|
||||
use pocketmine\entity\projectile\EnderPearl;
|
||||
use pocketmine\entity\projectile\ExperienceBottle;
|
||||
use pocketmine\entity\projectile\Snowball;
|
||||
use pocketmine\entity\projectile\SplashPotion;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
@ -233,6 +234,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
Entity::registerEntity(Arrow::class, false, ['Arrow', 'minecraft:arrow']);
|
||||
Entity::registerEntity(Egg::class, false, ['Egg', 'minecraft:egg']);
|
||||
Entity::registerEntity(EnderPearl::class, false, ['ThrownEnderpearl', 'minecraft:ender_pearl']);
|
||||
Entity::registerEntity(ExperienceBottle::class, false, ['ThrownExpBottle', 'minecraft:xp_bottle']);
|
||||
Entity::registerEntity(ExperienceOrb::class, false, ['XPOrb', 'minecraft:xp_orb']);
|
||||
Entity::registerEntity(FallingSand::class, false, ['FallingSand', 'minecraft:falling_block']);
|
||||
Entity::registerEntity(Item::class, false, ['Item', 'minecraft:item']);
|
||||
|
48
src/pocketmine/entity/projectile/ExperienceBottle.php
Normal file
48
src/pocketmine/entity/projectile/ExperienceBottle.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\entity\projectile;
|
||||
|
||||
use pocketmine\event\entity\ProjectileHitEvent;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\utils\Color;
|
||||
|
||||
class ExperienceBottle extends Throwable{
|
||||
public const NETWORK_ID = self::XP_BOTTLE;
|
||||
|
||||
protected $gravity = 0.07;
|
||||
|
||||
public function getResultDamage() : int{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function onHit(ProjectileHitEvent $event) : void{
|
||||
$this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_PARTICLE_SPLASH, (new Color(0x38, 0x5d, 0xc6))->toARGB());
|
||||
$this->level->broadcastLevelSoundEvent($this, LevelSoundEventPacket::SOUND_GLASS);
|
||||
|
||||
$this->level->dropExperience($this, mt_rand(3, 11));
|
||||
|
||||
$this->flagForDespawn();
|
||||
}
|
||||
}
|
38
src/pocketmine/item/ExperienceBottle.php
Normal file
38
src/pocketmine/item/ExperienceBottle.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
|
||||
class ExperienceBottle extends ProjectileItem{
|
||||
public function __construct(int $meta = 0){
|
||||
parent::__construct(self::EXPERIENCE_BOTTLE, $meta, "Bottle o' Enchanting");
|
||||
}
|
||||
|
||||
public function getProjectileEntityType() : string{
|
||||
return "ThrownExpBottle";
|
||||
}
|
||||
|
||||
public function getThrowForce() : float{
|
||||
return 0.7;
|
||||
}
|
||||
}
|
@ -167,7 +167,7 @@ class ItemFactory{
|
||||
//TODO: ENDER_EYE
|
||||
self::registerItem(new Item(Item::GLISTERING_MELON, 0, "Glistering Melon"));
|
||||
self::registerItem(new SpawnEgg());
|
||||
//TODO: BOTTLE_O_ENCHANTING
|
||||
self::registerItem(new ExperienceBottle());
|
||||
//TODO: FIREBALL
|
||||
self::registerItem(new WritableBook());
|
||||
self::registerItem(new WrittenBook());
|
||||
|
Loading…
x
Reference in New Issue
Block a user