Compare commits
18 Commits
@@ -12,13 +12,13 @@ jobs:
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: 2.9.9
|
||||
xmake-version: 3.0.0
|
||||
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
- run: |
|
||||
xmake f -a x64 -m release -p windows -v -y
|
||||
xmake f -a x64 -m release -p windows -y
|
||||
|
||||
- run: |
|
||||
xmake -w -y
|
||||
|
||||
@@ -12,13 +12,13 @@ jobs:
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: 2.9.9
|
||||
xmake-version: 3.0.0
|
||||
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
- run: |
|
||||
xmake f -a x64 -m release -p windows -v -y
|
||||
xmake f -a x64 -m release -p windows -y
|
||||
|
||||
- run: |
|
||||
xmake -w -y
|
||||
|
||||
@@ -19,31 +19,6 @@ const PlaceholderAPI = {
|
||||
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
||||
}
|
||||
|
||||
Function.prototype.getName =
|
||||
/**
|
||||
* 获取函数名字
|
||||
* @returns {string}
|
||||
*/
|
||||
function () {
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串哈希值
|
||||
* @param {string} str 字符串
|
||||
* @returns {number}
|
||||
*/
|
||||
function getStringHashCode(str) {
|
||||
let hash = 0, chr;
|
||||
if (str.length === 0) return hash;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
/** PAPI变量类 */
|
||||
class PAPI {
|
||||
constructor() {
|
||||
@@ -58,8 +33,8 @@ class PAPI {
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,8 +45,8 @@ class PAPI {
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +58,8 @@ class PAPI {
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName, UpdateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+52
-49
@@ -1,51 +1,54 @@
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (getPluginName.PluginNameCache) return getPluginName.PluginNameCache;
|
||||
|
||||
// nodejs
|
||||
try {
|
||||
const path = require('path');
|
||||
const selfFileName = path.basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) =>
|
||||
key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
return getPluginName.PluginNameCache = (() => {
|
||||
if (ll.getCurrentPluginInfo) return ll.getCurrentPluginInfo().name;
|
||||
|
||||
const error = new Error("getPluginName");
|
||||
switch (ll.scriptEngineVersion) {
|
||||
case "QuickJS": {
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "V8 12.4.254.21-node.21": {
|
||||
try {
|
||||
const selfFileName = require('path').basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) => key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
return "Unknown";
|
||||
})();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@@ -116,7 +119,7 @@ module.exports = {
|
||||
*/
|
||||
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
||||
if (typeof callback !== "function") throw new Error("callback must be a function!");
|
||||
const /** @type {number} */ eventId = ll.importss("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
||||
const /** @type {number} */ eventId = ll.imports("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
||||
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
|
||||
ll.exports((...data) => {
|
||||
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
||||
@@ -146,7 +149,7 @@ module.exports = {
|
||||
* @param {boolean}
|
||||
*/
|
||||
removeListener: function (eventId) {
|
||||
const result = ll.importss("GMLIB_Event_API", "removeListener")(eventId);
|
||||
const result = ll.imports("GMLIB_Event_API", "removeListener")(eventId);
|
||||
if (result) {
|
||||
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
||||
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
||||
@@ -162,7 +165,7 @@ module.exports = {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
hasListener: function (eventId) {
|
||||
return ll.importss("GMLIB_Event_API", "hasListener")(eventId);
|
||||
return ll.imports("GMLIB_Event_API", "hasListener")(eventId);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -171,7 +174,7 @@ module.exports = {
|
||||
* @returns {number?}
|
||||
*/
|
||||
getListenerPriority: function (eventId) {
|
||||
const priority = ll.importss("GMLIB_Event_API", "getListenerPriority")(eventId);
|
||||
const priority = ll.imports("GMLIB_Event_API", "getListenerPriority")(eventId);
|
||||
return priority === -1 ? undefined : priority;
|
||||
},
|
||||
|
||||
|
||||
Vendored
+196
-167
@@ -183,19 +183,34 @@ export class Minecraft {
|
||||
pos: IntPos
|
||||
): void;
|
||||
|
||||
/** 启用教育版内容 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用教育版内容
|
||||
*/
|
||||
static setEducationFeatureEnabled(): void;
|
||||
|
||||
/** 注册Ability命令 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 注册Ability命令
|
||||
*/
|
||||
static registerAbilityCommand(): void;
|
||||
|
||||
/** 启用Xbox成就 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用Xbox成就
|
||||
*/
|
||||
static setEnableAchievement(): void;
|
||||
|
||||
/** 信任所有玩家皮肤 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 信任所有玩家皮肤
|
||||
*/
|
||||
static setForceTrustSkins(): void;
|
||||
|
||||
/** 启用资源包双端共存 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用资源包双端共存
|
||||
*/
|
||||
static enableCoResourcePack(): void;
|
||||
|
||||
/** 获取存档名称 */
|
||||
@@ -206,13 +221,19 @@ export class Minecraft {
|
||||
name: string
|
||||
): boolean;
|
||||
|
||||
/** 设置假种子 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 设置假种子
|
||||
*/
|
||||
static setFakeSeed(
|
||||
/** 要设置的假种子 */
|
||||
seed: number | undefined
|
||||
): void;
|
||||
|
||||
/** 启用错误方块清理 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用错误方块清理
|
||||
*/
|
||||
static setUnknownBlockCleaner(): void;
|
||||
|
||||
/** 强制生成实体 */
|
||||
@@ -309,7 +330,10 @@ export class Minecraft {
|
||||
/** 移除所有虚假列表玩家 */
|
||||
static removeAllFakeLists(): boolean;
|
||||
|
||||
/** 启用I18n修复 */
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用I18n修复
|
||||
*/
|
||||
static setFixI18nEnabled(): void;
|
||||
|
||||
/** 保存NBT至文件 */
|
||||
@@ -359,7 +383,7 @@ export class Minecraft {
|
||||
): string;
|
||||
|
||||
/** 通过附魔ID获取附魔命名空间ID */
|
||||
static getMaxPlayers(
|
||||
static getEnchantTypeNameFromId(
|
||||
/** 附魔ID */
|
||||
id: number
|
||||
): string | null;
|
||||
@@ -367,6 +391,14 @@ export class Minecraft {
|
||||
/** 获取最大玩家数 */
|
||||
static getMaxPlayers(): number;
|
||||
|
||||
/** 设置最大玩家数 */
|
||||
static setMaxPlayers(
|
||||
/** 最大玩家数 */
|
||||
count: number,
|
||||
/** 是否忽略原版限制 */
|
||||
ignoreVanillaLimit?: boolean
|
||||
): void;
|
||||
|
||||
/** 玩家是否拥有NBT */
|
||||
static hasPlayerNbt(
|
||||
/** 玩家的uuid */
|
||||
@@ -1046,12 +1078,12 @@ export class UserCache {
|
||||
|
||||
/** 获取玩家信息 */
|
||||
static getPlayerInfo(
|
||||
/** 玩家名 或 xuid 或 uuid */
|
||||
/** 玩家名 或 xuid 或 uuid 或 serverId 或 uniqueId */
|
||||
playerIdentifier: string
|
||||
): { Xuid: String, Uuid: string, Name: string } | null;
|
||||
): { Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string } | null;
|
||||
|
||||
/** 获取所有玩家信息 */
|
||||
static getAllPlayerInfo(): { Xuid: String; Uuid: string; Name: string; }[]
|
||||
static getAllPlayerInfo(): { Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string }[]
|
||||
}
|
||||
|
||||
type PacketDataItem = (
|
||||
@@ -1349,161 +1381,158 @@ export class GMLIB_BinaryStream {
|
||||
|
||||
export enum ActorType {
|
||||
Undefined = 1,
|
||||
TypeMask = 0b11111111,
|
||||
None = 0,
|
||||
Mob = 1 << 8,
|
||||
PathfinderMob = 1 << 9 | Mob,
|
||||
UnknownType = 1 << 10,
|
||||
Monster = 1 << 11 | PathfinderMob,
|
||||
Animal = 1 << 12 | PathfinderMob,
|
||||
WaterAnimal = 1 << 13 | PathfinderMob,
|
||||
TamableAnimal = 1 << 14 | Animal,
|
||||
Ambient = 1 << 15 | Mob,
|
||||
UndeadMob = 1 << 16 | Monster,
|
||||
ZombieMonster = 1 << 17 | UndeadMob,
|
||||
Arthropod = 1 << 18 | Monster,
|
||||
Minecart = 1 << 19,
|
||||
SkeletonMonster = 1 << 20 | UndeadMob,
|
||||
EquineAnimal = 1 << 21 | TamableAnimal,
|
||||
Projectile = 1 << 22,
|
||||
AbstractArrow = 1 << 23,
|
||||
VillagerBase = 1 << 24 | PathfinderMob,
|
||||
|
||||
Chicken = 10 | Animal,
|
||||
Cow = 11 | Animal,
|
||||
Pig = 12 | Animal,
|
||||
Sheep = 13 | Animal,
|
||||
Wolf = 14 | TamableAnimal,
|
||||
Villager = 15 | VillagerBase,
|
||||
MushroomCow = 16 | Animal,
|
||||
Squid = 17 | WaterAnimal,
|
||||
Rabbit = 18 | Animal,
|
||||
Bat = 19 | Ambient,
|
||||
IronGolem = 20 | PathfinderMob,
|
||||
SnowGolem = 21 | PathfinderMob,
|
||||
Ocelot = 22 | TamableAnimal,
|
||||
Horse = 23 | EquineAnimal,
|
||||
Donkey = 24 | EquineAnimal,
|
||||
Mule = 25 | EquineAnimal,
|
||||
SkeletonHorse = 26 | EquineAnimal | UndeadMob,
|
||||
ZombieHorse = 27 | EquineAnimal | UndeadMob,
|
||||
PolarBear = 28 | Animal,
|
||||
Llama = 29 | Animal,
|
||||
Parrot = 30 | TamableAnimal,
|
||||
Dolphin = 31 | WaterAnimal,
|
||||
Zombie = 32 | ZombieMonster,
|
||||
Creeper = 33 | Monster,
|
||||
Skeleton = 34 | SkeletonMonster,
|
||||
Spider = 35 | Arthropod,
|
||||
PigZombie = 36 | UndeadMob,
|
||||
Slime = 37 | Monster,
|
||||
EnderMan = 38 | Monster,
|
||||
Silverfish = 39 | Arthropod,
|
||||
CaveSpider = 40 | Arthropod,
|
||||
Ghast = 41 | Monster,
|
||||
LavaSlime = 42 | Monster,
|
||||
Blaze = 43 | Monster,
|
||||
ZombieVillager = 44 | ZombieMonster,
|
||||
Witch = 45 | Monster,
|
||||
Stray = 46 | SkeletonMonster,
|
||||
Husk = 47 | ZombieMonster,
|
||||
WitherSkeleton = 48 | SkeletonMonster,
|
||||
Guardian = 49 | Monster,
|
||||
ElderGuardian = 50 | Monster,
|
||||
Npc = 51 | Mob,
|
||||
WitherBoss = 52 | UndeadMob,
|
||||
Dragon = 53 | Monster,
|
||||
Shulker = 54 | Monster,
|
||||
Endermite = 55 | Arthropod,
|
||||
Agent = 56 | Mob,
|
||||
Vindicator = 57 | Monster,
|
||||
Phantom = 58 | UndeadMob,
|
||||
IllagerBeast = 59 | Monster,
|
||||
UNUSED60 = 60,
|
||||
ArmorStand = 61 | Mob,
|
||||
TripodCamera = 62 | Mob,
|
||||
Player = 63 | Mob,
|
||||
ItemEntity = 64 | None,
|
||||
PrimedTnt = 65 | None,
|
||||
FallingBlock = 66 | None,
|
||||
MovingBlock = 67 | None,
|
||||
ExperiencePotion = 68 | Projectile,
|
||||
Experience = 69 | None,
|
||||
EyeOfEnder = 70 | None,
|
||||
EnderCrystal = 71 | None,
|
||||
FireworksRocket = 72 | None,
|
||||
Trident = 73 | Projectile | AbstractArrow,
|
||||
Turtle = 74 | Animal,
|
||||
Cat = 75 | TamableAnimal,
|
||||
ShulkerBullet = 76 | Projectile,
|
||||
FishingHook = 77 | None,
|
||||
Chalkboard = 78 | None,
|
||||
DragonFireball = 79 | Projectile,
|
||||
Arrow = 80 | Projectile | AbstractArrow,
|
||||
Snowball = 81 | Projectile,
|
||||
ThrownEgg = 82 | Projectile,
|
||||
Painting = 83 | None,
|
||||
MinecartRideable = 84 | Minecart,
|
||||
LargeFireball = 85 | Projectile,
|
||||
ThrownPotion = 86 | Projectile,
|
||||
Enderpearl = 87 | Projectile,
|
||||
LeashKnot = 88 | None,
|
||||
WitherSkull = 89 | Projectile,
|
||||
BoatRideable = 90 | None,
|
||||
WitherSkullDangerous = 91 | Projectile,
|
||||
UNUSED92 = 92,
|
||||
LightningBolt = 93 | None,
|
||||
SmallFireball = 94 | Projectile,
|
||||
AreaEffectCloud = 95 | None,
|
||||
MinecartHopper = 96 | Minecart,
|
||||
MinecartTNT = 97 | Minecart,
|
||||
MinecartChest = 98 | Minecart,
|
||||
MinecartFurnace = 99 | Minecart,
|
||||
MinecartCommandBlock = 100 | Minecart,
|
||||
LingeringPotion = 101 | Projectile,
|
||||
LlamaSpit = 102 | Projectile,
|
||||
EvocationFang = 103 | Projectile,
|
||||
EvocationIllager = 104 | Monster,
|
||||
Vex = 105 | Monster,
|
||||
IceBomb = 106 | Projectile,
|
||||
Balloon = 107 | None,
|
||||
Pufferfish = 108 | WaterAnimal,
|
||||
Salmon = 109 | WaterAnimal,
|
||||
Drowned = 110 | ZombieMonster,
|
||||
Tropicalfish = 111 | WaterAnimal,
|
||||
Fish = 112 | WaterAnimal,
|
||||
Panda = 113 | Animal,
|
||||
Pillager = 114 | Monster,
|
||||
VillagerV2 = 115 | VillagerBase,
|
||||
ZombieVillagerV2 = 116 | ZombieMonster,
|
||||
Shield = 117 | None,
|
||||
WanderingTrader = 118 | PathfinderMob,
|
||||
Lectern = 119 | None,
|
||||
ElderGuardianGhost = 120 | Monster,
|
||||
Fox = 121 | Animal,
|
||||
Bee = 122 | Mob,
|
||||
Piglin = 123 | Mob,
|
||||
Hoglin = 124 | Animal,
|
||||
Strider = 125 | Animal,
|
||||
Zoglin = 126 | UndeadMob,
|
||||
PiglinBrute = 127 | Mob,
|
||||
Goat = 128 | Animal,
|
||||
GlowSquid = 129 | WaterAnimal,
|
||||
Axolotl = 130 | Animal,
|
||||
Warden = 131 | Monster,
|
||||
Frog = 132 | Animal,
|
||||
Tadpole = 133 | WaterAnimal,
|
||||
Allay = 134 | Mob,
|
||||
ChestBoatRideable = 136 | BoatRideable,
|
||||
TraderLlama = 137 | Llama,
|
||||
Camel = 138 | Animal,
|
||||
Sniffer = 139 | Animal,
|
||||
Breeze = 140 | Monster,
|
||||
BreezeWindChargeProjectile = 141 | Projectile,
|
||||
Armadillo = 142 | Animal,
|
||||
WindChargeProjectile = 143 | Projectile,
|
||||
Bogged = 144 | SkeletonMonster,
|
||||
OminousItemSpawner = 145
|
||||
TypeMask = 255,
|
||||
Mob = 256,
|
||||
PathfinderMob = 768,
|
||||
Monster = 2816,
|
||||
Animal = 4864,
|
||||
TamableAnimal = 21248,
|
||||
Ambient = 33024,
|
||||
UndeadMob = 68352,
|
||||
ZombieMonster = 199424,
|
||||
Arthropod = 264960,
|
||||
Minecart = 524288,
|
||||
SkeletonMonster = 1116928,
|
||||
EquineAnimal = 2118400,
|
||||
Projectile = 4194304,
|
||||
AbstractArrow = 8388608,
|
||||
WaterAnimal = 8960,
|
||||
VillagerBase = 16777984,
|
||||
Chicken = 4874,
|
||||
Cow = 4875,
|
||||
Pig = 4876,
|
||||
Sheep = 4877,
|
||||
Wolf = 21262,
|
||||
Villager = 16777999,
|
||||
MushroomCow = 4880,
|
||||
Squid = 8977,
|
||||
Rabbit = 4882,
|
||||
Bat = 33043,
|
||||
IronGolem = 788,
|
||||
SnowGolem = 789,
|
||||
Ocelot = 21270,
|
||||
Horse = 2118423,
|
||||
PolarBear = 4892,
|
||||
Llama = 4893,
|
||||
Parrot = 21278,
|
||||
Dolphin = 8991,
|
||||
Donkey = 2118424,
|
||||
Mule = 2118425,
|
||||
SkeletonHorse = 2186010,
|
||||
ZombieHorse = 2186011,
|
||||
Zombie = 199456,
|
||||
Creeper = 2849,
|
||||
Skeleton = 1116962,
|
||||
Spider = 264995,
|
||||
PigZombie = 68388,
|
||||
Slime = 2853,
|
||||
EnderMan = 2854,
|
||||
Silverfish = 264999,
|
||||
CaveSpider = 265000,
|
||||
Ghast = 2857,
|
||||
LavaSlime = 2858,
|
||||
Blaze = 2859,
|
||||
ZombieVillager = 199468,
|
||||
Witch = 2861,
|
||||
Stray = 1116974,
|
||||
Husk = 199471,
|
||||
WitherSkeleton = 1116976,
|
||||
Guardian = 2865,
|
||||
ElderGuardian = 2866,
|
||||
Npc = 307,
|
||||
WitherBoss = 68404,
|
||||
Dragon = 2869,
|
||||
Shulker = 2870,
|
||||
Endermite = 265015,
|
||||
Agent = 312,
|
||||
Vindicator = 2873,
|
||||
Phantom = 68410,
|
||||
IllagerBeast = 2875,
|
||||
ArmorStand = 317,
|
||||
TripodCamera = 318,
|
||||
Player = 319,
|
||||
ItemEntity = 64,
|
||||
PrimedTnt = 65,
|
||||
FallingBlock = 66,
|
||||
MovingBlock = 67,
|
||||
ExperiencePotion = 4194372,
|
||||
Experience = 69,
|
||||
EyeOfEnder = 70,
|
||||
EnderCrystal = 71,
|
||||
FireworksRocket = 72,
|
||||
Trident = 12582985,
|
||||
Turtle = 4938,
|
||||
Cat = 21323,
|
||||
ShulkerBullet = 4194380,
|
||||
FishingHook = 77,
|
||||
Chalkboard = 78,
|
||||
DragonFireball = 4194383,
|
||||
Arrow = 12582992,
|
||||
Snowball = 4194385,
|
||||
ThrownEgg = 4194386,
|
||||
Painting = 83,
|
||||
LargeFireball = 4194389,
|
||||
ThrownPotion = 4194390,
|
||||
Enderpearl = 4194391,
|
||||
LeashKnot = 88,
|
||||
WitherSkull = 4194393,
|
||||
BoatRideable = 90,
|
||||
WitherSkullDangerous = 4194395,
|
||||
LightningBolt = 93,
|
||||
SmallFireball = 4194398,
|
||||
AreaEffectCloud = 95,
|
||||
LingeringPotion = 4194405,
|
||||
LlamaSpit = 4194406,
|
||||
EvocationFang = 4194407,
|
||||
EvocationIllager = 2920,
|
||||
Vex = 2921,
|
||||
MinecartRideable = 524372,
|
||||
MinecartHopper = 524384,
|
||||
MinecartTNT = 524385,
|
||||
MinecartChest = 524386,
|
||||
MinecartFurnace = 524387,
|
||||
MinecartCommandBlock = 524388,
|
||||
IceBomb = 4194410,
|
||||
Balloon = 107,
|
||||
Pufferfish = 9068,
|
||||
Salmon = 9069,
|
||||
Drowned = 199534,
|
||||
Tropicalfish = 9071,
|
||||
Fish = 9072,
|
||||
Panda = 4977,
|
||||
Pillager = 2930,
|
||||
VillagerV2 = 16778099,
|
||||
ZombieVillagerV2 = 199540,
|
||||
Shield = 117,
|
||||
WanderingTrader = 886,
|
||||
Lectern = 119,
|
||||
ElderGuardianGhost = 2936,
|
||||
Fox = 4985,
|
||||
Bee = 378,
|
||||
Piglin = 379,
|
||||
Hoglin = 4988,
|
||||
Strider = 4989,
|
||||
Zoglin = 68478,
|
||||
PiglinBrute = 383,
|
||||
Goat = 4992,
|
||||
GlowSquid = 9089,
|
||||
Axolotl = 4994,
|
||||
Warden = 2947,
|
||||
Frog = 4996,
|
||||
Tadpole = 9093,
|
||||
Allay = 390,
|
||||
ChestBoatRideable = 218,
|
||||
TraderLlama = 5021,
|
||||
Camel = 5002,
|
||||
Sniffer = 5003,
|
||||
Breeze = 2956,
|
||||
BreezeWindChargeProjectile = 4194445,
|
||||
Armadillo = 5006,
|
||||
WindChargeProjectile = 4194447,
|
||||
Bogged = 1117072,
|
||||
OminousItemSpawner = 145,
|
||||
Creaking = 2962,
|
||||
HappyGhast = 5011,
|
||||
}
|
||||
|
||||
interface Player {
|
||||
|
||||
+178
-166
@@ -216,16 +216,18 @@ const GMLIB_API = {
|
||||
getXuidByName: ll.imports("GMLIB_API", "getXuidByName"),
|
||||
/** 根据名字获取uuid @type {function(string):string} */
|
||||
getUuidByName: ll.imports("GMLIB_API", "getUuidByName"),
|
||||
/** 获取所有已记录的玩家信息 @type {function():Array.<{"Uuid":string,"Xuid":string,"Name":string}>} */
|
||||
/** 根据信息获取玩家信息 @type {function():{"Uuid":string,"Xuid":string,"Name":string,"ServerId":string,"ActorUniqueID":string}} */
|
||||
getPlayerInfo: ll.imports("GMLIB_API", "getPlayerInfo"),
|
||||
/** 获取所有已记录的玩家信息 @type {function():Array.<{"Uuid":string,"Xuid":string,"Name":string,"ServerId":string,"ActorUniqueID":string}>} */
|
||||
getAllPlayerInfo: ll.imports("GMLIB_API", "getAllPlayerInfo"),
|
||||
/** 获取方块RuntimeId @type {function(string,number):number} */
|
||||
getBlockRuntimeId: ll.imports("GMLIB_API", "getBlockRuntimeId"),
|
||||
/** 添加虚假列表玩家 @type {function(string,string):boolean} */
|
||||
addFakeList: ll.imports("GMLIB_API", "addFakeList"),
|
||||
addFakeList: ll.imports("GMLib_ServerAPI", "addFakeList"),
|
||||
/** 删除虚假列表玩家 @type {function(string):boolean} */
|
||||
removeFakeList: ll.imports("GMLIB_API", "removeFakeList"),
|
||||
removeFakeList: ll.imports("GMLib_ServerAPI", "removeFakeList"),
|
||||
/** 删除所有虚假列表玩家 @type {function():void} */
|
||||
removeAllFakeLists: ll.imports("GMLIB_API", "removeAllFakeList"),
|
||||
removeAllFakeLists: ll.imports("GMLib_ServerAPI", "removeAllFakeList"),
|
||||
/** 启用I18n修复 @type {function():void} */
|
||||
setFixI18nEnabled: ll.imports("GMLib_ModAPI", "setFixI18nEnabled"),
|
||||
/** 获取方块翻译键名 @type {function(Block):string} */
|
||||
@@ -280,6 +282,8 @@ const GMLIB_API = {
|
||||
getEnchantTypeNameFromId: ll.imports("GMLIB_API", "getEnchantTypeNameFromId"),
|
||||
/** 获取最大玩家数 @type {function():number} */
|
||||
getMaxPlayers: ll.imports("GMLib_ServerAPI", "getMaxPlayers"),
|
||||
/** 获取最大玩家数 @type {function(number,boolean):void} */
|
||||
setMaxPlayers: ll.imports("GMLib_ServerAPI", "setMaxPlayers"),
|
||||
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
|
||||
dropPlayerItem: ll.imports("GMLIB_API", "dropPlayerItem"),
|
||||
/** 获取玩家的RuntimeId @type {function(Player):number} */
|
||||
@@ -324,7 +328,7 @@ const GMLIB_API = {
|
||||
getItemCategoryName: ll.imports("GMLIB_API", "getItemCategoryName"),
|
||||
/** 获取物品的命名 @type {function(Item):string} */
|
||||
getItemCustomName: ll.imports("GMLIB_API", "getItemCustomName"),
|
||||
/** 获取物品BUFF效果名称 @type {function(Item):string} */
|
||||
/** 获取物品BUFF效果名称 @type {function(Item,boolean):string} */
|
||||
getItemEffecName: ll.imports("GMLIB_API", "getItemEffecName"),
|
||||
/** 物品是否为食物 @type {function(Item):boolean} */
|
||||
itemIsFood: ll.imports("GMLIB_API", "itemIsFood"),
|
||||
@@ -1113,6 +1117,15 @@ class Minecraft {
|
||||
return GMLIB_API.getMaxPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大玩家数量
|
||||
* @param {number} count 最大玩家数量
|
||||
* @param {boolean} [ignoreVanillaLimit=false] 是否忽略原版限制
|
||||
*/
|
||||
static setMaxPlayers(count, ignoreVanillaLimit = false) {
|
||||
return GMLIB_API.setMaxPlayers(count, ignoreVanillaLimit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家是否拥有NBT
|
||||
* @param {string} uuid 玩家的uuid
|
||||
@@ -2096,16 +2109,17 @@ class UserCache {
|
||||
|
||||
/**
|
||||
* 获取玩家信息
|
||||
* @param {string} playerIdentifier 玩家的 xuid 或 uuid 或 名称
|
||||
* @returns {{Xuid: String, Uuid: string, Name: string}?} 玩家信息
|
||||
* @param {string} playerIdentifier 玩家的 xuid 或 uuid 或 realName 或 serverId 或 uniqueId
|
||||
* @returns {{Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string}?} 玩家信息
|
||||
*/
|
||||
static getPlayerInfo(playerIdentifier) {
|
||||
return GMLIB_API.getAllPlayerInfo().find(Info => Object.keys(Info).some(InfoKey => Info[InfoKey] === playerIdentifier));
|
||||
const result = GMLIB_API.getPlayerInfo(playerIdentifier)
|
||||
return Object.keys(result).length === 0 ? null : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有玩家信息
|
||||
* @returns {Array.<{Xuid: String, Uuid: string, Name: string}>} 包含所有玩家信息的数组
|
||||
* @returns {Array.<{Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string}>} 包含所有玩家信息的数组
|
||||
*/
|
||||
static getAllPlayerInfo() {
|
||||
return GMLIB_API.getAllPlayerInfo();
|
||||
@@ -2990,10 +3004,11 @@ LLSE_Item.prototype.getCustomName =
|
||||
LLSE_Item.prototype.getEffecName =
|
||||
/**
|
||||
* 获取物品的BUFF效果名称
|
||||
* @param {boolean} playerIsCreative 玩家是否为创造模式
|
||||
* @returns {string}
|
||||
*/
|
||||
function () {
|
||||
return GMLIB_API.getItemEffecName(this);
|
||||
function (playerIsCreative = false) {
|
||||
return GMLIB_API.getItemEffecName(this, playerIsCreative);
|
||||
};
|
||||
|
||||
LLSE_Item.prototype.isFood =
|
||||
@@ -3119,7 +3134,7 @@ LLSE_Entity.prototype.getAllEffectsInfo =
|
||||
* @returns {{Id: number, Amplifier: number, Duration: number, DurationEasy: number, DurationNormal: number, DurationHard: number, Ambient: boolean, ShowParticles: boolean}[]}
|
||||
*/
|
||||
function () {
|
||||
return this.getAllEffects().map(effectId => this.getEffectInfo(effectId));
|
||||
return this.getAllEffects().map(effectId => this.getEffectInfo(effectId)).filter(effectId => effectId);
|
||||
};
|
||||
|
||||
LLSE_Entity.prototype.isType =
|
||||
@@ -3153,161 +3168,158 @@ LLSE_Entity.prototype.getEntityTypeId =
|
||||
|
||||
const ActorType = Object.freeze({
|
||||
Undefined: 1,
|
||||
TypeMask: 0b11111111,
|
||||
None: 0,
|
||||
Mob: 1 << 8,
|
||||
PathfinderMob: 1 << 9 | this.Mob,
|
||||
UnknownType: 1 << 10,
|
||||
Monster: 1 << 11 | this.PathfinderMob,
|
||||
Animal: 1 << 12 | this.PathfinderMob,
|
||||
WaterAnimal: 1 << 13 | this.PathfinderMob,
|
||||
TamableAnimal: 1 << 14 | this.Animal,
|
||||
Ambient: 1 << 15 | this.Mob,
|
||||
UndeadMob: 1 << 16 | this.Monster,
|
||||
ZombieMonster: 1 << 17 | this.UndeadMob,
|
||||
Arthropod: 1 << 18 | this.Monster,
|
||||
Minecart: 1 << 19,
|
||||
SkeletonMonster: 1 << 20 | this.UndeadMob,
|
||||
EquineAnimal: 1 << 21 | this.TamableAnimal,
|
||||
Projectile: 1 << 22,
|
||||
AbstractArrow: 1 << 23,
|
||||
VillagerBase: 1 << 24 | this.PathfinderMob,
|
||||
|
||||
Chicken: 10 | this.Animal,
|
||||
Cow: 11 | this.Animal,
|
||||
Pig: 12 | this.Animal,
|
||||
Sheep: 13 | this.Animal,
|
||||
Wolf: 14 | this.TamableAnimal,
|
||||
Villager: 15 | this.VillagerBase,
|
||||
MushroomCow: 16 | this.Animal,
|
||||
Squid: 17 | this.WaterAnimal,
|
||||
Rabbit: 18 | this.Animal,
|
||||
Bat: 19 | this.Ambient,
|
||||
IronGolem: 20 | this.PathfinderMob,
|
||||
SnowGolem: 21 | this.PathfinderMob,
|
||||
Ocelot: 22 | this.TamableAnimal,
|
||||
Horse: 23 | this.EquineAnimal,
|
||||
Donkey: 24 | this.EquineAnimal,
|
||||
Mule: 25 | this.EquineAnimal,
|
||||
SkeletonHorse: 26 | this.EquineAnimal | this.UndeadMob,
|
||||
ZombieHorse: 27 | this.EquineAnimal | this.UndeadMob,
|
||||
PolarBear: 28 | this.Animal,
|
||||
Llama: 29 | this.Animal,
|
||||
Parrot: 30 | this.TamableAnimal,
|
||||
Dolphin: 31 | this.WaterAnimal,
|
||||
Zombie: 32 | this.ZombieMonster,
|
||||
Creeper: 33 | this.Monster,
|
||||
Skeleton: 34 | this.SkeletonMonster,
|
||||
Spider: 35 | this.Arthropod,
|
||||
PigZombie: 36 | this.UndeadMob,
|
||||
Slime: 37 | this.Monster,
|
||||
EnderMan: 38 | this.Monster,
|
||||
Silverfish: 39 | this.Arthropod,
|
||||
CaveSpider: 40 | this.Arthropod,
|
||||
Ghast: 41 | this.Monster,
|
||||
LavaSlime: 42 | this.Monster,
|
||||
Blaze: 43 | this.Monster,
|
||||
ZombieVillager: 44 | this.ZombieMonster,
|
||||
Witch: 45 | this.Monster,
|
||||
Stray: 46 | this.SkeletonMonster,
|
||||
Husk: 47 | this.ZombieMonster,
|
||||
WitherSkeleton: 48 | this.SkeletonMonster,
|
||||
Guardian: 49 | this.Monster,
|
||||
ElderGuardian: 50 | this.Monster,
|
||||
Npc: 51 | this.Mob,
|
||||
WitherBoss: 52 | this.UndeadMob,
|
||||
Dragon: 53 | this.Monster,
|
||||
Shulker: 54 | this.Monster,
|
||||
Endermite: 55 | this.Arthropod,
|
||||
Agent: 56 | this.Mob,
|
||||
Vindicator: 57 | this.Monster,
|
||||
Phantom: 58 | this.UndeadMob,
|
||||
IllagerBeast: 59 | this.Monster,
|
||||
UNUSED60: 60,
|
||||
ArmorStand: 61 | this.Mob,
|
||||
TripodCamera: 62 | this.Mob,
|
||||
Player: 63 | this.Mob,
|
||||
ItemEntity: 64 | this.None,
|
||||
PrimedTnt: 65 | this.None,
|
||||
FallingBlock: 66 | this.None,
|
||||
MovingBlock: 67 | this.None,
|
||||
ExperiencePotion: 68 | this.Projectile,
|
||||
Experience: 69 | this.None,
|
||||
EyeOfEnder: 70 | this.None,
|
||||
EnderCrystal: 71 | this.None,
|
||||
FireworksRocket: 72 | this.None,
|
||||
Trident: 73 | this.Projectile | this.AbstractArrow,
|
||||
Turtle: 74 | this.Animal,
|
||||
Cat: 75 | this.TamableAnimal,
|
||||
ShulkerBullet: 76 | this.Projectile,
|
||||
FishingHook: 77 | this.None,
|
||||
Chalkboard: 78 | this.None,
|
||||
DragonFireball: 79 | this.Projectile,
|
||||
Arrow: 80 | this.Projectile | this.AbstractArrow,
|
||||
Snowball: 81 | this.Projectile,
|
||||
ThrownEgg: 82 | this.Projectile,
|
||||
Painting: 83 | this.None,
|
||||
MinecartRideable: 84 | this.Minecart,
|
||||
LargeFireball: 85 | this.Projectile,
|
||||
ThrownPotion: 86 | this.Projectile,
|
||||
Enderpearl: 87 | this.Projectile,
|
||||
LeashKnot: 88 | this.None,
|
||||
WitherSkull: 89 | this.Projectile,
|
||||
BoatRideable: 90 | this.None,
|
||||
WitherSkullDangerous: 91 | this.Projectile,
|
||||
UNUSED92: 92,
|
||||
LightningBolt: 93 | this.None,
|
||||
SmallFireball: 94 | this.Projectile,
|
||||
AreaEffectCloud: 95 | this.None,
|
||||
MinecartHopper: 96 | this.Minecart,
|
||||
MinecartTNT: 97 | this.Minecart,
|
||||
MinecartChest: 98 | this.Minecart,
|
||||
MinecartFurnace: 99 | this.Minecart,
|
||||
MinecartCommandBlock: 100 | this.Minecart,
|
||||
LingeringPotion: 101 | this.Projectile,
|
||||
LlamaSpit: 102 | this.Projectile,
|
||||
EvocationFang: 103 | this.Projectile,
|
||||
EvocationIllager: 104 | this.Monster,
|
||||
Vex: 105 | this.Monster,
|
||||
IceBomb: 106 | this.Projectile,
|
||||
Balloon: 107 | this.None,
|
||||
Pufferfish: 108 | this.WaterAnimal,
|
||||
Salmon: 109 | this.WaterAnimal,
|
||||
Drowned: 110 | this.ZombieMonster,
|
||||
Tropicalfish: 111 | this.WaterAnimal,
|
||||
Fish: 112 | this.WaterAnimal,
|
||||
Panda: 113 | this.Animal,
|
||||
Pillager: 114 | this.Monster,
|
||||
VillagerV2: 115 | this.VillagerBase,
|
||||
ZombieVillagerV2: 116 | this.ZombieMonster,
|
||||
Shield: 117 | this.None,
|
||||
WanderingTrader: 118 | this.PathfinderMob,
|
||||
Lectern: 119 | this.None,
|
||||
ElderGuardianGhost: 120 | this.Monster,
|
||||
Fox: 121 | this.Animal,
|
||||
Bee: 122 | this.Mob,
|
||||
Piglin: 123 | this.Mob,
|
||||
Hoglin: 124 | this.Animal,
|
||||
Strider: 125 | this.Animal,
|
||||
Zoglin: 126 | this.UndeadMob,
|
||||
PiglinBrute: 127 | this.Mob,
|
||||
Goat: 128 | this.Animal,
|
||||
GlowSquid: 129 | this.WaterAnimal,
|
||||
Axolotl: 130 | this.Animal,
|
||||
Warden: 131 | this.Monster,
|
||||
Frog: 132 | this.Animal,
|
||||
Tadpole: 133 | this.WaterAnimal,
|
||||
Allay: 134 | this.Mob,
|
||||
ChestBoatRideable: 136 | this.BoatRideable,
|
||||
TraderLlama: 137 | this.Llama,
|
||||
Camel: 138 | this.Animal,
|
||||
Sniffer: 139 | this.Animal,
|
||||
Breeze: 140 | this.Monster,
|
||||
BreezeWindChargeProjectile: 141 | this.Projectile,
|
||||
Armadillo: 142 | this.Animal,
|
||||
WindChargeProjectile: 143 | this.Projectile,
|
||||
Bogged: 144 | this.SkeletonMonster,
|
||||
TypeMask: 255,
|
||||
Mob: 256,
|
||||
PathfinderMob: 768,
|
||||
Monster: 2816,
|
||||
Animal: 4864,
|
||||
TamableAnimal: 21248,
|
||||
Ambient: 33024,
|
||||
UndeadMob: 68352,
|
||||
ZombieMonster: 199424,
|
||||
Arthropod: 264960,
|
||||
Minecart: 524288,
|
||||
SkeletonMonster: 1116928,
|
||||
EquineAnimal: 2118400,
|
||||
Projectile: 4194304,
|
||||
AbstractArrow: 8388608,
|
||||
WaterAnimal: 8960,
|
||||
VillagerBase: 16777984,
|
||||
Chicken: 4874,
|
||||
Cow: 4875,
|
||||
Pig: 4876,
|
||||
Sheep: 4877,
|
||||
Wolf: 21262,
|
||||
Villager: 16777999,
|
||||
MushroomCow: 4880,
|
||||
Squid: 8977,
|
||||
Rabbit: 4882,
|
||||
Bat: 33043,
|
||||
IronGolem: 788,
|
||||
SnowGolem: 789,
|
||||
Ocelot: 21270,
|
||||
Horse: 2118423,
|
||||
PolarBear: 4892,
|
||||
Llama: 4893,
|
||||
Parrot: 21278,
|
||||
Dolphin: 8991,
|
||||
Donkey: 2118424,
|
||||
Mule: 2118425,
|
||||
SkeletonHorse: 2186010,
|
||||
ZombieHorse: 2186011,
|
||||
Zombie: 199456,
|
||||
Creeper: 2849,
|
||||
Skeleton: 1116962,
|
||||
Spider: 264995,
|
||||
PigZombie: 68388,
|
||||
Slime: 2853,
|
||||
EnderMan: 2854,
|
||||
Silverfish: 264999,
|
||||
CaveSpider: 265000,
|
||||
Ghast: 2857,
|
||||
LavaSlime: 2858,
|
||||
Blaze: 2859,
|
||||
ZombieVillager: 199468,
|
||||
Witch: 2861,
|
||||
Stray: 1116974,
|
||||
Husk: 199471,
|
||||
WitherSkeleton: 1116976,
|
||||
Guardian: 2865,
|
||||
ElderGuardian: 2866,
|
||||
Npc: 307,
|
||||
WitherBoss: 68404,
|
||||
Dragon: 2869,
|
||||
Shulker: 2870,
|
||||
Endermite: 265015,
|
||||
Agent: 312,
|
||||
Vindicator: 2873,
|
||||
Phantom: 68410,
|
||||
IllagerBeast: 2875,
|
||||
ArmorStand: 317,
|
||||
TripodCamera: 318,
|
||||
Player: 319,
|
||||
ItemEntity: 64,
|
||||
PrimedTnt: 65,
|
||||
FallingBlock: 66,
|
||||
MovingBlock: 67,
|
||||
ExperiencePotion: 4194372,
|
||||
Experience: 69,
|
||||
EyeOfEnder: 70,
|
||||
EnderCrystal: 71,
|
||||
FireworksRocket: 72,
|
||||
Trident: 12582985,
|
||||
Turtle: 4938,
|
||||
Cat: 21323,
|
||||
ShulkerBullet: 4194380,
|
||||
FishingHook: 77,
|
||||
Chalkboard: 78,
|
||||
DragonFireball: 4194383,
|
||||
Arrow: 12582992,
|
||||
Snowball: 4194385,
|
||||
ThrownEgg: 4194386,
|
||||
Painting: 83,
|
||||
LargeFireball: 4194389,
|
||||
ThrownPotion: 4194390,
|
||||
Enderpearl: 4194391,
|
||||
LeashKnot: 88,
|
||||
WitherSkull: 4194393,
|
||||
BoatRideable: 90,
|
||||
WitherSkullDangerous: 4194395,
|
||||
LightningBolt: 93,
|
||||
SmallFireball: 4194398,
|
||||
AreaEffectCloud: 95,
|
||||
LingeringPotion: 4194405,
|
||||
LlamaSpit: 4194406,
|
||||
EvocationFang: 4194407,
|
||||
EvocationIllager: 2920,
|
||||
Vex: 2921,
|
||||
MinecartRideable: 524372,
|
||||
MinecartHopper: 524384,
|
||||
MinecartTNT: 524385,
|
||||
MinecartChest: 524386,
|
||||
MinecartFurnace: 524387,
|
||||
MinecartCommandBlock: 524388,
|
||||
IceBomb: 4194410,
|
||||
Balloon: 107,
|
||||
Pufferfish: 9068,
|
||||
Salmon: 9069,
|
||||
Drowned: 199534,
|
||||
Tropicalfish: 9071,
|
||||
Fish: 9072,
|
||||
Panda: 4977,
|
||||
Pillager: 2930,
|
||||
VillagerV2: 16778099,
|
||||
ZombieVillagerV2: 199540,
|
||||
Shield: 117,
|
||||
WanderingTrader: 886,
|
||||
Lectern: 119,
|
||||
ElderGuardianGhost: 2936,
|
||||
Fox: 4985,
|
||||
Bee: 378,
|
||||
Piglin: 379,
|
||||
Hoglin: 4988,
|
||||
Strider: 4989,
|
||||
Zoglin: 68478,
|
||||
PiglinBrute: 383,
|
||||
Goat: 4992,
|
||||
GlowSquid: 9089,
|
||||
Axolotl: 4994,
|
||||
Warden: 2947,
|
||||
Frog: 4996,
|
||||
Tadpole: 9093,
|
||||
Allay: 390,
|
||||
ChestBoatRideable: 218,
|
||||
TraderLlama: 5021,
|
||||
Camel: 5002,
|
||||
Sniffer: 5003,
|
||||
Breeze: 2956,
|
||||
BreezeWindChargeProjectile: 4194445,
|
||||
Armadillo: 5006,
|
||||
WindChargeProjectile: 4194447,
|
||||
Bogged: 1117072,
|
||||
OminousItemSpawner: 145,
|
||||
Creaking: 2962,
|
||||
HappyGhast: 5011,
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
+56
-75
@@ -1,102 +1,83 @@
|
||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (getPluginName.PluginNameCache) return getPluginName.PluginNameCache;
|
||||
|
||||
// nodejs
|
||||
try {
|
||||
const path = require('path');
|
||||
const selfFileName = path.basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) =>
|
||||
key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
return getPluginName.PluginNameCache = (() => {
|
||||
if (ll.getCurrentPluginInfo) return ll.getCurrentPluginInfo().name;
|
||||
|
||||
const error = new Error("getPluginName");
|
||||
switch (ll.scriptEngineVersion) {
|
||||
case "QuickJS": {
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "V8 12.4.254.21-node.21": {
|
||||
try {
|
||||
const selfFileName = require('path').basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) => key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
return "Unknown";
|
||||
})();
|
||||
};
|
||||
|
||||
Function.prototype.getName =
|
||||
/**
|
||||
* 获取函数名字
|
||||
* @returns {string}
|
||||
*/
|
||||
function () {
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取字符串哈希值
|
||||
* @param {string} str 字符串
|
||||
* @returns {number}
|
||||
*/
|
||||
function getStringHashCode(str) {
|
||||
let hash = 0, chr;
|
||||
if (str.length === 0) return hash;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
translate(value, actor = undefined, language = "") {
|
||||
return actor instanceof LLSE_Entity
|
||||
? ll.importss("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
||||
: ll.importss("PlaceholderAPI", "translate")(value, language);
|
||||
? ll.imports("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
||||
: ll.imports("PlaceholderAPI", "translate")(value, language);
|
||||
},
|
||||
registerPlaceholder(placeholder, callback) {
|
||||
const pluginName = getPluginName();
|
||||
ll.exports((...args) => {
|
||||
if(!args[0].uniqueId) args[0] = undefined;
|
||||
return callback(...args) ?? "<std::nullopt>";
|
||||
}, pluginName, callback.getName());
|
||||
ll.importss("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
|
||||
}, pluginName, `Placeholder_${placeholder}`);
|
||||
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, `Placeholder_${placeholder}`, pluginName);
|
||||
},
|
||||
unregisterPlaceholder(placeholder) {
|
||||
return ll.importss("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||
},
|
||||
unregisterPlaceholderFromModName(placeholder) {
|
||||
return ll.importss("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||
},
|
||||
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
||||
if (actor instanceof LLSE_Player) actor = ll.imports("GMLib_ServerAPI", "PlayerToEntity")(actor);
|
||||
const result = actor instanceof LLSE_Entity
|
||||
? ll.importss("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||
: ll.importss("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||
return result !== "<std::nullopt>" ? result : undefined;
|
||||
}
|
||||
};
|
||||
+6
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"version": "1.1.2",
|
||||
"name": "${modName}",
|
||||
"entry": "${modFile}",
|
||||
"version": "${modVersion}",
|
||||
"author": "GroupMountain",
|
||||
"type": "native",
|
||||
"passive": true,
|
||||
@@ -14,6 +14,9 @@
|
||||
},
|
||||
{
|
||||
"name": "iListenAttentively"
|
||||
},
|
||||
{
|
||||
"name": "ModAPI"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
function beautify_json(value, indent)
|
||||
import("core.base.json")
|
||||
local json_text = ""
|
||||
local stack = {}
|
||||
|
||||
local function escape_str(s)
|
||||
return string.gsub(s, '[%c\\"]', function(c)
|
||||
local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'}
|
||||
return replacements[c] or string.format('\\u%04x', c:byte())
|
||||
end)
|
||||
end
|
||||
|
||||
local function is_null(v)
|
||||
return v == json.null
|
||||
end
|
||||
|
||||
local function is_empty_table(t)
|
||||
if type(t) ~= 'table' then return false end
|
||||
for _ in pairs(t) do
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function is_array(t)
|
||||
return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0
|
||||
end
|
||||
|
||||
local function serialize(val, level)
|
||||
local spaces = string.rep(" ", level * indent)
|
||||
|
||||
if type(val) == "table" and not stack[val] then
|
||||
if is_empty_table(val) then
|
||||
json_text = json_text .. (is_array(val) and "[]" or "{}")
|
||||
return
|
||||
end
|
||||
|
||||
stack[val] = true
|
||||
local isArray = is_array(val)
|
||||
json_text = json_text .. (isArray and "[\n" or "{\n")
|
||||
|
||||
local keys = isArray and {} or {}
|
||||
for k in pairs(val) do
|
||||
table.insert(keys, k)
|
||||
end
|
||||
if not isArray then
|
||||
table.sort(keys)
|
||||
end
|
||||
|
||||
for _, k in ipairs(keys) do
|
||||
local v = val[k]
|
||||
json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ')
|
||||
serialize(v, level + 1)
|
||||
json_text = json_text .. ",\n"
|
||||
end
|
||||
|
||||
json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}")
|
||||
stack[val] = nil
|
||||
elseif type(val) == "string" then
|
||||
json_text = json_text .. '"' .. escape_str(val) .. '"'
|
||||
elseif type(val) == "number" then
|
||||
if val % 1 == 0 then
|
||||
json_text = json_text .. tostring(math.floor(val))
|
||||
else
|
||||
json_text = json_text .. tostring(val)
|
||||
end
|
||||
elseif type(val) == "boolean" then
|
||||
json_text = json_text .. tostring(val)
|
||||
elseif is_null(val) then
|
||||
json_text = json_text .. "null"
|
||||
else
|
||||
error("Invalid value type: " .. type(val))
|
||||
end
|
||||
end
|
||||
serialize(value, 1)
|
||||
return json_text
|
||||
end
|
||||
|
||||
function string_formatter(str, variables)
|
||||
return str:gsub("%${(.-)}", function(var)
|
||||
return variables[var] or "${" .. var .. "}"
|
||||
end)
|
||||
end
|
||||
|
||||
function pack_plugin(target,plugin_define)
|
||||
import("lib.detect.find_file")
|
||||
|
||||
local manifest_path = find_file("manifest.json", os.projectdir())
|
||||
if manifest_path then
|
||||
local manifest = io.readfile(manifest_path)
|
||||
local bindir = path.join(os.projectdir(), "bin/DLL")
|
||||
local pdbdir = path.join(os.projectdir(), "bin/PDB")
|
||||
local outputdir = path.join(bindir, plugin_define.pluginName)
|
||||
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
||||
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
||||
local libfile = path.join(os.projectdir(), "lib")
|
||||
local manifestfile = path.join(outputdir, "manifest.json")
|
||||
local oritargetfile = target:targetfile()
|
||||
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
|
||||
|
||||
os.mkdir(outputdir)
|
||||
os.cp(oritargetfile, targetfile)
|
||||
if os.isfile(oripdbfile) then
|
||||
os.cp(oripdbfile, pdbfile)
|
||||
end
|
||||
os.cp(libfile, outputdir)
|
||||
|
||||
formattedmanifest = string_formatter(manifest, plugin_define)
|
||||
io.writefile(manifestfile,formattedmanifest)
|
||||
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir)
|
||||
else
|
||||
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
pack_plugin = pack_plugin,
|
||||
beautify_json = beautify_json,
|
||||
string_formatter = string_formatter
|
||||
}
|
||||
@@ -78,6 +78,7 @@ void Export_BinaryStream_API() {
|
||||
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||
EXPORTAPI("writeUnsignedChar", uchar, bs->writeUnsignedChar(value));
|
||||
EXPORTAPI2(writeBool);
|
||||
EXPORTAPI2(writeByte);
|
||||
EXPORTAPI2(writeDouble);
|
||||
@@ -86,7 +87,6 @@ void Export_BinaryStream_API() {
|
||||
EXPORTAPI2(writeSignedInt);
|
||||
EXPORTAPI2(writeSignedInt64);
|
||||
EXPORTAPI2(writeSignedShort);
|
||||
EXPORTAPI2(writeUnsignedChar);
|
||||
EXPORTAPI2(writeUnsignedInt);
|
||||
EXPORTAPI2(writeUnsignedInt64);
|
||||
EXPORTAPI2(writeUnsignedShort);
|
||||
|
||||
+113
-52
@@ -11,7 +11,7 @@ void Export_Compatibility_API() {
|
||||
return CustomRecipeRegistry::getInstance().unregisterRecipe(id, true);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||
AddonsLoader::addCustomPackPath(path);
|
||||
AddonsLoader::getInstance().addCustomPackPath(path);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||
return GMLevel::getInstance().transform(
|
||||
@@ -19,14 +19,10 @@ void Export_Compatibility_API() {
|
||||
).value_or(0.0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> float { return level.getServerCurrentTps(); }
|
||||
).value_or(0.0);
|
||||
return TpsStatus::getInstance().getLevelCurrentTps();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> double { return level.getServerAverageTps(); }
|
||||
).value_or(0.0);
|
||||
return TpsStatus::getInstance().getLevelAverageTps();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||
std::vector<std::string> result;
|
||||
@@ -45,7 +41,8 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"setPlayerNbt",
|
||||
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) return player->setNbt(*nbt);
|
||||
auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid));
|
||||
if (player&&player->hasNbt()) return player->setNbt(*nbt);
|
||||
return forceCreate ? OfflinePlayer::createNewPlayerNbt(mce::UUID::fromString(uuid), *nbt).has_value()
|
||||
: false;
|
||||
}
|
||||
@@ -444,7 +441,30 @@ void Export_Compatibility_API() {
|
||||
return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId), false);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
||||
return {GMLevel::getInstance()->getLevelData().getSpawnPos(), 0};
|
||||
constexpr static HashedString SPAWN_POS{"spawnPos"};
|
||||
using mUnkfc867e = std::variant<
|
||||
int,
|
||||
bool,
|
||||
float,
|
||||
std::string,
|
||||
GeneratorType,
|
||||
GameType,
|
||||
BlockPos,
|
||||
LevelSeed64,
|
||||
LevelDataValue::Tag,
|
||||
DaylightCycle>;
|
||||
auto& levelData = GMLevel::getInstance()->getLevelData();
|
||||
if (auto it = levelData.mValues->find(SPAWN_POS); it != levelData.mValues->end()) {
|
||||
if (auto value = std::get_if<BlockPos>(&it->second.mUnkfc867e.as<mUnkfc867e>()); value) {
|
||||
return {*value, 0};
|
||||
}
|
||||
}
|
||||
if (auto it = levelData.mOverrides->find(SPAWN_POS); it != levelData.mOverrides->end()) {
|
||||
if (auto value = std::get_if<BlockPos>(&it->second.mUnkfc867e.as<mUnkfc867e>()); value) {
|
||||
return {*value, 0};
|
||||
}
|
||||
}
|
||||
return {BlockPos::ZERO(), 1};
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
||||
if (pos.second != 0) return false;
|
||||
@@ -492,6 +512,7 @@ void Export_Compatibility_API() {
|
||||
if (auto uce = UserCache::getInstance()->from(mce::UUID::fromString(uuid))) {
|
||||
return uce->mName;
|
||||
}
|
||||
return "";
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||
if (auto uce = UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)) {
|
||||
@@ -511,17 +532,46 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
return "";
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"getPlayerInfo",
|
||||
[](std::string const& info) -> std::unordered_map<std::string, std::string> {
|
||||
// TODO: 下个GMLIB更新直接改成from(info, UserCache::QueryType::All)
|
||||
std::unordered_map<std::string, std::string> result;
|
||||
if (auto uce = UserCache::getInstance()->from(mce::UUID::fromString(info))) {
|
||||
ll::reflection::forEachMember(*uce, [&](std::string_view name, auto&& member) {
|
||||
result[std::string{name.substr(1)}] = fmt::to_string(member);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
if (auto uniqeuId = ll::string_utils::svtoll(info); uniqeuId) {
|
||||
if (auto uce = UserCache::getInstance()->from(ActorUniqueID{*uniqeuId})) {
|
||||
ll::reflection::forEachMember(*uce, [&](std::string_view name, auto&& member) {
|
||||
result[std::string{name.substr(1)}] = fmt::to_string(member);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (auto uce = UserCache::getInstance()->from(info, UserCache::QueryType::Default)) {
|
||||
ll::reflection::forEachMember(*uce, [&](std::string_view name, auto&& member) {
|
||||
result[std::string{name.substr(1)}] = fmt::to_string(member);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"getAllPlayerInfo",
|
||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||
for (auto entry : UserCache::getInstance()->entries()) {
|
||||
result.push_back({
|
||||
{"Name", entry.mName },
|
||||
{"Xuid", entry.mXuid },
|
||||
{"Uuid", entry.mUuid.asString()}
|
||||
for (auto& entry : UserCache::getInstance()->entries()) {
|
||||
std::unordered_map<std::string, std::string> item;
|
||||
ll::reflection::forEachMember(entry, [&](std::string_view name, auto&& member) {
|
||||
item[std::string{name.substr(1)}] = fmt::to_string(member);
|
||||
});
|
||||
result.emplace_back(std::move(item));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -532,7 +582,7 @@ void Export_Compatibility_API() {
|
||||
.value_or(0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||
return block->getLegacyBlock().mDescriptionId.get() + ".name";
|
||||
return block->mBlockType->mDescriptionId.get() + ".name";
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||
return item->getDescriptionId();
|
||||
@@ -558,7 +608,7 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
||||
return block->mDirectData->mUnkc08fbd.as<float>();
|
||||
return block->mDirectData->mDestroySpeed;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
||||
return item->getItem()->getDestroySpeed(*item, *block);
|
||||
@@ -571,8 +621,8 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
||||
return std::ranges::any_of(item->mCanDestroy, [block](BlockLegacy const* blockLegacy) {
|
||||
return block->getTypeName() == blockLegacy->getTypeName();
|
||||
return std::ranges::any_of(item->mCanDestroy, [block](BlockType const* blockLegacy) {
|
||||
return blockLegacy && block->getTypeName() == blockLegacy->getTypeName();
|
||||
});
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
||||
@@ -582,16 +632,19 @@ void Export_Compatibility_API() {
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
||||
return item->getItem()->canDestroySpecial(*block);
|
||||
if (auto itemDef = item->getItem(); itemDef) {
|
||||
return itemDef->canDestroySpecial(*block);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||
return !block->getLegacyBlock().mRequiresCorrectToolForDrops;
|
||||
return !block->mBlockType->mRequiresCorrectToolForDrops;
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"blockPlayerWillDestroy",
|
||||
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
|
||||
return block->getLegacyBlock().playerWillDestroy(*player, pos.first, *block);
|
||||
return block->mBlockType->playerWillDestroy(*player, pos.first, *block);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
||||
@@ -612,7 +665,7 @@ void Export_Compatibility_API() {
|
||||
"getBlockLightEmission",
|
||||
[](std::string const& blockName, short legacyData) -> char {
|
||||
return Block::tryGetFromRegistry(blockName)
|
||||
.transform([](const Block& block) -> char { return block.mDirectData->mUnkda4e0e.as<char>(); })
|
||||
.transform([](const Block& block) -> char { return block.mDirectData->mLightEmission->mValue; })
|
||||
.value_or(-1);
|
||||
}
|
||||
);
|
||||
@@ -625,23 +678,23 @@ void Export_Compatibility_API() {
|
||||
switch (gameRule.mType) {
|
||||
case GameRule::Type::Bool:
|
||||
result.push_back({
|
||||
{"Name", gameRule.mName },
|
||||
{"Type", "Bool" },
|
||||
{"Value", std::to_string(gameRule.mValue->boolVal)}
|
||||
{"Name", gameRule.mName },
|
||||
{"Type", "Bool" },
|
||||
{"Value", std::to_string(std::get<bool>(*gameRule.mValue))}
|
||||
});
|
||||
break;
|
||||
case GameRule::Type::Float:
|
||||
result.push_back({
|
||||
{"Name", gameRule.mName },
|
||||
{"Type", "Float" },
|
||||
{"Value", std::to_string(gameRule.mValue->floatVal)}
|
||||
{"Name", gameRule.mName },
|
||||
{"Type", "Float" },
|
||||
{"Value", std::to_string(std::get<float>(*gameRule.mValue))}
|
||||
});
|
||||
break;
|
||||
case GameRule::Type::Int:
|
||||
result.push_back({
|
||||
{"Name", gameRule.mName },
|
||||
{"Type", "Int" },
|
||||
{"Value", std::to_string(gameRule.mValue->intVal)}
|
||||
{"Name", gameRule.mName },
|
||||
{"Type", "Int" },
|
||||
{"Value", std::to_string(std::get<int>(*gameRule.mValue))}
|
||||
});
|
||||
break;
|
||||
case GameRule::Type::Invalid:
|
||||
@@ -669,7 +722,7 @@ void Export_Compatibility_API() {
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { item->removeEnchants(); });
|
||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { (void)item->removeEnchants(); });
|
||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
||||
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
|
||||
});
|
||||
@@ -709,10 +762,10 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](ItemStack const* item, bool value) -> void {
|
||||
auto nbt = ((GMItemStack*)item)->getNbt();
|
||||
if (value) {
|
||||
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
|
||||
(*nbt)["tag"]["minecraft:keep_on_death"] = true;
|
||||
} else {
|
||||
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")) {
|
||||
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
||||
if (nbt->contains("tag") && (*nbt)["tag"].contains("minecraft:keep_on_death")) {
|
||||
(*nbt)["tag"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
||||
}
|
||||
}
|
||||
((GMItemStack*)item)->setNbt(*nbt);
|
||||
@@ -740,9 +793,9 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"setItemCanDestroy",
|
||||
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||
std::vector<const BlockLegacy*> data;
|
||||
std::vector<const BlockType*> data;
|
||||
for (auto& name : blocks) {
|
||||
if (auto block = BlockLegacy::tryGetFromRegistry(name)) {
|
||||
if (auto block = BlockType::tryGetFromRegistry(name)) {
|
||||
data.push_back(block.as_ptr());
|
||||
}
|
||||
}
|
||||
@@ -760,9 +813,9 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"setItemCanPlaceOn",
|
||||
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||
std::vector<const BlockLegacy*> data;
|
||||
std::vector<const BlockType*> data;
|
||||
for (auto& name : blocks) {
|
||||
if (auto block = BlockLegacy::tryGetFromRegistry(name)) {
|
||||
if (auto block = BlockType::tryGetFromRegistry(name)) {
|
||||
data.push_back(block.as_ptr());
|
||||
}
|
||||
}
|
||||
@@ -790,9 +843,9 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemCustomName", [](ItemStack const* item) -> std::string {
|
||||
return item->getCustomName();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item, bool playerIsCreative) -> std::string {
|
||||
if (auto item2 = item->mItem) {
|
||||
return item2->buildEffectDescriptionName(*item);
|
||||
return item2->buildEffectDescriptionName(*item, playerIsCreative);
|
||||
}
|
||||
return "";
|
||||
});
|
||||
@@ -832,36 +885,39 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "getPlayerDestroyBlockProgress", [](Player* player, Block const* block) -> float {
|
||||
return player->getDestroyProgress(*block);
|
||||
});
|
||||
|
||||
static constexpr size_t effectMaxCount = 36;
|
||||
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectVisible", [](Actor* entity, int effectId) -> bool {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mEffectVisible;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount|| !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mDuration->mValue;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mDurationEasy->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mDurationHard->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount|| !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mDurationNormal->transform(
|
||||
[](auto&& duration) -> int { return duration.mValue; }
|
||||
@@ -870,21 +926,23 @@ void Export_Compatibility_API() {
|
||||
return 0;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmplifier", [](Actor* entity, int effectId) -> int {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mAmplifier;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmbient", [](Actor* entity, int effectId) -> bool {
|
||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||
return effect->mAmbient;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "entityHasEffect", [](Actor* entity, int effectId) -> bool {
|
||||
return effectId > 0x24 ? false : entity->hasEffect(*MobEffect::mMobEffects()[effectId]);
|
||||
return effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]
|
||||
? false
|
||||
: entity->hasEffect(*MobEffect::mMobEffects()[effectId]);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
||||
return ll::service::getLevel().transform(
|
||||
@@ -962,7 +1020,10 @@ void Export_Compatibility_API() {
|
||||
return entity->isType((ActorType)type);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "entityHasType", [](Actor* entity, int type) -> bool {
|
||||
return entity->hasType((ActorType)type);
|
||||
if (auto component = entity->mEntityContext->tryGetComponent<ActorTypeComponent>(); component) {
|
||||
return (type & std::to_underlying(component->mType)) == type;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
|
||||
return (int)entity->getEntityTypeId();
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ bool LegacyRemoteCallApi::load() {
|
||||
logger->info(
|
||||
"Loaded Version: {} with {}",
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.to_string())
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-{}", LIB_VERSION.to_string())
|
||||
);
|
||||
logger->info("Author: GroupMountain");
|
||||
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||
|
||||
+49
-57
@@ -162,12 +162,10 @@ void Export_Event_API() {
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.pos(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.pos(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
@@ -182,7 +180,7 @@ void Export_Event_API() {
|
||||
ila::mc::PlayerStopSleepBeforeEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
@@ -218,10 +216,11 @@ void Export_Event_API() {
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(ila::mc::MobTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
event.setCancelled(result);
|
||||
, if (!event.self().isType(ActorType::EnderMan)) return;);
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||
@@ -251,43 +250,36 @@ void Export_Event_API() {
|
||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::SpawnWanderingTraderAfterEvent,
|
||||
(std::pair<BlockPos, int> pos),
|
||||
({event.pos(), event.blockSource().getDimensionId()}),
|
||||
);
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot,
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot,
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||
(
|
||||
@@ -310,18 +302,18 @@ void Export_Event_API() {
|
||||
),
|
||||
,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerCloseContainerAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerCloseContainerAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
}
|
||||
+34
-7
@@ -1,18 +1,29 @@
|
||||
#pragma once
|
||||
// clang-format off
|
||||
#define GMLIB_GLOBAL_USING
|
||||
#include <gmlib/GlobalUsing.h>
|
||||
#include <gmlib/include_all.h>
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#pragma include_alias("mc/world/item/HumanoidArmorItem.h", "modapi/item/types/mc/HumanoidArmorItem.h")
|
||||
#include <gmlib/include_ll.h>
|
||||
#include <gmlib/include_lib.h>
|
||||
#include <gmlib/include_mc.h>
|
||||
#include <ila/include_all.h>
|
||||
#include <modapi/addons/AddonsLoader.h>
|
||||
#include <modapi/recipe/CustomRecipeRegistry.h>
|
||||
#include <modapi/item/CustomItemRegistry.h>
|
||||
#include <RemoteCallAPI.h>
|
||||
using namespace gmlib::mod;
|
||||
using namespace gmlib;
|
||||
using namespace gmlib::ui;
|
||||
using namespace gmlib::i18n;
|
||||
using namespace gmlib::memory;
|
||||
using namespace modapi;
|
||||
#pragma warning(pop)
|
||||
// clang-format on
|
||||
|
||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||
|
||||
#define LIB_VERSION_MAJOR 1
|
||||
#define LIB_VERSION_MINOR 0
|
||||
#define LIB_VERSION_PATCH 0
|
||||
#define LIB_VERSION_MINOR 7
|
||||
#define LIB_VERSION_PATCH 1
|
||||
#define LIB_VERSION_PRERELEASE std::nullopt
|
||||
|
||||
#ifdef LIB_VERSION_PRERELEASE
|
||||
@@ -29,4 +40,20 @@ extern void Export_Event_API();
|
||||
extern void Export_BinaryStream_API();
|
||||
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||
extern ll::io::Logger& getLogger();
|
||||
// extern void Export_Form_API();
|
||||
// extern void Export_Form_API();
|
||||
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<ActorUniqueID> : fmt::formatter<int64> {
|
||||
template <class FormatContext>
|
||||
auto format(ActorUniqueID const& t, FormatContext& ctx) const {
|
||||
return formatter<int64>::format(t.rawID, ctx);
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct fmt::formatter<mce::UUID> : fmt::formatter<std::string> {
|
||||
template <class FormatContext>
|
||||
auto format(mce::UUID const& t, FormatContext& ctx) const {
|
||||
return formatter<std::string>::format(t.asString(), ctx);
|
||||
}
|
||||
};
|
||||
@@ -79,4 +79,9 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||
).value_or(0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setMaxPlayers", [&](int count, bool ignoreVanillaLimit) {
|
||||
if (auto level = GMLevel::getInstance(); level) {
|
||||
level->setMaxPlayerCount(count, ignoreVanillaLimit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+39
-27
@@ -2,10 +2,12 @@
|
||||
#include <regex>
|
||||
|
||||
namespace PAPIRemoteCall {
|
||||
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from, std::nullopt).value_or(""); }
|
||||
std::string GetValue(std::string const& from) {
|
||||
return PlaceholderAPI::getInstance().getValue(from, std::nullopt).value_or("");
|
||||
}
|
||||
|
||||
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||
return PlaceholderAPI::getValue(key, (GMActor*)player).value_or("");
|
||||
return PlaceholderAPI::getInstance().getValue(key, (GMActor*)player).value_or("");
|
||||
}
|
||||
|
||||
void registerPlayerPlaceholder(
|
||||
@@ -15,15 +17,15 @@ void registerPlayerPlaceholder(
|
||||
) {
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, auto&&...
|
||||
)](optional_ref<Actor> actor, ll::SmallStringMap<std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> {
|
||||
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
@@ -34,6 +36,7 @@ void registerPlayerPlaceholder(
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
false,
|
||||
mod
|
||||
);
|
||||
};
|
||||
@@ -51,21 +54,22 @@ void registerServerPlaceholder(
|
||||
) {
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](auto, ll::StringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
|
||||
)](auto, ll::SmallStringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call(paramMap);
|
||||
},
|
||||
false,
|
||||
mod
|
||||
);
|
||||
};
|
||||
@@ -84,13 +88,14 @@ void registerStaticPlaceholder(
|
||||
) {
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...)
|
||||
-> std::optional<std::string> { return Call(); },
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...
|
||||
) -> std::optional<std::string> { return Call(); },
|
||||
false,
|
||||
mod
|
||||
);
|
||||
};
|
||||
@@ -102,16 +107,18 @@ void registerStaticPlaceholder(
|
||||
}
|
||||
|
||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||
return PlaceholderAPI::translate(str, (GMActor*)pl);
|
||||
return PlaceholderAPI::getInstance().translate(str, (GMActor*)pl);
|
||||
}
|
||||
|
||||
std::string translateString(std::string const& str) { return PlaceholderAPI::translate(str, std::nullopt); }
|
||||
std::string translateString(std::string const& str) {
|
||||
return PlaceholderAPI::getInstance().translate(str, std::nullopt);
|
||||
}
|
||||
|
||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::getInstance().unregisterPlaceholder(str); }
|
||||
|
||||
std::vector<std::string> getAllPAPI() {
|
||||
std::vector<std::string> result;
|
||||
for (auto& papi : PlaceholderAPI::getAllPlaceholderData()) {
|
||||
for (auto& papi : PlaceholderAPI::getInstance().getAllPlaceholderData()) {
|
||||
result.push_back(papi.first);
|
||||
}
|
||||
return result;
|
||||
@@ -121,23 +128,23 @@ std::vector<std::string> getAllPAPI() {
|
||||
|
||||
namespace NewPapiRemoteCall {
|
||||
std::string translate(std::string const& value, std::string const& language) {
|
||||
return PlaceholderAPI::translate(value, std::nullopt, language);
|
||||
return PlaceholderAPI::getInstance().translate(value, std::nullopt, language);
|
||||
}
|
||||
std::string translateFromActor(std::string const& value, Actor* actor, std::string const& language) {
|
||||
return PlaceholderAPI::translate(value, (GMActor*)actor, language);
|
||||
return PlaceholderAPI::getInstance().translate(value, (GMActor*)actor, language);
|
||||
}
|
||||
void registerPlaceholder(std::string const& placeholder, std::string const& funcName, std::string const& pluginName) {
|
||||
if (!RemoteCall::hasFunc(pluginName, funcName)) return;
|
||||
auto func = [=]() -> void {
|
||||
if (std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName); !mod.expired()) {
|
||||
PlaceholderAPI::unregisterPlaceholder(placeholder);
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(placeholder);
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
placeholder,
|
||||
[Call = RemoteCall::importAs<
|
||||
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
|
||||
pluginName,
|
||||
funcName
|
||||
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, std::string const& language
|
||||
)](optional_ref<Actor> actor, ll::SmallStringMap<std::string> const& params, std::string const& language
|
||||
) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
@@ -146,6 +153,7 @@ void registerPlaceholder(std::string const& placeholder, std::string const& func
|
||||
auto result = Call((Actor*)actor.as_ptr(), paramMap, language);
|
||||
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
|
||||
},
|
||||
false,
|
||||
mod
|
||||
);
|
||||
}
|
||||
@@ -157,23 +165,25 @@ void registerPlaceholder(std::string const& placeholder, std::string const& func
|
||||
}
|
||||
}
|
||||
bool unregisterPlaceholder(std::string const& placeholder) {
|
||||
return PlaceholderAPI::unregisterPlaceholder(placeholder);
|
||||
return PlaceholderAPI::getInstance().unregisterPlaceholder(placeholder);
|
||||
}
|
||||
bool unregisterPlaceholderFromModName(std::string const& pluginName) {
|
||||
std::weak_ptr plugin = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName);
|
||||
if (plugin.expired()) return false;
|
||||
return PlaceholderAPI::unregisterPlaceholder(plugin);
|
||||
return PlaceholderAPI::getInstance().unregisterPlaceholder(plugin);
|
||||
}
|
||||
std::string getValue(
|
||||
std::string const& placeholder,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
ll::StringMap<std::string> paramMap;
|
||||
ll::SmallStringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getValue(placeholder, std::nullopt, paramMap, language).value_or("<std::nullopt>");
|
||||
return PlaceholderAPI::getInstance()
|
||||
.getValue(placeholder, std::nullopt, paramMap, language)
|
||||
.value_or("<std::nullopt>");
|
||||
}
|
||||
std::string getValueFromActor(
|
||||
std::string const& placeholder,
|
||||
@@ -181,11 +191,13 @@ std::string getValueFromActor(
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
ll::StringMap<std::string> paramMap;
|
||||
ll::SmallStringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, paramMap, language).value_or("<std::nullopt>");
|
||||
return PlaceholderAPI::getInstance()
|
||||
.getValue(placeholder, (GMActor*)actor, paramMap, language)
|
||||
.value_or("<std::nullopt>");
|
||||
}
|
||||
} // namespace NewPapiRemoteCall
|
||||
|
||||
|
||||
+6
-5
@@ -2,7 +2,7 @@
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"version": "1.1.2",
|
||||
"version": "1.7.1",
|
||||
"info": {
|
||||
"name": "GMLIB-LegacyRemoteCallApi",
|
||||
"description": "Legacy RemoteCall API for GMLIB",
|
||||
@@ -19,15 +19,16 @@
|
||||
{
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.2.0",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.2.0-rc.1",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.5.0-rc.1"
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.7.0",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.7.0",
|
||||
"github.com/GroupMountain/ModAPI-Release": ">=0.3.0",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.10.0"
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
"type": "zip",
|
||||
"urls": [
|
||||
"https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v$(version)/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
||||
"https://{{tooth}}/releases/download/v{{version}}/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
||||
],
|
||||
"placements": [
|
||||
{
|
||||
|
||||
@@ -8,11 +8,12 @@ if not has_config("vs_runtime") then
|
||||
set_runtimes("MD")
|
||||
end
|
||||
|
||||
add_requires("levilamina 1.2.0", {configs = {target_type = "server"}})
|
||||
add_requires("levilamina 1.7.3", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("levibuildscript")
|
||||
add_requires("ilistenattentively 0.5.0-rc.1")
|
||||
add_requires("gmlib 1.2.0-rc.1")
|
||||
add_requires("levibuildscript 0.5.2")
|
||||
add_requires("ilistenattentively 0.10.0")
|
||||
add_requires("gmlib 1.7.0")
|
||||
add_requires("modapi 0.3.0")
|
||||
|
||||
target("GMLIB-LegacyRemoteCallApi")
|
||||
add_cxflags(
|
||||
@@ -35,21 +36,19 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
"levilamina",
|
||||
"legacyremotecall",
|
||||
"ilistenattentively",
|
||||
"gmlib"
|
||||
"gmlib",
|
||||
"modapi"
|
||||
)
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
add_rules("@levibuildscript/modpacker")
|
||||
set_exceptions("none")
|
||||
set_kind("shared")
|
||||
set_languages("cxx20")
|
||||
set_symbols("debug")
|
||||
|
||||
after_build(function (target)
|
||||
local plugin_packer = import("scripts.after_build")
|
||||
|
||||
local plugin_define = {
|
||||
pluginName = target:name(),
|
||||
pluginFile = path.filename(target:targetfile()),
|
||||
}
|
||||
|
||||
plugin_packer.pack_plugin(target,plugin_define)
|
||||
end)
|
||||
local target_path = path.join("bin", target:name(), "lib")
|
||||
if os.exists(target_path) then
|
||||
os.rm(target_path)
|
||||
end
|
||||
os.cp("lib", target_path)
|
||||
end)
|
||||
Reference in New Issue
Block a user