#include "InventoryMove.h"

#include "Client.h"

#include "Utils/MoveUtils.h"

auto InventoryMove::onClient() -> void {
	if (!enabled) return;

	auto clientinstance = Client::clientinstance;
	if (!clientinstance) return;

	auto localplayer = clientinstance->getLocalPlayer();
	if (!localplayer) return;

	glm::vec3 velocity = Utils::Move::getVelocity(localplayer);
	if (
		Client::screenName != _("small_chest_screen") &&
		Client::screenName != _("large_chest_screen") &&
		Client::screenName != _("ender_chest_screen") &&
		Client::screenName != _("inventory_screen")
		) {
		lastvelocity = velocity;
	}
	else {
		lastvelocity.y = velocity.y;
		Utils::Move::setVelocity(localplayer, lastvelocity);
	}
}

auto InventoryMove::onPacketSendAfter2(Packet* packet, bool* cancel) -> void {
	if (packet->getID() == PacketID::PlayerAuthInput) {
		auto playerauthinput = reinterpret_cast<PlayerAuthInputPacket*>(packet);
		if (
			Client::screenName != _("small_chest_screen") &&
			Client::screenName != _("large_chest_screen") &&
			Client::screenName != _("ender_chest_screen") &&
			Client::screenName != _("inventory_screen")
			) {
			playerauthinput->setDeltaPos(glm::vec3(0.f, 0.f, 0.f));
		}
	}
}

auto InventoryMove::getMode() -> std::string {
	switch (mode) {
	case 0:
		return _("Flareon");
	}

	return _("Unknown");
}
