diff --git a/src/Player.php b/src/Player.php index 864a099a..951acc64 100755 --- a/src/Player.php +++ b/src/Player.php @@ -633,7 +633,6 @@ class Player{ foreach($this->hotbar as $slot){ $hotbar[] = $slot <= -1 ? -1 : $slot + 9; } - $pk = new ContainerSetContentPacket; $pk->windowid = 0; $pk->slots = $this->inventory; @@ -1846,7 +1845,8 @@ class Player{ switch($packet->action){ case 5: //Shot arrow if($this->entity->inAction){ - if($this->getSlot($this->slot)->getID() === BOW){ //TODO check arrow count + $arrowSlot = $this->hasItem(ARROW); + if($this->getSlot($this->slot)->getID() === BOW && (($this->gamemode & 0x01) == 0x1 || $arrowSlot !== false)){ //TODO check arrow count if($this->startAction !== false){ $initalPower = $this->entity->inActionCounter; $power = $initalPower / 20; @@ -1882,8 +1882,18 @@ class Player{ $e->critical = ($power == 1); $e->shoot($e->speedX, $e->speedY, $e->speedZ, ($power+$power) * 1.5, 1.0); $this->server->api->entity->spawnToAll($e); + if(($this->gamemode & 0x01) == 0x0) { + $bow = $this->getSlot($this->slot); + if(++$bow->meta >= $bow->getMaxDurability()){ + $this->inventory[$this->slot] = BlockAPI::getItem(AIR, 0, 0); + } + $this->removeItem(ARROW, 0, 1, false); + $this->sendInventory(); + } } } + }else{ //inv desynced, resend + $this->sendInventory(); } } $this->startAction = false; diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 4091b880..43d9f737 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1318,7 +1318,11 @@ class Entity extends Position } $dmg = $this->applyArmor($dmg, $cause); $ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force); - + + if($this->isPlayer() && $this->player->gamemode & 0x01 == 0x01){ + return false; + } + if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) { $d = $entity->x - $this->x; diff --git a/src/material/item/tool/BowItem.php b/src/material/item/tool/BowItem.php index 0b2d5ef8..6adf23dd 100644 --- a/src/material/item/tool/BowItem.php +++ b/src/material/item/tool/BowItem.php @@ -2,7 +2,7 @@ class BowItem extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(BOW, 0, $count, "Bow"); + parent::__construct(BOW, $meta, $count, "Bow"); } public function isTool(){ //it is tool too return true;