summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMasy98 <masy@antheruscraft.de>2014-12-20 10:31:34 +0100
committerMasy98 <masy@antheruscraft.de>2014-12-20 10:31:34 +0100
commit6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71 (patch)
tree0c7e7083444d2dc9c797c7a962fc05185c03eb1e /src
parentMerge pull request #1680 from Masy98/entities (diff)
downloadcuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.tar
cuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.tar.gz
cuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.tar.bz2
cuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.tar.lz
cuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.tar.xz
cuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.tar.zst
cuberite-6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71.zip
Diffstat (limited to '')
-rw-r--r--src/BlockID.h1
-rw-r--r--src/Items/ItemSpawnEgg.h1
-rw-r--r--src/MobSpawner.cpp2
-rw-r--r--src/Mobs/IncludeAllMonsters.h1
-rw-r--r--src/Mobs/Monster.cpp4
-rw-r--r--src/Mobs/MonsterTypes.h1
-rw-r--r--src/Mobs/Rabbit.cpp38
-rw-r--r--src/Mobs/Rabbit.h24
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp2
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp24
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.h1
11 files changed, 99 insertions, 0 deletions
diff --git a/src/BlockID.h b/src/BlockID.h
index bfb6b8d6d..41ccf90b5 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -971,6 +971,7 @@ enum
E_META_SPAWN_EGG_OCELOT = 98,
E_META_SPAWN_EGG_IRON_GOLEM = 99,
E_META_SPAWN_EGG_HORSE = 100,
+ E_META_SPAWN_EGG_RABBIT = 101,
E_META_SPAWN_EGG_VILLAGER = 120,
E_META_SPAWN_EGG_ENDER_CRYSTAL = 200,
} ;
diff --git a/src/Items/ItemSpawnEgg.h b/src/Items/ItemSpawnEgg.h
index 2f28ec6eb..dee8a9057 100644
--- a/src/Items/ItemSpawnEgg.h
+++ b/src/Items/ItemSpawnEgg.h
@@ -70,6 +70,7 @@ public:
case E_META_SPAWN_EGG_MOOSHROOM: return mtMooshroom;
case E_META_SPAWN_EGG_OCELOT: return mtOcelot;
case E_META_SPAWN_EGG_PIG: return mtPig;
+ case E_META_SPAWN_EGG_RABBIT: return mtRabbit;
case E_META_SPAWN_EGG_SHEEP: return mtSheep;
case E_META_SPAWN_EGG_SILVERFISH: return mtSilverfish;
case E_META_SPAWN_EGG_SKELETON: return mtSkeleton;
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index bd34d8fcd..0a32d17ef 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -92,6 +92,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
addIfAllowed(mtCow, allowedMobs);
addIfAllowed(mtChicken, allowedMobs);
addIfAllowed(mtEnderman, allowedMobs);
+ addIfAllowed(mtRabbit, allowedMobs);
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
if ((a_Biome == biForest) || (a_Biome == biForestHills) || (a_Biome == biTaiga) || (a_Biome == biTaigaHills))
@@ -164,6 +165,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
case mtCow:
case mtPig:
case mtHorse:
+ case mtRabbit:
case mtSheep:
{
return (
diff --git a/src/Mobs/IncludeAllMonsters.h b/src/Mobs/IncludeAllMonsters.h
index f5eb9dcc3..53c709c2b 100644
--- a/src/Mobs/IncludeAllMonsters.h
+++ b/src/Mobs/IncludeAllMonsters.h
@@ -15,6 +15,7 @@
#include "Mooshroom.h"
#include "Ocelot.h"
#include "Pig.h"
+#include "Rabbit.h"
#include "Sheep.h"
#include "Silverfish.h"
#include "Skeleton.h"
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 3d174677c..a02ea357e 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -45,6 +45,7 @@ static const struct
{mtMooshroom, "mooshroom", "MushroomCow"},
{mtOcelot, "ocelot", "Ozelot"},
{mtPig, "pig", "Pig"},
+ {mtRabbit, "rabbit", "Rabbit"},
{mtSheep, "sheep", "Sheep"},
{mtSilverfish, "silverfish", "Silverfish"},
{mtSkeleton, "skeleton", "Skeleton"},
@@ -499,6 +500,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
case mtCow:
case mtHorse:
case mtPig:
+ case mtRabbit:
case mtSheep:
case mtSquid:
case mtMooshroom:
@@ -851,6 +853,7 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type)
case mtMooshroom: return mfHostile;
case mtOcelot: return mfPassive;
case mtPig: return mfPassive;
+ case mtRabbit: return mfPassive;
case mtSheep: return mfPassive;
case mtSilverfish: return mfHostile;
case mtSkeleton: return mfHostile;
@@ -963,6 +966,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
case mtMooshroom: toReturn = new cMooshroom(); break;
case mtOcelot: toReturn = new cOcelot(); break;
case mtPig: toReturn = new cPig(); break;
+ case mtRabbit: toReturn = new cRabbit(); break;
case mtSheep: toReturn = new cSheep(); break;
case mtSilverfish: toReturn = new cSilverfish(); break;
case mtSnowGolem: toReturn = new cSnowGolem(); break;
diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h
index 0d716cca3..02bec267b 100644
--- a/src/Mobs/MonsterTypes.h
+++ b/src/Mobs/MonsterTypes.h
@@ -25,6 +25,7 @@ enum eMonsterType
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
mtOcelot = E_META_SPAWN_EGG_OCELOT,
mtPig = E_META_SPAWN_EGG_PIG,
+ mtRabbit = E_META_SPAWN_EGG_RABBIT,
mtSheep = E_META_SPAWN_EGG_SHEEP,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp
new file mode 100644
index 000000000..1c7d810b7
--- /dev/null
+++ b/src/Mobs/Rabbit.cpp
@@ -0,0 +1,38 @@
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Rabbit.h"
+#include "../Entities/Player.h"
+#include "../World.h"
+
+
+
+
+
+cRabbit::cRabbit(void) :
+ super("Rabbit", mtRabbit, "mob.rabbit.idle", "mob.rabbit.death", 0.9, 0.9)
+{
+}
+
+
+
+
+
+void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+{
+ int LootingLevel = 0;
+ if (a_Killer != nullptr)
+ {
+ LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
+ }
+ AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_RABBIT : E_ITEM_RAW_RABBIT);
+ AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RABBIT_HIDE);
+ cItems RareDrops;
+ RareDrops.Add(cItem(E_ITEM_RABBITS_FOOT));
+ AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
+}
+
+
+
+
+
diff --git a/src/Mobs/Rabbit.h b/src/Mobs/Rabbit.h
new file mode 100644
index 000000000..5ea03d09b
--- /dev/null
+++ b/src/Mobs/Rabbit.h
@@ -0,0 +1,24 @@
+
+#pragma once
+
+#include "PassiveMonster.h"
+
+
+
+
+
+class cRabbit :
+ public cPassiveMonster
+{
+ typedef cPassiveMonster super;
+
+public:
+ cRabbit();
+
+ CLASS_PROTODEF(cRabbit)
+
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+
+ virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
+
+} ; \ No newline at end of file
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 9d8e20b0b..c87397542 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -502,6 +502,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtMooshroom: EntityClass = "MushroomCow"; break;
case mtOcelot: EntityClass = "Ozelot"; break;
case mtPig: EntityClass = "Pig"; break;
+ case mtRabbit: EntityClass = "Rabbit"; break;
case mtSheep: EntityClass = "Sheep"; break;
case mtSilverfish: EntityClass = "Silverfish"; break;
case mtSkeleton: EntityClass = "Skeleton"; break;
@@ -633,6 +634,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtMooshroom:
case mtOcelot:
case mtPig:
+ case mtRabbit:
case mtSilverfish:
case mtSnowGolem:
case mtSpider:
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index a045497bc..cf51ab19c 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1442,6 +1442,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
LoadPigFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
+ else if (strncmp(a_IDTag, "Rabbit", a_IDTagLength) == 0)
+ {
+ LoadRabbitFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
+ }
else if (strncmp(a_IDTag, "Sheep", a_IDTagLength) == 0)
{
LoadSheepFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
@@ -2363,6 +2367,26 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
+void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ std::unique_ptr<cRabbit> Monster(new cRabbit());
+ if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ {
+ return;
+ }
+
+ if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ {
+ return;
+ }
+
+ a_Entities.push_back(Monster.release());
+}
+
+
+
+
+
void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color");
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 7bcdd259e..362796614 100755
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -198,6 +198,7 @@ protected:
void LoadMooshroomFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadOcelotFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadPigFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadRabbitFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSheepFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSilverfishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSkeletonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);