Skip to content

Commit

Permalink
Merge pull request #20 from zimuya4153/main
Browse files Browse the repository at this point in the history
adapt to GMLIB v0.13.7 and fix the Ability error when close
  • Loading branch information
Zhongzi8972 authored Nov 9, 2024
2 parents 7db7ae9 + 6346ef2 commit 6bcef6e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void RegisterCommand() {
.getOrCreateCommand("freecamera", tr("freecamera.command.desc"), CommandPermissionLevel::Any);
ll::service::getCommandRegistry()->registerAlias("freecamera", "fc");
cmd.overload().execute<[&](CommandOrigin const& origin, CommandOutput& output) {
auto entity = (gmlib::world::Actor*)origin.getEntity();
auto entity = (GMLIB_Actor*)origin.getEntity();
if (entity && entity->isPlayer()) {
auto pl = (Player*)entity;
auto guid = pl->getNetworkIdentifier().mGuid.g;
Expand Down
6 changes: 3 additions & 3 deletions src/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ bool Entry::load() {
mI18n->updateOrCreateLanguage("en_US", en_US);
mI18n->updateOrCreateLanguage("zh_CN", zh_CN);
mI18n->loadAllLanguages();
if (gmlib::Version::getProtocolVersion() != TARGET_PROTOCOL) {
if (GMLIB::Version::getProtocolVersion() != TARGET_PROTOCOL) {
logger.error(tr("error.protocolMismatch.info"));
logger.error(
tr("error.protocolMismatch.version",
{std::to_string(TARGET_PROTOCOL), std::to_string(gmlib::Version::getProtocolVersion())})
{std::to_string(TARGET_PROTOCOL), std::to_string(GMLIB::Version::getProtocolVersion())})
);
return false;
}
Expand Down Expand Up @@ -56,7 +56,7 @@ bool Entry::unload() {

Config& Entry::getConfig() { return mConfig.value(); }

gmlib::i18n::LangI18n& Entry::getI18n() { return mI18n.value(); }
GMLIB::Files::I18n::LangI18n& Entry::getI18n() { return mI18n.value(); }

} // namespace FreeCamera

Expand Down
8 changes: 4 additions & 4 deletions src/Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class Entry {

Config& getConfig();

gmlib::i18n::LangI18n& getI18n();
GMLIB::Files::I18n::LangI18n& getI18n();

private:
ll::mod::NativeMod& mSelf;
std::optional<Config> mConfig;
std::optional<gmlib::i18n::LangI18n> mI18n;
ll::mod::NativeMod& mSelf;
std::optional<Config> mConfig;
std::optional<GMLIB::Files::I18n::LangI18n> mI18n;
};

} // namespace FreeCamera
11 changes: 6 additions & 5 deletions src/FreeCamera.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "Global.h"
#include "mc/network/packet/UpdateAbilitiesPacket.h"

std::unordered_set<uint64> FreeCamList;

namespace FreeCamera {

void EnableFreeCameraPacket(Player* pl) { ((gmlib::world::Player*)pl)->setClientGamemode(GameType::Spectator); }
void EnableFreeCameraPacket(Player* pl) { ((GMLIB_Player*)pl)->setClientGamemode(GameType::Spectator); }

void SendFakePlayerPacket(Player* pl) {
// Client Player
Expand All @@ -15,7 +16,7 @@ void SendFakePlayerPacket(Player* pl) {
pl->sendNetworkPacket(pkt1);
// Update Skin
auto skin = pl->getSkin();
gmlib::network::BinaryStream bs;
GMLIB_BinaryStream bs;
bs.writePacketHeader(MinecraftPacketIds::PlayerSkin);
bs.writeUuid(randomUuid);
bs.writeSkin(skin);
Expand All @@ -26,11 +27,11 @@ void SendFakePlayerPacket(Player* pl) {
}

void DisableFreeCameraPacket(Player* pl) {
((gmlib::world::Player*)pl)->setClientGamemode(pl->getPlayerGameType());
((GMLIB_Player*)pl)->setClientGamemode(pl->getPlayerGameType());
auto uniqueId = pl->getOrCreateUniqueID();
uniqueId.id = uniqueId.id + 114514;
auto pkt2 = RemoveActorPacket(uniqueId);
pl->sendNetworkPacket(pkt2);
RemoveActorPacket(uniqueId).sendTo(*pl);
UpdateAbilitiesPacket(pl->getOrCreateUniqueID(), pl->getAbilities()).sendTo(*pl);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/Global.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <headers/include_all.h>
#include <include_all.h>

#define MOD_NAME "FreeCamera"
#define TARGET_PROTOCOL 686
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end

-- Option 1: Use the latest version of LeviLamina released on GitHub.
add_requires("levilamina")
add_requires("gmlib")
add_requires("gmlib 0.13.7")


-- Option 2: Use a specific version of LeviLamina released on GitHub.
Expand Down

0 comments on commit 6bcef6e

Please sign in to comment.