Skip to content

Commit

Permalink
适配 ll 1.0.0-rc.3
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Jan 22, 2025
1 parent 9abebb7 commit 2c35c74
Show file tree
Hide file tree
Showing 32 changed files with 603 additions and 651 deletions.
1 change: 0 additions & 1 deletion include/plotcraft/EconomySystem.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include "mc/deps/core/mce/UUID.h"
#include "mc/world/actor/player/Player.h"
#include "plotcraft/Global.h"

Expand Down
7 changes: 3 additions & 4 deletions include/plotcraft/Global.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "ll/api/schedule/Scheduler.h"
#include "mc/deps/core/mce/UUID.h"
#include "ll/api/chrono/GameChrono.h"
#include "mc/deps/core/math/Vec3.h"
#include "mc/platform/UUID.h"
#include "mc/world/level/BlockPos.h"
#include <nlohmann/json.hpp>
#include <string>
Expand All @@ -25,7 +26,6 @@

namespace plot {


using string = std::string;
using json = nlohmann::json;
using DiagonPos = std::pair<Vec3, Vec3>;
Expand All @@ -44,7 +44,6 @@ PLAPI int getPlotWorldDimensionId();


using ll::chrono_literals::operator""_tick;
PLAPI extern ll::schedule::GameTickScheduler GlobalPlotScheduler;


} // namespace plot
2 changes: 0 additions & 2 deletions include/plotcraft/data/PlotMetadata.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#include "mc/math/Vec3.h"
#include "mc/world/level/BlockPos.h"
#include "plotcraft/Global.h"
#include "plotcraft/math/PlotPos.h"
#include <memory>
Expand Down
2 changes: 0 additions & 2 deletions include/plotcraft/math/PlotCross.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#include "mc/math/Vec3.h"
#include "mc/world/level/BlockPos.h"
#include "mc/world/level/block/Block.h"
#include "plotcraft/Global.h"
#include <vector>
Expand Down
6 changes: 2 additions & 4 deletions include/plotcraft/math/PlotPos.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#include "mc/math/Vec3.h"
#include "mc/world/level/BlockPos.h"
#include "mc/world/level/block/Block.h"
#include "plotcraft/Global.h"
#include <memory>
Expand Down Expand Up @@ -35,9 +33,9 @@ class PlotPos {

PLAPI bool isPosInPlot(const Vec3& vec3) const; // 判断一个点是否在地皮内

PLAPI bool isPosOnBorder(Vec3 const& vec3) const; // 判断一个点是否在地皮边界上
PLAPI bool isPosOnBorder(Vec3 const& vec3) const; // 判断一个点是否在地皮边界上
PLAPI bool isAABBOnBorder(BlockPos const& min, BlockPos const& max) const; // 判断一个立方体是否在地皮边界上
PLAPI bool isRadiusOnBorder(BlockPos const& center, int radius) const; // 判断一个圆是否在地皮边界上
PLAPI bool isRadiusOnBorder(BlockPos const& center, int radius) const; // 判断一个圆是否在地皮边界上

PLAPI bool operator==(PlotPos const& other) const;
PLAPI bool operator!=(PlotPos const& other) const;
Expand Down
2 changes: 0 additions & 2 deletions include/plotcraft/math/PlotRoad.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once
#include "PlotDirection.h"
#include "mc/math/Vec3.h"
#include "mc/world/level/BlockPos.h"
#include "mc/world/level/block/Block.h"
#include "plotcraft/Global.h"
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion include/plotcraft/math/Polygon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include "mc/math/Vec3.h"
#include "mc/world/level/BlockPos.h"
#include "plotcraft/Global.h"

Expand Down
51 changes: 22 additions & 29 deletions include/plotcraft/utils/Mc.h
Original file line number Diff line number Diff line change
@@ -1,56 +1,44 @@
#pragma once
#include "ll/api/command/CommandRegistrar.h"
#include "ll/api/event/EventBus.h"
#include "ll/api/event/server/ServerStartedEvent.h"
#include "fmt/format.h"
#include "ll/api/service/Bedrock.h"
#include "ll/api/service/ServerInfo.h"
#include "ll/api/service/Service.h"
#include "ll/api/service/ServiceId.h"
#include "ll/api/utils/HashUtils.h"
#include "mc/_HeaderOutputPredefine.h"
#include "mc/codebuilder/MCRESULT.h"
#include "mc/common/wrapper/GenerateMessageResult.h"
#include "mc/deps/json/JsonHelpers.h"
#include "mc/enums/CurrentCmdVersion.h"
#include "mc/deps/core/string/HashedString.h"
#include "mc/deps/core/utility/MCRESULT.h"
#include "mc/external/render_dragon/frame_renderer/CommandContext.h"
#include "mc/locale/I18n.h"
#include "mc/locale/Localization.h"
#include "mc/server/ServerLevel.h"
#include "mc/server/commands/BlockStateCommandParam.h"
#include "mc/server/commands/CommandBlockName.h"
#include "mc/server/commands/CommandBlockNameResult.h"
#include "mc/server/commands/CommandContext.h"
#include "mc/server/commands/CommandOriginLoader.h"
#include "mc/server/commands/CommandOrigin.h"
#include "mc/server/commands/CommandOutput.h"
#include "mc/server/commands/CommandOutputParameter.h"
#include "mc/server/commands/CommandOutputType.h"
#include "mc/server/commands/CommandPermissionLevel.h"
#include "mc/server/commands/CommandVersion.h"
#include "mc/server/commands/CurrentCmdVersion.h"
#include "mc/server/commands/MinecraftCommands.h"
#include "mc/server/commands/PlayerCommandOrigin.h"
#include "mc/server/commands/ServerCommandOrigin.h"
#include "mc/world/Minecraft.h"
#include "mc/world/actor/player/Player.h"
#include "mc/world/item/ItemInstance.h"
#include "mc/world/item/registry/ItemStack.h"
#include "mc/world/level/BlockPos.h"
#include "mc/world/level/BlockSource.h"
#include "mc/world/level/ChunkBlockPos.h"
#include "mc/world/level/Level.h"
#include "mc/world/level/block/Block.h"
#include "mc/world/level/block/actor/BlockActor.h"
#include "mc/world/level/chunk/LevelChunk.h"
#include "mc/world/level/dimension/Dimension.h"
#include "plotcraft/Global.h"
#include <ll/api/service/Bedrock.h>
#include <ll/api/service/ServerInfo.h>
#include <ll/api/service/Service.h>
#include <ll/api/service/ServiceManager.h>
#include <mc/common/wrapper/optional_ref.h>
#include <mc/deps/core/utility/optional_ref.h>
#include <mc/server/commands/Command.h>
#include <mc/server/commands/CommandContext.h>
#include <mc/server/commands/MinecraftCommands.h>
#include <mc/server/commands/PlayerCommandOrigin.h>
#include <mc/world/Minecraft.h>
#include <mc/world/actor/player/Player.h>
#include <mc/world/level/Command.h>
#include <memory>
#include <string>

Expand All @@ -63,11 +51,15 @@ PLAPI inline Block const& getBlock(BlockPos& bp, int dimid) {
return ll::service::getLevel()->getDimension(dimid)->getBlockSourceFromMainChunkSource().getBlock(bp);
}

PLAPI inline void executeCommand(const string& cmd, Player* player = nullptr) {
PLAPI inline void executeCommand(const std::string& cmd, Player* player = nullptr) {
if (player) {
// player
CommandContext ctx = CommandContext(cmd, std::make_unique<PlayerCommandOrigin>(PlayerCommandOrigin(*player)));
ll::service::getMinecraft()->getCommands().executeCommand(ctx);
CommandContext ctx = CommandContext(
cmd,
std::make_unique<PlayerCommandOrigin>(PlayerCommandOrigin(*player)),
CommandVersion::CurrentVersion()
);
ll::service::getMinecraft()->getCommands().executeCommand(ctx, true);
} else {
// console
CommandContext ctx = CommandContext(
Expand All @@ -77,19 +69,20 @@ PLAPI inline void executeCommand(const string& cmd, Player* player = nullptr) {
ll::service::getLevel()->asServer(),
CommandPermissionLevel::Owner,
0
)
),
CommandVersion::CurrentVersion()
);
ll::service::getMinecraft()->getCommands().executeCommand(ctx);
ll::service::getMinecraft()->getCommands().executeCommand(ctx, true);
}
}
PLAPI inline std::pair<bool, string> executeCommandEx(const string& cmd) {
PLAPI inline std::pair<bool, std::string> executeCommandEx(const std::string& cmd) {
std::pair<bool, std::string> result;
auto origin =
ServerCommandOrigin("Server", ll::service::getLevel()->asServer(), CommandPermissionLevel::Internal, 0);
auto command = ll::service::getMinecraft()->getCommands().compileCommand(
std::string(cmd),
cmd.c_str(),
origin,
(CurrentCmdVersion)CommandVersion::CurrentVersion,
(CurrentCmdVersion)CommandVersion::CurrentVersion(),
[&](std::string const& err) { result.second.append(err).append("\n"); }
);
if (command) {
Expand Down
121 changes: 0 additions & 121 deletions scripts/after_build.lua

This file was deleted.

Loading

0 comments on commit 2c35c74

Please sign in to comment.