mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Renaming "Level" -> "World" (#2907)
This has been a pain point for a long time due to the misleading nature of the name "level". It's also confusing when trying to do things like getting the XP level of the player or such, and also does not translate well to other languages. This transition was already executed on the UI some time ago (language strings) and now it's time for the same change to occur on the API. This will burn a lot of plugins, but they'll acclimatize. Despite the scary size of this PR, there isn't actually so many changes to make. Most of this came from renaming `Position->getLevel()` to `Position->getWorld()`, or cosmetic changes like changing variable names or doc comments.
This commit is contained in:
@ -40,7 +40,6 @@ use pocketmine\item\Consumable;
|
||||
use pocketmine\item\Durable;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\sound\ItemBreakSound;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\math\VoxelRayTrace;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -54,6 +53,7 @@ use pocketmine\Player;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Color;
|
||||
use pocketmine\world\sound\ItemBreakSound;
|
||||
use function abs;
|
||||
use function array_shift;
|
||||
use function atan2;
|
||||
@ -546,7 +546,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
private function damageItem(Durable $item, int $durabilityRemoved) : void{
|
||||
$item->applyDamage($durabilityRemoved);
|
||||
if($item->isBroken()){
|
||||
$this->level->addSound($this, new ItemBreakSound());
|
||||
$this->world->addSound($this, new ItemBreakSound());
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,7 +598,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
$source->getCause() === EntityDamageEvent::CAUSE_PROJECTILE or
|
||||
$source->getCause() === EntityDamageEvent::CAUSE_ENTITY_ATTACK
|
||||
) and $e->isOnFire()){
|
||||
$this->setOnFire(2 * $this->level->getDifficulty());
|
||||
$this->setOnFire(2 * $this->world->getDifficulty());
|
||||
}
|
||||
|
||||
$deltaX = $this->x - $e->x;
|
||||
@ -646,11 +646,11 @@ abstract class Living extends Entity implements Damageable{
|
||||
$ev = new EntityDeathEvent($this, $this->getDrops(), $this->getXpDropAmount());
|
||||
$ev->call();
|
||||
foreach($ev->getDrops() as $item){
|
||||
$this->getLevel()->dropItem($this, $item);
|
||||
$this->getWorld()->dropItem($this, $item);
|
||||
}
|
||||
|
||||
//TODO: check death conditions (must have been damaged by player < 5 seconds from death)
|
||||
$this->level->dropExperience($this, $ev->getXpDropAmount());
|
||||
$this->world->dropExperience($this, $ev->getXpDropAmount());
|
||||
|
||||
$this->startDeathAnimation();
|
||||
}
|
||||
@ -864,7 +864,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
$nextIndex = 0;
|
||||
|
||||
foreach(VoxelRayTrace::inDirection($this->add(0, $this->eyeHeight, 0), $this->getDirectionVector(), $maxDistance) as $vector3){
|
||||
$block = $this->level->getBlockAt($vector3->x, $vector3->y, $vector3->z);
|
||||
$block = $this->world->getBlockAt($vector3->x, $vector3->y, $vector3->z);
|
||||
$blocks[$nextIndex++] = $block;
|
||||
|
||||
if($maxLength !== 0 and count($blocks) > $maxLength){
|
||||
|
Reference in New Issue
Block a user