mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-23 14:36:05 +00:00
exclude unused GameMode implementations, format Platform/Common/Tutorial
This commit is contained in:
@@ -9,116 +9,102 @@
|
||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
#include "TutorialMode.h"
|
||||
|
||||
TutorialMode::TutorialMode(int iPad, Minecraft *minecraft, ClientConnection *connection) : MultiPlayerGameMode( minecraft, connection ), m_iPad( iPad )
|
||||
{
|
||||
TutorialMode::TutorialMode(int iPad, Minecraft* minecraft,
|
||||
ClientConnection* connection)
|
||||
: MultiPlayerGameMode(minecraft, connection), m_iPad(iPad) {}
|
||||
|
||||
TutorialMode::~TutorialMode() {
|
||||
if (tutorial != NULL) delete tutorial;
|
||||
}
|
||||
|
||||
TutorialMode::~TutorialMode()
|
||||
{
|
||||
if(tutorial != NULL)
|
||||
delete tutorial;
|
||||
void TutorialMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||
if (!tutorial->m_allTutorialsComplete) {
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
tutorial->startDestroyBlock(minecraft->player->inventory->getSelected(),
|
||||
Tile::tiles[t]);
|
||||
}
|
||||
MultiPlayerGameMode::startDestroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
void TutorialMode::startDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
{
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
tutorial->startDestroyBlock(minecraft->player->inventory->getSelected(), Tile::tiles[t]);
|
||||
}
|
||||
MultiPlayerGameMode::startDestroyBlock( x, y, z, face );
|
||||
bool TutorialMode::destroyBlock(int x, int y, int z, int face) {
|
||||
if (!tutorial->m_allTutorialsComplete) {
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
tutorial->destroyBlock(Tile::tiles[t]);
|
||||
}
|
||||
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
||||
int damageBefore;
|
||||
if (item != NULL) {
|
||||
damageBefore = item->getDamageValue();
|
||||
}
|
||||
bool changed = MultiPlayerGameMode::destroyBlock(x, y, z, face);
|
||||
|
||||
if (!tutorial->m_allTutorialsComplete) {
|
||||
if (item != NULL && item->isDamageableItem()) {
|
||||
int max = item->getMaxDamage();
|
||||
int damageNow = item->getDamageValue();
|
||||
|
||||
if (damageNow > damageBefore && damageNow > (max / 2)) {
|
||||
tutorial->itemDamaged(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool TutorialMode::destroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
{
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
tutorial->destroyBlock(Tile::tiles[t]);
|
||||
}
|
||||
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
||||
int damageBefore;
|
||||
if(item != NULL)
|
||||
{
|
||||
damageBefore = item->getDamageValue();
|
||||
}
|
||||
bool changed = MultiPlayerGameMode::destroyBlock( x, y, z, face );
|
||||
void TutorialMode::tick() {
|
||||
MultiPlayerGameMode::tick();
|
||||
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
{
|
||||
if ( item != NULL && item->isDamageableItem() )
|
||||
{
|
||||
int max = item->getMaxDamage();
|
||||
int damageNow = item->getDamageValue();
|
||||
if (!tutorial->m_allTutorialsComplete) tutorial->tick();
|
||||
|
||||
if(damageNow > damageBefore && damageNow > (max/2) )
|
||||
{
|
||||
tutorial->itemDamaged( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
/*
|
||||
if( tutorial.m_allTutorialsComplete && (tutorial.lastMessageTime +
|
||||
m_iTutorialDisplayMessageTime) < GetTickCount() )
|
||||
{
|
||||
// Exit tutorial
|
||||
minecraft->gameMode = new SurvivalMode( this );
|
||||
delete this;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void TutorialMode::tick()
|
||||
{
|
||||
MultiPlayerGameMode::tick();
|
||||
bool TutorialMode::useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face, Vec3* hit, bool bTestUseOnly,
|
||||
bool* pbUsedItem) {
|
||||
bool haveItem = false;
|
||||
int itemCount = 0;
|
||||
if (!tutorial->m_allTutorialsComplete) {
|
||||
tutorial->useItemOn(level, item, x, y, z, bTestUseOnly);
|
||||
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
tutorial->tick();
|
||||
if (!bTestUseOnly) {
|
||||
if (item != NULL) {
|
||||
haveItem = true;
|
||||
itemCount = item->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool result = MultiPlayerGameMode::useItemOn(
|
||||
player, level, item, x, y, z, face, hit, bTestUseOnly, pbUsedItem);
|
||||
|
||||
/*
|
||||
if( tutorial.m_allTutorialsComplete && (tutorial.lastMessageTime + m_iTutorialDisplayMessageTime) < GetTickCount() )
|
||||
{
|
||||
// Exit tutorial
|
||||
minecraft->gameMode = new SurvivalMode( this );
|
||||
delete this;
|
||||
}
|
||||
*/
|
||||
if (!bTestUseOnly) {
|
||||
if (!tutorial->m_allTutorialsComplete) {
|
||||
if (result && haveItem && itemCount > item->count) {
|
||||
tutorial->useItemOn(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TutorialMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly, bool *pbUsedItem)
|
||||
{
|
||||
bool haveItem = false;
|
||||
int itemCount = 0;
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
{
|
||||
tutorial->useItemOn(level, item, x, y, z, bTestUseOnly);
|
||||
void TutorialMode::attack(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity) {
|
||||
if (!tutorial->m_allTutorialsComplete) tutorial->attack(player, entity);
|
||||
|
||||
if(!bTestUseOnly)
|
||||
{
|
||||
if(item != NULL)
|
||||
{
|
||||
haveItem = true;
|
||||
itemCount = item->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool result = MultiPlayerGameMode::useItemOn( player, level, item, x, y, z, face, hit, bTestUseOnly, pbUsedItem );
|
||||
|
||||
if(!bTestUseOnly)
|
||||
{
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
{
|
||||
if( result && haveItem && itemCount > item->count )
|
||||
{
|
||||
tutorial->useItemOn(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
MultiPlayerGameMode::attack(player, entity);
|
||||
}
|
||||
|
||||
void TutorialMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||
{
|
||||
if(!tutorial->m_allTutorialsComplete)
|
||||
tutorial->attack(player, entity);
|
||||
|
||||
MultiPlayerGameMode::attack( player, entity );
|
||||
}
|
||||
|
||||
bool TutorialMode::isInputAllowed(int mapping)
|
||||
{
|
||||
return tutorial->m_allTutorialsComplete || tutorial->isInputAllowed( mapping );
|
||||
bool TutorialMode::isInputAllowed(int mapping) {
|
||||
return tutorial->m_allTutorialsComplete ||
|
||||
tutorial->isInputAllowed(mapping);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user