aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Spider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/Spider.cpp')
-rw-r--r--Minecraft.World/Spider.cpp112
1 files changed, 86 insertions, 26 deletions
diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp
index ba58ce54..49997db3 100644
--- a/Minecraft.World/Spider.cpp
+++ b/Minecraft.World/Spider.cpp
@@ -2,11 +2,14 @@
#include "net.minecraft.world.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.item.h"
+#include "net.minecraft.world.entity.ai.attributes.h"
#include "net.minecraft.world.entity.item.h"
#include "net.minecraft.world.entity.player.h"
#include "net.minecraft.world.effect.h"
#include "net.minecraft.world.entity.h"
+#include "net.minecraft.world.entity.monster.h"
#include "com.mojang.nbt.h"
+#include "BasicTypeContainers.h"
#include "Spider.h"
#include "..\Minecraft.Client\Textures.h"
#include "SoundTypes.h"
@@ -18,13 +21,10 @@ Spider::Spider(Level *level) : Monster( level )
// 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
// the derived version of the function is called
this->defineSynchedData();
+ registerAttributes();
+ setHealth(getMaxHealth());
- // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that the derived version of the function is called
- health = getMaxHealth();
-
- this->textureIdx = TN_MOB_SPIDER; // 4J was L"/mob/spider.png";
this->setSize(1.4f, 0.9f);
- runSpeed = 0.8f;
}
void Spider::defineSynchedData()
@@ -46,19 +46,12 @@ void Spider::tick()
}
}
-int Spider::getMaxHealth()
-{
- return 16;
-}
-
-double Spider::getRideHeight()
+void Spider::registerAttributes()
{
- return bbHeight * 0.75 - 0.5f;
-}
+ Monster::registerAttributes();
-bool Spider::makeStepSound()
-{
- return false;
+ getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(16);
+ getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.8f);
}
shared_ptr<Entity> Spider::findAttackTarget()
@@ -96,12 +89,17 @@ int Spider::getDeathSound()
return eSoundType_MOB_SPIDER_DEATH;
}
+void Spider::playStepSound(int xt, int yt, int zt, int t)
+{
+ playSound(eSoundType_MOB_SPIDER_STEP, 0.15f, 1);
+}
+
void Spider::checkHurtTarget(shared_ptr<Entity> target, float d)
{
float br = getBrightness(1);
if (br > 0.5f && random->nextInt(100) == 0)
{
- this->attackTarget = nullptr;
+ attackTarget = nullptr;
return;
}
@@ -139,25 +137,20 @@ void Spider::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
}
/**
- * The the spiders act as if they're always on a ladder, which enables them
- * to climb walls.
- */
+* The the spiders act as if they're always on a ladder, which enables them
+* to climb walls.
+*/
bool Spider::onLadder()
{
return isClimbing();
}
-
+
void Spider::makeStuckInWeb()
{
// do nothing - spiders don't get stuck in web
}
-float Spider::getModelScale()
-{
- return 1.0f;
-}
-
MobType Spider::getMobType()
{
return ARTHROPOD;
@@ -189,4 +182,71 @@ void Spider::setClimbing(bool value)
flags &= ~0x1;
}
entityData->set(DATA_FLAGS_ID, flags);
+}
+
+MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param
+{
+ groupData = Monster::finalizeMobSpawn(groupData);
+
+#ifndef _CONTENT_PACKAGE
+ // 4J-JEV: Added for spider-jockey spawn-egg.
+ if ( (level->random->nextInt(100) == 0) || (extraData != 0) )
+#else
+ if (level->random->nextInt(100) == 0)
+#endif
+ {
+ shared_ptr<Skeleton> skeleton = shared_ptr<Skeleton>( new Skeleton(level) );
+ skeleton->moveTo(x, y, z, yRot, 0);
+ skeleton->finalizeMobSpawn(NULL);
+ level->addEntity(skeleton);
+ skeleton->ride(shared_from_this());
+ }
+
+ if (groupData == NULL)
+ {
+ groupData = new SpiderEffectsGroupData();
+
+ if (level->difficulty > Difficulty::NORMAL && level->random->nextFloat() < SPIDER_SPECIAL_EFFECT_CHANCE * level->getDifficulty(x, y, z))
+ {
+ ((SpiderEffectsGroupData *) groupData)->setRandomEffect(level->random);
+ }
+ }
+ if ( dynamic_cast<SpiderEffectsGroupData *>( groupData ) != NULL)
+ {
+ int effect = ((SpiderEffectsGroupData *) groupData)->effectId;
+ if (effect > 0 && MobEffect::effects[effect] != NULL)
+ {
+ addEffect(new MobEffectInstance(effect, Integer::MAX_VALUE));
+ }
+ }
+
+ return groupData;
+}
+
+const float Spider::SPIDER_SPECIAL_EFFECT_CHANCE = .1f;
+
+Spider::SpiderEffectsGroupData::SpiderEffectsGroupData()
+{
+ effectId = 0;
+}
+
+void Spider::SpiderEffectsGroupData::setRandomEffect(Random *random)
+{
+ int selection = random->nextInt(5);
+ if (selection <= 1)
+ {
+ effectId = MobEffect::movementSpeed->id;
+ }
+ else if (selection <= 2)
+ {
+ effectId = MobEffect::damageBoost->id;
+ }
+ else if (selection <= 3)
+ {
+ effectId = MobEffect::regeneration->id;
+ }
+ else if (selection <= 4)
+ {
+ effectId = MobEffect::invisibility->id;
+ }
} \ No newline at end of file