mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-24 13:39:44 +00:00
tweaks to inv to make it better on serverside, fixed eattile, spiders are a bit faster
This commit is contained in:
parent
e28498c4c2
commit
89717f86a4
4 changed files with 32 additions and 31 deletions
|
|
@ -897,34 +897,32 @@ class Player{
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function addItem($type, $damage, $count, $send = true){
|
public function addItem($type, $damage, $count, $send = true){
|
||||||
while($count > 0){
|
|
||||||
$add = 0;
|
foreach($this->inventory as $s => $item){ //force check the inventory for non-full stacks of this item first
|
||||||
foreach($this->inventory as $s => $item){
|
if($item->getID() === $type and $item->getMetadata() === $damage){
|
||||||
if($item->getID() === AIR){
|
$add = min($item->getMaxStackSize() - $item->count, $count);
|
||||||
$add = min($item->getMaxStackSize(), $count);
|
if($add <= 0){
|
||||||
$this->inventory[$s] = BlockAPI::getItem($type, $damage, $add);
|
continue;
|
||||||
if($send === true){
|
|
||||||
$this->sendInventorySlot($s);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}elseif($item->getID() === $type and $item->getMetadata() === $damage){
|
|
||||||
$add = min($item->getMaxStackSize() - $item->count, $count);
|
|
||||||
if($add <= 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$item->count += $add;
|
|
||||||
if($send === true){
|
|
||||||
$this->sendInventorySlot($s);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
$item->count += $add;
|
||||||
|
if($send) $this->sendInventorySlot($s);
|
||||||
|
|
||||||
|
$count -= $add;
|
||||||
|
if($count <= 0) return true;
|
||||||
}
|
}
|
||||||
if($add <= 0){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$count -= $add;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
foreach($this->inventory as $s => $item){
|
||||||
|
if($item->getID() === AIR){
|
||||||
|
$add = min($item->getMaxStackSize(), $count);
|
||||||
|
$this->inventory[$s] = BlockAPI::getItem($type, $damage, $add);
|
||||||
|
if($send) $this->sendInventorySlot($s);
|
||||||
|
$count -= $add;
|
||||||
|
if($count <= 0) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($count <= 0) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ class TaskEatTileGoal extends TaskBase
|
||||||
|
|
||||||
public function onUpdate(EntityAI $ai)
|
public function onUpdate(EntityAI $ai)
|
||||||
{
|
{
|
||||||
if($ai->isStarted("TaskEatTileGoal")){
|
if($ai->isStarted("TaskPanic")){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--$this->selfCounter == 4)
|
if (--$this->selfCounter == 4)
|
||||||
{
|
{
|
||||||
$id = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y, $ai->entity->z);
|
$id = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y, $ai->entity->z);
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ class Spider extends Monster{
|
||||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
|
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
|
||||||
$this->setName("Spider");
|
$this->setName("Spider");
|
||||||
$this->setSpeed(0.3);
|
$this->setSpeed(0.3);
|
||||||
$this->ai->addTask(new TaskRandomWalk(1.0));
|
$this->ai->addTask(new TaskRandomWalk(1.2));
|
||||||
$this->ai->addTask(new TaskLookAround());
|
$this->ai->addTask(new TaskLookAround());
|
||||||
$this->ai->addTask(new TaskSwimming());
|
$this->ai->addTask(new TaskSwimming());
|
||||||
$this->ai->addTask(new TaskAttackPlayer(1.0, 16));
|
$this->ai->addTask(new TaskAttackPlayer(1.2, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttackDamage(){
|
public function getAttackDamage(){
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@ abstract class ItemTool extends Item
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function useOn($object, $force = false){
|
public function useOn($object, $force = false){
|
||||||
if(($object instanceof Entity) and !$this->isSword()){
|
|
||||||
|
if($this->isSword() && !($object instanceof Entity)){
|
||||||
|
$this->meta += 2;
|
||||||
|
}else if(($object instanceof Entity) && !$this->isSword()){
|
||||||
$this->meta += 2;
|
$this->meta += 2;
|
||||||
}else{
|
}else{
|
||||||
$this->meta++;
|
$this->meta++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue