mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Only spawn break particles when needed
This commit is contained in:
parent
383fcba8e1
commit
d881dbf1a2
@ -2197,7 +2197,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
$oldItem = clone $item;
|
$oldItem = clone $item;
|
||||||
|
|
||||||
if($this->canInteract($vector->add(0.5, 0.5, 0.5), 13) and $this->level->useBreakOn($vector, $item, $this) === true){
|
if($this->canInteract($vector->add(0.5, 0.5, 0.5), 13) and $this->level->useBreakOn($vector, $item, $this, true)){
|
||||||
if($this->isSurvival()){
|
if($this->isSurvival()){
|
||||||
if(!$item->equals($oldItem, true) or $item->getCount() !== $oldItem->getCount()){
|
if(!$item->equals($oldItem, true) or $item->getCount() !== $oldItem->getCount()){
|
||||||
$this->inventory->setItemInHand($item, $this);
|
$this->inventory->setItemInHand($item, $this);
|
||||||
|
@ -1422,10 +1422,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @param Vector3 $vector
|
* @param Vector3 $vector
|
||||||
* @param Item &$item (if null, can break anything)
|
* @param Item &$item (if null, can break anything)
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
|
* @param bool $createParticles
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null){
|
public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, $createParticles = false){
|
||||||
$target = $this->getBlock($vector);
|
$target = $this->getBlock($vector);
|
||||||
//TODO: Adventure mode checks
|
//TODO: Adventure mode checks
|
||||||
|
|
||||||
@ -1452,7 +1453,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
$breakTime = $player->isCreative() ? 0.15 : $target->getBreakTime($item);
|
$breakTime = $player->isCreative() ? 0.15 : $target->getBreakTime($item);
|
||||||
if($player->hasEffect(Effect::SWIFTNESS)){
|
if($player->hasEffect(Effect::SWIFTNESS)){
|
||||||
$breakTime *= pow(0.80, $player->getEffect(Effect::SWIFTNESS)->getAmplifier() + 1);
|
$breakTime *= 0.80 * ($player->getEffect(Effect::SWIFTNESS)->getAmplifier() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$ev->getInstaBreak() and ($player->lastBreak + $breakTime) >= microtime(true)){
|
if(!$ev->getInstaBreak() and ($player->lastBreak + $breakTime) >= microtime(true)){
|
||||||
@ -1479,6 +1480,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($createParticles){
|
||||||
$players = $this->getChunkPlayers($target->x >> 4, $target->z >> 4);
|
$players = $this->getChunkPlayers($target->x >> 4, $target->z >> 4);
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
unset($players[$player->getLoaderId()]);
|
unset($players[$player->getLoaderId()]);
|
||||||
@ -1491,6 +1493,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$pk->z = $target->z + 0.5;
|
$pk->z = $target->z + 0.5;
|
||||||
$pk->data = $target->getId() + ($target->getDamage() << 12);
|
$pk->data = $target->getId() + ($target->getDamage() << 12);
|
||||||
Server::broadcastPacket($players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
Server::broadcastPacket($players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||||
|
}
|
||||||
|
|
||||||
$target->onBreak($item);
|
$target->onBreak($item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user