#include "Jesus.h"

#include "Utils/MoveUtils.h"

auto Jesus::onWorldTick(Player* _this) -> void {
	auto clientinstance = Client::clientinstance;
	if (!clientinstance) return;

	auto blocksource = clientinstance->getBlockSource();
	if (!blocksource) return;

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

	glm::vec3 under = Utils::Move::getBlockPosition(localplayer);
	glm::ivec3 iunder = glm::ivec3(under.x, under.y - 1.f, under.z);
	std::string name = blocksource->getBlock(&iunder)->getBlockLegacy()->getName();
	if (name == _("tile.water") && !Utils::Move::isJumping()) {
		glm::vec3 velocity = Utils::Move::getVelocity(localplayer);
		Utils::Move::setVelocity(localplayer, glm::vec3(velocity.x, 0, velocity.z));
	}
}
