mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 01:16:15 +00:00
Kill the instabreak anti-cheat
This is annoying and it requires that the server must match this precisely to not cause bugs. Additionally, this code shits its pants when the client hits a spot of network lag. This can be implemented easily as a plugin. There is no reason whatsoever for this to be in the core.
This commit is contained in:
@ -28,7 +28,6 @@ namespace pocketmine\level;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Item as DroppedItem;
|
||||
use pocketmine\entity\object\ExperienceOrb;
|
||||
@ -1780,7 +1779,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$drops = ($player !== null and $player->isCreative()) ? [] : array_merge(...array_map(function(Block $block) use ($item) : array{ return $block->getDrops($item); }, $affectedBlocks));
|
||||
|
||||
if($player !== null){
|
||||
$ev = new BlockBreakEvent($player, $target, $item, $player->isCreative() or $player->allowInstaBreak(), $drops);
|
||||
$ev = new BlockBreakEvent($player, $target, $item, $player->isCreative(), $drops);
|
||||
|
||||
if(($player->isSurvival() and !$target->isBreakable($item)) or $player->isSpectator()){
|
||||
$ev->setCancelled();
|
||||
@ -1811,28 +1810,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
return false;
|
||||
}
|
||||
|
||||
$breakTime = ceil($target->getBreakTime($item) * 20);
|
||||
|
||||
if($player->isCreative() and $breakTime > 3){
|
||||
$breakTime = 3;
|
||||
}
|
||||
|
||||
if($player->hasEffect(Effect::HASTE)){
|
||||
$breakTime *= 1 - (0.2 * $player->getEffect(Effect::HASTE)->getEffectLevel());
|
||||
}
|
||||
|
||||
if($player->hasEffect(Effect::MINING_FATIGUE)){
|
||||
$breakTime *= 1 + (0.3 * $player->getEffect(Effect::MINING_FATIGUE)->getEffectLevel());
|
||||
}
|
||||
|
||||
$breakTime -= 1; //1 tick compensation
|
||||
|
||||
if(!$ev->getInstaBreak() and (ceil($player->lastBreak * 20) + $breakTime) > ceil(microtime(true) * 20)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$player->lastBreak = PHP_INT_MAX;
|
||||
|
||||
$drops = $ev->getDrops();
|
||||
|
||||
}elseif(!$target->isBreakable($item)){
|
||||
|
Reference in New Issue
Block a user