mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-04-23 07:24:14 +00:00
fix: fix ded server crash because colour table is null
This commit is contained in:
parent
395fe4baeb
commit
994e3a4819
|
|
@ -180,11 +180,39 @@ int PotionBrewing::getAppearanceValue(int brew)
|
|||
return valueOf(brew, 5, 4, 3, 2, 1);
|
||||
}
|
||||
|
||||
static unsigned int GetFallbackPotionColour(eMinecraftColour id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case eMinecraftColour_Potion_BaseColour: return 0x385DC6;
|
||||
case eMinecraftColour_Effect_MovementSpeed: return 0x7CAFC6;
|
||||
case eMinecraftColour_Effect_MovementSlowDown: return 0x5A6C81;
|
||||
case eMinecraftColour_Effect_DigSpeed: return 0xD9C043;
|
||||
case eMinecraftColour_Effect_DigSlowdown: return 0x4A4217;
|
||||
case eMinecraftColour_Effect_DamageBoost: return 0x932423;
|
||||
case eMinecraftColour_Effect_Heal: return 0xF82423;
|
||||
case eMinecraftColour_Effect_Harm: return 0x430A09;
|
||||
case eMinecraftColour_Effect_Jump: return 0x786297;
|
||||
case eMinecraftColour_Effect_Confusion: return 0x551D4A;
|
||||
case eMinecraftColour_Effect_Regeneration: return 0xCD5CAB;
|
||||
case eMinecraftColour_Effect_DamageResistance: return 0x99453A;
|
||||
case eMinecraftColour_Effect_FireResistance: return 0xE49A3A;
|
||||
case eMinecraftColour_Effect_WaterBreathing: return 0x2E5299;
|
||||
case eMinecraftColour_Effect_Invisiblity: return 0x7F8392;
|
||||
case eMinecraftColour_Effect_Blindness: return 0x1F1F23;
|
||||
case eMinecraftColour_Effect_NightVision: return 0x1F1FA1;
|
||||
case eMinecraftColour_Effect_Hunger: return 0x587653;
|
||||
case eMinecraftColour_Effect_Weakness: return 0x484D48;
|
||||
case eMinecraftColour_Effect_Poison: return 0x4E9331;
|
||||
default: return 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
|
||||
{
|
||||
ColourTable *colourTable = Minecraft::GetInstance()->getColourTable();
|
||||
|
||||
int baseColor = colourTable->getColor( eMinecraftColour_Potion_BaseColour );
|
||||
int baseColor = colourTable != NULL ? colourTable->getColor(eMinecraftColour_Potion_BaseColour) : GetFallbackPotionColour(eMinecraftColour_Potion_BaseColour);
|
||||
|
||||
if (effects == NULL || effects->empty())
|
||||
{
|
||||
|
|
@ -200,7 +228,8 @@ int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
|
|||
for(AUTO_VAR(it, effects->begin()); it != effects->end(); ++it)
|
||||
{
|
||||
MobEffectInstance *effect = *it;
|
||||
int potionColor = colourTable->getColor( MobEffect::effects[effect->getId()]->getColor() );
|
||||
eMinecraftColour effectColorId = MobEffect::effects[effect->getId()]->getColor();
|
||||
int potionColor = colourTable != NULL ? colourTable->getColor(effectColorId) : GetFallbackPotionColour(effectColorId);
|
||||
|
||||
for (int potency = 0; potency <= effect->getAmplifier(); potency++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue