Skip to content

Commit

Permalink
chore: update version
Browse files Browse the repository at this point in the history
  • Loading branch information
KobeBryant114514 committed Oct 9, 2024
1 parent eefd8e3 commit 99cb674
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 57 deletions.
Binary file modified bin/DLL/GMLIB/GMLIB.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/DLL/GMLIB/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"author": "GroupMountain",
"description": "Group Mountain Library",
"passive": true,
"version": "0.13.6"
"version": "0.13.7"
}
24 changes: 24 additions & 0 deletions bin/SDK/include/GMLIB/Mod/CustomGenerator/CustomFeature.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include "GMLIB/Macros.h"
#include "mc/util/Random.h"
#include "mc/world/level/BlockPos.h"
#include "mc/world/level/BlockSource.h"
#include "mc/world/level/levelgen/feature/helpers/RenderParams.h"
#include "nlohmann/json.hpp"

namespace GMLIB::Mod {

class GMLIB_Feature {
public:
virtual ~GMLIB_Feature();
virtual std::optional<BlockPos>
place(class BlockSource& source, class BlockPos const& pos, class Random& random, class RenderParams& renderParams)
const = 0;
};
class CustomFeature {
public:
GMLIB_API static void registerFeature(std::string const& name, std::shared_ptr<GMLIB_Feature> feature);
GMLIB_API static void registerFeatureRule(nlohmann::json const& json);
};

} // namespace GMLIB::Mod
47 changes: 25 additions & 22 deletions bin/SDK/include/GMLIB/Server/FormAPI/ChestForm.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
#pragma once
#include "GMLIB/Macros.h"
#include "mc/world/actor/player/Player.h"
#include "mc/world/effect/MobEffect.h"
#include "mc/world/item/registry/ItemStack.h"


namespace GMLIB::Server::Form {

class ChestForm {

public:
enum SlotType : int {
enum class SlotType : int {
Chest,
Inventory,
Cursor,
// The SlotType::None will be showed in callback in some special circumstances,
// such as player throwing the item out of the chest.
// Do not use SlotType::None to register a slot !!!!!
None
}; // The SlotType::None will be showed in callback in some special circumstances,
// such as player throwing the item out of the chest.
//Do not use SlotType::None to register a slot !!!!!
};

enum class FormType : int { SimpleChest, BigChest };

enum FormType : int { SimpleChest, BigChest };
struct ChangingSlot {
int slot;
SlotType type;
};

public:
std::unordered_map<int, std::string> mChestItems = std::unordered_map<int, std::string>();
std::unordered_map<int, std::string> mInventoryItems = std::unordered_map<int, std::string>();
std::string mCurorItem;
std::string mName;
FormType mFormType;
protected:
std::unordered_map<int, ItemStack> mChestItems;
std::unordered_map<int, ItemStack> mInventoryItems;
ItemStack mCurorItem;
std::string mName;
FormType mFormType;
std::function<void(ChestForm&, Player&, ChangingSlot, ChangingSlot, int)> mCallback;

public:
std::function<void(ChestForm&, Player&, ChangingSlot, ChangingSlot, int)> getCallback();

public:
/**
Expand All @@ -43,13 +44,16 @@ class ChestForm {
*/
GMLIB_API ChestForm(
std::string const& name,
FormType formType,

// Src is the slot where player pick the item.
// Dst is the slot where player place the item.
// Amount is the amount of item changes.
std::function<void(ChestForm&, Player&, ChangingSlot src, ChangingSlot dst, int amount)> mCallback
std::function<void(ChestForm&, Player&, ChangingSlot src, ChangingSlot dst, int amount)> callback,
FormType formType = FormType::BigChest
);

ChestForm() = delete;

public:
/**
* Init a slot in the form.
* @param slot If the type is SlotType::Cursor, this param won't take effect(The cursor has only one slot).
Expand All @@ -59,13 +63,12 @@ class ChestForm {
GMLIB_API void registerSlot(int slot, ItemStack const& item, SlotType type);

GMLIB_API bool
setSlot(int slot, ItemStack const& item, Player& pl, SlotType type); // Hot change ,return true if success
setSlot(int slot, ItemStack const& item, Player& pl, SlotType type); // Hot change, return true if succeed

GMLIB_API void sendTo(Player& pl);
GMLIB_API static bool closeChestForm(Player& pl);
GMLIB_API void sendTo(Player& pl);

ChestForm() = delete;
public:
GMLIB_API static bool closeChestForm(Player& pl);
};


} // namespace GMLIB::Server::Form
6 changes: 4 additions & 2 deletions bin/SDK/include/GMLIB/Server/FormAPI/NpcDialogueForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NpcDialogueForm {
Open = 2 // Close Command
};

public:
protected:
std::string mDialogue;
std::string mSceneName;
std::string mNpcName;
Expand All @@ -28,9 +28,11 @@ class NpcDialogueForm {
NpcDialogueForm() = delete;

public:
virtual ~NpcDialogueForm();
std::function<void(Player& pl, int index, NpcRequestPacket::RequestType type)> getCallback();

public:
GMLIB_API int addButton(std::string const& name);

GMLIB_API int addAction(
std::string const& name,
NpcDialogueFormAction type = NpcDialogueFormAction::Button,
Expand Down
79 changes: 77 additions & 2 deletions bin/SDK/include/GMLIB/Server/FormAPI/ServerSettingForm.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,83 @@
#pragma once
#include "GMLIB/Macros.h"
#include "ll/api/form/CustomForm.h"
#include "mc/world/actor/player/Player.h"

class GMLIB_ServerSettingForm {
namespace GMLIB::Server::Form {

enum class IconType : uchar { Texture = 0, Url = 1 };

class ServerSettingForm {
public:
ll::form::CustomForm mForm;
GMLIB_API static int getDefaultPriority();

GMLIB_API static bool hasTitle();

GMLIB_API static std::string getTitle();

GMLIB_API static bool setTitle(std::string const& title, bool forceModify = false);

GMLIB_API static bool hasIcon();

GMLIB_API static std::optional<std::string> getIconData();

GMLIB_API static std::optional<IconType> getIconType();

GMLIB_API static bool setIcon(std::string const& data, IconType type = IconType::Texture, bool forceModify = false);

GMLIB_API static uint addLabel(
std::string const& text,
std::function<bool(Player&)> playerDetector = [](Player& pl) -> bool { return true; },
uint priority = getDefaultPriority()
);

GMLIB_API static uint addInput(
std::string const& text,
std::string const& placeholder = {},
std::string const& defaultVal = {},
std::function<void(Player&, std::string const&)> callback = nullptr,
std::function<bool(Player&)> playerDetector = [](Player& pl) -> bool { return true; },
uint priority = getDefaultPriority()
);

GMLIB_API static uint addToggle(
std::string const& text,
bool defaultVal = false,
std::function<void(Player&, bool)> callback = nullptr,
std::function<bool(Player&)> playerDetector = [](Player& pl) -> bool { return true; },
uint priority = getDefaultPriority()
);

GMLIB_API static uint addDropdown(
std::string const& text,
std::vector<std::string> const& options,
size_t defaultVal = 0,
std::function<void(Player&, int64)> callback = nullptr,
std::function<bool(Player&)> playerDetector = [](Player& pl) -> bool { return true; },
uint priority = getDefaultPriority()
);

GMLIB_API static uint addSlider(
std::string const& text,
double min,
double max,
double step = 0.0,
double defaultVal = 0.0,
std::function<void(Player&, double)> callback = nullptr,
std::function<bool(Player&)> playerDetector = [](Player& pl) -> bool { return true; },
uint priority = getDefaultPriority()
);

GMLIB_API static uint addStepSlider(
std::string const& text,
std::vector<std::string> const& steps,
size_t defaultVal = 0,
std::function<void(Player&, int64)> callback = nullptr,
std::function<bool(Player&)> playerDetector = [](Player& pl) -> bool { return true; },
uint priority = getDefaultPriority()
);

GMLIB_API static bool removeElement(uint id);
};

} // namespace GMLIB::Server::Form
2 changes: 2 additions & 0 deletions bin/SDK/include/GMLIB/Server/ItemStackAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ class GMLIB_ItemStack : public ItemStack {

GMLIB_API void setItemLockMode(::ItemLockMode mode);

GMLIB_API bool setEmptyEnchanted();

GMLIB_NDAPI ::ItemLockMode getItemLockMode();
};
44 changes: 21 additions & 23 deletions bin/SDK/include/GMLIB/Server/LevelAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mc/world/level/levelgen/structure/StructureFeatureType.h"
#include "mc/world/level/storage/DBStorage.h"
#include "mc/world/level/storage/GameRuleId.h"
#include "mc/world/level/storage/GameRules.h"

class GMLIB_Level : public Level {
public:
Expand Down Expand Up @@ -63,35 +64,34 @@ class GMLIB_Level : public Level {

GMLIB_API void setAndUpdateTime(int time);

GMLIB_API WeatherType getWeather();
GMLIB_NDAPI WeatherType getWeather();

GMLIB_API void setWeather(WeatherType weather);

GMLIB_API void setWeather(WeatherType weather, int lastTick);

GMLIB_API std::optional<bool> getGameruleBool(GameRuleId id);

GMLIB_API std::optional<bool> getGameruleBool(std::string_view name);

GMLIB_API std::optional<float> getGameruleFloat(GameRuleId id);

GMLIB_API std::optional<float> getGameruleFloat(std::string_view name);

GMLIB_API std::optional<int> getGameruleInt(GameRuleId id);
GMLIB_NDAPI std::optional<bool> getGameruleBool(GameRules::GameRulesIndex index);
GMLIB_NDAPI std::optional<float> getGameruleFloat(GameRules::GameRulesIndex index);
GMLIB_NDAPI std::optional<int> getGameruleInt(GameRules::GameRulesIndex index);

GMLIB_API std::optional<int> getGameruleInt(std::string_view name);
GMLIB_NDAPI std::optional<bool> getGameruleBool(std::string_view name);
GMLIB_NDAPI std::optional<float> getGameruleFloat(std::string_view name);
GMLIB_NDAPI std::optional<int> getGameruleInt(std::string_view name);

GMLIB_API void setGamerule(GameRuleId id, bool value);
GMLIB_NDAPI std::optional<bool> getGameruleBool(GameRuleId id);
GMLIB_NDAPI std::optional<float> getGameruleFloat(GameRuleId id);
GMLIB_NDAPI std::optional<int> getGameruleInt(GameRuleId id);

GMLIB_API void setGamerule(std::string_view name, bool value);
GMLIB_API bool setGamerule(GameRules::GameRulesIndex index, bool value);
GMLIB_API bool setGamerule(GameRules::GameRulesIndex index, float value);
GMLIB_API bool setGamerule(GameRules::GameRulesIndex index, int value);

GMLIB_API void setGamerule(GameRuleId id, float value);
GMLIB_API bool setGamerule(std::string_view name, bool value);
GMLIB_API bool setGamerule(std::string_view name, float value);
GMLIB_API bool setGamerule(std::string_view name, int value);

GMLIB_API void setGamerule(std::string_view name, float value);

GMLIB_API void setGamerule(GameRuleId id, int value);

GMLIB_API void setGamerule(std::string_view name, int value);
GMLIB_API bool setGamerule(GameRuleId id, bool value);
GMLIB_API bool setGamerule(GameRuleId id, float value);
GMLIB_API bool setGamerule(GameRuleId id, int value);

GMLIB_API void createExplosion(
Vec3 const& pos,
Expand Down Expand Up @@ -123,7 +123,6 @@ class GMLIB_Level : public Level {
GMLIB_NDAPI Block const& loadAndGetBlock(BlockPos const& pos, DimensionType dimId);

GMLIB_API bool setBlock(BlockPos const& pos, DimensionType dimId, Block const& block);

GMLIB_API bool setBlock(BlockPos const& pos, DimensionType dimId, std::string_view name, short aux = 0);

GMLIB_API int fillBlocks(
Expand Down Expand Up @@ -185,7 +184,7 @@ class GMLIB_Level : public Level {

GMLIB_NDAPI StructureFeatureType getStructureFeature(BlockPos const& pos, DimensionType dimId);

GMLIB_NDAPI std::string_view getStructureFeatureName(BlockPos const& pos, DimensionType dimId);
GMLIB_NDAPI std::string getStructureFeatureName(BlockPos const& pos, DimensionType dimId);

GMLIB_NDAPI std::optional<BlockPos> locateNearestStructureFeature(
StructureFeatureType structure,
Expand All @@ -210,7 +209,6 @@ class GMLIB_Level : public Level {
GMLIB_API void sendPacketTo(Packet& packet, Player& player);

GMLIB_API void setClientWeather(WeatherType weather, Player& pl);

GMLIB_API void setClientWeather(WeatherType weather);

GMLIB_API void broadcast(std::string_view message);
Expand Down
6 changes: 3 additions & 3 deletions bin/SDK/include/GMLIB/Server/PlayerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ class GMLIB_Player : public Player {

GMLIB_NDAPI std::optional<int> getScore(std::string const& objective);

GMLIB_NDAPI std::string_view getIP();
GMLIB_NDAPI std::string getIP();

GMLIB_NDAPI ushort getPort();

GMLIB_NDAPI int getAvgPing();

GMLIB_NDAPI int getLastPing();

GMLIB_NDAPI std::string_view getLanguageCode();
GMLIB_NDAPI std::string getLanguageCode();

GMLIB_API std::optional<int>
setScore(std::string const& objective, int value, PlayerScoreSetFunction action = PlayerScoreSetFunction::Set);
Expand Down Expand Up @@ -324,7 +324,7 @@ class GMLIB_Player : public Player {

GMLIB_NDAPI StructureFeatureType getStructureFeature();

GMLIB_NDAPI std::string_view getStructureFeatureName();
GMLIB_NDAPI std::string getStructureFeatureName();

GMLIB_NDAPI std::optional<BlockPos>
locateNearestStructureFeature(StructureFeatureType structure, bool useNewChunksOnly = false);
Expand Down
4 changes: 2 additions & 2 deletions bin/SDK/include/GMLIB/Server/StorageAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

class StorageAPI : public DBStorage {
public:
using DBStorage::deleteData;
using DBStorage::forEachKeyWithPrefix;
using DBStorage::getCompoundTag;
using DBStorage::hasKey;
using DBStorage::saveData;
using DBStorage::deleteData;

public:
GMLIB_NDAPI static optional_ref<StorageAPI> getInstance();

public:
GMLIB_NDAPI bool hasKey(std::string_view key);

GMLIB_NDAPI std::string_view getData(std::string_view key);
GMLIB_NDAPI std::string getData(std::string_view key);

GMLIB_API void saveData(std::string_view key, std::string_view data);

Expand Down
Binary file modified bin/SDK/lib/GMLIB.lib
Binary file not shown.
4 changes: 2 additions & 2 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"format_version": 2,
"tooth": "github.com/GroupMountain/GMLIB",
"version": "0.13.6",
"version": "0.13.7",
"info": {
"name": "GMLIB",
"description": "Group Mountain Library",
Expand All @@ -13,7 +13,7 @@
"library"
]
},
"asset_url": "https://github.com/GroupMountain/GMLIB/releases/download/v0.13.6/GMLIB-windows-x64.zip",
"asset_url": "https://github.com/GroupMountain/GMLIB/releases/download/v0.13.7/GMLIB-windows-x64.zip",
"prerequisites": {
"github.com/LiteLDev/LeviLamina": "0.13.x"
},
Expand Down

0 comments on commit 99cb674

Please sign in to comment.