Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit b28c71a

Browse files
author
dearminder
committed
Merge remote-tracking branch 'upstream/stable' into stable
2 parents 99e984d + d8875ec commit b28c71a

File tree

7 files changed

+53
-34
lines changed

7 files changed

+53
-34
lines changed

src/pocketmine/Player.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public function showPlayer(Player $player){
629629
}
630630

631631
public function canCollideWith(Entity $entity) : bool{
632-
return false;
632+
return $entity instanceof Living;
633633
}
634634

635635
public function canBeCollidedWith() : bool{
@@ -4297,10 +4297,6 @@ public function isTeleporting() : bool{
42974297
return $this->isTeleporting;
42984298
}
42994299

4300-
public function canBePushed() : bool{
4301-
return true;
4302-
}
4303-
43044300
public function getDeviceOS(): ?int{
43054301
return $this->deviceOS;
43064302
}

src/pocketmine/command/defaults/GameRuleCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
7474
public function getKnownGameRules() : array{
7575
return [
7676
"commandblockoutput", "dodaylightcycle", "doentitydrops", "dofiretick", "doinsomnia", "domobloot",
77-
"domobspawning", "dotiledrops", "doweathercycle", "drowningdamage", "falldamage", "firedamage",
77+
"domobspawning", "dotiledrops", "doimmediaterespawn", "doweathercycle", "drowningdamage", "falldamage", "firedamage",
7878
"keepinventory", "maxcommandchainlength", "mobgriefing", "naturalregeneration", "pvp",
7979
"sendcommandfeedback", "showcoordinates", "tntexplodes"
8080
];

src/pocketmine/command/defaults/SaveCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
4545
return true;
4646
}
4747

48-
Command::broadcastCommandMessage($sender, new TranslationContainer("pocketmine.save.start"));
48+
Command::broadcastCommandMessage($sender, new TranslationContainer("command.save.start"));
4949
$start = microtime(true);
5050

5151
foreach($sender->getServer()->getOnlinePlayers() as $player){
@@ -56,7 +56,7 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
5656
$level->save(true);
5757
}
5858

59-
Command::broadcastCommandMessage($sender, new TranslationContainer("pocketmine.save.success", [round(microtime(true) - $start, 3)]));
59+
Command::broadcastCommandMessage($sender, new TranslationContainer("command.save.success", [round(microtime(true) - $start, 3)]));
6060

6161
return true;
6262
}

src/pocketmine/entity/Entity.php

+39-24
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
use pocketmine\level\Level;
9797
use pocketmine\level\Location;
9898
use pocketmine\level\Position;
99+
use pocketmine\level\sound\PlaySound;
99100
use pocketmine\math\AxisAlignedBB;
100101
use pocketmine\math\Vector2;
101102
use pocketmine\math\Vector3;
@@ -114,6 +115,7 @@
114115
use pocketmine\network\mcpe\protocol\SetActorDataPacket;
115116
use pocketmine\network\mcpe\protocol\SetActorLinkPacket;
116117
use pocketmine\network\mcpe\protocol\SetActorMotionPacket;
118+
use pocketmine\network\mcpe\protocol\StopSoundPacket;
117119
use pocketmine\network\mcpe\protocol\types\DimensionIds;
118120
use pocketmine\network\mcpe\protocol\types\EntityLink;
119121
use pocketmine\Player;
@@ -1615,34 +1617,24 @@ protected function broadcastMotion() : void{
16151617
}
16161618

16171619
/**
1618-
* Pushes the this entity and other entity
1620+
* Pushes the other entity
16191621
*
16201622
* @param Entity $entity
16211623
*/
1622-
protected function applyEntityCollision(Entity $entity) : void{
1623-
if($this->canBePushed() and !$this->isRiding() and !$entity->isRiding()){
1624-
if(!($entity instanceof Player and $entity->isSpectator()) and !($this instanceof Player and $this->isSpectator())){
1624+
public function applyEntityCollision(Entity $entity) : void{
1625+
if(!$this->isRiding() and !$entity->isRiding()){
1626+
if(!($entity instanceof Player and $entity->isSpectator())){
16251627
$d0 = $entity->x - $this->x;
16261628
$d1 = $entity->z - $this->z;
16271629
$d2 = abs(max($d0, $d1));
16281630

1629-
if($d2 >= 0.009){
1631+
if($d2 > 0){
16301632
$d2 = sqrt($d2);
1631-
$d0 = $d0 / $d2;
1632-
$d1 = $d1 / $d2;
1633-
$d3 = 1 / $d2;
1633+
$d0 /= $d2;
1634+
$d1 /= $d2;
1635+
$d3 = min(1, 1 / $d2);
16341636

1635-
if($d3 > 1) $d3 = 1;
1636-
1637-
$d0 = $d0 * $d3;
1638-
$d1 = $d1 * $d3;
1639-
$d0 = $d0 * 0.05;
1640-
$d1 = $d1 * 0.05;
1641-
$d0 = $d0 * (1 - $this->entityCollisionReduction);
1642-
$d1 = $d1 * (1 - $this->entityCollisionReduction);
1643-
1644-
$this->motion = $this->motion->subtract($d0, 0, $d1);
1645-
$entity->motion = $entity->motion->add($d0, 0, $d1);
1637+
$entity->setMotion($entity->getMotion()->add($d0 * $d3 * 0.05, 0, $d1 * $d3 * 0.05));
16461638
}
16471639
}
16481640
}
@@ -2136,7 +2128,9 @@ public function onCollideWithPlayer(Player $player) : void{
21362128
}
21372129

21382130
public function onCollideWithEntity(Entity $entity) : void{
2139-
$entity->applyEntityCollision($this);
2131+
if($entity->canBePushed()){
2132+
$this->applyEntityCollision($entity);
2133+
}
21402134
}
21412135

21422136
public function isUnderwater() : bool{
@@ -2439,10 +2433,8 @@ protected function checkBlockCollision() : void{
24392433
}
24402434

24412435
protected function checkEntityCollision() : void{
2442-
if($this->canBePushed()){
2443-
foreach($this->level->getCollidingEntities($this->getBoundingBox()->expandedCopy(0.2, 0, 0.2), $this) as $e){
2444-
$this->onCollideWithEntity($e);
2445-
}
2436+
foreach($this->level->getCollidingEntities($this->getBoundingBox()->expandedCopy(0.2, 0, 0.2), $this) as $e){
2437+
$this->onCollideWithEntity($e);
24462438
}
24472439
}
24482440

@@ -2570,6 +2562,29 @@ public function addMotion(float $x, float $y, float $z) : void{
25702562
$this->motion->z += $z;
25712563
}
25722564

2565+
/**
2566+
* @param string $sound
2567+
* @param float $volume
2568+
* @param float $pitch
2569+
* @param array|null $targets
2570+
*/
2571+
public function playSound(string $sound, float $volume = 1.0, float $pitch = 1.0, array $targets = null) : void{
2572+
$this->level->addSound(new PlaySound($this, $sound, $volume, $pitch), $targets ?? null);
2573+
}
2574+
2575+
/**
2576+
* @param string $sound
2577+
* @param bool $stopAll
2578+
* @param array|null $targets
2579+
*/
2580+
public function stopSound(string $sound, bool $stopAll = false, array $targets = null) : void{
2581+
$pk = new StopSoundPacket();
2582+
$pk->soundName = $sound;
2583+
$pk->stopAll = $stopAll;
2584+
2585+
$this->server->broadcastPacket($targets ?? $this->level->getViewersForPosition($this), $pk);
2586+
}
2587+
25732588
public function isOnGround() : bool{
25742589
return $this->onGround;
25752590
}

src/pocketmine/entity/hostile/Slime.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
use pocketmine\level\generator\Flat;
4343
use pocketmine\level\particle\GenericParticle;
4444
use pocketmine\level\particle\Particle;
45+
use pocketmine\nbt\tag\ByteTag;
4546
use pocketmine\nbt\tag\IntTag;
4647
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
4748
use pocketmine\Player;
@@ -79,7 +80,11 @@ protected function initEntity() : void{
7980
$this->moveHelper = new EntitySlimeMoveHelper($this);
8081

8182
if($this->namedtag->hasTag("Size", IntTag::class)){
83+
// Before Altay used IntTag.
8284
$this->setSlimeSize($this->namedtag->getInt("Size"));
85+
$this->namedtag->removeTag("Size");
86+
}elseif($this->namedtag->hasTag("Size", ByteTag::class)){
87+
$this->setSlimeSize($this->namedtag->getByte("Size"));
8388
}else{
8489
$i = $this->random->nextBoundedInt(3);
8590

@@ -120,7 +125,7 @@ public function getSlimeSize() : int{
120125
public function saveNBT() : void{
121126
parent::saveNBT();
122127

123-
$this->namedtag->setInt("Size", $this->getSlimeSize());
128+
$this->namedtag->setByte("Size", $this->getSlimeSize());
124129
$this->namedtag->setByte("wasOnGround", intval($this->wasOnGround));
125130
}
126131

src/pocketmine/level/GameRules.php

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class GameRules{
4040
public const RULE_DO_MOB_LOOT = "doMobLoot";
4141
public const RULE_DO_MOB_SPAWNING = "doMobSpawning";
4242
public const RULE_DO_TILE_DROPS = "doTileDrops";
43+
public const RULE_DO_IMMEDIATE_RESPAWN = "doimmediaterespawn";
4344
public const RULE_DO_WEATHER_CYCLE = "doWeatherCycle";
4445
public const RULE_DROWNING_DAMAGE = "drowningdamage";
4546
public const RULE_FALL_DAMAGE = "falldamage";
@@ -73,6 +74,7 @@ public function __construct(){
7374
$this->setBool(self::RULE_DO_MOB_LOOT, true);
7475
$this->setBool(self::RULE_DO_MOB_SPAWNING, false);
7576
$this->setBool(self::RULE_DO_TILE_DROPS, true);
77+
$this->setBool(self::RULE_DO_IMMEDIATE_RESPAWN, false);
7678
$this->setBool(self::RULE_DO_WEATHER_CYCLE, true);
7779
$this->setBool(self::RULE_DROWNING_DAMAGE, true);
7880
$this->setBool(self::RULE_FALL_DAMAGE, true);

src/pocketmine/level/sound/PlaySound.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ class PlaySound extends Sound{
3636
/** @var float */
3737
protected $pitch = 1;
3838

39-
public function __construct(Vector3 $pos, string $soundName, float $volume = 100, float $pitch = 1){
39+
public function __construct(Vector3 $pos, string $soundName, float $volume = 1.0, float $pitch = 1.0){
4040
parent::__construct($pos->x, $pos->y, $pos->z);
41+
4142
$this->soundName = $soundName;
4243
$this->volume = $volume;
4344
$this->pitch = $pitch;

0 commit comments

Comments
 (0)