Skip to content

Commit

Permalink
Auto disable crawling
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Feb 26, 2024
1 parent 85d6a6d commit 5ece22f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/network/mcpe/handler/InGamePacketHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,14 @@ public function handlePlayerAuthInput(PlayerAuthInputPacket $packet) : bool{
$swimming = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SWIMMING, PlayerAuthInputFlags::STOP_SWIMMING);
$gliding = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_GLIDING, PlayerAuthInputFlags::STOP_GLIDING);
$flying = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_FLYING, PlayerAuthInputFlags::STOP_FLYING);
$crawling = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_CRAWLING, PlayerAuthInputFlags::STOP_CRAWLING);
$mismatch =
($sneaking !== null && !$this->player->toggleSneak($sneaking)) |
($sprinting !== null && !$this->player->toggleSprint($sprinting)) |
($swimming !== null && !$this->player->toggleSwim($swimming)) |
($gliding !== null && !$this->player->toggleGlide($gliding)) |
($flying !== null && !$this->player->toggleFlight($flying));
($flying !== null && !$this->player->toggleFlight($flying)) |
($crawling !== null && !$this->player->toggleCrawl($crawling));
if((bool) $mismatch){
$this->player->sendData([$this->player]);
}
Expand Down Expand Up @@ -753,7 +755,6 @@ public function handleBlockActorData(BlockActorDataPacket $packet) : bool{
throw new PacketHandlingException("Invalid tag type " . get_debug_type($frontTextTag) . " for tag \"" . Sign::TAG_FRONT_TEXT . "\" in sign update data");
}
$textBlobTag = $frontTextTag->getTag(Sign::TAG_TEXT_BLOB);

if(!$textBlobTag instanceof StringTag){
throw new PacketHandlingException("Invalid tag type " . get_debug_type($textBlobTag) . " for tag \"" . Sign::TAG_TEXT_BLOB . "\" in sign update data");
}
Expand Down
4 changes: 4 additions & 0 deletions src/player/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,10 @@ public function toggleFlight(bool $fly) : bool{
return true;
}

public function toggleCrawl(bool $crawl) : bool{
return false;
}

public function toggleGlide(bool $glide) : bool{
if($glide === $this->gliding){
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/world/World.php
Original file line number Diff line number Diff line change
Expand Up @@ -2259,9 +2259,9 @@ public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $cli
return false;
}

//if($blockClicked->getTypeId() === BlockTypeIds::AIR){
// return false;
//}
if($blockClicked->getTypeId() === BlockTypeIds::AIR){
return false;
}

if($player !== null){
$ev = new PlayerInteractEvent($player, $item, $blockClicked, $clickVector, $face, PlayerInteractEvent::RIGHT_CLICK_BLOCK);
Expand Down Expand Up @@ -2292,7 +2292,7 @@ public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $cli
$hand = $item->getBlock($face);
$hand->position($this, $blockReplace->getPosition()->x, $blockReplace->getPosition()->y, $blockReplace->getPosition()->z);

if($blockClicked->getTypeId() !== BlockTypeIds::AIR && $hand->canBePlacedAt($blockClicked, $clickVector, $face, true)){
if($hand->canBePlacedAt($blockClicked, $clickVector, $face, true)){
$blockReplace = $blockClicked;
//TODO: while this mimics the vanilla behaviour with replaceable blocks, we should really pass some other
//value like NULL and let place() deal with it. This will look like a bug to anyone who doesn't know about
Expand Down

0 comments on commit 5ece22f

Please sign in to comment.