diff --git a/Minecraft.Client/EntityTracker.cpp b/Minecraft.Client/EntityTracker.cpp index 087227e7..dc94f239 100644 --- a/Minecraft.Client/EntityTracker.cpp +++ b/Minecraft.Client/EntityTracker.cpp @@ -29,44 +29,91 @@ EntityTracker::EntityTracker(ServerLevel *level) void EntityTracker::addEntity(shared_ptr e) { - if (e->instanceof(eTYPE_SERVERPLAYER)) +/* + if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender)) { - addEntity(e, 32 * 16, 2); - shared_ptr player = dynamic_pointer_cast(e); - for ( auto& it : entities ) + int maxChunkDistance = 16; + if (e->instanceof(eTYPE_SERVERPLAYER)) { - if( it && it->e != player ) + addEntity(e, 16 * maxChunkDistance, 2); + shared_ptr player = dynamic_pointer_cast(e); + for ( auto& it : entities ) { - it->updatePlayer(this, player); + if( it && it->e != player ) + { + it->updatePlayer(this, player); + } } - } - } - else if (e->instanceof(eTYPE_FISHINGHOOK)) addEntity(e, 16 * 4, 5, true); - else if (e->instanceof(eTYPE_SMALL_FIREBALL)) addEntity(e, 16 * 4, 10, false); - else if (e->instanceof(eTYPE_DRAGON_FIREBALL)) addEntity(e, 16 * 4, 10, false); // 4J Added TU9 - else if (e->instanceof(eTYPE_ARROW)) addEntity(e, 16 * 4, 20, false); - else if (e->instanceof(eTYPE_FIREBALL)) addEntity(e, 16 * 4, 10, false); - else if (e->instanceof(eTYPE_SNOWBALL)) addEntity(e, 16 * 4, 10, true); - else if (e->instanceof(eTYPE_THROWNENDERPEARL)) addEntity(e, 16 * 4, 10, true); - else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL)) addEntity(e, 16 * 4, 4, true); - else if (e->instanceof(eTYPE_THROWNEGG)) addEntity(e, 16 * 4, 10, true); - else if (e->instanceof(eTYPE_THROWNPOTION)) addEntity(e, 16 * 4, 10, true); - else if (e->instanceof(eTYPE_THROWNEXPBOTTLE)) addEntity(e, 16 * 4, 10, true); - else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) addEntity(e, 16 * 4, 10, true); - else if (e->instanceof(eTYPE_ITEMENTITY)) addEntity(e, 16 * 4, 20, true); - else if (e->instanceof(eTYPE_MINECART)) addEntity(e, 16 * 5, 1, true); - else if (e->instanceof(eTYPE_BOAT)) addEntity(e, 16 * 5, 1, true); - else if (e->instanceof(eTYPE_SQUID)) addEntity(e, 16 * 4, 1, true); - else if (e->instanceof(eTYPE_WITHERBOSS)) addEntity(e, 16 * 5, 1, false); - else if (e->instanceof(eTYPE_BAT)) addEntity(e, 16 * 5, 1, false); - else if (dynamic_pointer_cast(e)!=nullptr) addEntity(e, 16 * 5, 1, true); - else if (e->instanceof(eTYPE_ENDERDRAGON)) addEntity(e, 16 * 10, 1, true); - else if (e->instanceof(eTYPE_PRIMEDTNT)) addEntity(e, 16 * 10, 10, true); - else if (e->instanceof(eTYPE_FALLINGTILE)) addEntity(e, 16 * 10, 20, true); - else if (e->instanceof(eTYPE_HANGING_ENTITY)) addEntity(e, 16 * 10, INT_MAX, false); - else if (e->instanceof(eTYPE_EXPERIENCEORB)) addEntity(e, 16 * 10, 20, true); - else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) addEntity(e, 16 * 16, INT_MAX, false); - else if (e->instanceof(eTYPE_ITEM_FRAME)) addEntity(e, 16 * 10, INT_MAX, false); + } + else if (e->instanceof(eTYPE_FISHINGHOOK)) addEntity(e, 16 * maxChunkDistance, 5, true); + else if (e->instanceof(eTYPE_SMALL_FIREBALL)) addEntity(e, 16 * maxChunkDistance, 10, false); + else if (e->instanceof(eTYPE_DRAGON_FIREBALL)) addEntity(e, 16 * maxChunkDistance, 10, false); // 4J Added TU9 + else if (e->instanceof(eTYPE_ARROW)) addEntity(e, 16 * maxChunkDistance, 20, false); + else if (e->instanceof(eTYPE_FIREBALL)) addEntity(e, 16 * maxChunkDistance, 10, false); + else if (e->instanceof(eTYPE_SNOWBALL)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_THROWNENDERPEARL)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL)) addEntity(e, 16 * maxChunkDistance, 4, true); + else if (e->instanceof(eTYPE_THROWNEGG)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_THROWNPOTION)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_THROWNEXPBOTTLE)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_ITEMENTITY)) addEntity(e, 16 * maxChunkDistance, 20, true); + else if (e->instanceof(eTYPE_MINECART)) addEntity(e, 16 * maxChunkDistance, 1, true); + else if (e->instanceof(eTYPE_BOAT)) addEntity(e, 16 * maxChunkDistance, 1, true); + else if (e->instanceof(eTYPE_SQUID)) addEntity(e, 16 * maxChunkDistance, 1, true); + else if (e->instanceof(eTYPE_WITHERBOSS)) addEntity(e, 16 * maxChunkDistance, 1, false); + else if (e->instanceof(eTYPE_BAT)) addEntity(e, 16 * maxChunkDistance, 1, false); + else if (dynamic_pointer_cast(e)!=nullptr) addEntity(e, 16 * maxChunkDistance, 1, true); + else if (e->instanceof(eTYPE_ENDERDRAGON)) addEntity(e, 16 * maxChunkDistance, 1, true); + else if (e->instanceof(eTYPE_PRIMEDTNT)) addEntity(e, 16 * maxChunkDistance, 10, true); + else if (e->instanceof(eTYPE_FALLINGTILE)) addEntity(e, 16 * maxChunkDistance, 20, true); + else if (e->instanceof(eTYPE_HANGING_ENTITY)) addEntity(e, 16 * maxChunkDistance, INT_MAX, false); + else if (e->instanceof(eTYPE_EXPERIENCEORB)) addEntity(e, 16 * maxChunkDistance, 20, true); + else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) addEntity(e, 16 * maxChunkDistance, INT_MAX, false); + else if (e->instanceof(eTYPE_ITEM_FRAME)) addEntity(e, 16 * maxChunkDistance, INT_MAX, false); + } + else +*/ + { + if (e->instanceof(eTYPE_SERVERPLAYER)) + { + addEntity(e, 16 * 32, 2); + shared_ptr player = dynamic_pointer_cast(e); + for ( auto& it : entities ) + { + if( it && it->e != player ) + { + it->updatePlayer(this, player); + } + } + } + else if (e->instanceof(eTYPE_FISHINGHOOK)) addEntity(e, 16 * 4, 5, true); + else if (e->instanceof(eTYPE_SMALL_FIREBALL)) addEntity(e, 16 * 4, 10, false); + else if (e->instanceof(eTYPE_DRAGON_FIREBALL)) addEntity(e, 16 * 4, 10, false); // 4J Added TU9 + else if (e->instanceof(eTYPE_ARROW)) addEntity(e, 16 * 4, 20, false); + else if (e->instanceof(eTYPE_FIREBALL)) addEntity(e, 16 * 4, 10, false); + else if (e->instanceof(eTYPE_SNOWBALL)) addEntity(e, 16 * 4, 10, true); + else if (e->instanceof(eTYPE_THROWNENDERPEARL)) addEntity(e, 16 * 4, 10, true); + else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL)) addEntity(e, 16 * 4, 4, true); + else if (e->instanceof(eTYPE_THROWNEGG)) addEntity(e, 16 * 4, 10, true); + else if (e->instanceof(eTYPE_THROWNPOTION)) addEntity(e, 16 * 4, 10, true); + else if (e->instanceof(eTYPE_THROWNEXPBOTTLE)) addEntity(e, 16 * 4, 10, true); + else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) addEntity(e, 16 * 4, 10, true); + else if (e->instanceof(eTYPE_ITEMENTITY)) addEntity(e, 16 * 4, 20, true); + else if (e->instanceof(eTYPE_MINECART)) addEntity(e, 16 * 5, 1, true); + else if (e->instanceof(eTYPE_BOAT)) addEntity(e, 16 * 5, 1, true); + else if (e->instanceof(eTYPE_SQUID)) addEntity(e, 16 * 4, 1, true); + else if (e->instanceof(eTYPE_WITHERBOSS)) addEntity(e, 16 * 5, 1, false); + else if (e->instanceof(eTYPE_BAT)) addEntity(e, 16 * 5, 1, false); + else if (dynamic_pointer_cast(e)!=nullptr) addEntity(e, 16 * 5, 1, true); + else if (e->instanceof(eTYPE_ENDERDRAGON)) addEntity(e, 16 * 10, 1, true); + else if (e->instanceof(eTYPE_PRIMEDTNT)) addEntity(e, 16 * 10, 10, true); + else if (e->instanceof(eTYPE_FALLINGTILE)) addEntity(e, 16 * 10, 20, true); + else if (e->instanceof(eTYPE_HANGING_ENTITY)) addEntity(e, 16 * 10, INT_MAX, false); + else if (e->instanceof(eTYPE_EXPERIENCEORB)) addEntity(e, 16 * 10, 20, true); + else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) addEntity(e, 16 * 16, INT_MAX, false); + else if (e->instanceof(eTYPE_ITEM_FRAME)) addEntity(e, 16 * 10, INT_MAX, false); + } } void EntityTracker::addEntity(shared_ptr e, int range, int updateInterval) diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 535f7ba3..0fd9bc64 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -1324,18 +1324,51 @@ void Entity::awardKillScore(shared_ptr victim, int score) bool Entity::shouldRender(Vec3 *c) { - double xd = x - c->x; - double yd = y - c->y; - double zd = z - c->z; - double distance = xd * xd + yd * yd + zd * zd; - return shouldRenderAtSqrDistance(distance); +/* + if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender)) + { + int entityChunkX = (int)std::floor(x / 16.0); + int entityChunkY = (int)std::floor(y / 16.0); + int entityChunkZ = (int)std::floor(z / 16.0); + + int cameraChunkX = (int)std::floor(c->x / 16.0); + int cameraChunkY = (int)std::floor(c->y / 16.0); + int cameraChunkZ = (int)std::floor(c->z / 16.0); + + int chunkDiffX = std::abs(entityChunkX - cameraChunkX); + int chunkDiffY = std::abs(entityChunkY - cameraChunkY); + int chunkDiffZ = std::abs(entityChunkZ - cameraChunkZ); + + int maxXZ = (chunkDiffX > chunkDiffZ) ? chunkDiffX : chunkDiffZ; + int chunkDistance = (maxXZ > chunkDiffY) ? maxXZ : chunkDiffY; + return shouldRenderAtSqrDistance(chunkDistance); + } + else +*/ + { + double xd = x - c->x; + double yd = y - c->y; + double zd = z - c->z; + double distance = xd * xd + yd * yd + zd * zd; + return shouldRenderAtSqrDistance(distance); + } } bool Entity::shouldRenderAtSqrDistance(double distance) { - double size = bb->getSize(); - size *= 64.0f * viewScale; //TODO Implement Entity Distance Render Option - return distance < size * size; +/* + if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender)) + { + int maxChunkDistance = 16; + return distance <= maxChunkDistance; + } + else +*/ + { + double size = bb->getSize(); + size *= 64.0f * viewScale; + return distance < size * size; + } } bool Entity::isCreativeModeAllowed()