mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-01 03:22:33 +00:00
refactor: extend ITutorial to cover MultiPlayerLocalPlayer event hooks
This commit is contained in:
@@ -5,9 +5,8 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "app/common/Tutorial/Tutorial.h"
|
||||
#include "app/common/Tutorial/TutorialMode.h"
|
||||
#include "minecraft/IGameServices.h"
|
||||
#include "minecraft/world/tutorial/ITutorial.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerGameMode.h"
|
||||
#include "minecraft/client/player/Input.h"
|
||||
@@ -234,10 +233,11 @@ void MultiplayerLocalPlayer::actuallyHurt(DamageSource* source, float dmg) {
|
||||
void MultiplayerLocalPlayer::completeUsingItem() {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (useItem != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->completeUsingItem(useItem);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->completeUsingItem(useItem);
|
||||
}
|
||||
}
|
||||
Player::completeUsingItem();
|
||||
}
|
||||
@@ -245,10 +245,11 @@ void MultiplayerLocalPlayer::completeUsingItem() {
|
||||
void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance* effect) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
}
|
||||
}
|
||||
Player::onEffectAdded(effect);
|
||||
}
|
||||
@@ -257,10 +258,11 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect,
|
||||
bool doRefreshAttributes) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
}
|
||||
}
|
||||
Player::onEffectUpdated(effect, doRefreshAttributes);
|
||||
}
|
||||
@@ -268,10 +270,12 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect,
|
||||
void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()], true);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()],
|
||||
true);
|
||||
}
|
||||
}
|
||||
Player::onEffectRemoved(effect);
|
||||
}
|
||||
@@ -351,13 +355,14 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
if (wasRiding && !isRiding) {
|
||||
gameMode->getTutorial()->changeTutorialState(
|
||||
e_Tutorial_State_Gameplay);
|
||||
} else if (!wasRiding && isRiding) {
|
||||
gameMode->getTutorial()->onRideEntity(e);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
if (wasRiding && !isRiding) {
|
||||
tutorial->changeTutorialState(e_Tutorial_State_Gameplay);
|
||||
} else if (!wasRiding && isRiding) {
|
||||
tutorial->onRideEntity(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user