diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.Client/Minecraft.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
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 <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.Client/Minecraft.cpp')
| -rw-r--r-- | Minecraft.Client/Minecraft.cpp | 904 |
1 files changed, 506 insertions, 398 deletions
diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 3192410d..87f1b8be 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -61,6 +61,7 @@ #include "..\Minecraft.World\Villager.h" #include "..\Minecraft.World\SparseLightStorage.h" #include "..\Minecraft.World\SparseDataStorage.h" +#include "..\Minecraft.World\ChestTileEntity.h" #include "TextureManager.h" #ifdef _XBOX #include "Xbox\Network\NetworkPlayerXbox.h" @@ -73,6 +74,7 @@ #include "Orbis\Network\PsPlusUpsellWrapper_Orbis.h" #endif +// #define DISABLE_SPU_CODE // 4J Turning this on will change the graph at the bottom of the debug overlay to show the number of packets of each type added per fram //#define DEBUG_RENDER_SHOWS_PACKETS 1 //#define SPLITSCREEN_TEST @@ -103,8 +105,16 @@ int QuickSelectBoxWidth[3]= 111, 142 }; + +// 4J - TomK ToDo: these really shouldn't be magic numbers, it should read the hud position from flash. +int iToolTipOffset = 85; + #endif +ResourceLocation Minecraft::DEFAULT_FONT_LOCATION = ResourceLocation(TN_DEFAULT_FONT); +ResourceLocation Minecraft::ALT_FONT_LOCATION = ResourceLocation(TN_ALT_FONT); + + Minecraft::Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen) { // 4J - added this block of initialisers @@ -294,7 +304,7 @@ void Minecraft::init() */ } catch (LWJGLException e) { // This COULD be because of a bug! A delay followed by a new attempt - // is supposed to fix it. + // is supposed getWorkingDirectoryto fix it. e.printStackTrace(); try { Thread.sleep(1000); @@ -311,7 +321,7 @@ void Minecraft::init() // glClearColor(0.2f, 0.2f, 0.2f, 1); - workingDirectory = getWorkingDirectory(); + workingDirectory = File(L"");//getWorkingDirectory(); levelSource = new McRegionLevelStorageSource(File(workingDirectory, L"saves")); // levelSource = new MemoryLevelStorageSource(); options = new Options(this, workingDirectory); @@ -320,8 +330,8 @@ void Minecraft::init() textures = new Textures(skins, options); //renderLoadingScreen(); - font = new Font(options, L"font/Default.png", textures, false, TN_DEFAULT_FONT, 23, 20, 8, 8, SFontData::Codepoints); - altFont = new Font(options, L"font/alternate.png", textures, false, TN_ALT_FONT, 16, 16, 8, 8); + font = new Font(options, L"font/Default.png", textures, false, &DEFAULT_FONT_LOCATION, 23, 20, 8, 8, SFontData::Codepoints); + altFont = new Font(options, L"font/alternate.png", textures, false, &ALT_FONT_LOCATION, 16, 16, 8, 8); //if (options.languageCode != null) { // Language.getInstance().loadLanguage(options.languageCode); @@ -390,16 +400,13 @@ void Minecraft::init() // openGLCapabilities = new OpenGLCapabilities(); // 4J - removed levelRenderer = new LevelRenderer(this, textures); + //textures->register(&TextureAtlas::LOCATION_BLOCKS, new TextureAtlas(Icon::TYPE_TERRAIN, TN_TERRAIN)); + //textures->register(&TextureAtlas::LOCATION_ITEMS, new TextureAtlas(Icon::TYPE_ITEM, TN_GUI_ITEMS)); textures->stitch(); glViewport(0, 0, width, height); particleEngine = new ParticleEngine(level, textures); - // try { // 4J - removed try/catch - bgLoader = new BackgroundDownloader(workingDirectory, this); - bgLoader->start(); - // } catch (Exception e) { - // } MemSect(31); checkGlError(L"Post startup"); @@ -483,53 +490,6 @@ void Minecraft::blit(int x, int y, int sx, int sy, int w, int h) t->end(); } -File Minecraft::getWorkingDirectory() -{ - if (workDir.getPath().empty()) workDir = getWorkingDirectory(L"minecraft"); - return workDir; -} - -File Minecraft::getWorkingDirectory(const wstring& applicationName) -{ -#if 0 - // 4J - original version - final String userHome = System.getProperty("user.home", "."); - final File workingDirectory; - switch (getPlatform()) { - case linux: - case solaris: - workingDirectory = new File(userHome, '.' + applicationName + '/'); - break; - case windows: - final String applicationData = System.getenv("APPDATA"); - if (applicationData != null) workingDirectory = new File(applicationData, "." + applicationName + '/'); - else workingDirectory = new File(userHome, '.' + applicationName + '/'); - break; - case macos: - workingDirectory = new File(userHome, "Library/Application Support/" + applicationName); - break; - default: - workingDirectory = new File(userHome, applicationName + '/'); - } - if (!workingDirectory.exists()) if (!workingDirectory.mkdirs()) throw new RuntimeException("The working directory could not be created: " + workingDirectory); - return workingDirectory; -#else - wstring userHome = L"home"; // 4J - TODO - File workingDirectory(userHome, applicationName); - // 4J Removed - //if (!workingDirectory.exists()) - //{ - // workingDirectory.mkdirs(); - //} - return workingDirectory; -#endif -} - -Minecraft::OS Minecraft::getPlatform() -{ - return xbox; -} - LevelStorageSource *Minecraft::getLevelSource() { return levelSource; @@ -537,8 +497,6 @@ LevelStorageSource *Minecraft::getLevelSource() void Minecraft::setScreen(Screen *screen) { - if( dynamic_cast<ErrorScreen *>(this->screen) != NULL ) return; - if (this->screen != NULL) { this->screen->removed(); @@ -631,15 +589,6 @@ void Minecraft::destroy() /*stats->forceSend(); stats->forceSave();*/ - // 4J - all try/catch/finally things in here removed - // try { - if (this->bgLoader != NULL) - { - bgLoader->halt(); - } - // } catch (Exception e) { - // } - // try { setLevel(NULL); // } catch (Throwable e) { @@ -651,8 +600,6 @@ void Minecraft::destroy() // } soundEngine->destroy(); - Mouse::destroy(); - Keyboard::destroy(); //} finally { Display::destroy(); // if (!hasCrashed) System.exit(0); //4J - removed @@ -1088,7 +1035,7 @@ shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, co localplayers[idx]->setOnlineXuid(playerXUIDOnline); localplayers[idx]->setIsGuest(ProfileManager.IsGuest(idx)); - localplayers[idx]->displayName = ProfileManager.GetDisplayName(idx); + localplayers[idx]->m_displayName = ProfileManager.GetDisplayName(idx); localplayers[idx]->m_iScreenSection = tempScreenSection; @@ -1177,7 +1124,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) updateXui = false; #endif // 4J Stu - Adding this back in for exactly the reason my comment above suggests it was added in the first place -#ifdef _XBOX_ONE +#if defined(_XBOX_ONE) || defined(__ORBIS__) g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); #endif } @@ -1463,7 +1410,7 @@ void Minecraft::run_middle() else { UINT uiIDA[1] = { IDS_OK }; - ui.RequestMessageBox( IDS_CANTJOIN_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, i, NULL, NULL, app.GetStringTable() ); + ui.RequestErrorMessage( IDS_CANTJOIN_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, i); } } else @@ -1704,7 +1651,7 @@ void Minecraft::run_middle() { UINT uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, i, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, i); } else if (ProfileManager.IsSignedIn(i) && !ProfileManager.IsSignedInLive(i)) { @@ -1712,14 +1659,14 @@ void Minecraft::run_middle() UINT uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_CANCEL; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, i,&Minecraft::MustSignInReturnedPSN, this, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, i,&Minecraft::MustSignInReturnedPSN, this); } else #endif { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, i, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, i); } } //else @@ -1755,14 +1702,14 @@ void Minecraft::run_middle() { firstEmptyUser = i; break; + } } - } // For durango, check for unmapped controllers for(unsigned int iPad = XUSER_MAX_COUNT; iPad < (XUSER_MAX_COUNT + InputManager.MAX_GAMEPADS); ++iPad) { - if(InputManager.IsPadLocked(iPad) || !InputManager.IsPadConnected(iPad) ) continue; - if(!InputManager.ButtonPressed(iPad)) continue; + bool isPadLocked = InputManager.IsPadLocked(iPad), isPadConnected = InputManager.IsPadConnected(iPad), buttonPressed = InputManager.ButtonPressed(iPad); + if (isPadLocked || !isPadConnected || !buttonPressed) continue; if(!ui.PressStartPlaying(firstEmptyUser)) { @@ -1897,7 +1844,6 @@ void Minecraft::run_middle() PIXBeginNamedEvent(0,"Light update"); - if (level != NULL) level->updateLights(); glEnable(GL_TEXTURE_2D); PIXEndNamedEvent(); @@ -1978,6 +1924,10 @@ void Minecraft::run_middle() } */ +#if PACKET_ENABLE_STAT_TRACKING + Packet::updatePacketStatsPIX(); +#endif + if (options->renderDebug) { //renderFpsMeter(tickDuraction); @@ -2278,7 +2228,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if (!pause && level != NULL) gameMode->tick(); MemSect(31); - glBindTexture(GL_TEXTURE_2D, textures->loadTexture(TN_TERRAIN));//L"/terrain.png")); + glBindTexture(GL_TEXTURE_2D, textures->loadTexture(TN_TERRAIN)); //L"/terrain.png")); MemSect(0); if( bFirst ) { @@ -2330,7 +2280,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if (screen == NULL && !ui.GetMenuDisplayed(iPad) ) { // 4J-PB - add some tooltips if required - int iA=-1, iB=-1, iX, iY=IDS_CONTROLS_INVENTORY, iLT=-1, iRT=-1, iLB=-1, iRB=-1; + int iA=-1, iB=-1, iX, iY=IDS_CONTROLS_INVENTORY, iLT=-1, iRT=-1, iLB=-1, iRB=-1, iLS=-1, iRS=-1; if(player->abilities.instabuild) { @@ -2344,10 +2294,12 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) int *piAction; int *piJump; int *piUse; + int *piAlt; unsigned int uiAction = InputManager.GetGameJoypadMaps(InputManager.GetJoypadMapVal( iPad ) ,MINECRAFT_ACTION_ACTION ); unsigned int uiJump = InputManager.GetGameJoypadMaps(InputManager.GetJoypadMapVal( iPad ) ,MINECRAFT_ACTION_JUMP ); unsigned int uiUse = InputManager.GetGameJoypadMaps(InputManager.GetJoypadMapVal( iPad ) ,MINECRAFT_ACTION_USE ); + unsigned int uiAlt = InputManager.GetGameJoypadMaps(InputManager.GetJoypadMapVal( iPad ) ,MINECRAFT_ACTION_SNEAK_TOGGLE ); // Also need to handle PS3 having swapped triggers/bumpers switch(uiAction) @@ -2407,6 +2359,16 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) break; } + switch(uiAlt) + { + default: + case _360_JOY_BUTTON_LSTICK_RIGHT: + piAlt=&iRS; + break; + + //TODO + } + if (player->isUnderLiquid(Material::water)) { *piJump=IDS_TOOLTIPS_SWIMUP; @@ -2418,6 +2380,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piUse=-1; *piAction=-1; + *piAlt=-1; // 4J-PB another special case for when the player is sleeping in a bed if (player->isSleeping() && (level != NULL) && level->isClientSide) @@ -2426,6 +2389,20 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } else { + if (player->isRiding()) + { + shared_ptr<Entity> mount = player->riding; + + if ( mount->instanceof(eTYPE_MINECART) || mount->instanceof(eTYPE_BOAT) ) + { + *piAlt = IDS_TOOLTIPS_EXIT; + } + else + { + *piAlt = IDS_TOOLTIPS_DISMOUNT; + } + } + // no hit result, but we may have something in our hand that we can do something with shared_ptr<ItemInstance> itemInstance = player->inventory->getSelected(); @@ -2470,11 +2447,12 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } break; - case Item::milk_Id: + case Item::bucket_milk_Id: *piUse=IDS_TOOLTIPS_DRINK; break; case Item::fishingRod_Id: // use + case Item::emptyMap_Id: *piUse=IDS_TOOLTIPS_USE; break; @@ -2504,6 +2482,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if (bUseItem) *piUse=IDS_TOOLTIPS_COLLECT; break; + case Item::bucket_lava_Id: + case Item::bucket_water_Id: + *piUse=IDS_TOOLTIPS_EMPTY; + break; + case Item::boat_Id: case Tile::waterLily_Id: if (bUseItem) *piUse=IDS_TOOLTIPS_PLACE; @@ -2568,8 +2551,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { switch (itemInstance->getItem()->id) { - case Tile::mushroom1_Id: - case Tile::mushroom2_Id: + case Tile::mushroom_brown_Id: + case Tile::mushroom_red_Id: case Tile::tallgrass_Id: case Tile::cactus_Id: case Tile::sapling_Id: @@ -2589,28 +2572,10 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) break; case Item::seeds_wheat_Id: - case Item::netherStalkSeeds_Id: + case Item::netherwart_seeds_Id: *piUse=IDS_TOOLTIPS_PLANT; break; - case Item::bucket_empty_Id: - switch(iTileID) - { - // can collect lava or water in the empty bucket - case Tile::water_Id: - case Tile::calmWater_Id: - case Tile::lava_Id: - case Tile::calmLava_Id: - *piUse=IDS_TOOLTIPS_COLLECT; - break; - } - break; - - case Item::bucket_lava_Id: - case Item::bucket_water_Id: - *piUse=IDS_TOOLTIPS_EMPTY; - break; - case Item::dye_powder_Id: // bonemeal grows various plants if (itemInstance->getAuxValue() == DyePowderItem::WHITE) @@ -2618,10 +2583,10 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) switch(iTileID) { case Tile::sapling_Id: - case Tile::crops_Id: + case Tile::wheat_Id: case Tile::grass_Id: - case Tile::mushroom1_Id: - case Tile::mushroom2_Id: + case Tile::mushroom_brown_Id: + case Tile::mushroom_red_Id: case Tile::melonStem_Id: case Tile::pumpkinStem_Id: case Tile::carrots_Id: @@ -2641,6 +2606,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piUse=IDS_TOOLTIPS_IGNITE; break; + case Item::fireworks_Id: + *piUse=IDS_TOOLTIPS_FIREWORK_LAUNCH; + break; + + case Item::lead_Id: + *piUse=IDS_TOOLTIPS_ATTACH; + break; + default: *piUse=IDS_TOOLTIPS_PLACE; break; @@ -2662,29 +2635,38 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case Tile::button_wood_Id: case Tile::trapdoor_Id: case Tile::fenceGate_Id: + case Tile::beacon_Id: *piAction=IDS_TOOLTIPS_MINE; *piUse=IDS_TOOLTIPS_USE; break; - case Tile::goldenRail_Id: - case Tile::detectorRail_Id: - case Tile::rail_Id: - if (bUseItemOn) *piUse=IDS_TOOLTIPS_PLACE; - *piAction=IDS_TOOLTIPS_MINE; + case Tile::chest_Id: + *piAction = IDS_TOOLTIPS_MINE; + *piUse = (Tile::chest->getContainer(level,x,y,z) != NULL) ? IDS_TOOLTIPS_OPEN : -1; break; - case Tile::chest_Id: case Tile::enderChest_Id: + case Tile::chest_trap_Id: + case Tile::dropper_Id: + case Tile::hopper_Id: *piUse=IDS_TOOLTIPS_OPEN; *piAction=IDS_TOOLTIPS_MINE; break; + case Tile::activatorRail_Id: + case Tile::goldenRail_Id: + case Tile::detectorRail_Id: + case Tile::rail_Id: + if (bUseItemOn) *piUse=IDS_TOOLTIPS_PLACE; + *piAction=IDS_TOOLTIPS_MINE; + break; + case Tile::bed_Id: if (bUseItemOn) *piUse=IDS_TOOLTIPS_SLEEP; *piAction=IDS_TOOLTIPS_MINE; break; - case Tile::musicBlock_Id: + case Tile::noteblock_Id: // if in creative mode, we will mine if (player->abilities.instabuild) *piAction=IDS_TOOLTIPS_MINE; else *piAction=IDS_TOOLTIPS_PLAY; @@ -2728,7 +2710,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } break; - case Tile::recordPlayer_Id: + case Tile::jukebox_Id: if (!bUseItemOn && itemInstance!=NULL) { int iID=itemInstance->getItem()->id; @@ -2740,7 +2722,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } else { - if (Tile::recordPlayer->TestUse(level, x, y, z, player)) // means we can eject + if (Tile::jukebox->TestUse(level, x, y, z, player)) // means we can eject { *piUse=IDS_TOOLTIPS_EJECT; } @@ -2759,8 +2741,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case Tile::flower_Id: case Tile::rose_Id: case Tile::sapling_Id: - case Tile::mushroom1_Id: - case Tile::mushroom2_Id: + case Tile::mushroom_brown_Id: + case Tile::mushroom_red_Id: case Tile::cactus_Id: case Tile::deadBush_Id: *piUse=IDS_TOOLTIPS_PLANT; @@ -2775,6 +2757,31 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piAction=IDS_TOOLTIPS_MINE; break; + case Tile::comparator_off_Id: + case Tile::comparator_on_Id: + *piUse=IDS_TOOLTIPS_USE; + *piAction=IDS_TOOLTIPS_MINE; + break; + + case Tile::diode_off_Id: + case Tile::diode_on_Id: + *piUse=IDS_TOOLTIPS_USE; + *piAction=IDS_TOOLTIPS_MINE; + break; + + case Tile::redStoneOre_Id: + if (bUseItemOn) *piUse=IDS_TOOLTIPS_USE; + *piAction=IDS_TOOLTIPS_MINE; + break; + + case Tile::door_iron_Id: + if(*piUse==IDS_TOOLTIPS_PLACE) + { + *piUse = -1; + } + *piAction=IDS_TOOLTIPS_MINE; + break; + default: *piAction=IDS_TOOLTIPS_MINE; break; @@ -2785,177 +2792,198 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case HitResult::ENTITY: eINSTANCEOF entityType = hitResult->entity->GetType(); - if( gameMode != NULL && gameMode->getTutorial() != NULL ) + if ( (gameMode != NULL) && (gameMode->getTutorial() != NULL) ) { // 4J Stu - For the tutorial we want to be able to record what items we look at so that we can give hints - gameMode->getTutorial()->onLookAtEntity(entityType); + gameMode->getTutorial()->onLookAtEntity(hitResult->entity); } + shared_ptr<ItemInstance> heldItem = nullptr; + if (player->inventory->IsHeldItem()) + { + heldItem = player->inventory->getSelected(); + } + int heldItemId = heldItem != NULL ? heldItem->getItem()->id : -1; + switch(entityType) { case eTYPE_CHICKEN: - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - // is there an object in hand? - if(player->inventory->IsHeldItem()) { - shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); - int iID=heldItem->getItem()->id; + if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + + shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); + + if (animal->isLeashed() && animal->getLeashHolder() == player) + { + *piUse=IDS_TOOLTIPS_UNLEASH; + break; + } - switch(iID) + switch(heldItemId) { + case Item::nameTag_Id: + *piUse=IDS_TOOLTIPS_NAME; + break; + + case Item::lead_Id: + if (!animal->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; + break; + default: { - shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) { *piUse=IDS_TOOLTIPS_LOVEMODE; } } break; + + case -1: break; // 4J-JEV: Empty hand. } } break; case eTYPE_COW: - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - // is there an object in hand? - if(player->inventory->IsHeldItem()) { - shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); - int iID=heldItem->getItem()->id; + if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + + shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - // It's an item - switch(iID) + if (animal->isLeashed() && animal->getLeashHolder() == player) { - // Things to USE - case Item::bucket_empty_Id: - *piUse=IDS_TOOLTIPS_MILK; + *piUse=IDS_TOOLTIPS_UNLEASH; break; - default: - { - shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); + } - if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) + switch (heldItemId) + { + // Things to USE + case Item::nameTag_Id: + *piUse=IDS_TOOLTIPS_NAME; + break; + case Item::lead_Id: + if (!animal->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; + break; + case Item::bucket_empty_Id: + *piUse=IDS_TOOLTIPS_MILK; + break; + default: { - *piUse=IDS_TOOLTIPS_LOVEMODE; + if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) + { + *piUse=IDS_TOOLTIPS_LOVEMODE; + } } + break; + + case -1: break; // 4J-JEV: Empty hand. } - break; - } } break; case eTYPE_MUSHROOMCOW: - // is there an object in hand? - if(player->inventory->IsHeldItem()) { + // 4J-PB - Fix for #13081 - No tooltip is displayed for hitting a cow when you have nothing in your hand if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); - int iID=heldItem->getItem()->id; + shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - // It's an item - switch(iID) + if (animal->isLeashed() && animal->getLeashHolder() == player) + { + *piUse=IDS_TOOLTIPS_UNLEASH; + break; + } + + // It's an item + switch(heldItemId) { // Things to USE - case Item::bowl_Id: - case Item::bucket_empty_Id: // You can milk a mooshroom with either a bowl (mushroom soup) or a bucket (milk)! - *piUse=IDS_TOOLTIPS_MILK; + case Item::nameTag_Id: + *piUse=IDS_TOOLTIPS_NAME; break; - case Item::shears_Id: - { - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR; - } + + case Item::lead_Id: + if (!animal->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; break; - default: - { - shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) + case Item::bowl_Id: + case Item::bucket_empty_Id: // You can milk a mooshroom with either a bowl (mushroom soup) or a bucket (milk)! + *piUse=IDS_TOOLTIPS_MILK; + break; + case Item::shears_Id: + { + if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR; + } + break; + default: { - *piUse=IDS_TOOLTIPS_LOVEMODE; + if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) + { + *piUse=IDS_TOOLTIPS_LOVEMODE; + } } - } - break; + break; + + case -1: break; // 4J-JEV: Empty hand. } } - else - { - // 4J-PB - Fix for #13081 - No tooltip is displayed for hitting a cow when you have nothing in your hand - // nothing in your hand - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - } break; case eTYPE_BOAT: *piAction=IDS_TOOLTIPS_MINE; + *piUse=IDS_TOOLTIPS_SAIL; + break; - // are we in the boat already? - if (dynamic_pointer_cast<Boat>( player->riding ) != NULL) - { - *piUse=IDS_TOOLTIPS_EXIT; - } - else - { - *piUse=IDS_TOOLTIPS_SAIL; - } + case eTYPE_MINECART_RIDEABLE: + *piAction = IDS_TOOLTIPS_MINE; + *piUse = IDS_TOOLTIPS_RIDE; // are we in the minecart already? - 4J-JEV: Doesn't matter anymore. + break; + + case eTYPE_MINECART_FURNACE: + *piAction = IDS_TOOLTIPS_MINE; + + // if you have coal, it'll go. Is there an object in hand? + if (heldItemId == Item::coal_Id) *piUse=IDS_TOOLTIPS_USE; break; - case eTYPE_MINECART: - *piAction=IDS_TOOLTIPS_MINE; - // are we in the minecart already? - if (dynamic_pointer_cast<Minecart>( player->riding ) != NULL) - { - *piUse=IDS_TOOLTIPS_EXIT; - } - else - { - switch(dynamic_pointer_cast<Minecart>(hitResult->entity)->type) - { - case Minecart::RIDEABLE: - *piUse=IDS_TOOLTIPS_RIDE; - break; - case Minecart::CHEST: - *piUse=IDS_TOOLTIPS_OPEN; - break; - case Minecart::FURNACE: - // if you have coal, it'll go - // is there an object in hand? - if(player->inventory->IsHeldItem()) - { - shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); - int iID=heldItem->getItem()->id; - if(iID==Item::coal->id) - { - *piUse=IDS_TOOLTIPS_USE; - } - else - { - *piUse=IDS_TOOLTIPS_HIT; - } - } - break; - } - } + case eTYPE_MINECART_CHEST: + case eTYPE_MINECART_HOPPER: + *piAction = IDS_TOOLTIPS_MINE; + *piUse = IDS_TOOLTIPS_OPEN; + break; + case eTYPE_MINECART_SPAWNER: + case eTYPE_MINECART_TNT: + *piUse = IDS_TOOLTIPS_MINE; break; + case eTYPE_SHEEP: - // can dye a sheep - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - if(player->inventory->IsHeldItem()) { - shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); - int iID=heldItem->getItem()->id; + // can dye a sheep + if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + + shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity); + + if (sheep->isLeashed() && sheep->getLeashHolder() == player) + { + *piUse=IDS_TOOLTIPS_UNLEASH; + break; + } - switch(iID) + switch(heldItemId) { + case Item::nameTag_Id: + *piUse=IDS_TOOLTIPS_NAME; + break; + + case Item::lead_Id: + if (!sheep->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; + break; + case Item::dye_powder_Id: { - shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity); // convert to tile-based color value (0 is white instead of black) - int newColor = ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue()); + int newColor = ColoredTile::getTileDataForItemAuxValue(heldItem->getAuxValue()); // can only use a dye on sheep that haven't been sheared if(!(sheep->isSheared() && sheep->getColor() != newColor)) @@ -2966,10 +2994,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) break; case Item::shears_Id: { - shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity); - // can only shear a sheep that hasn't been sheared - if(!sheep->isSheared() ) + if ( !sheep->isBaby() && !sheep->isSheared() ) { *piUse=IDS_TOOLTIPS_SHEAR; } @@ -2978,49 +3004,54 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) break; default: { - shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - - if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) + if(!sheep->isBaby() && !sheep->isInLove() && (sheep->getAge() == 0) && sheep->isFood(heldItem)) { *piUse=IDS_TOOLTIPS_LOVEMODE; } } break; + + case -1: break; // 4J-JEV: Empty hand. } } - break; + case eTYPE_PIG: - // can ride a pig - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - if (dynamic_pointer_cast<Pig>( player->riding ) != NULL) - { - *piUse=IDS_TOOLTIPS_EXIT; - } - else { - // does the pig have a saddle? - if(dynamic_pointer_cast<Pig>(hitResult->entity)->hasSaddle()) + // can ride a pig + if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + + shared_ptr<Pig> pig = dynamic_pointer_cast<Pig>(hitResult->entity); + + if (pig->isLeashed() && pig->getLeashHolder() == player) + { + *piUse=IDS_TOOLTIPS_UNLEASH; + } + else if (heldItemId == Item::lead_Id) { - *piUse=IDS_TOOLTIPS_RIDE; + if (!pig->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; } - else if (!dynamic_pointer_cast<Pig>(hitResult->entity)->isBaby()) + else if (heldItemId == Item::nameTag_Id) + { + *piUse = IDS_TOOLTIPS_NAME; + } + else if (pig->hasSaddle()) // does the pig have a saddle? + { + *piUse=IDS_TOOLTIPS_MOUNT; + } + else if (!pig->isBaby()) { if(player->inventory->IsHeldItem()) { - shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); - int iID=heldItem->getItem()->id; - - switch(iID) + switch(heldItemId) { case Item::saddle_Id: *piUse=IDS_TOOLTIPS_SADDLE; break; + default: { - shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); - - if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) + if (!pig->isInLove() && (pig->getAge() == 0) && pig->isFood(heldItem)) { *piUse=IDS_TOOLTIPS_LOVEMODE; } @@ -3030,25 +3061,31 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } } - break; + case eTYPE_WOLF: // can be tamed, fed, and made to sit/stand, or enter love mode { - int iID=-1; - shared_ptr<ItemInstance> heldItem=nullptr; shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity); - if(player->inventory->IsHeldItem()) + if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + + if (wolf->isLeashed() && wolf->getLeashHolder() == player) { - heldItem=player->inventory->getSelected(); - iID=heldItem->getItem()->id; + *piUse=IDS_TOOLTIPS_UNLEASH; + break; } - if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - - switch(iID) + switch(heldItemId) { + case Item::nameTag_Id: + *piUse=IDS_TOOLTIPS_NAME; + break; + + case Item::lead_Id: + if (!wolf->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; + break; + case Item::bone_Id: if (!wolf->isAngry() && !wolf->isTame()) { @@ -3073,7 +3110,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case Item::dye_powder_Id: if (wolf->isTame()) { - if (ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue()) != wolf->getCollarColor()) + if (ColoredTile::getTileDataForItemAuxValue(heldItem->getAuxValue()) != wolf->getCollarColor()) { *piUse=IDS_TOOLTIPS_DYECOLLAR; } @@ -3123,21 +3160,25 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } break; - case eTYPE_OZELOT: + case eTYPE_OCELOT: { - int iID=-1; - shared_ptr<ItemInstance> heldItem=nullptr; - shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity); - - if(player->inventory->IsHeldItem()) - { - heldItem=player->inventory->getSelected(); - iID=heldItem->getItem()->id; - } + shared_ptr<Ocelot> ocelot = dynamic_pointer_cast<Ocelot>(hitResult->entity); if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - if(ocelot->isTame()) + if (ocelot->isLeashed() && ocelot->getLeashHolder() == player) + { + *piUse = IDS_TOOLTIPS_UNLEASH; + } + else if (heldItemId == Item::lead_Id) + { + if (!ocelot->isLeashed()) *piUse = IDS_TOOLTIPS_LEASH; + } + else if (heldItemId == Item::nameTag_Id) + { + *piUse = IDS_TOOLTIPS_NAME; + } + else if(ocelot->isTame()) { // 4J-PB - if you have a raw fish in your hand, you will feed the ocelot rather than have it sit/follow if(ocelot->isFood(heldItem)) @@ -3158,7 +3199,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } - else if (equalsIgnoreCase(player->getUUID(), ocelot->getOwnerUUID())) + else if (equalsIgnoreCase(player->getUUID(), ocelot->getOwnerUUID()) && !ocelot->isSittingOnTile() ) { if(ocelot->isSitting()) { @@ -3170,19 +3211,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } } - else if(iID!=-1) + else if(heldItemId >= 0) { - switch(iID) - { - default: - { - if(ocelot->isFood(heldItem)) *piUse=IDS_TOOLTIPS_TAME; - } - break; - } + if (ocelot->isFood(heldItem)) *piUse=IDS_TOOLTIPS_TAME; } } - break; case eTYPE_PLAYER: @@ -3199,6 +3232,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } break; + case eTYPE_ITEM_FRAME: { shared_ptr<ItemFrame> itemFrame = dynamic_pointer_cast<ItemFrame>(hitResult->entity); @@ -3212,17 +3246,17 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) else { // is there an object in hand? - if(player->inventory->IsHeldItem()) - { - *piUse=IDS_TOOLTIPS_PLACE; - } + if(heldItemId >= 0) *piUse=IDS_TOOLTIPS_PLACE; } *piAction=IDS_TOOLTIPS_HIT; } break; + case eTYPE_VILLAGER: { + // 4J-JEV: Cannot leash villagers. + shared_ptr<Villager> villager = dynamic_pointer_cast<Villager>(hitResult->entity); if (!villager->isBaby()) { @@ -3230,35 +3264,162 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } *piAction=IDS_TOOLTIPS_HIT; } - break; + break; + case eTYPE_ZOMBIE: { shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity); - shared_ptr<ItemInstance> heldItem=nullptr; + static GoldenAppleItem *goldapple = (GoldenAppleItem *) Item::apple_gold; + + //zomb->hasEffect(MobEffect::weakness) - not present on client. + if ( zomb->isVillager() && zomb->isWeakened() && (heldItemId == Item::apple_gold_Id) && !goldapple->isFoil(heldItem) ) + { + *piUse=IDS_TOOLTIPS_CURE; + } + *piAction=IDS_TOOLTIPS_HIT; + } + break; - if(player->inventory->IsHeldItem()) + case eTYPE_HORSE: + { + shared_ptr<EntityHorse> horse = dynamic_pointer_cast<EntityHorse>(hitResult->entity); + + bool heldItemIsFood = false, heldItemIsLove = false, heldItemIsArmour = false; + + switch( heldItemId ) { - heldItem=player->inventory->getSelected(); + case Item::wheat_Id: + case Item::sugar_Id: + case Item::bread_Id: + case Tile::hayBlock_Id: + case Item::apple_Id: + heldItemIsFood = true; + break; + case Item::carrotGolden_Id: + case Item::apple_gold_Id: + heldItemIsLove = true; + heldItemIsFood = true; + break; + case Item::horseArmorDiamond_Id: + case Item::horseArmorGold_Id: + case Item::horseArmorMetal_Id: + heldItemIsArmour = true; + break; } - if ( zomb->isVillager() && zomb->isWeakened() //zomb->hasEffect(MobEffect::weakness) - not present on client. - && heldItem != NULL && heldItem->getItem()->id == Item::apple_gold_Id ) + if (horse->isLeashed() && horse->getLeashHolder() == player) { - *piUse=IDS_TOOLTIPS_CURE; + *piUse=IDS_TOOLTIPS_UNLEASH; } - *piAction=IDS_TOOLTIPS_HIT; + else if ( heldItemId == Item::lead_Id) + { + if (!horse->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; + } + else if (heldItemId == Item::nameTag_Id) + { + *piUse = IDS_TOOLTIPS_NAME; + } + else if (horse->isBaby()) // 4J-JEV: Can't ride baby horses due to morals. + { + if (heldItemIsFood) + { + // 4j - Can feed foles to speed growth. + *piUse = IDS_TOOLTIPS_FEED; + } + } + else if ( !horse->isTamed() ) + { + if (heldItemId == -1) + { + // 4j - Player not holding anything, ride and attempt to break untamed horse. + *piUse = IDS_TOOLTIPS_TAME; + } + else if (heldItemIsFood) + { + // 4j - Attempt to make it like you more by feeding it. + *piUse = IDS_TOOLTIPS_FEED; + } + } + else if ( player->isSneaking() + || (heldItemId == Item::saddle_Id) + || (horse->canWearArmor() && heldItemIsArmour) + ) + { + // 4j - Access horses inventory + if (*piUse == -1) *piUse = IDS_TOOLTIPS_OPEN; + } + else if ( horse->canWearBags() + && !horse->isChestedHorse() + && (heldItemId == Tile::chest_Id) ) + { + // 4j - Attach saddle-bags (chest) to donkey or mule. + *piUse = IDS_TOOLTIPS_ATTACH; + } + else if ( horse->isReadyForParenting() + && heldItemIsLove ) + { + // 4j - Different food to mate horses. + *piUse = IDS_TOOLTIPS_LOVEMODE; + } + else if ( heldItemIsFood && (horse->getHealth() < horse->getMaxHealth()) ) + { + // 4j - Horse is damaged and can eat held item to heal + *piUse = IDS_TOOLTIPS_HEAL; + } + else + { + // 4j - Ride tamed horse. + *piUse = IDS_TOOLTIPS_MOUNT; + } + + if (player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; + } + break; + + case eTYPE_ENDERDRAGON: + // 4J-JEV: Enderdragon cannot be named. + *piAction = IDS_TOOLTIPS_HIT; + break; + + case eTYPE_LEASHFENCEKNOT: + *piAction = IDS_TOOLTIPS_UNLEASH; + if (heldItemId == Item::lead_Id && LeashItem::bindPlayerMobsTest(player, level, player->x, player->y, player->z)) + { + *piUse = IDS_TOOLTIPS_ATTACH; + } + else + { + *piUse = IDS_TOOLTIPS_UNLEASH; } break; + default: + if ( hitResult->entity->instanceof(eTYPE_MOB) ) + { + shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(hitResult->entity); + if (mob->isLeashed() && mob->getLeashHolder() == player) + { + *piUse=IDS_TOOLTIPS_UNLEASH; + } + else if (heldItemId == Item::lead_Id) + { + if (!mob->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; + } + else if (heldItemId == Item::nameTag_Id) + { + *piUse=IDS_TOOLTIPS_NAME; + } + } *piAction=IDS_TOOLTIPS_HIT; - break; + break; } break; } } } - ui.SetTooltips( iPad, iA,iB,iX,iY,iLT,iRT,iLB,iRB); + // 4J-JEV: Don't set tooltips when we're reloading the skin, it'll crash. + if (!ui.IsReloadingSkin()) ui.SetTooltips( iPad, iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS); int wheel = 0; if (InputManager.GetValue(iPad, MINECRAFT_ACTION_LEFT_SCROLL, true) > 0 && gameMode->isInputAllowed(MINECRAFT_ACTION_LEFT_SCROLL) ) @@ -3502,14 +3663,22 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY)) { - shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player ); + shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->player; ui.PlayUISFX(eSFX_Press); - app.LoadInventoryMenu(iPad,player); + + if(gameMode->isServerControlledInventory()) + { + player->sendOpenInventory(); + } + else + { + app.LoadInventoryMenu(iPad,player); + } } if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING)) { - shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player ); + shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->player; // 4J-PB - reordered the if statement so creative mode doesn't bring up the crafting table // Fix for #39014 - TU5: Creative Mode: Pressing X to access the creative menu while looking at a crafting table causes the crafting menu to display @@ -3561,8 +3730,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if(pTouchData->reportNum==1) { int iHudSize=app.GetGameSettings(iPad,eGameSetting_UISize); + int iYOffset = (app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_Tooltips) == 0) ? iToolTipOffset : 0; if((pTouchData->report[0].x>QuickSelectRect[iHudSize].left)&&(pTouchData->report[0].x<QuickSelectRect[iHudSize].right) && - (pTouchData->report[0].y>QuickSelectRect[iHudSize].top)&&(pTouchData->report[0].y<QuickSelectRect[iHudSize].bottom)) + (pTouchData->report[0].y>QuickSelectRect[iHudSize].top+iYOffset)&&(pTouchData->report[0].y<QuickSelectRect[iHudSize].bottom+iYOffset)) { player->inventory->selected=(pTouchData->report[0].x-QuickSelectRect[iHudSize].left)/QuickSelectBoxWidth[iHudSize]; selected = true; @@ -3822,7 +3992,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if (!pause) { - if (levels[i]->lightningBoltTime > 0) levels[i]->lightningBoltTime--; + if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--; PIXBeginNamedEvent(0,"Level entity tick"); levels[i]->tickEntities(); PIXEndNamedEvent(); @@ -3841,7 +4011,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) setLocalPlayerIdx(idx); gameRenderer->setupCamera(timer->a, i); Camera::prepare(localplayers[idx], localplayers[idx]->ThirdPersonView() == 2); - shared_ptr<Mob> cameraEntity = cameraTargetPlayer; + shared_ptr<LivingEntity> cameraEntity = cameraTargetPlayer; double xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * timer->a; double yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * timer->a; double zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * timer->a; @@ -4107,7 +4277,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt player->setXuid(playerXUIDOffline); player->setOnlineXuid(playerXUIDOnline); - player->displayName = ProfileManager.GetDisplayName(iPrimaryPlayer); + player->m_displayName = ProfileManager.GetDisplayName(iPrimaryPlayer); @@ -4226,8 +4396,6 @@ void Minecraft::prepareLevel(int title) if(progressRenderer != NULL) this->progressRenderer->progressStagePercentage((pp++) * 100 / max); level->getTile(spawnPos->x + x, 64, spawnPos->z + z); if (!gameMode->isCutScene()) { - while (level->updateLights()) - ; } } } @@ -4239,34 +4407,6 @@ void Minecraft::prepareLevel(int title) } } -void Minecraft::fileDownloaded(const wstring& name, File *file) -{ - int p = (int)name.find(L"/"); - wstring category = name.substr(0, p); - wstring name2 = name.substr(p + 1); - toLower(category); - if (category==L"sound") - { - soundEngine->add(name, file); - } - else if (category==L"newsound") - { - soundEngine->add(name, file); - } - else if (category==L"streaming") - { - soundEngine->addStreaming(name, file); - } - else if (category==L"music") - { - soundEngine->addMusic(name, file); - } - else if (category==L"newmusic") - { - soundEngine->addMusic(name, file); - } -} - wstring Minecraft::gatherStats1() { //return levelRenderer->gatherStats1(); @@ -4300,7 +4440,6 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) if (localPlayer != NULL) { - level->removeEntity(localPlayer); } @@ -4321,7 +4460,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) player->setOnlineXuid(playerXUIDOnline); player->setIsGuest( ProfileManager.IsGuest(iTempPad) ); - player->displayName = ProfileManager.GetDisplayName(iPad); + player->m_displayName = ProfileManager.GetDisplayName(iPad); player->SetXboxPad(iTempPad); @@ -4520,24 +4659,26 @@ void Minecraft::main() #endif // 4J Stu - This block generates XML for the game rules schema - //for(unsigned int i = 0; i < Item::items.length; ++i) - //{ - // if(Item::items[i] != NULL) - // { - // wprintf(L"<xs:enumeration value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n", i, app.GetString( Item::items[i]->getDescriptionId() )); - // } - //} +#if 0 + for(unsigned int i = 0; i < Item::items.length; ++i) + { + if(Item::items[i] != NULL) + { + app.DebugPrintf("<xs:enumeration value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n", i, app.GetString( Item::items[i]->getDescriptionId() )); + } + } - //wprintf(L"\n\n\n\n\n"); - // - //for(unsigned int i = 0; i < 256; ++i) - //{ - // if(Tile::tiles[i] != NULL) - // { - // wprintf(L"<xs:enumeration value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n", i, app.GetString( Tile::tiles[i]->getDescriptionId() )); - // } - //} - //__debugbreak(); + app.DebugPrintf("\n\n\n\n\n"); + + for(unsigned int i = 0; i < 256; ++i) + { + if(Tile::tiles[i] != NULL) + { + app.DebugPrintf("<xs:enumeration value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n", i, app.GetString( Tile::tiles[i]->getDescriptionId() )); + } + } + __debugbreak(); +#endif // 4J-PB - Can't call this for the first 5 seconds of a game - MS rule //if (ProfileManager.IsFullVersion()) @@ -4577,7 +4718,7 @@ bool Minecraft::useFancyGraphics() bool Minecraft::useAmbientOcclusion() { - return (m_instance != NULL && m_instance->options->ambientOcclusion); + return (m_instance != NULL && m_instance->options->ambientOcclusion != Options::AO_OFF); } bool Minecraft::renderDebug() @@ -4587,43 +4728,6 @@ bool Minecraft::renderDebug() bool Minecraft::handleClientSideCommand(const wstring& chatMessage) { - /* 4J - TODO - if (chatMessage.startsWith("/")) { - if (DEADMAU5_CAMERA_CHEATS) { - if (chatMessage.startsWith("/follow")) { - String[] tokens = chatMessage.split(" "); - if (tokens.length >= 2) { - String playerName = tokens[1]; - - boolean found = false; - for (Player player : level.players) { - if (playerName.equalsIgnoreCase(player.name)) { - cameraTargetPlayer = player; - found = true; - break; - } - } - - if (!found) { - try { - int entityId = Integer.parseInt(playerName); - for (Entity e : level.entities) { - if (e.entityId == entityId && e instanceof Mob) { - cameraTargetPlayer = (Mob) e; - found = true; - break; - } - } - } catch (NumberFormatException e) { - } - } - } - - return true; - } - } - } - */ return false; } @@ -4848,7 +4952,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP { UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestMessageBox(IDS_MULTIPLAYER_FULL_TITLE, IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE, IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1); ProfileManager.RemoveGamepadFromGame(iPad); } else if( ProfileManager.IsSignedInLive(iPad) && ProfileManager.AllowedToPlayMultiplayer(iPad) ) @@ -4876,7 +4980,11 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP } #endif +#ifdef _XBOX_ONE +int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad, int iController) +#else int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) +#endif { Minecraft* pMinecraftClass = (Minecraft*)pParam; @@ -4905,7 +5013,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) { UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestMessageBox(IDS_MULTIPLAYER_FULL_TITLE, IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE, IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1); #ifdef _DURANGO ProfileManager.RemoveGamepadFromGame(iPad); #endif @@ -4949,7 +5057,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) //ProfileManager.RequestConvertOfflineToGuestUI( &Minecraft::InGame_SignInReturned, pMinecraftClass,iPad); UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,iPad,NULL,NULL, app.GetStringTable()); + ui.RequestErrorMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,iPad); #ifdef _DURANGO ProfileManager.RemoveGamepadFromGame(iPad); #endif @@ -5016,14 +5124,14 @@ ColourTable *Minecraft::getColourTable() #if defined __ORBIS__ int Minecraft::MustSignInReturnedPSN(void *pParam, int iPad, C4JStorage::EMessageResult result) { - Minecraft* pMinecraft = (Minecraft *)pParam; + Minecraft* pMinecraft = (Minecraft *)pParam; - if(result == C4JStorage::EMessage_ResultAccept) - { + if(result == C4JStorage::EMessage_ResultAccept) + { SQRNetworkManager_Orbis::AttemptPSNSignIn(&Minecraft::InGame_SignInReturned, pMinecraft, false, iPad); - } + } - return 0; + return 0; } #endif |
