mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +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;
|
||||
|
||||
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(!$item->equals($oldItem, true) or $item->getCount() !== $oldItem->getCount()){
|
||||
$this->inventory->setItemInHand($item, $this);
|
||||
|
@ -1422,10 +1422,11 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @param Vector3 $vector
|
||||
* @param Item &$item (if null, can break anything)
|
||||
* @param Player $player
|
||||
* @param bool $createParticles
|
||||
*
|
||||
* @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);
|
||||
//TODO: Adventure mode checks
|
||||
|
||||
@ -1452,7 +1453,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
$breakTime = $player->isCreative() ? 0.15 : $target->getBreakTime($item);
|
||||
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)){
|
||||
@ -1479,18 +1480,20 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
$players = $this->getChunkPlayers($target->x >> 4, $target->z >> 4);
|
||||
if($player !== null){
|
||||
unset($players[$player->getLoaderId()]);
|
||||
}
|
||||
if($createParticles){
|
||||
$players = $this->getChunkPlayers($target->x >> 4, $target->z >> 4);
|
||||
if($player !== null){
|
||||
unset($players[$player->getLoaderId()]);
|
||||
}
|
||||
|
||||
$pk = new LevelEventPacket();
|
||||
$pk->evid = 2001;
|
||||
$pk->x = $target->x + 0.5;
|
||||
$pk->y = $target->y + 0.5;
|
||||
$pk->z = $target->z + 0.5;
|
||||
$pk->data = $target->getId() + ($target->getDamage() << 12);
|
||||
Server::broadcastPacket($players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||
$pk = new LevelEventPacket();
|
||||
$pk->evid = 2001;
|
||||
$pk->x = $target->x + 0.5;
|
||||
$pk->y = $target->y + 0.5;
|
||||
$pk->z = $target->z + 0.5;
|
||||
$pk->data = $target->getId() + ($target->getDamage() << 12);
|
||||
Server::broadcastPacket($players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||
}
|
||||
|
||||
$target->onBreak($item);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user