diff --git a/lib/GMLIB_API-JS.d.ts b/lib/GMLIB_API-JS.d.ts index edf5c2c..2310392 100644 --- a/lib/GMLIB_API-JS.d.ts +++ b/lib/GMLIB_API-JS.d.ts @@ -330,7 +330,10 @@ export class Minecraft { /** 移除所有虚假列表玩家 */ static removeAllFakeLists(): boolean; - /** 启用I18n修复 */ + /** + * @deprecated 已删 + * 启用I18n修复 + */ static setFixI18nEnabled(): void; /** 保存NBT至文件 */ @@ -1378,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 { diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index 6a89682..cb8ff4e 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -3130,7 +3130,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 = @@ -3164,161 +3164,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 = { diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index d6d7835..a0f42d3 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -574,7 +574,7 @@ 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 blockLegacy && block->getTypeName() == blockLegacy->getTypeName(); }); }); RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool { @@ -584,7 +584,10 @@ 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; @@ -834,36 +837,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; } @@ -872,21 +878,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( diff --git a/src/Global.h b/src/Global.h index 71c5b16..d951d01 100644 --- a/src/Global.h +++ b/src/Global.h @@ -1,11 +1,14 @@ #pragma once // clang-format off +#pragma warning(push) +#pragma warning(disable : 4996) #define GMLIB_GLOBAL_USING #include #include #include #include using namespace gmlib::mod; +#pragma warning(pop) // clang-format on #define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA") diff --git a/xmake.lua b/xmake.lua index afa2cce..9222203 100644 --- a/xmake.lua +++ b/xmake.lua @@ -12,7 +12,7 @@ add_requires("levilamina 1.4.1", {configs = {target_type = "server"}}) add_requires("legacyremotecall") add_requires("levibuildscript") add_requires("ilistenattentively 0.7.0") -add_requires("gmlib 1.4.0") +add_requires("gmlib 1.4.3") target("GMLIB-LegacyRemoteCallApi") add_cxflags(