From 7404279f15b9b22b17d4798c0cd76ae5157c4f14 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 8 Jun 2013 18:34:28 +0200 Subject: [PATCH] Added spawn-animals and spawn-mobs --- src/API/ServerAPI.php | 2 ++ src/world/Entity.php | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 4a676a329..7af0211fd 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -72,6 +72,8 @@ class ServerAPI{ "view-distance" => 10, "max-players" => 20, "allow-flight" => false, + "spawn-animals" => true, + "spawn-mobs" => true, "gamemode" => SURVIVAL, "hardcore" => false, "pvp" => true, diff --git a/src/world/Entity.php b/src/world/Entity.php index 9eae12e09..8c4c9566a 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -241,6 +241,30 @@ class Entity extends Position{ return false; } } + + if($this->class === ENTITY_MOB){ + switch($this->type){ + case MOB_CHICKEN: + case MOB_SHEEP: + case MOB_COW: + case MOB_PIG: + if($this->server->api->getProperty("spawn-animals") !== true){ + $this->close(); + return false; + } + break; + case MOB_ZOMBIE: + case MOB_CREEPER: + case MOB_PIGMAN: + case MOB_SKELETON: + case MOB_SPIDER: + if($this->server->api->getProperty("spawn-mobs") !== true){ + $this->close(); + return false; + } + break; + } + } if($this->class !== ENTITY_PLAYER and ($this->x <= 0 or $this->z <= 0 or $this->x >= 256 or $this->z >= 256 or $this->y >= 128 or $this->y <= 0)){ $this->close();