the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 124 lines 3.1 kB view raw
1#include "stdafx.h" 2#include <memory> 3#include "..\..\Minecraft.h" 4#include "..\..\MultiplayerLocalPlayer.h" 5#include "..\..\MultiPlayerLevel.h" 6#include "..\..\..\Minecraft.World\Inventory.h" 7#include "..\..\..\Minecraft.World\net.minecraft.world.item.h" 8#include "..\..\..\Minecraft.World\net.minecraft.world.level.h" 9#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h" 10#include "TutorialMode.h" 11 12TutorialMode::TutorialMode(int iPad, Minecraft *minecraft, ClientConnection *connection) : MultiPlayerGameMode( minecraft, connection ), m_iPad( iPad ) 13{ 14} 15 16TutorialMode::~TutorialMode() 17{ 18 if(tutorial != NULL) 19 delete tutorial; 20} 21 22void TutorialMode::startDestroyBlock(int x, int y, int z, int face) 23{ 24 if(!tutorial->m_allTutorialsComplete) 25 { 26 int t = minecraft->level->getTile(x, y, z); 27 tutorial->startDestroyBlock(minecraft->player->inventory->getSelected(), Tile::tiles[t]); 28 } 29 MultiPlayerGameMode::startDestroyBlock( x, y, z, face ); 30} 31 32bool TutorialMode::destroyBlock(int x, int y, int z, int face) 33{ 34 if(!tutorial->m_allTutorialsComplete) 35 { 36 int t = minecraft->level->getTile(x, y, z); 37 tutorial->destroyBlock(Tile::tiles[t]); 38 } 39 shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem(); 40 int damageBefore; 41 if(item != NULL) 42 { 43 damageBefore = item->getDamageValue(); 44 } 45 bool changed = MultiPlayerGameMode::destroyBlock( x, y, z, face ); 46 47 if(!tutorial->m_allTutorialsComplete) 48 { 49 if ( item != NULL && item->isDamageableItem() ) 50 { 51 int max = item->getMaxDamage(); 52 int damageNow = item->getDamageValue(); 53 54 if(damageNow > damageBefore && damageNow > (max/2) ) 55 { 56 tutorial->itemDamaged( item ); 57 } 58 } 59 } 60 61 return changed; 62} 63 64void TutorialMode::tick() 65{ 66 MultiPlayerGameMode::tick(); 67 68 if(!tutorial->m_allTutorialsComplete) 69 tutorial->tick(); 70 71 /* 72 if( tutorial.m_allTutorialsComplete && (tutorial.lastMessageTime + m_iTutorialDisplayMessageTime) < GetTickCount() ) 73 { 74 // Exit tutorial 75 minecraft->gameMode = new SurvivalMode( this ); 76 delete this; 77 } 78 */ 79} 80 81bool TutorialMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly, bool *pbUsedItem) 82{ 83 bool haveItem = false; 84 int itemCount = 0; 85 if(!tutorial->m_allTutorialsComplete) 86 { 87 tutorial->useItemOn(level, item, x, y, z, bTestUseOnly); 88 89 if(!bTestUseOnly) 90 { 91 if(item != NULL) 92 { 93 haveItem = true; 94 itemCount = item->count; 95 } 96 } 97 } 98 bool result = MultiPlayerGameMode::useItemOn( player, level, item, x, y, z, face, hit, bTestUseOnly, pbUsedItem ); 99 100 if(!bTestUseOnly) 101 { 102 if(!tutorial->m_allTutorialsComplete) 103 { 104 if( result && haveItem && itemCount > item->count ) 105 { 106 tutorial->useItemOn(item); 107 } 108 } 109 } 110 return result; 111} 112 113void TutorialMode::attack(shared_ptr<Player> player, shared_ptr<Entity> entity) 114{ 115 if(!tutorial->m_allTutorialsComplete) 116 tutorial->attack(player, entity); 117 118 MultiPlayerGameMode::attack( player, entity ); 119} 120 121bool TutorialMode::isInputAllowed(int mapping) 122{ 123 return tutorial->m_allTutorialsComplete || tutorial->isInputAllowed( mapping ); 124}