summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLane Kolbly <lane@rscheme.org>2017-08-18 12:23:08 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2017-08-18 12:23:08 +0200
commit8f1ddfa6c3da1c410fcae6355234ca7f39ccee62 (patch)
tree42cd1d66b4244a1e4f914670c3caaa4c6ad70b24 /src
parentcBeaconEntity fix no world crash (diff)
downloadcuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.tar
cuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.tar.gz
cuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.tar.bz2
cuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.tar.lz
cuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.tar.xz
cuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.tar.zst
cuberite-8f1ddfa6c3da1c410fcae6355234ca7f39ccee62.zip
Diffstat (limited to 'src')
-rw-r--r--src/Mobs/Monster.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 6dc03c7e3..8077e41d6 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -5,6 +5,7 @@
#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"
+#include "../Items/ItemHandler.h"
#include "../World.h"
#include "../EffectID.h"
#include "../Entities/Player.h"
@@ -1093,7 +1094,13 @@ std::unique_ptr<cMonster> cMonster::NewMonsterFromType(eMonsterType a_MobType)
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
- auto Count = GetRandomProvider().RandInt<char>(static_cast<char>(a_Min), static_cast<char>(a_Max));
+ auto Count = GetRandomProvider().RandInt<unsigned int>(a_Min, a_Max);
+ auto MaxStackSize = static_cast<unsigned char>(ItemHandler(a_Item)->GetMaxStackSize());
+ while (Count > MaxStackSize)
+ {
+ a_Drops.emplace_back(a_Item, MaxStackSize, a_ItemHealth);
+ Count -= MaxStackSize;
+ }
if (Count > 0)
{
a_Drops.emplace_back(a_Item, Count, a_ItemHealth);