Fixed climbing blocks such as ladders and vines

Seems we can now climb ANY block if the climbing flag is true, and nothing if false. This commit adds local block checks to see if a climbable block exists at the entity's feet and if so, sets the flag.
This commit is contained in:
Dylan K. Taylor
2017-04-14 19:02:53 +01:00
parent f12a6eed29
commit 66924729ff
4 changed files with 66 additions and 5 deletions

View File

@ -56,6 +56,10 @@ class Vine extends Transparent{
return true;
}
public function canClimb() : bool{
return true;
}
public function onEntityCollide(Entity $entity){
$entity->resetFallDistance();
}
@ -122,7 +126,7 @@ class Vine extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if(!$target->isTransparent() and $target->isSolid()){
if($target->isSolid()){
$faces = [
2 => 1,
3 => 4,
@ -142,11 +146,16 @@ class Vine extends Transparent{
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
/*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1));
$this->getLevel()->setBlock($this, new Air(), true, true);
$sides = [
2 => 4,
3 => 1,
4 => 2,
5 => 8
];
if(!$this->getSide($sides[$this->meta])->isSolid()){ //Replace with common break method
$this->level->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}*/
}
}
return false;