mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
bow will consume durability, arrows will be deleted
This commit is contained in:
parent
0a1a4f33f3
commit
105b09e28f
3 changed files with 18 additions and 4 deletions
|
|
@ -633,7 +633,6 @@ class Player{
|
||||||
foreach($this->hotbar as $slot){
|
foreach($this->hotbar as $slot){
|
||||||
$hotbar[] = $slot <= -1 ? -1 : $slot + 9;
|
$hotbar[] = $slot <= -1 ? -1 : $slot + 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pk = new ContainerSetContentPacket;
|
$pk = new ContainerSetContentPacket;
|
||||||
$pk->windowid = 0;
|
$pk->windowid = 0;
|
||||||
$pk->slots = $this->inventory;
|
$pk->slots = $this->inventory;
|
||||||
|
|
@ -1846,7 +1845,8 @@ class Player{
|
||||||
switch($packet->action){
|
switch($packet->action){
|
||||||
case 5: //Shot arrow
|
case 5: //Shot arrow
|
||||||
if($this->entity->inAction){
|
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){
|
if($this->startAction !== false){
|
||||||
$initalPower = $this->entity->inActionCounter;
|
$initalPower = $this->entity->inActionCounter;
|
||||||
$power = $initalPower / 20;
|
$power = $initalPower / 20;
|
||||||
|
|
@ -1882,8 +1882,18 @@ class Player{
|
||||||
$e->critical = ($power == 1);
|
$e->critical = ($power == 1);
|
||||||
$e->shoot($e->speedX, $e->speedY, $e->speedZ, ($power+$power) * 1.5, 1.0);
|
$e->shoot($e->speedX, $e->speedY, $e->speedZ, ($power+$power) * 1.5, 1.0);
|
||||||
$this->server->api->entity->spawnToAll($e);
|
$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;
|
$this->startAction = false;
|
||||||
|
|
|
||||||
|
|
@ -1318,7 +1318,11 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
$dmg = $this->applyArmor($dmg, $cause);
|
$dmg = $this->applyArmor($dmg, $cause);
|
||||||
$ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force);
|
$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) {
|
if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) {
|
||||||
$d = $entity->x - $this->x;
|
$d = $entity->x - $this->x;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
class BowItem extends Item{
|
class BowItem extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
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
|
public function isTool(){ //it is tool too
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue