diff --git a/Minecraft.World/ArmorItem.cpp b/Minecraft.World/ArmorItem.cpp index 8763564e..e5b7e571 100644 --- a/Minecraft.World/ArmorItem.cpp +++ b/Minecraft.World/ArmorItem.cpp @@ -265,9 +265,9 @@ Icon *ArmorItem::getEmptyIcon(int slot) return nullptr; } +// TU25 Addition shared_ptr ArmorItem::use(shared_ptr item, Level *level, shared_ptr player) { - //TODO Play Equip Sound if ((player->getArmor(Mob::getEquipmentSlotForItem(item) - 1)) == nullptr) { shared_ptr equip = item->copy(); diff --git a/Minecraft.World/Bat.cpp b/Minecraft.World/Bat.cpp index 462fef57..43b7bb8e 100644 --- a/Minecraft.World/Bat.cpp +++ b/Minecraft.World/Bat.cpp @@ -41,9 +41,8 @@ float Bat::getVoicePitch() int Bat::getAmbientSound() { if (isResting() && random->nextInt(4) != 0) - { return -1; - } + return eSoundType_MOB_BAT_IDLE; //"mob.bat.idle"; } @@ -89,13 +88,9 @@ void Bat::setResting(bool value) { char current = entityData->getByte(DATA_ID_FLAGS); if (value) - { entityData->set(DATA_ID_FLAGS, static_cast(current | FLAG_RESTING)); - } else - { entityData->set(DATA_ID_FLAGS, static_cast(current & ~FLAG_RESTING)); - } } bool Bat::useNewAi() @@ -105,7 +100,6 @@ bool Bat::useNewAi() void Bat::tick() { - AmbientCreature::tick(); if (isResting()) @@ -114,10 +108,7 @@ void Bat::tick() y = Mth::floor(y) + 1.0 - bbHeight; } else - { yd *= .6f; - } - } inline int signum(double x) { return (x > 0) - (x < 0); } @@ -135,11 +126,8 @@ void Bat::newServerAiStep() } else { - if (random->nextInt(200) == 0) - { yHeadRot = random->nextInt(360); - } if (level->getNearestPlayer(shared_from_this(), 4.0f) != nullptr) { @@ -176,10 +164,7 @@ void Bat::newServerAiStep() yRot += rotDiff; if (random->nextInt(100) == 0 && level->isSolidBlockingTile(Mth::floor(x), static_cast(y) + 1, Mth::floor(z))) - { setResting(true); - } - } } @@ -188,9 +173,7 @@ bool Bat::makeStepSound() return false; } -void Bat::causeFallDamage(float distance) -{ -} +void Bat::causeFallDamage(float distance) {} void Bat::checkFallDamage(double ya, bool onGround) { @@ -205,13 +188,13 @@ bool Bat::isIgnoringTileTriggers() bool Bat::hurt(DamageSource *source, float dmg) { - if (isInvulnerable()) return false; + if (isInvulnerable()) + return false; + if (!level->isClientSide) { if (isResting()) - { setResting(false); - } } return AmbientCreature::hurt(source, dmg); @@ -231,11 +214,11 @@ void Bat::addAdditonalSaveData(CompoundTag *entityTag) entityTag->putByte(L"BatFlags", entityData->getByte(DATA_ID_FLAGS)); } - bool Bat::canSpawn() { int yt = Mth::floor(bb->y0); - if (yt >= level->seaLevel) return false; + if (yt >= level->seaLevel) + return false; int xt = Mth::floor(x); int zt = Mth::floor(z); @@ -244,15 +227,18 @@ bool Bat::canSpawn() int maxLight = 4; if ((Calendar::GetDayOfMonth() + 1 == 10 && Calendar::GetDayOfMonth() >= 20) || (Calendar::GetMonth() + 1 == 11 && Calendar::GetMonth() <= 3)) - { maxLight = 7; - } else if (random->nextBoolean()) - { return false; - } - if (br > random->nextInt(maxLight)) return false; + if (br > random->nextInt(maxLight)) + return false; return AmbientCreature::canSpawn(); +} + +// TU25 Addition +float Bat::getEyeHeight() +{ + return bbHeight * 0.5f; } \ No newline at end of file diff --git a/Minecraft.World/Bat.h b/Minecraft.World/Bat.h index 118fc6ed..6a76a679 100644 --- a/Minecraft.World/Bat.h +++ b/Minecraft.World/Bat.h @@ -55,4 +55,6 @@ public: virtual void readAdditionalSaveData(CompoundTag *tag); virtual void addAdditonalSaveData(CompoundTag *entityTag); virtual bool canSpawn(); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/CaveSpider.cpp b/Minecraft.World/CaveSpider.cpp index d9396c43..61658a80 100644 --- a/Minecraft.World/CaveSpider.cpp +++ b/Minecraft.World/CaveSpider.cpp @@ -60,4 +60,10 @@ MobGroupData *CaveSpider::finalizeMobSpawn(MobGroupData *groupData, int extraDat { // do nothing return groupData; +} + +// TU25 Addition +float CaveSpider::getEyeHeight() +{ + return 0.45f; } \ No newline at end of file diff --git a/Minecraft.World/CaveSpider.h b/Minecraft.World/CaveSpider.h index 79824e68..d7c993b6 100644 --- a/Minecraft.World/CaveSpider.h +++ b/Minecraft.World/CaveSpider.h @@ -17,4 +17,6 @@ protected: public: virtual bool doHurtTarget(shared_ptr target); MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Chicken.cpp b/Minecraft.World/Chicken.cpp index 355d8a25..568beed0 100644 --- a/Minecraft.World/Chicken.cpp +++ b/Minecraft.World/Chicken.cpp @@ -155,3 +155,9 @@ bool Chicken::isFood(shared_ptr itemInstance) { return (itemInstance->id == Item::seeds_wheat_Id) || (itemInstance->id == Item::netherwart_seeds_Id) || (itemInstance->id == Item::seeds_melon_Id) || (itemInstance->id == Item::seeds_pumpkin_Id); } + +// TU25 Addition +float Chicken::getEyeHeight() +{ + return bbHeight; +} \ No newline at end of file diff --git a/Minecraft.World/Chicken.h b/Minecraft.World/Chicken.h index 0f406219..f4d176f2 100644 --- a/Minecraft.World/Chicken.h +++ b/Minecraft.World/Chicken.h @@ -43,5 +43,6 @@ protected: public: virtual shared_ptr getBreedOffspring(shared_ptr target); virtual bool isFood(shared_ptr itemInstance); - + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/Cow.cpp b/Minecraft.World/Cow.cpp index 69628d64..f45b3c17 100644 --- a/Minecraft.World/Cow.cpp +++ b/Minecraft.World/Cow.cpp @@ -136,3 +136,9 @@ shared_ptr Cow::getBreedOffspring(shared_ptr target) return nullptr; } } + +// TU25 Addition +float Cow::getEyeHeight() +{ + return bbHeight; +} diff --git a/Minecraft.World/Cow.h b/Minecraft.World/Cow.h index 24210631..8d50b17d 100644 --- a/Minecraft.World/Cow.h +++ b/Minecraft.World/Cow.h @@ -30,4 +30,6 @@ protected: public: virtual bool mobInteract(shared_ptr player); virtual shared_ptr getBreedOffspring(shared_ptr target); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/EnderMan.cpp b/Minecraft.World/EnderMan.cpp index da469a3a..b7b92e17 100644 --- a/Minecraft.World/EnderMan.cpp +++ b/Minecraft.World/EnderMan.cpp @@ -90,9 +90,7 @@ shared_ptr EnderMan::findAttackTarget() { #ifndef _FINAL_BUILD if(app.GetMobsDontAttackEnabled()) - { return shared_ptr(); - } #endif shared_ptr player = level->getNearestAttackablePlayer(shared_from_this(), 64); @@ -101,7 +99,8 @@ shared_ptr EnderMan::findAttackTarget() if (isLookingAtMe(player)) { aggroedByPlayer = true; - if (aggroTime == 0) level->playEntitySound(player, eSoundType_MOB_ENDERMAN_STARE, 1, 1); + if (aggroTime == 0) + level->playEntitySound(player, eSoundType_MOB_ENDERMAN_STARE, 1, 1); if (aggroTime++ == 5) { aggroTime = 0; @@ -110,9 +109,7 @@ shared_ptr EnderMan::findAttackTarget() } } else - { aggroTime = 0; - } } return nullptr; } @@ -120,7 +117,8 @@ shared_ptr EnderMan::findAttackTarget() bool EnderMan::isLookingAtMe(shared_ptr player) { shared_ptr helmet = player->inventory->armor[3]; - if (helmet != nullptr && helmet->id == Tile::pumpkin_Id) return false; + if (helmet != nullptr && helmet->id == Tile::pumpkin_Id) + return false; Vec3 *look = player->getViewVector(1)->normalize(); Vec3 *dir = Vec3::newTemp(x - player->x, (bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()), z - player->z); @@ -128,9 +126,8 @@ bool EnderMan::isLookingAtMe(shared_ptr player) dir = dir->normalize(); double dot = look->dot(dir); if (dot > 1 - 0.025 / dist) - { return player->canSee(shared_from_this()); - } + return false; } @@ -144,9 +141,7 @@ void EnderMan::aiStep() speed->removeModifier(SPEED_MODIFIER_ATTACKING); if (attackTarget != nullptr) - { speed->addModifier(new AttributeModifier(*SPEED_MODIFIER_ATTACKING)); - } } lastAttackTarget = attackTarget; @@ -190,7 +185,6 @@ void EnderMan::aiStep() } } - for (int i = 0; i < 2; i++) { level->addParticle(eParticleType_ender, x + (random->nextDouble() - 0.5) * bbWidth, y + random->nextDouble() * bbHeight - 0.25f, z + (random->nextDouble() - 0.5) * bbWidth, @@ -221,15 +215,11 @@ void EnderMan::aiStep() } if (isCreepy() && !aggroedByPlayer && random->nextInt(100) == 0) - { setCreepy(false); - } jumping = false; if (attackTarget != nullptr) - { lookAt(attackTarget, 100, 100); - } if (!level->isClientSide && isAlive()) { @@ -238,9 +228,8 @@ void EnderMan::aiStep() if ( attackTarget->instanceof(eTYPE_PLAYER) && isLookingAtMe(dynamic_pointer_cast(attackTarget))) { if (attackTarget->distanceToSqr(shared_from_this()) < 4 * 4) - { teleport(); - } + teleportTime = 0; } else if (attackTarget->distanceToSqr(shared_from_this()) > 16 * 16) @@ -248,9 +237,7 @@ void EnderMan::aiStep() if (teleportTime++ >= 30) { if (teleportTowards(attackTarget)) - { teleportTime = 0; - } } } } @@ -309,21 +296,16 @@ bool EnderMan::teleport(double xx, double yy, double zz) yt--; } else - { landed = true; - } } if (landed) { setPos(x, y, z); if (level->getCubes(shared_from_this(), bb)->empty() && !level->containsAnyLiquid(bb)) - { ok = true; - } } } - if (ok) { int count = 128; @@ -411,22 +393,17 @@ bool EnderMan::hurt(DamageSource *source, float damage) if ( dynamic_cast(source) != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER)) { if (!dynamic_pointer_cast(source->getEntity())->abilities.invulnerable) - { aggroedByPlayer = true; - } else setCreepy(false); } - if (dynamic_cast(source) != nullptr) { aggroedByPlayer = false; for (int i = 0; i < 64; i++) { if (teleport()) - { return true; - } } return false; } @@ -441,4 +418,10 @@ bool EnderMan::isCreepy() void EnderMan::setCreepy(bool creepy) { entityData->set(DATA_CREEPY, static_cast(creepy ? 1 : 0)); +} + +// TU25 Addition +float EnderMan::getEyeHeight() +{ + return 2.55f; } \ No newline at end of file diff --git a/Minecraft.World/EnderMan.h b/Minecraft.World/EnderMan.h index 10fb2b37..90f6b91d 100644 --- a/Minecraft.World/EnderMan.h +++ b/Minecraft.World/EnderMan.h @@ -63,4 +63,6 @@ public: virtual bool hurt(DamageSource *source, float damage); bool isCreepy(); void setCreepy(bool creepy); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 83f626e6..94c3ecb9 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -2116,6 +2116,28 @@ wstring Entity::getNetworkName() return getDisplayName(); } +// TU25 Addition +bool Entity::hasCustomName() +{ + return false; +} +bool Entity::shouldShowName() +{ + return false; +} +AABB *Entity::getBoundingBox() +{ + return this->bb; +} +void Entity::setBoundingBox(AABB *bb) +{ + this->bb = bb; +} +float Entity::getEyeHeight() +{ + return this->bbHeight * 0.85F; +} + void Entity::setAnimOverrideBitmask(unsigned int uiBitmask) { m_uiAnimOverrideBitmask=uiBitmask; diff --git a/Minecraft.World/Entity.h b/Minecraft.World/Entity.h index a738c2ba..5e5c7162 100644 --- a/Minecraft.World/Entity.h +++ b/Minecraft.World/Entity.h @@ -419,6 +419,12 @@ public: virtual bool isPushedByWater(); virtual wstring getDisplayName(); virtual wstring getNetworkName(); // 4J: Added + //TU25 Addition + virtual bool hasCustomName(); + virtual bool shouldShowName(); + virtual AABB *getBoundingBox(); + virtual void setBoundingBox(AABB *bb); + virtual float getEyeHeight(); private: unsigned int m_uiAnimOverrideBitmask; diff --git a/Minecraft.World/EntityHorse.cpp b/Minecraft.World/EntityHorse.cpp index f4b4ea26..5bb5ced1 100644 --- a/Minecraft.World/EntityHorse.cpp +++ b/Minecraft.World/EntityHorse.cpp @@ -1841,4 +1841,10 @@ bool EntityHorse::onLadder() shared_ptr EntityHorse::getOwner() { return level->getPlayerByUUID(getOwnerName()); +} + +// TU25 Addition +float EntityHorse::getEyeHeight() +{ + return bbHeight; } \ No newline at end of file diff --git a/Minecraft.World/EntityHorse.h b/Minecraft.World/EntityHorse.h index 6a71a3bc..e842e6b2 100644 --- a/Minecraft.World/EntityHorse.h +++ b/Minecraft.World/EntityHorse.h @@ -342,4 +342,6 @@ public: static bool isHorseArmor(int itemId); virtual bool onLadder(); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Ghast.cpp b/Minecraft.World/Ghast.cpp index 738a42da..61f6a385 100644 --- a/Minecraft.World/Ghast.cpp +++ b/Minecraft.World/Ghast.cpp @@ -15,8 +15,6 @@ #include "LevelEvent.h" #include "SoundTypes.h" - - void Ghast::_init() { explosionPower = 1; @@ -121,14 +119,13 @@ void Ghast::serverAiStep() } } - if (target != nullptr && target->removed) target = nullptr; + if (target != nullptr && target->removed) + target = nullptr; if (target == nullptr || retargetTime-- <= 0) { target = level->getNearestAttackablePlayer(shared_from_this(), 100); if (target != nullptr) - { retargetTime = 20; - } } double maxDist = 64.0f; @@ -162,10 +159,8 @@ void Ghast::serverAiStep() charge = -40; } } - else - { - if (charge > 0) charge--; - } + else if (charge > 0) + charge--; } else { @@ -178,9 +173,7 @@ void Ghast::serverAiStep() byte old = entityData->getByte(DATA_IS_CHARGING); byte current = static_cast(charge > 10 ? 1 : 0); if (old != current) - { entityData->set(DATA_IS_CHARGING, current); - } } } @@ -224,14 +217,11 @@ void Ghast::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) { int count = random->nextInt(2) + random->nextInt(1 + playerBonusLevel); for (int i = 0; i < count; i++) - { spawnAtLocation(Item::ghastTear_Id, 1); - } + count = random->nextInt(3) + random->nextInt(1 + playerBonusLevel); for (int i = 0; i < count; i++) - { spawnAtLocation(Item::gunpowder_Id, 1); - } } float Ghast::getSoundVolume() @@ -248,6 +238,7 @@ int Ghast::getMaxSpawnClusterSize() { return 1; } + void Ghast::addAdditonalSaveData(CompoundTag *tag) { FlyingMob::addAdditonalSaveData(tag); @@ -258,4 +249,10 @@ void Ghast::readAdditionalSaveData(CompoundTag *tag) { FlyingMob::readAdditionalSaveData(tag); if (tag->contains(L"ExplosionPower")) explosionPower = tag->getInt(L"ExplosionPower"); +} + +// TU25 Addition +float Ghast::getEyeHeight() +{ + return 2.6f; } \ No newline at end of file diff --git a/Minecraft.World/Ghast.h b/Minecraft.World/Ghast.h index f19f737c..329821c3 100644 --- a/Minecraft.World/Ghast.h +++ b/Minecraft.World/Ghast.h @@ -63,4 +63,6 @@ public: virtual int getMaxSpawnClusterSize(); virtual void addAdditonalSaveData(CompoundTag *tag); virtual void readAdditionalSaveData(CompoundTag *tag); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/Giant.cpp b/Minecraft.World/Giant.cpp index dbb790bf..f762a17b 100644 --- a/Minecraft.World/Giant.cpp +++ b/Minecraft.World/Giant.cpp @@ -5,8 +5,6 @@ #include "Giant.h" #include "..\Minecraft.Client\Textures.h" - - Giant::Giant(Level *level) : Monster( level ) { // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that @@ -30,4 +28,10 @@ void Giant::registerAttributes() float Giant::getWalkTargetValue(int x, int y, int z) { return level->getBrightness(x, y, z)-0.5f; +} + +// TU25 Addition +float Giant::getEyeHeight() +{ + return 1.62f * 6.0f; } \ No newline at end of file diff --git a/Minecraft.World/Giant.h b/Minecraft.World/Giant.h index 478de94c..e7cf779f 100644 --- a/Minecraft.World/Giant.h +++ b/Minecraft.World/Giant.h @@ -18,4 +18,6 @@ protected: public: virtual float getWalkTargetValue(int x, int y, int z); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/LeashFenceKnotEntity.cpp b/Minecraft.World/LeashFenceKnotEntity.cpp index f94bcba7..99f5a9c9 100644 --- a/Minecraft.World/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/LeashFenceKnotEntity.cpp @@ -154,4 +154,10 @@ shared_ptr LeashFenceKnotEntity::findKnotAt(Level *level, delete knots; } return nullptr; +} + +// TU25 Addition +float LeashFenceKnotEntity::getEyeHeight() +{ + return -0.0625f; } \ No newline at end of file diff --git a/Minecraft.World/LeashFenceKnotEntity.h b/Minecraft.World/LeashFenceKnotEntity.h index 1bf3a7b7..64f2f77c 100644 --- a/Minecraft.World/LeashFenceKnotEntity.h +++ b/Minecraft.World/LeashFenceKnotEntity.h @@ -33,4 +33,6 @@ public: virtual bool survives(); static shared_ptr createAndAddKnot(Level *level, int x, int y, int z); static shared_ptr findKnotAt(Level *level, int x, int y, int z); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index 88c0e384..f408605d 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -1815,56 +1815,48 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z, bool bTes } if (isRiding()) - { ride(nullptr); - } setSize(0.2f, 0.2f); heightOffset = .2f; if (level->hasChunkAt(x, y, z)) { - - int data = level->getData(x, y, z); int direction = BedTile::getDirection(data); float xo = .5f, zo = .5f; switch (direction) { - case Direction::SOUTH: - zo = .9f; + case Direction::SOUTH: + zo = .9f; break; - case Direction::NORTH: - zo = .1f; + case Direction::NORTH: + zo = .1f; break; - case Direction::WEST: - xo = .1f; + case Direction::WEST: + xo = .1f; break; - case Direction::EAST: - xo = .9f; + case Direction::EAST: + xo = .9f; break; } setBedOffset(direction); setPos(x + xo, y + 15.0f / 16.0f, z + zo); } else - { setPos(x + .5f, y + 15.0f / 16.0f, z + .5f); - } + m_isSleeping = true; sleepCounter = 0; bedPosition = new Pos(x, y, z); xd = zd = yd = 0; if (!level->isClientSide) - { level->updateSleepingPlayerList(); - } return OK; } - void Player::setBedOffset(int bedDirection) { // place position on pillow and feet at bottom @@ -1873,22 +1865,21 @@ void Player::setBedOffset(int bedDirection) switch (bedDirection) { - case Direction::SOUTH: - bedOffsetZ = -1.8f; + case Direction::SOUTH: + bedOffsetZ = -1.8f; break; - case Direction::NORTH: - bedOffsetZ = 1.8f; + case Direction::NORTH: + bedOffsetZ = 1.8f; break; - case Direction::WEST: - bedOffsetX = 1.8f; + case Direction::WEST: + bedOffsetX = 1.8f; break; - case Direction::EAST: - bedOffsetX = -1.8f; + case Direction::EAST: + bedOffsetX = -1.8f; break; } } - /** * * @param forcefulWakeUp @@ -1903,7 +1894,6 @@ void Player::setBedOffset(int bedDirection) */ void Player::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint) { - setSize(0.6f, 1.8f); setDefaultHeadHeight(); @@ -1915,38 +1905,29 @@ void Player::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool save standUp = BedTile::findStandUpPosition(level, pos->x, pos->y, pos->z, 0); if (standUp == nullptr) - { standUp = new Pos(pos->x, pos->y + 1, pos->z); - } + setPos(standUp->x + .5f, standUp->y + heightOffset + .1f, standUp->z + .5f); } m_isSleeping = false; if (!level->isClientSide && updateLevelList) - { level->updateSleepingPlayerList(); - } - if (forcefulWakeUp) - { - sleepCounter = 0; - } - else - { - sleepCounter = SLEEP_DURATION; - } - if (saveRespawnPoint) - { - setRespawnPosition(bedPosition, false); - } -} + if (forcefulWakeUp) + sleepCounter = 0; + else + sleepCounter = SLEEP_DURATION; + + if (saveRespawnPoint) + setRespawnPosition(bedPosition, false); +} bool Player::checkBed() { return (level->getTile(bedPosition->x, bedPosition->y, bedPosition->z) == Tile::bed_Id); } - Pos *Player::checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced) { // make sure the chunks around the bed exist @@ -1965,9 +1946,8 @@ Pos *Player::checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced) bool freeHead = !topMaterial->isSolid() && !topMaterial->isLiquid(); if (forced && freeFeet && freeHead) - { return pos; - } + return nullptr; } // make sure the bed still has a stand-up position @@ -1984,14 +1964,14 @@ float Player::getSleepRotation() switch (direction) { - case Direction::SOUTH: - return 90; - case Direction::WEST: - return 0; - case Direction::NORTH: - return 270; - case Direction::EAST: - return 180; + case Direction::SOUTH: + return 90; + case Direction::WEST: + return 0; + case Direction::NORTH: + return 270; + case Direction::EAST: + return 180; } } return 0; @@ -2027,25 +2007,17 @@ void Player::setPlayerFlag(int flag, bool value) { byte currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID); if (value) - { entityData->set(DATA_PLAYER_FLAGS_ID, static_cast(currentValue | (1 << flag))); - } else - { entityData->set(DATA_PLAYER_FLAGS_ID, static_cast(currentValue & ~(1 << flag))); - } } - /** * This method is currently only relevant to client-side players. It will * try to load the messageId from the language file and display it to the * client. */ -void Player::displayClientMessage(int messageId) -{ - -} +void Player::displayClientMessage(int messageId) {} Pos *Player::getRespawnPosition() { @@ -2074,12 +2046,9 @@ void Player::setRespawnPosition(Pos *respawnPosition, bool forced) void Player::awardStat(Stat *stat, byteArray paramBlob) { if (paramBlob.data != nullptr) - { delete [] paramBlob.data; - } } - void Player::jumpFromGround() { LivingEntity::jumpFromGround(); @@ -2088,16 +2057,11 @@ void Player::jumpFromGround() //awardStat(Stats::jump, 1); if (isSprinting()) - { causeFoodExhaustion(FoodConstants::EXHAUSTION_SPRINT_JUMP); - } else - { causeFoodExhaustion(FoodConstants::EXHAUSTION_JUMP); - } } - void Player::travel(float xa, float ya) { double preX = x, preY = y, preZ = z; @@ -2112,9 +2076,7 @@ void Player::travel(float xa, float ya) flyingSpeed = ofs; } else - { LivingEntity::travel(xa, ya); - } checkMovementStatistiscs(x - preX, y - preY, z - preZ); } @@ -2126,11 +2088,9 @@ float Player::getSpeed() void Player::checkMovementStatistiscs(double dx, double dy, double dz) { - if (riding != nullptr) - { return; - } + if (isUnderLiquid(Material::water)) { int distance = static_cast(Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f)); @@ -2181,18 +2141,13 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz) awardStat( GenericStats::walkOneM(), GenericStats::param_walk(newDistance/100) ); } if (isSprinting()) - { causeFoodExhaustion(FoodConstants::EXHAUSTION_SPRINT * horizontalDistance * .01f); - } else - { causeFoodExhaustion(FoodConstants::EXHAUSTION_WALK * horizontalDistance * .01f); - } } } } - void Player::checkRidingStatistiscs(double dx, double dy, double dz) { if (riding != nullptr) @@ -2212,9 +2167,8 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) int dist = 0; if (minecartAchievementPos == nullptr) - { minecartAchievementPos = new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z)); - } + // 4J-PB - changed this because our world isn't big enough to go 1000m else { @@ -2227,9 +2181,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) if(dist < 500) { if((dist>0) && (dist%100==0)) - { awardStat(GenericStats::onARail(), GenericStats::param_onARail(dist)); - } } else { @@ -2271,7 +2223,6 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) } } - void Player::causeFallDamage(float distance) { if (abilities.mayfly) return; @@ -2289,7 +2240,6 @@ void Player::causeFallDamage(float distance) LivingEntity::causeFallDamage(distance); } - void Player::killed(shared_ptr mob) { // 4J-PB - added the lavaslime enemy - fix for #64007 - TU7: Code: Achievements: TCR#073: Killing Magma Cubes doesn't unlock "Monster Hunter" Achievement. @@ -2299,78 +2249,67 @@ void Player::killed(shared_ptr mob) switch( mob->GetType() ) { - case eTYPE_CREEPER: - awardStat(GenericStats::killsCreeper(), GenericStats::param_noArgs()); + case eTYPE_CREEPER: + awardStat(GenericStats::killsCreeper(), GenericStats::param_noArgs()); break; - case eTYPE_SKELETON: - if( mob->isRiding() && mob->riding->GetType() == eTYPE_SPIDER ) - awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs()); - else - awardStat(GenericStats::killsSkeleton(), GenericStats::param_noArgs()); + case eTYPE_SKELETON: + if( mob->isRiding() && mob->riding->GetType() == eTYPE_SPIDER ) + awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs()); + else + awardStat(GenericStats::killsSkeleton(), GenericStats::param_noArgs()); break; - case eTYPE_SPIDER: - if( mob->rider.lock() != nullptr && mob->rider.lock()->GetType() == eTYPE_SKELETON ) - awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs()); - else - awardStat(GenericStats::killsSpider(), GenericStats::param_noArgs()); + case eTYPE_SPIDER: + if( mob->rider.lock() != nullptr && mob->rider.lock()->GetType() == eTYPE_SKELETON ) + awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs()); + else + awardStat(GenericStats::killsSpider(), GenericStats::param_noArgs()); break; - case eTYPE_ZOMBIE: - awardStat(GenericStats::killsZombie(), GenericStats::param_noArgs()); + case eTYPE_ZOMBIE: + awardStat(GenericStats::killsZombie(), GenericStats::param_noArgs()); break; - case eTYPE_PIGZOMBIE: - if( level->dimension->id == 0 ) - awardStat(GenericStats::killsZombiePigman(), GenericStats::param_noArgs()); - else - awardStat(GenericStats::killsNetherZombiePigman(), GenericStats::param_noArgs()); + case eTYPE_PIGZOMBIE: + if( level->dimension->id == 0 ) + awardStat(GenericStats::killsZombiePigman(), GenericStats::param_noArgs()); + else + awardStat(GenericStats::killsNetherZombiePigman(), GenericStats::param_noArgs()); break; - case eTYPE_GHAST: - awardStat(GenericStats::killsGhast(), GenericStats::param_noArgs()); + case eTYPE_GHAST: + awardStat(GenericStats::killsGhast(), GenericStats::param_noArgs()); break; - case eTYPE_SLIME: - awardStat(GenericStats::killsSlime(), GenericStats::param_noArgs()); + case eTYPE_SLIME: + awardStat(GenericStats::killsSlime(), GenericStats::param_noArgs()); break; - case eTYPE_ENDERDRAGON: - awardStat(GenericStats::killsEnderdragon(), GenericStats::param_noArgs()); + case eTYPE_ENDERDRAGON: + awardStat(GenericStats::killsEnderdragon(), GenericStats::param_noArgs()); break; } } else if( mob->GetType() == eTYPE_COW ) - { awardStat(GenericStats::killCow(), GenericStats::param_noArgs()); - } } void Player::makeStuckInWeb() { - if (!abilities.flying) LivingEntity::makeStuckInWeb(); + if (!abilities.flying) + LivingEntity::makeStuckInWeb(); } Icon *Player::getItemInHandIcon(shared_ptr item, int layer) { Icon *icon = LivingEntity::getItemInHandIcon(item, layer); if (item->id == Item::fishingRod->id && fishing != nullptr) - { icon = Item::fishingRod->getEmptyIcon(); - } else if (item->getItem()->hasMultipleSpriteLayers()) - { return item->getItem()->getLayerIcon(item->getAuxValue(), layer); - } else if (useItem != nullptr && item->id == Item::bow_Id) { int ticksHeld = (item->getUseDuration() - useItemDuration); if (ticksHeld >= BowItem::MAX_DRAW_DURATION - 2) - { return Item::bow->getDrawnIcon(2); - } if (ticksHeld > (2 * BowItem::MAX_DRAW_DURATION) / 3) - { return Item::bow->getDrawnIcon(1); - } if (ticksHeld > 0) - { return Item::bow->getDrawnIcon(0); - } } return icon; } @@ -2385,9 +2324,8 @@ void Player::increaseXp(int i) increaseScore(i); int max = INT_MAX - totalExperience; if (i > max) - { i = max; - } + experienceProgress += static_cast(i) / getXpNeededForNextLevel(); totalExperience += i; while (experienceProgress >= 1) @@ -2420,13 +2358,11 @@ int Player::getXpNeededForNextLevel() { // Update xp calculations from 1.3 if (experienceLevel >= 30) - { return 17 + 15 * 3 + (experienceLevel - 30) * 7; - } + if (experienceLevel >= 15) - { return 17 + (experienceLevel - 15) * 3; - } + return 17; } @@ -2441,16 +2377,17 @@ int Player::getXpNeededForNextLevel() */ void Player::causeFoodExhaustion(float amount) { - if( isAllowedToIgnoreExhaustion() || ( isAllowedToFly() && abilities.flying) ) return; - if (abilities.invulnerable || hasInvulnerablePrivilege() ) return; + if( isAllowedToIgnoreExhaustion() || ( isAllowedToFly() && abilities.flying) ) + return; + if (abilities.invulnerable || hasInvulnerablePrivilege() ) + return; // 4J Stu - Added 1.8.2 bug fix (TU6) - If players cannot eat, then their food bar should not decrease due to exhaustion - if(app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) return; + if(app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) + return; if (!level->isClientSide) - { foodData.addExhaustion(amount); - } } FoodData *Player::getFoodData() @@ -2470,13 +2407,14 @@ bool Player::isHurt() void Player::startUsingItem(shared_ptr instance, int duration) { - if (instance == useItem) return; + if (instance == useItem) + return; + useItem = instance; useItemDuration = duration; + if (!level->isClientSide) - { setUsingItemFlag(true); - } // 4J-JEV, hook for ItemUsed event, and ironbelly achievement. awardStat(GenericStats::itemsUsed(instance->getItem()->id), @@ -2496,25 +2434,21 @@ bool Player::mayBuild() bool Player::mayDestroyBlockAt(int x, int y, int z) { if (abilities.mayBuild) - { return true; - } + int t = level->getTile(x, y, z); - if (t > 0) { + if (t > 0) + { Tile *tile = Tile::tiles[t]; if (tile->material->isDestroyedByHand()) - { return true; - } else if (getSelectedItem() != nullptr) { shared_ptr carried = getSelectedItem(); if (carried->canDestroySpecial(tile) || carried->getDestroySpeed(tile) > 1) - { return true; - } } } return false; @@ -2523,24 +2457,22 @@ bool Player::mayDestroyBlockAt(int x, int y, int z) bool Player::mayUseItemAt(int x, int y, int z, int face, shared_ptr item) { if (abilities.mayBuild) - { return true; - } if (item != nullptr) - { return item->mayBePlacedInAdventureMode(); - } + return false; } int Player::getExperienceReward(shared_ptr killedBy) { - if (level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) return 0; + if (level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) + return 0; + int reward = experienceLevel * 7; if (reward > 100) - { return 100; - } + return reward; } @@ -2593,13 +2525,9 @@ bool Player::makeStepSound() return !abilities.flying; } -void Player::onUpdateAbilities() -{ -} +void Player::onUpdateAbilities() {} -void Player::setGameMode(GameType *mode) -{ -} +void Player::setGameMode(GameType *mode) {} wstring Player::getName() { @@ -2687,29 +2615,43 @@ float Player::getAbsorptionAmount() return getEntityData()->getFloat(DATA_PLAYER_ABSORPTION_ID); } +// TU25 Addition +float Player::getEyeHeight() +{ + //TODO: Need the LCE one. This is from java + float f = 1.62F; + + if (isSleeping()) + f = 0.2F; + + if (isSneaking()) + f -= 0.08F; + + return f; +} + int Player::getTexture() { switch(m_skinIndex) { - case eDefaultSkins_Skin0: - return TN_MOB_CHAR; // 4J - was L"/mob/char.png"; - case eDefaultSkins_Skin1: - return TN_MOB_CHAR1; // 4J - was L"/mob/char1.png"; - case eDefaultSkins_Skin2: - return TN_MOB_CHAR2; // 4J - was L"/mob/char2.png"; - case eDefaultSkins_Skin3: - return TN_MOB_CHAR3; // 4J - was L"/mob/char3.png"; - case eDefaultSkins_Skin4: - return TN_MOB_CHAR4; // 4J - was L"/mob/char4.png"; - case eDefaultSkins_Skin5: - return TN_MOB_CHAR5; // 4J - was L"/mob/char5.png"; - case eDefaultSkins_Skin6: - return TN_MOB_CHAR6; // 4J - was L"/mob/char6.png"; - case eDefaultSkins_Skin7: - return TN_MOB_CHAR7; // 4J - was L"/mob/char7.png"; - - default: - return TN_MOB_CHAR; // 4J - was L"/mob/char.png"; + case eDefaultSkins_Skin0: + return TN_MOB_CHAR; // 4J - was L"/mob/char.png"; + case eDefaultSkins_Skin1: + return TN_MOB_CHAR1; // 4J - was L"/mob/char1.png"; + case eDefaultSkins_Skin2: + return TN_MOB_CHAR2; // 4J - was L"/mob/char2.png"; + case eDefaultSkins_Skin3: + return TN_MOB_CHAR3; // 4J - was L"/mob/char3.png"; + case eDefaultSkins_Skin4: + return TN_MOB_CHAR4; // 4J - was L"/mob/char4.png"; + case eDefaultSkins_Skin5: + return TN_MOB_CHAR5; // 4J - was L"/mob/char5.png"; + case eDefaultSkins_Skin6: + return TN_MOB_CHAR6; // 4J - was L"/mob/char6.png"; + case eDefaultSkins_Skin7: + return TN_MOB_CHAR7; // 4J - was L"/mob/char7.png"; + default: + return TN_MOB_CHAR; // 4J - was L"/mob/char.png"; } } @@ -2729,7 +2671,6 @@ bool Player::eq_test(const shared_ptr x, const shared_ptr y) return x->name.compare( y->name ) == 0; // 4J Stu - Names are completely unique? } - unsigned int Player::getPlayerGamePrivilege(EPlayerGamePrivileges privilege) { return Player::getPlayerGamePrivilege(m_uiGamePrivileges,privilege); @@ -2738,13 +2679,10 @@ unsigned int Player::getPlayerGamePrivilege(EPlayerGamePrivileges privilege) unsigned int Player::getPlayerGamePrivilege(unsigned int uiGamePrivileges, EPlayerGamePrivileges privilege) { if( privilege == ePlayerGamePrivilege_All ) - { return uiGamePrivileges; - } else if (privilege < ePlayerGamePrivilege_MAX ) - { return uiGamePrivileges&(1<id) { - case Tile::button_stone_Id: - case Tile::button_wood_Id: - case Tile::lever_Id: - case Tile::trapdoor_Id: - case Tile::iron_trapdoor_Id: - case Tile::comparator_off_Id: - case Tile::comparator_on_Id: - case Tile::daylightDetector_Id: - case Tile::daylightDetectorInverted_Id: - allowed = true; - break; - default: - allowed = DoorTile::isDoor(tile->id) || FenceGateTile::isFenceGate(tile->id); - break; + case Tile::button_stone_Id: + case Tile::button_wood_Id: + case Tile::lever_Id: + case Tile::trapdoor_Id: + case Tile::iron_trapdoor_Id: + case Tile::comparator_off_Id: + case Tile::comparator_on_Id: + case Tile::daylightDetector_Id: + case Tile::daylightDetectorInverted_Id: + allowed = true; + break; + default: + allowed = DoorTile::isDoor(tile->id) || FenceGateTile::isFenceGate(tile->id); + break; } } @@ -2840,20 +2772,20 @@ bool Player::isAllowedToUse(Tile *tile) { switch(tile->id) { - case Tile::dispenser_Id: - case Tile::chest_Id: - case Tile::furnace_Id: - case Tile::furnace_lit_Id: - case Tile::workBench_Id: - case Tile::enchantTable_Id: - case Tile::brewingStand_Id: - case Tile::enderChest_Id: - case Tile::beacon_Id: - case Tile::anvil_Id: - case Tile::chest_trap_Id: - case Tile::hopper_Id: - case Tile::dropper_Id: - allowed = true; + case Tile::dispenser_Id: + case Tile::chest_Id: + case Tile::furnace_Id: + case Tile::furnace_lit_Id: + case Tile::workBench_Id: + case Tile::enchantTable_Id: + case Tile::brewingStand_Id: + case Tile::enderChest_Id: + case Tile::beacon_Id: + case Tile::anvil_Id: + case Tile::chest_trap_Id: + case Tile::hopper_Id: + case Tile::dropper_Id: + allowed = true; break; } } @@ -2862,32 +2794,32 @@ bool Player::isAllowedToUse(Tile *tile) { switch(tile->id) { - case Tile::button_stone_Id: - case Tile::button_wood_Id: - case Tile::lever_Id: - case Tile::trapdoor_Id: - case Tile::iron_trapdoor_Id: - case Tile::comparator_off_Id: - case Tile::comparator_on_Id: - case Tile::daylightDetector_Id: - case Tile::daylightDetectorInverted_Id: - case Tile::dispenser_Id: - case Tile::chest_Id: - case Tile::furnace_Id: - case Tile::furnace_lit_Id: - case Tile::workBench_Id: - case Tile::enchantTable_Id: - case Tile::brewingStand_Id: - case Tile::enderChest_Id: - case Tile::beacon_Id: - case Tile::anvil_Id: - case Tile::chest_trap_Id: - case Tile::hopper_Id: - case Tile::dropper_Id: - allowed = false; + case Tile::button_stone_Id: + case Tile::button_wood_Id: + case Tile::lever_Id: + case Tile::trapdoor_Id: + case Tile::iron_trapdoor_Id: + case Tile::comparator_off_Id: + case Tile::comparator_on_Id: + case Tile::daylightDetector_Id: + case Tile::daylightDetectorInverted_Id: + case Tile::dispenser_Id: + case Tile::chest_Id: + case Tile::furnace_Id: + case Tile::furnace_lit_Id: + case Tile::workBench_Id: + case Tile::enchantTable_Id: + case Tile::brewingStand_Id: + case Tile::enderChest_Id: + case Tile::beacon_Id: + case Tile::anvil_Id: + case Tile::chest_trap_Id: + case Tile::hopper_Id: + case Tile::dropper_Id: + allowed = false; break; - default: - allowed = !(DoorTile::isDoor(tile->id) || FenceGateTile::isFenceGate(tile->id)); + default: + allowed = !(DoorTile::isDoor(tile->id) || FenceGateTile::isFenceGate(tile->id)); break; } } @@ -2902,37 +2834,35 @@ bool Player::isAllowedToUse(shared_ptr item) if(item != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { if(getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) - { allowed = false; - } // 4J Stu - TU8 Players should always be able to eat food items, even if the build option is turned of switch(item->id) { // food - case Item::mushroomStew_Id: - case Item::apple_Id: - case Item::bread_Id: - case Item::porkChop_raw_Id: - case Item::porkChop_cooked_Id: - case Item::apple_gold_Id: - case Item::fish_raw_Id: - case Item::fish_cooked_Id: - case Item::cookie_Id: - case Item::beef_cooked_Id: - case Item::beef_raw_Id: - case Item::chicken_cooked_Id: - case Item::chicken_raw_Id: - case Item::melon_Id: - case Item::rotten_flesh_Id: + case Item::mushroomStew_Id: + case Item::apple_Id: + case Item::bread_Id: + case Item::porkChop_raw_Id: + case Item::porkChop_cooked_Id: + case Item::apple_gold_Id: + case Item::fish_raw_Id: + case Item::fish_cooked_Id: + case Item::cookie_Id: + case Item::beef_cooked_Id: + case Item::beef_raw_Id: + case Item::chicken_cooked_Id: + case Item::chicken_raw_Id: + case Item::melon_Id: + case Item::rotten_flesh_Id: // bow - case Item::bow_Id: - case Item::sword_diamond_Id: - case Item::sword_gold_Id: - case Item::sword_iron_Id: - case Item::sword_stone_Id: - case Item::sword_wood_Id: - allowed = true; + case Item::bow_Id: + case Item::sword_diamond_Id: + case Item::sword_gold_Id: + case Item::sword_iron_Id: + case Item::sword_stone_Id: + case Item::sword_wood_Id: + allowed = true; break; } } @@ -2958,14 +2888,10 @@ bool Player::isAllowedToInteract(shared_ptr target) else { if(getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) - { allowed = false; - } if(getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotMine) != 0) - { allowed = false; - } } } @@ -2978,9 +2904,7 @@ bool Player::isAllowedToMine() if(app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { if(getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotMine) != 0) - { allowed = false; - } } return allowed; } @@ -2989,9 +2913,8 @@ bool Player::isAllowedToAttackPlayers() { bool allowed = true; if( hasInvisiblePrivilege() || ((app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotAttackPlayers)) ) - { allowed = false; - } + return allowed; } @@ -2999,9 +2922,8 @@ bool Player::isAllowedToAttackAnimals() { bool allowed = true; if( (app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotAttackAnimals) ) - { allowed = false; - } + return allowed; } @@ -3013,16 +2935,14 @@ bool Player::isAllowedToHurtEntity(shared_ptr target) { switch(target->GetType()) { - case eTYPE_HANGING_ENTITY: - case eTYPE_PAINTING: - case eTYPE_ITEM_FRAME: - - // 4J-JEV: Fix for #88212, - // Untrusted players shouldn't be able to damage minecarts or boats. - case eTYPE_BOAT: - case eTYPE_MINECART: - - allowed = false; + case eTYPE_HANGING_ENTITY: + case eTYPE_PAINTING: + case eTYPE_ITEM_FRAME: + // 4J-JEV: Fix for #88212, + // Untrusted players shouldn't be able to damage minecarts or boats. + case eTYPE_BOAT: + case eTYPE_MINECART: + allowed = false; break; }; } @@ -3033,20 +2953,17 @@ bool Player::isAllowedToFly() { bool allowed = false; if(app.GetGameHostOption(eGameHostOption_HostCanFly) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CanFly) != 0) - { allowed = true; - } + return allowed; } bool Player::isAllowedToIgnoreExhaustion() { bool allowed = false; - if( (app.GetGameHostOption(eGameHostOption_HostCanChangeHunger) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_ClassicHunger) != 0) || - (isAllowedToFly() && abilities.flying) ) - { + if( (app.GetGameHostOption(eGameHostOption_HostCanChangeHunger) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_ClassicHunger) != 0) || (isAllowedToFly() && abilities.flying) ) allowed = true; - } + return allowed; } @@ -3054,9 +2971,8 @@ bool Player::isAllowedToTeleport() { bool allowed = false; if( isModerator() && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CanTeleport) != 0) - { allowed = true; - } + return allowed; } @@ -3064,9 +2980,8 @@ bool Player::hasInvisiblePrivilege() { bool enabled = false; if(app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_Invisible) != 0) - { enabled = true; - } + return enabled; } @@ -3074,9 +2989,8 @@ bool Player::hasInvulnerablePrivilege() { bool enabled = false; if(app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_Invulnerable) != 0) - { enabled = true; - } + return enabled; } @@ -3117,9 +3031,8 @@ vector *Player::GetAdditionalModelParts() // If it's a default texture (which has no parts), we have the parts, or we already have the texture (in which case we should have parts if there are any) then we are done if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppAdditionalModelParts != nullptr || app.IsFileInMemoryTextures(customTextureUrl)) - { m_bCheckedForModelParts=true; - } + if(m_ppAdditionalModelParts == nullptr && !m_bCheckedDLCForModelParts) { m_bCheckedDLCForModelParts = true; @@ -3165,13 +3078,8 @@ Player::ePlayerNameValidState Player::GetPlayerNameValidState(void) void Player::SetPlayerNameValidState(bool bState) { if(bState) - { m_ePlayerNameValidState=ePlayerNameValid_True; - } else - { m_ePlayerNameValidState=ePlayerNameValid_False; - - } } -#endif +#endif \ No newline at end of file diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 4b7bc4e1..d73d556d 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -390,6 +390,8 @@ public: virtual Team *getTeam(); virtual void setAbsorptionAmount(float absorptionAmount); virtual float getAbsorptionAmount(); + // TU25 Addition + virtual float getEyeHeight(); //////// 4J ///////////////// diff --git a/Minecraft.World/PrimedTnt.cpp b/Minecraft.World/PrimedTnt.cpp index 39b3ea73..c39d39d2 100644 --- a/Minecraft.World/PrimedTnt.cpp +++ b/Minecraft.World/PrimedTnt.cpp @@ -4,8 +4,6 @@ #include "net.minecraft.world.level.h" #include "PrimedTnt.h" - - void PrimedTnt::_init() { life = 0; @@ -47,9 +45,7 @@ PrimedTnt::PrimedTnt(Level *level, double x, double y, double z, shared_ptrowner = weak_ptr(owner); } -void PrimedTnt::defineSynchedData() -{ -} +void PrimedTnt::defineSynchedData() {} bool PrimedTnt::makeStepSound() { @@ -84,25 +80,18 @@ void PrimedTnt::tick() { remove(); if (!level->isClientSide) - { explode(); - } } else - { level->addParticle(eParticleType_smoke, x, y + 0.5f, z, 0, 0, 0); - } - } - void PrimedTnt::explode() { float r = 4.0f; level->explode(shared_from_this(), x, y, z, r, true); } - void PrimedTnt::addAdditonalSaveData(CompoundTag *entityTag) { entityTag->putByte(L"Fuse", static_cast(life)); @@ -121,4 +110,10 @@ float PrimedTnt::getShadowHeightOffs() shared_ptr PrimedTnt::getOwner() { return owner.lock(); +} + +// TU25 Addition +float PrimedTnt::getEyeHeight() +{ + return 0.0f; } \ No newline at end of file diff --git a/Minecraft.World/PrimedTnt.h b/Minecraft.World/PrimedTnt.h index 0b65a5ca..ed50037f 100644 --- a/Minecraft.World/PrimedTnt.h +++ b/Minecraft.World/PrimedTnt.h @@ -36,4 +36,6 @@ protected: public: virtual float getShadowHeightOffs(); virtual shared_ptr getOwner(); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/Sheep.cpp b/Minecraft.World/Sheep.cpp index f06308f4..3da1f7e6 100644 --- a/Minecraft.World/Sheep.cpp +++ b/Minecraft.World/Sheep.cpp @@ -313,6 +313,12 @@ MobGroupData *Sheep::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= return groupData; } +// TU25 Addition +float Sheep::getEyeHeight() +{ + return 0.95f * bbHeight; +} + int Sheep::getOffspringColor(shared_ptr animal, shared_ptr partner) { int parent1DyeColor = getDyeColor(animal); @@ -339,3 +345,4 @@ int Sheep::getDyeColor(shared_ptr animal) { return 15 - dynamic_pointer_cast(animal)->getColor(); } + diff --git a/Minecraft.World/Sheep.h b/Minecraft.World/Sheep.h index 16ecfb4c..30459dd8 100644 --- a/Minecraft.World/Sheep.h +++ b/Minecraft.World/Sheep.h @@ -82,6 +82,9 @@ public: MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param + // TU25 Addition + virtual float getEyeHeight(); + private: int getOffspringColor(shared_ptr animal, shared_ptr partner); int getDyeColor(shared_ptr animal); diff --git a/Minecraft.World/Silverfish.cpp b/Minecraft.World/Silverfish.cpp index 98f559c9..e6875852 100644 --- a/Minecraft.World/Silverfish.cpp +++ b/Minecraft.World/Silverfish.cpp @@ -224,4 +224,10 @@ bool Silverfish::canSpawn() MobType Silverfish::getMobType() { return ARTHROPOD; +} + +// TU25 Addition +float Silverfish::getEyeHeight() +{ + return 0.1f; } \ No newline at end of file diff --git a/Minecraft.World/Silverfish.h b/Minecraft.World/Silverfish.h index e954fff1..8f3ce722 100644 --- a/Minecraft.World/Silverfish.h +++ b/Minecraft.World/Silverfish.h @@ -45,4 +45,6 @@ protected: public: virtual bool canSpawn(); virtual MobType getMobType(); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Skeleton.cpp b/Minecraft.World/Skeleton.cpp index cc325b97..0a670a8f 100644 --- a/Minecraft.World/Skeleton.cpp +++ b/Minecraft.World/Skeleton.cpp @@ -356,4 +356,13 @@ void Skeleton::setEquippedSlot(int slot, shared_ptr item) double Skeleton::getRidingHeight() { return Monster::getRidingHeight() - .5; +} + +// TU25 Addition +float Skeleton::getEyeHeight() +{ + if (getSkeletonType() == TYPE_WITHER) + return Entity::getEyeHeight(); + else + return 1.62f; } \ No newline at end of file diff --git a/Minecraft.World/Skeleton.h b/Minecraft.World/Skeleton.h index e2f6594c..04cb7bac 100644 --- a/Minecraft.World/Skeleton.h +++ b/Minecraft.World/Skeleton.h @@ -66,4 +66,6 @@ public: virtual void addAdditonalSaveData(CompoundTag *entityTag); virtual void setEquippedSlot(int slot, shared_ptr item); virtual double getRidingHeight(); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/Slime.cpp b/Minecraft.World/Slime.cpp index de76ef06..82467153 100644 --- a/Minecraft.World/Slime.cpp +++ b/Minecraft.World/Slime.cpp @@ -290,6 +290,12 @@ int Slime::getMaxHeadXRot() return 0; } +// TU25 Addition +float Slime::getEyeHeight() +{ + return 0.625f * bbHeight; +} + bool Slime::doPlayJumpSound() { return getSize() > 0; diff --git a/Minecraft.World/Slime.h b/Minecraft.World/Slime.h index 95a1aef1..af1ff564 100644 --- a/Minecraft.World/Slime.h +++ b/Minecraft.World/Slime.h @@ -70,6 +70,8 @@ protected: public: virtual int getMaxHeadXRot(); + // TU25 Addition + virtual float getEyeHeight(); protected: virtual bool doPlayJumpSound(); diff --git a/Minecraft.World/SnowMan.cpp b/Minecraft.World/SnowMan.cpp index 0db6343b..d92689c2 100644 --- a/Minecraft.World/SnowMan.cpp +++ b/Minecraft.World/SnowMan.cpp @@ -105,6 +105,7 @@ void SnowMan::performRangedAttack(shared_ptr target, float power) level->addEntity(snowball); } +// TU23 Fix: MCCE-622 – Snow Golem impervious to melee damage bool SnowMan::hurt(DamageSource *source, float dmg) { // 4J: Protect owned golem from untrusted players @@ -118,4 +119,10 @@ bool SnowMan::hurt(DamageSource *source, float dmg) } return Golem::hurt(source, dmg); +} + +// TU25 Addition +float SnowMan::getEyeHeight() +{ + return 1.7f; } \ No newline at end of file diff --git a/Minecraft.World/SnowMan.h b/Minecraft.World/SnowMan.h index eed8e225..ef7a7b96 100644 --- a/Minecraft.World/SnowMan.h +++ b/Minecraft.World/SnowMan.h @@ -26,4 +26,6 @@ protected: public: virtual void performRangedAttack(shared_ptr target, float power); virtual bool hurt(DamageSource *source, float dmg); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp index 5d7bdd2c..216a1f73 100644 --- a/Minecraft.World/Spider.cpp +++ b/Minecraft.World/Spider.cpp @@ -223,6 +223,12 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /* return groupData; } +// TU25 Addition +float Spider::getEyeHeight() +{ + return 0.65f; +} + const float Spider::SPIDER_SPECIAL_EFFECT_CHANCE = .1f; Spider::SpiderEffectsGroupData::SpiderEffectsGroupData() diff --git a/Minecraft.World/Spider.h b/Minecraft.World/Spider.h index 941ac45a..0b84906c 100644 --- a/Minecraft.World/Spider.h +++ b/Minecraft.World/Spider.h @@ -42,6 +42,8 @@ public: virtual bool isClimbing(); virtual void setClimbing(bool value); virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param + // TU25 Addition + virtual float getEyeHeight(); private: static const float SPIDER_SPECIAL_EFFECT_CHANCE; diff --git a/Minecraft.World/Squid.cpp b/Minecraft.World/Squid.cpp index f1b660eb..4f9d1cd1 100644 --- a/Minecraft.World/Squid.cpp +++ b/Minecraft.World/Squid.cpp @@ -191,3 +191,9 @@ bool Squid::canSpawn() { return y > 45 && y < level->seaLevel && WaterAnimal::canSpawn(); } + +// TU25 Addition +float Squid::getEyeHeight() +{ + return bbHeight * 0.5f; +} \ No newline at end of file diff --git a/Minecraft.World/Squid.h b/Minecraft.World/Squid.h index c645d9f8..f19a78ae 100644 --- a/Minecraft.World/Squid.h +++ b/Minecraft.World/Squid.h @@ -50,4 +50,6 @@ protected: public: virtual bool canSpawn(); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index d0bbc799..95d371be 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -776,3 +776,15 @@ wstring Villager::getDisplayName() }; return app.GetString(name); } + +// TU25 Addition +float Villager::getEyeHeight() +{ + //TODO: Use LCE instead of JAVA + float f = 1.62F; + + if (isBaby()) + f -= 0.81; + + return f; +} \ No newline at end of file diff --git a/Minecraft.World/Villager.h b/Minecraft.World/Villager.h index d8aeb15a..924eb8ff 100644 --- a/Minecraft.World/Villager.h +++ b/Minecraft.World/Villager.h @@ -147,4 +147,6 @@ public: virtual shared_ptr getBreedOffspring(shared_ptr target); virtual bool canBeLeashed(); virtual wstring getDisplayName(); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Witch.cpp b/Minecraft.World/Witch.cpp index 375c8388..0a83e142 100644 --- a/Minecraft.World/Witch.cpp +++ b/Minecraft.World/Witch.cpp @@ -221,4 +221,10 @@ void Witch::performRangedAttack(shared_ptr target, float power) potion->shoot(xd, yd + dist * 0.2f, zd, 0.75f, 8); level->addEntity(potion); +} + +// TU25 Addition +float Witch::getEyeHeight() +{ + return 1.62f; } \ No newline at end of file diff --git a/Minecraft.World/Witch.h b/Minecraft.World/Witch.h index 256f358f..b79729b8 100644 --- a/Minecraft.World/Witch.h +++ b/Minecraft.World/Witch.h @@ -45,4 +45,6 @@ protected: public: virtual void performRangedAttack(shared_ptr target, float power); + // TU25 Addition + virtual float getEyeHeight(); }; \ No newline at end of file diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 5545138a..583e8b15 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -596,4 +596,10 @@ bool Wolf::wantsToAttack(shared_ptr target, shared_ptr target, shared_ptr owner); + // TU25 Addition + virtual float getEyeHeight(); }; diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index f982d847..8d2cae92 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -238,6 +238,18 @@ void Zombie::updateSize(bool isBaby) setSize(0.6f, 1.8f * scale); } +// TU25 Addition +float Zombie::getEyeHeight() +{ + //TODO: Use LCE one instead of JAVA + float f = 1.74F; + + if (isBaby()) + f -= 0.81; + + return f; +} + int Zombie::getAmbientSound() { return eSoundType_MOB_ZOMBIE_AMBIENT; @@ -502,4 +514,4 @@ Zombie::ZombieGroupData::ZombieGroupData(bool baby, bool villager) { isBaby = baby; isVillager = villager; -} +} \ No newline at end of file diff --git a/Minecraft.World/Zombie.h b/Minecraft.World/Zombie.h index f788ea63..9b79ef55 100644 --- a/Minecraft.World/Zombie.h +++ b/Minecraft.World/Zombie.h @@ -61,6 +61,8 @@ public: virtual void tick(); virtual bool doHurtTarget(shared_ptr target); virtual void updateSize(bool isBaby); + // TU25 Addition + virtual float getEyeHeight(); protected: virtual int getAmbientSound();