diff --git a/Minecraft.Client/EntityTracker.cpp b/Minecraft.Client/EntityTracker.cpp index dc94f239..1719c41b 100644 --- a/Minecraft.Client/EntityTracker.cpp +++ b/Minecraft.Client/EntityTracker.cpp @@ -29,91 +29,44 @@ EntityTracker::EntityTracker(ServerLevel *level) void EntityTracker::addEntity(shared_ptr e) { -/* - if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender)) + if (e->instanceof(eTYPE_SERVERPLAYER)) { - int maxChunkDistance = 16; - if (e->instanceof(eTYPE_SERVERPLAYER)) + addEntity(e, 16 * 32, 2); + shared_ptr player = dynamic_pointer_cast(e); + for ( auto& it : entities ) { - addEntity(e, 16 * maxChunkDistance, 2); - shared_ptr player = dynamic_pointer_cast(e); - for ( auto& it : entities ) + if( it && it->e != player ) { - if( it && it->e != player ) - { - it->updatePlayer(this, player); - } + it->updatePlayer(this, player); } - } - 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); - } + } + } + 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) @@ -123,7 +76,14 @@ void EntityTracker::addEntity(shared_ptr e, int range, int updateInterva void EntityTracker::addEntity(shared_ptr e, int range, int updateInterval, bool trackDeltas) { - if (range > maxRange) range = maxRange; +// if (app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender)) +// { + if (range > maxRange) + range = maxRange; +// } +// else +// range = 16 * maxEntityDistance; + if (entityMap.find(e->entityId) != entityMap.end()) { assert(false); // Entity already tracked diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 0fd9bc64..e773bf18 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -1358,10 +1358,7 @@ bool Entity::shouldRenderAtSqrDistance(double distance) { /* if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender)) - { - int maxChunkDistance = 16; - return distance <= maxChunkDistance; - } + return distance <= maxEntityDistance; else */ {