From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.Client/EntityTracker.cpp | 65 ++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'Minecraft.Client/EntityTracker.cpp') diff --git a/Minecraft.Client/EntityTracker.cpp b/Minecraft.Client/EntityTracker.cpp index 8f1dbcd8..adc230ee 100644 --- a/Minecraft.Client/EntityTracker.cpp +++ b/Minecraft.Client/EntityTracker.cpp @@ -18,6 +18,7 @@ #include "..\Minecraft.World\net.minecraft.network.h" #include "..\Minecraft.World\net.minecraft.world.level.dimension.h" #include "..\Minecraft.World\BasicTypeContainers.h" +#include "..\Minecraft.World\net.minecraft.world.level.chunk.h" #include "PlayerConnection.h" EntityTracker::EntityTracker(ServerLevel *level) @@ -28,7 +29,7 @@ EntityTracker::EntityTracker(ServerLevel *level) void EntityTracker::addEntity(shared_ptr e) { - if (e->GetType() == eTYPE_SERVERPLAYER) + if (e->instanceof(eTYPE_SERVERPLAYER)) { addEntity(e, 32 * 16, 2); shared_ptr player = dynamic_pointer_cast(e); @@ -40,29 +41,32 @@ void EntityTracker::addEntity(shared_ptr e) } } } - else if (e->GetType() == eTYPE_FISHINGHOOK) addEntity(e, 16 * 4, 5, true); - else if (e->GetType() == eTYPE_SMALL_FIREBALL) addEntity(e, 16 * 4, 10, false); - else if (e->GetType() == eTYPE_DRAGON_FIREBALL) addEntity(e, 16 * 4, 10, false); // 4J Added TU9 - else if (e->GetType() == eTYPE_ARROW) addEntity(e, 16 * 4, 20, false); - else if (e->GetType() == eTYPE_FIREBALL) addEntity(e, 16 * 4, 10, false); - else if (e->GetType() == eTYPE_SNOWBALL) addEntity(e, 16 * 4, 10, true); - else if (e->GetType() == eTYPE_THROWNENDERPEARL) addEntity(e, 16 * 4, 10, true); - else if (e->GetType() == eTYPE_EYEOFENDERSIGNAL ) addEntity(e, 16 * 4, 4, true); - else if (e->GetType() == eTYPE_THROWNEGG) addEntity(e, 16 * 4, 10, true); - else if (e->GetType() == eTYPE_THROWNPOTION ) addEntity(e, 16 * 4, 10, true); - else if (e->GetType() == eTYPE_THROWNEXPBOTTLE) addEntity(e, 16 * 4, 10, true); - else if (e->GetType() == eTYPE_ITEMENTITY) addEntity(e, 16 * 4, 20, true); - else if (e->GetType() == eTYPE_MINECART) addEntity(e, 16 * 5, 3, true); - else if (e->GetType() == eTYPE_BOAT) addEntity(e, 16 * 5, 3, true); - else if (e->GetType() == eTYPE_SQUID) addEntity(e, 16 * 4, 3, true); + 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, 3, true); + else if (e->instanceof(eTYPE_BOAT)) addEntity(e, 16 * 5, 3, true); + else if (e->instanceof(eTYPE_SQUID)) addEntity(e, 16 * 4, 3, true); + else if (e->instanceof(eTYPE_WITHERBOSS)) addEntity(e, 16 * 5, 3, false); + else if (e->instanceof(eTYPE_BAT)) addEntity(e, 16 * 5, 3, false); else if (dynamic_pointer_cast(e)!=NULL) addEntity(e, 16 * 5, 3, true); - else if (e->GetType() == eTYPE_ENDERDRAGON ) addEntity(e, 16 * 10, 3, true); - else if (e->GetType() == eTYPE_PRIMEDTNT) addEntity(e, 16 * 10, 10, true); - else if (e->GetType() == eTYPE_FALLINGTILE) addEntity(e, 16 * 10, 20, true); - else if (e->GetType() == eTYPE_PAINTING) addEntity(e, 16 * 10, INT_MAX, false); - else if (e->GetType() == eTYPE_EXPERIENCEORB) addEntity(e, 16 * 10, 20, true); - else if (e->GetType() == eTYPE_ENDER_CRYSTAL) addEntity(e, 16 * 16, INT_MAX, false); - else if (e->GetType() == eTYPE_ITEM_FRAME) addEntity(e, 16 * 10, INT_MAX, false); + else if (e->instanceof(eTYPE_ENDERDRAGON)) addEntity(e, 16 * 10, 3, 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) @@ -110,6 +114,9 @@ void EntityTracker::removePlayer(shared_ptr e) { (*it)->removePlayer(player); } + + // 4J: Flush now to ensure remove packets are sent before player respawns and add entity packets are sent + player->flushEntitiesToRemove(); } } @@ -211,6 +218,18 @@ void EntityTracker::clear(shared_ptr serverPlayer) } } +void EntityTracker::playerLoadedChunk(shared_ptr player, LevelChunk *chunk) +{ + for (AUTO_VAR(it,entities.begin()); it != entities.end(); ++it) + { + shared_ptr te = *it; + if (te->e != player && te->e->xChunk == chunk->x && te->e->zChunk == chunk->z) + { + te->updatePlayer(this, player); + } + } +} + // AP added for Vita so the range can be increased once the level starts void EntityTracker::updateMaxRange() { -- cgit v1.2.3