diff --git a/README.md b/README.md
index d438eb24..77814adf 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
TeaSpoon
-[![Build Status](http://cortexpe.xyz:8080/job/TeaSpoon/badge/icon)](http://cortexpe.xyz:8080/job/TeaSpoon/) [![Poggit](https://poggit.pmmp.io/ci.shield/CortexPE/TeaSpoon/~)](https://poggit.pmmp.io/ci/CortexPE/TeaSpoon/~) [![Donate](https://img.shields.io/badge/donate-PayPal-yellow.svg?style=flat-square)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MABFZPDR8F5UG) [![HitCount](http://hits.dwyl.io/CortexPE/TeaSpoon.svg)](http://hits.dwyl.io/CortexPE/TeaSpoon) [![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/CortexPE/TeaSpoon/pulls) [![License](https://img.shields.io/badge/License-GNU%20AGPL%20v3-brightgreen.svg?style=flat-square)](https://github.com/CortexPE/TeaSpoon/blob/master/LICENSE)
+[![Build Status](http://cortexpe.xyz:8080/job/TeaSpoon/badge/icon)](http://cortexpe.xyz:8080/job/TeaSpoon/) [![Poggit](https://poggit.pmmp.io/ci.shield/CortexPE/TeaSpoon/~)](https://poggit.pmmp.io/ci/CortexPE/TeaSpoon/~) [![Donate](https://img.shields.io/badge/donate-PayPal-yellow.svg?style=flat-square)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MABFZPDR8F5UG) [![HitCount](http://hits.dwyl.io/CortexPE/TeaSpoon.svg)](http://hits.dwyl.io/CortexPE/TeaSpoon) [![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/CortexPE/TeaSpoon/pulls) [![License](https://img.shields.io/badge/license-GNU%20AGPL%20v3-brightgreen.svg?style=flat-square)](https://github.com/CortexPE/TeaSpoon/blob/master/LICENSE) [![Discord](https://img.shields.io/discord/350333413737365522.svg?style=flat-square&label=discord%20chat)](https://discord.gg/QA3eSjw)
A Massive PocketMine-MP plugin designed and is aiming to extend PMMP's functionalities (Without completely changing it) to Make it more Vanilla-Like.
diff --git a/src/CortexPE/EventListener.php b/src/CortexPE/EventListener.php
index e7d6fbdb..f9afe85c 100644
--- a/src/CortexPE/EventListener.php
+++ b/src/CortexPE/EventListener.php
@@ -257,7 +257,7 @@ public function onCheat(PlayerIllegalMoveEvent $ev){
public function onEntityDeath(EntityDeathEvent $ev){
$xp = Xp::getXpDropsForEntity($ev->getEntity());
if($xp > 0){
- Xp::spawnXpOrb($ev->getEntity()->getPosition(), $ev->getEntity()->getLevel(), $xp);
+ $ev->getEntity()->getLevel()->dropExperience($ev->getEntity()->asVector3(), $xp);
}
}
@@ -270,7 +270,7 @@ public function onBlockBreak(BlockBreakEvent $ev){
if($ev->isCancelled()) return;
$xp = Xp::getXpDropsForBlock($ev->getBlock());
if($xp > 0){
- Xp::spawnXpOrb($ev->getBlock(), $ev->getBlock()->getLevel(), $xp);
+ $ev->getPlayer()->getLevel()->dropExperience($ev->getBlock()->asVector3(), $xp);
}
}
diff --git a/src/CortexPE/entity/EndCrystal.php b/src/CortexPE/entity/EndCrystal.php
index b2671923..ff2c57f0 100644
--- a/src/CortexPE/entity/EndCrystal.php
+++ b/src/CortexPE/entity/EndCrystal.php
@@ -44,7 +44,6 @@
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\ListTag;
-use pocketmine\Server;
class EndCrystal extends Entity {
const NETWORK_ID = self::ENDER_CRYSTAL;
diff --git a/src/CortexPE/entity/EntityManager.php b/src/CortexPE/entity/EntityManager.php
index ec720d85..4282e8f6 100644
--- a/src/CortexPE/entity/EntityManager.php
+++ b/src/CortexPE/entity/EntityManager.php
@@ -102,7 +102,6 @@ public static function init(): void{
self::registerEntity(Arrow::class, true, ['Arrow', 'minecraft:arrow']);
// Other Entities ////
- self::registerEntity(XPOrb::class, true, ['XPOrb', 'minecraft:xporb']);
self::registerEntity(AreaEffectCloud::class, true, ['AreaEffectCloud', 'minecraft:areaeffectcloud']);
self::registerEntity(Lightning::class, true, ['Lightning', 'minecraft:lightning']);
self::registerEntity(EndCrystal::class, true, ['EnderCrystal', 'minecraft:ender_crystal']);
diff --git a/src/CortexPE/entity/XPOrb.php b/src/CortexPE/entity/XPOrb.php
deleted file mode 100644
index 4718d459..00000000
--- a/src/CortexPE/entity/XPOrb.php
+++ /dev/null
@@ -1,144 +0,0 @@
-namedtag->Experience)){
- $this->experience = $this->namedtag["Experience"];
- }else $this->close();
- }
-
- public function entityBaseTick(int $tickDiff = 1): bool{
- if($this->closed){
- return false;
- }
-
- $this->timings->startTiming();
-
- $hasUpdate = parent::entityBaseTick($tickDiff);
-
- if($this->age > 7000){
- $this->timings->stopTiming();
- $this->close();
-
- return true;
- }
-
- if(!$this->onGround){
- $this->motionY -= $this->gravity;
- }
-
- $Target = $this->FetchNearbyPlayer($this->followrange);
- if($Target instanceof Human){
- $moveSpeed = 0.5;
- $motX = ($Target->getX() - $this->x) / 8;
- $motY = ($Target->getY()/* + $Target->getEyeHeight() */ - $this->y) / 8;
- $motZ = ($Target->getZ() - $this->z) / 8 /* * (1 / $Target->getZ())*/
- ;
- $motSqrt = sqrt($motX * $motX + $motY * $motY + $motZ * $motZ);
- $motC = 1 - $motSqrt;
-
- if($motC > 0){
- $motC *= $motC;
- $d = $motSqrt * $motC * $moveSpeed;
- $d = ($d == 0 ? null : $d);
- if($d !== null){
- $this->motionX = $motX / $d;
- $this->motionY = $motY / $d;
- $this->motionZ = $motZ / $d;
- }
- }
-
- if($Target->distance($this) <= $this->pickuprange){
- $this->timings->stopTiming();
- $this->close();
- if($this->getExperience() > 0){
- Xp::addXp($Target, $this->getExperience());
- }
-
- return true;
- }
- }
-
- $this->move($this->motionX, $this->motionY, $this->motionZ);
-
- $this->updateMovement();
-
- $this->timings->stopTiming();
-
- return $hasUpdate or !$this->onGround or abs($this->motionX) > 0.00001 or abs($this->motionY) > 0.00001 or abs($this->motionZ) > 0.00001;
- }
-
- public function FetchNearbyPlayer($DistanceRange){
- $MinDistance = $DistanceRange;
- $Target = null;
- foreach($this->getLevel()->getPlayers() as $player){
- if($player->isAlive() and $MinDistance >= $Distance = $player->distance($this)){
- $Target = $player;
- $MinDistance = $Distance;
- }
- }
-
- return $Target;
- }
-
- public function getExperience(){
- return $this->experience;
- }
-
- public function setExperience($exp){
- $this->experience = $exp;
- }
-
- public function canCollideWith(Entity $entity): bool{
- return false;
- }
-
- public function saveNBT(){
- parent::saveNBT();
- $this->namedtag->Experience = new IntTag("Experience", $this->experience);
- }
-}
diff --git a/src/CortexPE/entity/projectile/EnchantingBottle.php b/src/CortexPE/entity/projectile/EnchantingBottle.php
index d941483a..cb371046 100644
--- a/src/CortexPE/entity/projectile/EnchantingBottle.php
+++ b/src/CortexPE/entity/projectile/EnchantingBottle.php
@@ -36,7 +36,6 @@
namespace CortexPE\entity\projectile;
use CortexPE\level\particle\SpellParticle;
-use CortexPE\utils\Xp;
use pocketmine\entity\{
Entity, projectile\Throwable
};
@@ -57,7 +56,7 @@ public function onUpdate(int $currentTick): bool{
$randomY = self::RAND_POS_Y[array_rand(self::RAND_POS_Y)];
$randomZ = self::RAND_POS_Z[array_rand(self::RAND_POS_Z)];
- Xp::spawnXpOrb($this->add($randomX, $randomY, $randomZ), $this->getLevel(), mt_rand(1, 4));
+ $this->getLevel()->dropExperience($this->add($randomX, $randomY, $randomZ), mt_rand(1,4));
}
$this->kill();
}
diff --git a/src/CortexPE/item/FishingRod.php b/src/CortexPE/item/FishingRod.php
index 694acc30..bc760d37 100644
--- a/src/CortexPE/item/FishingRod.php
+++ b/src/CortexPE/item/FishingRod.php
@@ -41,7 +41,6 @@
use CortexPE\Session;
use CortexPE\Utils;
use CortexPE\utils\FishingLootTable;
-use CortexPE\utils\Xp;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\entity\projectile\Projectile;
@@ -152,7 +151,8 @@ public function onClickAir(Player $player, Vector3 $directionVector): bool{
}
$item = FishingLootTable::getRandom($lvl);
$player->getInventory()->addItem($item);
- Xp::addXp($player, mt_rand(1, 6));
+
+ $player->addXp(mt_rand(1, 6));
}
$projectile->flagForDespawn();
diff --git a/src/CortexPE/utils/Xp.php b/src/CortexPE/utils/Xp.php
index 324aa08b..0bb133bc 100644
--- a/src/CortexPE/utils/Xp.php
+++ b/src/CortexPE/utils/Xp.php
@@ -36,67 +36,21 @@
namespace CortexPE\utils;
use CortexPE\entity\Lightning;
-use CortexPE\entity\XPOrb;
use CortexPE\Utils;
use pocketmine\block\Block;
use pocketmine\entity\Animal;
use pocketmine\entity\Entity;
use pocketmine\entity\Human;
use pocketmine\entity\Monster;
-use pocketmine\level\Level;
-use pocketmine\math\Vector3;
-use pocketmine\nbt\tag\FloatTag;
-use pocketmine\nbt\tag\IntTag;
-use pocketmine\Player;
class Xp extends Utils {
- // [ROT13 Encoded and is pretty Explicit] Jul gur shpx unfa'g CZZC Vzcyrzragrq n CEBCRE KC Flfgrz Lrg? Guvf vf Shpxvat fghcvq naq vf bar bs gur znal ernfbaf jul Crbcyr ybir fcbbaf -_-
- // hacky code to *SOMEHOW* get it working...
-
- // TODO: Base it all from this list: https://minecraft.gamepedia.com/Experience#Experience_amounts_by_source
-
- public static function addXp(Player $player, int $amount){
- $add = self::getLevelFromXp($player->getTotalXp() + $amount);
- $player->setXpProgress($add[1]);
- $player->setXpLevel(intval($player->getXpLevel() + round($player->getXpProgress())));
- self::saveData($player);
- }
-
- private static function saveData(Player $player){
- if(!isset($player->namedtag->XpLevel) or !($player->namedtag->XpLevel instanceof IntTag)){
- $player->namedtag->XpLevel = new IntTag("XpLevel", $player->getXpLevel());
- }else{
- $player->namedtag["XpLevel"] = $player->getXpLevel();
- }
-
- if(!isset($player->namedtag->XpP) or !($player->namedtag->XpP instanceof FloatTag)){
- $player->namedtag->XpP = new FloatTag("XpP", $player->getXpProgress());
- }else{
- $player->namedtag["XpP"] = $player->getXpProgress();
- }
-
- if(!isset($player->namedtag->XpTotal) or !($player->namedtag->XpTotal instanceof IntTag)){
- $player->namedtag->XpTotal = new IntTag("XpTotal", $player->getTotalXp());
- }else{
- $player->namedtag["XpTotal"] = $player->getTotalXp();
- }
- $player->getServer()->saveOfflinePlayerData($player->getName(), $player->namedtag, true);
- }
-
- public static function takeXp(Player $player, int $amount){
- if(($player->getTotalXp() - $amount) >= 0){
- $add = self::getLevelFromXp($player->getTotalXp() - $amount);
- $player->setXpProgress($add[1]);
- $player->setXpLevel(intval($player->getXpLevel() + round($player->getXpProgress())));
- self::saveData($player);
- }
- }
-
public static function getXpDropsForEntity(Entity $e): int{
switch($e::NETWORK_ID){
case Lightning::NETWORK_ID:
return 0;
- default:
+ case Human::NETWORK_ID: // Handled by PMMP ;)
+ return 0;
+ default: // todo: add proper XP Drop table
if($e instanceof Monster){
switch($e->getName()){
default:
@@ -107,8 +61,6 @@ public static function getXpDropsForEntity(Entity $e): int{
default:
return mt_rand(1, 3);
}
- }elseif($e instanceof Human){
- return 7;
}
return 0;
@@ -138,14 +90,4 @@ public static function getXpDropsForBlock(Block $b): int{
return 0;
}
}
-
- public static function spawnXpOrb(Vector3 $pos, Level $lvl, int $exp): XPOrb{
- $nbt = XPOrb::createBaseNBT($pos);
- $nbt->setLong("Experience", $exp);
- /** @var XPOrb $entity */
- $entity = Entity::createEntity("XPOrb", $lvl, $nbt);
- $entity->spawnToAll();
-
- return $entity;
- }
}
\ No newline at end of file