mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
armor is not resisting damage from anything except players, drop fix, and baby fix
This commit is contained in:
parent
e31546afa7
commit
b73205744e
4 changed files with 69 additions and 68 deletions
|
|
@ -90,84 +90,83 @@ class EntityAPI{
|
||||||
switch ($cmd){
|
switch ($cmd){
|
||||||
case 'summon':
|
case 'summon':
|
||||||
case 'spawnmob':
|
case 'spawnmob':
|
||||||
|
if(!($issuer instanceof Player)){
|
||||||
if(!($issuer instanceof Player)){
|
$output .= "Please run this command in-game.";
|
||||||
$output .= "Please run this command in-game.";
|
break;
|
||||||
break;
|
}
|
||||||
}
|
if((count($args) < 1) or (count($args) > 3)){
|
||||||
if((count($args) < 1) or (count($args) > 3)){
|
$output .= "Usage: /$cmd <mob> [amount] [baby]";
|
||||||
$output .= "Usage: /$cmd <mob> [amount] [baby]";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = $this->mob[strtolower($args[0])];
|
|
||||||
if($type != (10 or 11 or 12 or 13 or 32 or 33 or 34 or 35 or 36)){
|
|
||||||
$output .= "Unknown mob.";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($args) == 1){//summon <mob>
|
|
||||||
|
|
||||||
$spawnX = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);
|
|
||||||
$spawnY = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
|
||||||
$spawnZ = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
|
||||||
$spawnLevel = $issuer->entity->level;
|
|
||||||
|
|
||||||
$entityit = $this->add($spawnLevel, ENTITY_MOB, $type, array(
|
|
||||||
"x" => $spawnX,
|
|
||||||
"y" => $spawnY,
|
|
||||||
"z" => $spawnZ,
|
|
||||||
"Health" => $this->hp[$type],
|
|
||||||
));
|
|
||||||
$this->spawnToAll($entityit, $level);
|
|
||||||
$output .= $this->mobName[$type]." spawned in ".$spawnX.", ".$spawnY.", ".$spawnZ.".";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
elseif(is_numeric($args[1])){//summon <mob> [amount]
|
|
||||||
$amount = (int)$args[1];
|
|
||||||
if($amount > 25){
|
|
||||||
$output .= "Cannot spawn > 25 mobs";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$isBaby = 0;
|
$type = $this->mob[strtolower($args[0])];
|
||||||
if(strtolower($args[2]) == 'baby'){//summon <mob> [amount] [baby]
|
if($type != (10 or 11 or 12 or 13 or 32 or 33 or 34 or 35 or 36)){
|
||||||
if($type > 13){
|
$output .= "Unknown mob.";
|
||||||
$output .= "This mob cant be baby!";
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
$isBaby = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$spawnX = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);
|
if(count($args) == 1){//summon <mob>
|
||||||
$spawnY = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
|
||||||
$spawnZ = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
$spawnX = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);
|
||||||
$spawnLevel = $issuer->entity->level;
|
$spawnY = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$spawnZ = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$spawnLevel = $issuer->entity->level;
|
||||||
|
|
||||||
for($cnt = $amount; $cnt > 0; --$cnt){
|
|
||||||
$entityit = $this->add($spawnLevel, ENTITY_MOB, $type, array(
|
$entityit = $this->add($spawnLevel, ENTITY_MOB, $type, array(
|
||||||
"x" => $spawnX,
|
"x" => $spawnX,
|
||||||
"y" => $spawnY,
|
"y" => $spawnY,
|
||||||
"z" => $spawnZ,
|
"z" => $spawnZ,
|
||||||
"Health" => $this->hp[$type],
|
"Health" => $this->hp[$type],
|
||||||
"IsBaby" => $isBaby,
|
|
||||||
));
|
));
|
||||||
$this->spawnToAll($entityit, $level);
|
$this->spawnToAll($entityit, $level);
|
||||||
|
$output .= $this->mobName[$type]." spawned in ".$spawnX.", ".$spawnY.", ".$spawnZ.".";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
elseif(is_numeric($args[1])){//summon <mob> [amount]
|
||||||
|
$amount = (int)$args[1];
|
||||||
|
if($amount > 25){
|
||||||
|
$output .= "Cannot spawn > 25 mobs";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if($type == 13 or $amount == 1) $plural = '';
|
$isBaby = 0;
|
||||||
else $plural = 's';
|
if(strtolower($args[2]) == 'baby'){//summon <mob> [amount] [baby]
|
||||||
|
if($type > 13){
|
||||||
|
$output .= "This mob cant be baby!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$isBaby = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if($isBaby == 1) $baby = "Baby ";
|
$spawnX = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);
|
||||||
else $baby = '';
|
$spawnY = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$spawnZ = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$spawnLevel = $issuer->entity->level;
|
||||||
|
|
||||||
$output .= $amount." ".$baby.$this->mobName[$type].$plural." spawned in ".$spawnX.", ".$spawnY.", ".$spawnZ.".";
|
for($cnt = $amount; $cnt > 0; --$cnt){
|
||||||
|
$entityit = $this->add($spawnLevel, ENTITY_MOB, $type, array(
|
||||||
|
"x" => $spawnX,
|
||||||
|
"y" => $spawnY,
|
||||||
|
"z" => $spawnZ,
|
||||||
|
"Health" => $this->hp[$type],
|
||||||
|
"IsBaby" => $isBaby,
|
||||||
|
));
|
||||||
|
$this->spawnToAll($entityit, $level);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
if($type == 13 or $amount == 1) $plural = '';
|
||||||
|
else $plural = 's';
|
||||||
|
|
||||||
|
if($isBaby == 1) $baby = "Baby ";
|
||||||
|
else $baby = '';
|
||||||
|
|
||||||
|
$output .= $amount." ".$baby.$this->mobName[$type].$plural." spawned in ".$spawnX.", ".$spawnY.", ".$spawnZ.".";
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
elseif(strtolower($args[1]) == 'baby'){//summon <mob> [baby]
|
elseif(strtolower($args[1]) == 'baby'){//summon <mob> [baby]
|
||||||
if($type > 13){
|
if($type > 13){
|
||||||
$output .= "Baby can be only animals!";
|
$output .= "This mob cant be baby!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -175,7 +174,6 @@ class EntityAPI{
|
||||||
$spawnY = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
$spawnY = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
||||||
$spawnZ = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
$spawnZ = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
||||||
$spawnLevel = $issuer->entity->level;
|
$spawnLevel = $issuer->entity->level;
|
||||||
|
|
||||||
$entityit = $this->add($spawnLevel, ENTITY_MOB, $type, array(
|
$entityit = $this->add($spawnLevel, ENTITY_MOB, $type, array(
|
||||||
"x" => $spawnX,
|
"x" => $spawnX,
|
||||||
"y" => $spawnY,
|
"y" => $spawnY,
|
||||||
|
|
@ -201,7 +199,7 @@ class EntityAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output .= $cnt." mobs has been despawned!";
|
$output .= $cnt." mobs have been despawned!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
|
|
@ -270,7 +268,7 @@ class EntityAPI{
|
||||||
|
|
||||||
public function add(Level $level, $class, $type = 0, $data = array()){
|
public function add(Level $level, $class, $type = 0, $data = array()){
|
||||||
$eid = $this->eCnt++;
|
$eid = $this->eCnt++;
|
||||||
$efl = EntityRegistry::$entityList->getEntityFromType($type);
|
$efl = EntityRegistry::$entityList->getEntityFromTypeAndClass($type, $class);
|
||||||
if($efl instanceof PropertyEntity){
|
if($efl instanceof PropertyEntity){
|
||||||
$class = $efl->getEntityName();
|
$class = $efl->getEntityName();
|
||||||
$this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data);
|
$this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ move methods
|
||||||
*/
|
*/
|
||||||
abstract class Animal extends Creature implements Ageable, Breedable{
|
abstract class Animal extends Creature implements Ageable, Breedable{
|
||||||
public function isBaby(){
|
public function isBaby(){
|
||||||
|
if(!isset($this->data["IsBaby"])){
|
||||||
|
$this->data["IsBaby"] = false;
|
||||||
|
}
|
||||||
return $this->data["IsBaby"];
|
return $this->data["IsBaby"];
|
||||||
}
|
}
|
||||||
public function getMetadata(){
|
public function getMetadata(){
|
||||||
|
|
|
||||||
|
|
@ -960,8 +960,8 @@ class Entity extends Position{
|
||||||
);
|
);
|
||||||
foreach($this->player->armor as $slot=>$part){
|
foreach($this->player->armor as $slot=>$part){
|
||||||
if($part instanceof Item and isset($values[$part->getID()])){
|
if($part instanceof Item and isset($values[$part->getID()])){
|
||||||
$points += $values[$part->getID()];
|
|
||||||
if(is_numeric($cause)){ //check was entity damage by another entity
|
if(is_numeric($cause)){ //check was entity damage by another entity
|
||||||
|
$points += $values[$part->getID()];
|
||||||
$this->player->damageArmorPart($slot, $part);
|
$this->player->damageArmorPart($slot, $part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ class EntityList{
|
||||||
$this->entities[$property->getEntityType()] = $property;
|
$this->entities[$property->getEntityType()] = $property;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntityFromType($type){
|
public function getEntityFromTypeAndClass($type, $class){
|
||||||
return isset($this->entities[$type]) ? $this->entities[$type] : 0;
|
return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0;
|
||||||
}
|
}
|
||||||
private $entities = [];
|
private $entities = [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue