diff --git a/CHANGELOG.md b/CHANGELOG.md index dae82e0..7ee5583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.6.0 + +Wranglin' in AuraSkills. + +- **With AuraSkills installed**, Wranglin' is one of its skills, with a lead as its icon and MobSquad's level. MobSquad still keeps the level in the player's file and copies it to AuraSkills when it changes, when the player joins and when an admin uses `/mobsquad xp`. A level set with AuraSkills' commands is put back at the next change or join. AuraSkills' XP multipliers and rewards don't apply. +- The skill's AuraSkills settings are written to `plugins/MobSquad/auraskills` the first time. MobSquad declares `auraskills.skill.wranglin` (default true), which AuraSkills checks for each skill. +- Without AuraSkills nothing changes. Built against AuraSkills 2.4.0. +- **World groups.** Tested with Multiverse-Inventories 5.3.6: crossing to another inventory group sends critters home, the sidekick comes along as one copy, and nothing turns into an item. +- **Fixed:** a block the enderman fetched went into your inventory in whatever world you were in a second later, so it could cross world groups, and it was lost if the enderman went home in that second. It now goes to you only in the world it came from, and otherwise drops where the block was. + ## 0.5.0 The sidekick and the later parts of four specials. diff --git a/README.md b/README.md index 1dd11fc..e3ad6e2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Coax mobs into critters for Paper: they follow you, fight only hostile mobs, and live safely in a shared Bunkhouse. No client mods. Gotta coax em all... Pokemob! -**Status:** 0.5.0. The sidekick, and the later parts of four specials. Passed with bots on throwaway Paper 26.1.2 and 26.2 servers (164 checks each). On 26.3 the bots can't use blocks, so the Bunkhouse menu and everything sent out from it didn't run there (75 checks ran). Bots can't crouch where the server sees it, so the creeper and fox puzzles were tested with a test-only stand-in for crouching; real crouching is untested. The daily sidekick roll is covered by unit tests only, since it needs 10 hours out. Nothing has been seen in a real game client yet. +**Status:** 0.6.0. Wranglin' in AuraSkills, and world groups tested with Multiverse-Inventories. Passed with bots on throwaway Paper 26.1.2 and 26.2 servers (164 checks each, plus 30 with AuraSkills and 22 with Multiverse on 26.2). On 26.3 the bots can't use blocks, so the Bunkhouse menu and everything sent out from it didn't run there (75 checks ran). Bots can't crouch where the server sees it, so the creeper and fox puzzles were tested with a test-only stand-in for crouching; real crouching is untested. The daily sidekick roll is covered by unit tests only, since it needs 10 hours out. Nothing has been seen in a real game client yet. ## What it does @@ -13,7 +13,7 @@ Coax mobs into critters for Paper: they follow you, fight only hostile mobs, and - Chicken: you fall slowly while it's out. From level 25 it lays a speedy egg at your feet every 5 minutes (a minute sooner at each later milestone); right-click it for Speed II for 10 seconds, Speed III from level 75. - Axolotl: water breathing and regeneration while you're within 6 blocks of it. It goes after drowned and guardians first, and plays dead and heals when it's badly hurt. - Bee: crops near it grow faster, one crop a second. From level 25 its sting makes a hostile mob glow, so you can see it through walls. - - Fox: fetches items you drop or leave behind (drops from blocks you break and mobs you beat), after they've lain 5 seconds. It never touches anyone else's. From level 25 it pounces on a hostile mob that isn't after it, for a double first hit. + - Fox: fetches items you drop or leave behind (drops from blocks you break and mobs you beat), after they've lain 5 seconds. It never touches anyone else's. From level 25 it pounces on a hostile mob that isn't after it, and the hit it lands with the pounce does double damage. - Allay: right-click it holding an ore, a raw ore or a gem, and it flies to the nearest matching ore within 8 blocks of you. - Creeper: a blast that hurts only the hostile mobs around its target and breaks nothing. It never goes off with a player within 6 blocks. - Enderman: right-click it, then swing at a block within 8 blocks, and it fetches it for you. Only blocks an enderman can carry, and only where you could dig yourself, so claims say no. When it's badly hurt, it teleports to you. @@ -25,6 +25,8 @@ Coax mobs into critters for Paper: they follow you, fight only hostile mobs, and - **Bunkhouses.** An admin marks a vault block as a Bunkhouse. Anyone who right-clicks it sees only their own critters. Click one to send it out or call it back. Critters never exist as items, so they can't be dropped, traded or duplicated. - **Following.** A critter out with you walks after you and steps beside you if it's left more than 24 blocks behind. - **Wranglin'.** Coaxing earns Wranglin' experience. One critter can be out at once, two from level 10 and three from level 25. Mob tiers unlock at levels 1, 10, 25 and 40. +- **AuraSkills.** If AuraSkills is installed, Wranglin' shows up as one of its skills, with MobSquad's level. MobSquad keeps the level in the player's file and copies it to AuraSkills when it changes and when the player joins, so a level set with AuraSkills' own commands is put back. AuraSkills' XP multipliers and rewards don't apply to Wranglin'. The skill's AuraSkills settings are in `plugins/MobSquad/auraskills`. Without AuraSkills, nothing changes. +- **World groups.** With Multiverse-Inventories, critters cross to another inventory group only through the Bunkhouse: crossing sends the ones out with you home, and you can send them out again from a Bunkhouse there. The sidekick comes along, one copy. A block the enderman fetches only goes into your inventory in the world it came from. - **Safety.** A critter never targets or hurts a player, and players can't hurt it. It never changes a block on its own, explodes, burns in the sun or wanders off by teleporting. The two specials that touch blocks go through the server's own checks: the bee's crops grow through the same event as natural growth, and the enderman takes a block only where a block-break check as you passes. Out of health, it's tuckered out: it drops nothing and rests in the Bunkhouse for 5 real minutes. - **The dinnerbell.** Ring it and every critter out with you heads home. - **Plain files.** One text file per player in `plugins/MobSquad/players`. A critter out in the world is never saved with the world, so after a restart, a crash or the player leaving, it's back in the Bunkhouse exactly once. diff --git a/build.gradle.kts b/build.gradle.kts index 15815e1..c739650 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "com.extantape" -version = "0.5.0" +version = "0.6.0" java { toolchain.languageVersion.set(JavaLanguageVersion.of(25)) diff --git a/docs/decisions.md b/docs/decisions.md index 472a556..b4eff25 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -9,6 +9,7 @@ Dated decisions for this repo, newest last. - 2026-11-15: 0.1.0 builds the core loop from plan.md step 1. Wranglin' is MobSquad's own level in 0.1.0; the AuraSkills hook follows once it can be tested on a throwaway server with AuraSkills installed. - 2026-11-15: critters out in the world are non-persistent mobs; only the player's Bunkhouse file is saved. A critter left in a chunk after a crash is removed when the chunk loads. - 2026-11-15: a tier gates sending a critter out as well as coaxing it, so a critter an admin gives early waits for the level. +- 2026-11-15, 0.6.0: MobSquad keeps the Wranglin' level and copies it to AuraSkills, rather than handing AuraSkills the experience. On a test server, AuraSkills 2.4.0 dropped experience given to a skill from another plugin: `addSkillXp` gave none at all, and `addSkillXpRaw` lost it when the skill levelled up. Copying the level also keeps posse sizes and tiers on one curve. This replaces the earlier AuraSkills decision above. - 2026-11-15: running on a seed trail means sprinting, riding, gliding, flying or crossing more than 1.35 blocks in a quarter second, about 1.25 times walking pace. A longer jump counts as a teleport, which loses the trail instead. - 2026-11-15: bot tests use port 25631. - 2026-11-15: public at the first release under the owner's standing yes of 2026-11-07, relayed by Simon: MIT, Copyright (c) 2026 EXTANT APE, after the first-public-push audit (no secrets, addresses, player data or build output; no private-term hits in any file, commit or message). diff --git a/docs/test-audit.md b/docs/test-audit.md index 273c1dd..8d54308 100644 --- a/docs/test-audit.md +++ b/docs/test-audit.md @@ -2,6 +2,15 @@ Kept by this repo's owning session, per `~/Code/CLAUDE.md`, "Test self-audits". Newest first. +## 2026-11-15: 0.6.0 + +- Promises added: README "AuraSkills" and "World groups", CHANGELOG 0.6.0, the 0.6.0 AuraSkills decision. +- Covered by bots with AuraSkills 2.4.0 (30 checks on 26.1.2 and 26.2, 25 on 26.3): Wranglin' registers as a skill; a level-up from coaxing shows in AuraSkills; a MobSquad level shows in AuraSkills when a player joins; MobSquad's own level counts whatever AuraSkills says; `/mobsquad xp` sets both; MobSquad keeps its own count. +- Covered by bots with Multiverse-Core 5.8.2 and Multiverse-Inventories 5.3.6 (22 checks on 26.2): inventories are really kept apart; crossing sends a critter home, in neither world; the sidekick comes along as one copy and comes back; nothing turns into an item; every critter stays in the file once; an enderman block fetched as you cross groups stays behind and drops where it was taken. +- Full suite after the change: 164 on 26.1.2 and 26.2, 75 on 26.3. The fox pounce check now looks for one double hit among the first three, since a plain hit can land first; the README says so. +- Gaps skipped: AuraSkills' own menus and messages (AuraSkills draws them from the registered skill); the world-group checks on 26.1.2 and 26.3 (the same MobSquad code as 26.2; on 26.3 the bots can't open the Bunkhouse). +- Gaps for later: crossing groups through a Waystation gate, with the Waystation hook. + ## 2026-11-15: 0.5.0 - Promises added: README "The sidekick" and the level 25 additions to four specials, CHANGELOG 0.5.0, the sidekick and later-specials decisions. diff --git a/src/main/java/com/extantape/mobsquad/MobSquadPlugin.java b/src/main/java/com/extantape/mobsquad/MobSquadPlugin.java index 7b19bac..0894f12 100644 --- a/src/main/java/com/extantape/mobsquad/MobSquadPlugin.java +++ b/src/main/java/com/extantape/mobsquad/MobSquadPlugin.java @@ -51,6 +51,14 @@ public final class MobSquadPlugin extends JavaPlugin { public void onEnable() { saveDefaultConfig(); squads = new Squads(new Store(getDataFolder().toPath().resolve("players")), getLogger(), Settings.read(getConfig(), getLogger())); + if (getServer().getPluginManager().getPlugin("AuraSkills") != null) { + try { + squads.skill(com.extantape.mobsquad.hook.AuraSkillsWranglin.register(this)); + getLogger().info("Wranglin' is an AuraSkills skill."); + } catch (RuntimeException | LinkageError e) { + getLogger().log(java.util.logging.Level.WARNING, "Couldn't register Wranglin' with AuraSkills, so MobSquad keeps its own level.", e); + } + } Posse posse = new Posse(this, o -> {}); squads.posse(posse); bunkhouses = new Bunkhouses(this); @@ -76,6 +84,8 @@ public void onEnable() { @EventHandler public void onJoin(org.bukkit.event.player.PlayerJoinEvent e) { e.getPlayer().discoverRecipe(vittles.key()); + if (squads.skill() != null) // a few seconds on, once AuraSkills has loaded the player + getServer().getScheduler().runTaskLater(MobSquadPlugin.this, () -> { if (e.getPlayer().isOnline()) squads.showWranglin(e.getPlayer()); }, 60L); } /** A critter left behind by a crash is never saved, but if one turns up, it goes. */ @@ -258,6 +268,7 @@ private int xp(CommandContext c) throws CommandSyntaxExcepti } w.wranglinXp = c.getArgument("amount", Integer.class); squads.save(w); + squads.showWranglin(p); say(c, "[MobSquad] " + p.getName() + " has " + w.wranglinXp + " Wranglin' experience, level " + Levels.level(w.wranglinXp) + ".", NamedTextColor.GREEN); return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/com/extantape/mobsquad/Squads.java b/src/main/java/com/extantape/mobsquad/Squads.java index 4e6a14a..dc41dae 100644 --- a/src/main/java/com/extantape/mobsquad/Squads.java +++ b/src/main/java/com/extantape/mobsquad/Squads.java @@ -23,6 +23,7 @@ public final class Squads { private final Map online = new HashMap<>(); private Posse posse; private Settings settings; + private com.extantape.mobsquad.hook.WranglinSkill skill; private java.util.function.BiConsumer pageOpener; public Squads(Store store, Logger log, Settings settings) { @@ -75,11 +76,25 @@ public void leave(Player p) { save(online.remove(p.getUniqueId())); } + /** A skill plugin (AuraSkills) that shows Wranglin', or null. */ + public void skill(com.extantape.mobsquad.hook.WranglinSkill skill) { + this.skill = skill; + } + + public com.extantape.mobsquad.hook.WranglinSkill skill() { + return skill; + } + public int wranglinLevel(Player p) { Wrangler w = get(p); return w == null ? 1 : Levels.level(w.wranglinXp); } + /** Copies the player's Wranglin' level to the skill plugin, if there is one. */ + public void showWranglin(Player p) { + if (skill != null) skill.show(p, wranglinLevel(p)); + } + public void addWranglin(Player p, long xp) { Wrangler w = get(p); if (w == null) return; @@ -87,6 +102,7 @@ public void addWranglin(Player p, long xp) { w.wranglinXp += xp; int after = Levels.level(w.wranglinXp); save(w); + if (skill != null && after != before) skill.show(p, after); if (after > before) p.sendMessage(Component.text("Your Wranglin' is now level " + after + ".", NamedTextColor.GOLD)); } diff --git a/src/main/java/com/extantape/mobsquad/hook/AuraSkillsWranglin.java b/src/main/java/com/extantape/mobsquad/hook/AuraSkillsWranglin.java new file mode 100644 index 0000000..e184cd0 --- /dev/null +++ b/src/main/java/com/extantape/mobsquad/hook/AuraSkillsWranglin.java @@ -0,0 +1,50 @@ +package com.extantape.mobsquad.hook; + +import dev.aurelium.auraskills.api.AuraSkillsApi; +import dev.aurelium.auraskills.api.item.ItemContext; +import dev.aurelium.auraskills.api.registry.NamespacedId; +import dev.aurelium.auraskills.api.registry.NamespacedRegistry; +import dev.aurelium.auraskills.api.skill.CustomSkill; +import dev.aurelium.auraskills.api.user.SkillsUser; +import java.io.File; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Wranglin' as an AuraSkills skill (brief, "How the plugins fit"). Only loaded when AuraSkills is installed, so the + * rest of MobSquad never touches its classes. The skill's settings are in {@code plugins/MobSquad/auraskills}. + *

MobSquad sets the level rather than adding experience: AuraSkills 2.4.0 loses experience that other plugins add to + * their own skills when it levels them up, and its level curve differs from MobSquad's. + */ +public final class AuraSkillsWranglin implements WranglinSkill { + private final AuraSkillsApi api; + private final CustomSkill skill; + + private AuraSkillsWranglin(AuraSkillsApi api, CustomSkill skill) { + this.api = api; + this.skill = skill; + } + + public static AuraSkillsWranglin register(JavaPlugin plugin) { + File dir = new File(plugin.getDataFolder(), "auraskills"); + for (String f : new String[] {"auraskills/skills.yml", "auraskills/sources/wranglin.yml"}) + if (!new File(plugin.getDataFolder(), f).exists()) plugin.saveResource(f, false); + AuraSkillsApi api = AuraSkillsApi.get(); + NamespacedRegistry registry = api.useRegistry("mobsquad", dir); + CustomSkill skill = CustomSkill.builder(NamespacedId.of("mobsquad", "wranglin")) + .displayName("Wranglin'") + .description("Coax mobs into critters. Higher levels let more critters out at once and open new tiers of mobs.") + .item(ItemContext.builder().material("lead").pos("4,5").build()) + .build(); + registry.registerSkill(skill); + return new AuraSkillsWranglin(api, skill); + } + + @Override + public void show(Player p, int level) { + SkillsUser u = api.getUser(p.getUniqueId()); + if (u == null || !u.isLoaded() || u.getSkillLevel(skill) == level) return; + u.setSkillLevel(skill, level); + u.setSkillXp(skill, 0); + } +} diff --git a/src/main/java/com/extantape/mobsquad/hook/WranglinSkill.java b/src/main/java/com/extantape/mobsquad/hook/WranglinSkill.java new file mode 100644 index 0000000..4e788a5 --- /dev/null +++ b/src/main/java/com/extantape/mobsquad/hook/WranglinSkill.java @@ -0,0 +1,12 @@ +package com.extantape.mobsquad.hook; + +import org.bukkit.entity.Player; + +/** + * A skill plugin that shows Wranglin'. MobSquad keeps the level itself, in the player's file, and copies it here, so the + * two never disagree and nothing is lost if that plugin goes away. + */ +public interface WranglinSkill { + /** Shows this level for the player. Does nothing when their data isn't loaded yet. */ + void show(Player p, int level); +} diff --git a/src/main/java/com/extantape/mobsquad/world/Specials.java b/src/main/java/com/extantape/mobsquad/world/Specials.java index 2f23e9c..3e12830 100644 --- a/src/main/java/com/extantape/mobsquad/world/Specials.java +++ b/src/main/java/com/extantape/mobsquad/world/Specials.java @@ -396,12 +396,16 @@ boolean fetchBlock(Player p) { posse().moveCritter(e, b.getLocation().add(0.5, 1, 0.5)); b.setType(Material.AIR, true); b.getWorld().spawnParticle(Particle.PORTAL, b.getLocation().add(0.5, 0.5, 0.5), 30, 0.3, 0.5, 0.3); + Location spot = b.getLocation().add(0.5, 0.5, 0.5); Bukkit.getScheduler().runTaskLater(plugin, () -> { + // the block is the owner's even if the enderman went home meanwhile, but only in the world it came from, so + // nothing crosses world groups (Multiverse-Inventories); otherwise it drops where the block was + boolean here = p.isOnline() && p.getWorld().equals(spot.getWorld()); + if (here) give(p, new ItemStack(item)); + else spot.getWorld().dropItem(spot, new ItemStack(item)); if (!e.isValid()) return; e.setCarriedBlock(null); - Location home = p.isOnline() && p.getWorld().equals(e.getWorld()) ? p.getLocation() : back; - posse().moveCritter(e, home); - if (p.isOnline()) give(p, new ItemStack(item)); + posse().moveCritter(e, here && p.getWorld().equals(e.getWorld()) ? p.getLocation() : back); }, 20L); return true; } diff --git a/src/main/resources/auraskills/skills.yml b/src/main/resources/auraskills/skills.yml new file mode 100644 index 0000000..84049df --- /dev/null +++ b/src/main/resources/auraskills/skills.yml @@ -0,0 +1,10 @@ +# Wranglin' in AuraSkills, read by AuraSkills when MobSquad registers the skill. +# MobSquad's posse sizes and tiers use these levels: 2 critters out from level 10, 3 from 25; tiers at 1, 10, 25 and 40. +skills: + mobsquad/wranglin: + abilities: [] + options: + enabled: true + max_level: 100 + check_cancelled: true + check_multiplier_permissions: true diff --git a/src/main/resources/auraskills/sources/wranglin.yml b/src/main/resources/auraskills/sources/wranglin.yml new file mode 100644 index 0000000..c25a34b --- /dev/null +++ b/src/main/resources/auraskills/sources/wranglin.yml @@ -0,0 +1,2 @@ +# Wranglin' experience comes only from MobSquad (coaxing a critter), so there are no AuraSkills sources here. +sources: {} diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index f29e0c8..cea4f8f 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -4,6 +4,13 @@ main: com.extantape.mobsquad.MobSquadPlugin api-version: '26.1' description: "Coax mobs into critters that follow you, fight only hostile mobs and rest in a Bunkhouse. Gotta coax em all... Pokemob!" website: https://github.com/ExtantApe/MobSquad +# Optional: with AuraSkills installed, Wranglin' is an AuraSkills skill. +dependencies: + server: + AuraSkills: + load: BEFORE + required: false + join-classpath: true # Commands are registered with Brigadier in code, so there is no commands section. permissions: mobsquad.use: @@ -12,3 +19,6 @@ permissions: mobsquad.admin: description: Mark Bunkhouses and use /mobsquad admin commands. default: op + auraskills.skill.wranglin: + description: Earn Wranglin' in AuraSkills. AuraSkills checks this for each skill but doesn't declare it for skills other plugins add, so MobSquad does. + default: true diff --git a/test/fetch-jars.mjs b/test/fetch-jars.mjs index c080677..fe856cc 100644 --- a/test/fetch-jars.mjs +++ b/test/fetch-jars.mjs @@ -34,6 +34,9 @@ for (const [project, name, pick] of [ ['griefprevention', 'GriefPrevention.jar', { version: '16.18.7' }], // the one release listed for 26.1.2 to 26.3 ['coreprotect', 'CoreProtect.jar', { version: '24.1' }], ['prism', 'Prism.jar', { game: '26.3' }], // 4.5, the first 4.x listed for 26.3 + ['auraskills', 'AuraSkills.jar', { version: '2.4.0' }], // the version the hook is built against; lists 26.1.2 to 26.3 + ['multiverse-core', 'Multiverse-Core.jar', { version: '5.8.2' }], // world groups test + ['multiverse-inventories', 'Multiverse-Inventories.jar', { version: '5.3.6' }], ]) { const versions = await json(`https://api.modrinth.com/v2/project/${project}/version`) const v = pick.version ? versions.find(x => x.version_number === pick.version) diff --git a/test/suite.mjs b/test/suite.mjs index 0b648bc..539d2a4 100644 --- a/test/suite.mjs +++ b/test/suite.mjs @@ -8,7 +8,8 @@ // chicken is done with small /tp steps on every version, and the sprint check runs on 26.1.2 and 26.2 only. // - On 26.3 the bots can't use a block either (PaulBunyan's suite found this first), so the Bunkhouse menu and // everything driven through it (sending out, following, safety, restarts) runs on 26.1.2 and 26.2 only. -import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs' +import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs' +import { createHash } from 'node:crypto' import path from 'node:path' import { Vec3 } from 'vec3' import { bot, check, DEFAULT_CONFIG, freshServer, jar, quit, section, Server, sleep, summary, until } from './harness.mjs' @@ -16,14 +17,18 @@ import { bot, check, DEFAULT_CONFIG, freshServer, jar, quit, section, Server, sl const MC = process.argv[2] if (!['26.1.2', '26.2', '26.3'].includes(MC)) throw new Error('usage: node suite.mjs <26.1.2|26.2|26.3> [only=a,b]') const ONLY = (process.argv.find(a => a.startsWith('only=')) || '').slice(5).split(',').filter(Boolean) -const want = n => ONLY.length === 0 || ONLY.includes(n) +// MS_TEST_AURA=1 adds AuraSkills, so Wranglin' is an AuraSkills skill; run it with only=aura (and coax for coaxing XP). +const AURA = !!process.env.MS_TEST_AURA +// MS_TEST_MV=1 adds Multiverse-Core and Multiverse-Inventories; run it with only=bunkhouse,groups +const MV = !!process.env.MS_TEST_MV +const want = n => (ONLY.length === 0 && n !== 'aura' && n !== 'groups') || ONLY.includes(n) const PHYSICS = MC !== '26.3' const MENU = PHYSICS const skip = name => { if (want(name)) console.log(`\n# ${name}: skipped on ${MC}, where the bots can't use a block`) } const Y = -60 const dir = freshServer('suite-' + MC, { paper: jar(`paper-${MC}.jar`), - plugins: [jar('ViaVersion.jar'), jar('ViaBackwards.jar'), jar('GriefPrevention.jar')], props: { difficulty: 'easy' } }) + plugins: [jar('ViaVersion.jar'), jar('ViaBackwards.jar'), jar('GriefPrevention.jar'), ...(AURA ? [jar('AuraSkills.jar')] : []), ...(MV ? [jar('Multiverse-Core.jar'), jar('Multiverse-Inventories.jar')] : [])], props: { difficulty: 'easy' } }) const s = new Server({ dir, jvm: ['-Dmobsquad.test.sneak-tag=true'] }) // a tagged player counts as crouching; see Puzzles.crouching const cfgFile = path.join(dir, 'plugins/MobSquad/config.yml') const playersDir = path.join(dir, 'plugins/MobSquad/players') @@ -684,8 +689,11 @@ else if (want('specials')) { await stand(me, 'Wrangler', X, Z, 0, 20) await s.ask(`summon husk ${X} ${Y} ${Z - 6} {Tags:["foe"],PersistenceRequired:1b,NoAI:1b,attributes:[{id:"minecraft:armor",base:0}]}`, 200) const drops = []; let last = 20 - await until(async () => { const h = await health('@e[tag=foe,limit=1]'); if (h === null) return true; if (h < last) { drops.push(+(last - h).toFixed(2)); last = h } return drops.length >= 2 }, 20000, 150) - check('from level 25 the fox pounces for a double first hit', drops.length >= 2 && drops[0] > 1.7 * drops[1], drops.join(', ')) + await until(async () => { const h = await health('@e[tag=foe,limit=1]'); if (h === null) return true; if (h < last) { drops.push(+(last - h).toFixed(2)); last = h } return drops.length >= 3 }, 20000, 150) + // the pounce is the first hit after the fox has sized up a mob that isn't after it, which is usually but not always + // the very first hit, so look for one double hit among the first three + const d3 = drops.slice(0, 3) + check('from level 25 the fox pounces for a double hit', d3.length >= 2 && Math.max(...d3) > 1.7 * Math.min(...d3), drops.join(', ')) await sendOnly('chicken') await s.ask('clear Wrangler', 200) check('from level 25 the chicken lays a speedy egg at your feet', await until(() => me.inventory.items().some(i => i.name === 'egg'), 45000, 500)) @@ -843,6 +851,97 @@ if (want('sidekick')) { await quit(buddy) } +// ---------- world groups ---------- +if (want('groups') && MV) { + section('World groups (Multiverse-Inventories)') + await s.ask('mv create elsewhere normal --world-type flat --no-structures', 500) + check('a second world, outside the default inventory group', await until(async () => (await s.ask('mv list', 400)).join(' ').includes('elsewhere'), 60000, 2000), (await s.ask('mv list', 400)).join(' ')) + // Multiverse-Inventories keeps a world outside the default group apart; the diamond check below proves it + const countIn = async (world, sel) => { const out = (await s.ask(`execute in minecraft:${world === 'testworld' ? 'overworld' : world} if entity ${sel.includes('distance=') ? sel : sel.replace(']', ',distance=0..]')}`, 400)).join(' '); const m = out.match(/count: (\d+)/i); return m ? +m[1] : 0 } + const tp = async (name, world) => { const out = (await s.ask(`mv tp ${name} ${world}`, 1500)).join(' '); await sleep(2500); return out } + const tv = await bot('Traveler', { physics: PHYSICS }) + await uuidOf('Traveler') + await s.ask('gamemode survival Traveler', 200); await s.ask('clear Traveler', 200) + await s.ask('mobsquad xp Traveler 40000', 300) + await stand(tv, 'Traveler', X, Z, 0, 20) + await s.ask('give Traveler diamond 1', 300); await sleep(500) + let out = await tp('Traveler', 'elsewhere') + const inElsewhere = (await s.ask('data get entity Traveler Dimension', 400)).join(' ') + check('the groups really keep inventories apart', /elsewhere/.test(inElsewhere) && !tv.inventory.items().some(i => i.name === 'diamond'), out + ' / ' + inElsewhere) + await tp('Traveler', 'testworld') + await stand(tv, 'Traveler', X, Z, 0, 20) + check('and give them back', await until(() => tv.inventory.items().some(i => i.name === 'diamond'), 4000)) + await s.ask('clear Traveler', 200) + for (const k of ['chicken', 'enderman', 'bee']) await s.ask(`mobsquad give Traveler ${k}`, 250) + await s.ask('mobsquad sidekick Traveler bee', 400) + check('the sidekick comes out', await until(async () => await countIn('testworld', '@e[type=bee,name=Bee]') === 1, 5000, 300)) + const lines = critterLines('Traveler'), slot = k => lines.map(l => l.split(' ')[2] === k).indexOf(true) + await openBunkhouse(tv, vault); await tv.clickWindow(slot('chicken'), 0, 0); await sleep(500); await closeMenu(tv) + check('a critter goes out from the Bunkhouse', await until(async () => await countIn('testworld', '@e[type=chicken,name=Chicken]') === 1, 4000, 250)) + out = await tp('Traveler', 'elsewhere') + const where = async () => `tp: ${out.slice(0, 120)}; dim ${(await s.ask('data get entity Traveler Dimension', 400)).join(' ').slice(-40)}; chickens ${await countIn('testworld', '@e[type=chicken,name=Chicken]')}/${await countIn('elsewhere', '@e[type=chicken,name=Chicken]')}, bees ${await countIn('testworld', '@e[type=bee,name=Bee]')}/${await countIn('elsewhere', '@e[type=bee,name=Bee]')}` + check('crossing to another group sends a critter home, in neither world', await countIn('testworld', '@e[type=chicken,name=Chicken]') === 0 && await countIn('elsewhere', '@e[type=chicken,name=Chicken]') === 0, await where()) + check('the sidekick comes along, one copy', await until(async () => await countIn('elsewhere', '@e[type=bee,name=Bee]') === 1, 5000, 300) && await countIn('testworld', '@e[type=bee,name=Bee]') === 0, await where()) + check('no critter turns into an item on the way', !tv.inventory.items().some(i => /spawn_egg|egg|lead/.test(i.name)), tv.inventory.items().map(i => i.name).join(',')) + check('the critters are still in the Bunkhouse file, once each', ['chicken', 'enderman', 'bee'].every(k => critterLines('Traveler').filter(l => l.split(' ')[2] === k).length === 1), critterLines('Traveler').join(' / ')) + await tp('Traveler', 'testworld') + await stand(tv, 'Traveler', X, Z, 0, 20) + check('coming back, the sidekick returns and the other critter stays home', await until(async () => await countIn('testworld', '@e[type=bee,name=Bee]') === 1, 5000, 300) && await countIn('testworld', '@e[type=chicken,name=Chicken]') === 0 && await countIn('elsewhere', '@e[type=bee,name=Bee]') === 0, await where()) + // the enderman's fetched block stays in the world it came from + await openBunkhouse(tv, vault); await tv.clickWindow(slot('enderman'), 0, 0); await sleep(500); await closeMenu(tv) + await until(async () => await countIn('testworld', '@e[type=enderman,name=Enderman]') === 1, 4000, 250) + const at = new Vec3(X + 3, Y, Z) + await s.ask(`setblock ${at.x} ${at.y} ${at.z} pumpkin`, 300) + await poke(tv, entity(tv, e => e.name === 'enderman')); await sleep(500) + await tv.lookAt(at.offset(0.5, 0.5, 0.5), true); await sleep(300) + tv.swingArm() + await s.ask(`mv tp Traveler elsewhere`, 200); await sleep(3000) + check('the enderman took the block', (await s.ask(`execute in minecraft:overworld if block ${at.x} ${at.y} ${at.z} air`, 200)).join(' ').includes('passed')) + check('a block fetched as you cross groups doesn\'t follow you', !tv.inventory.items().some(i => i.name === 'pumpkin'), tv.inventory.items().map(i => i.name).join(',')) + check('it drops where it was taken', await countIn('testworld', `@e[type=item,x=${at.x},y=${at.y},z=${at.z},distance=..3,nbt={Item:{id:"minecraft:pumpkin"}}]`) === 1) + await tp('Traveler', 'testworld') + await s.ask('kick Traveler', 300); await quit(tv); await sleep(1000) +} + +// ---------- AuraSkills ---------- +if (want('aura') && AURA) { + section('Wranglin\' as an AuraSkills skill') + check('MobSquad registers Wranglin\' with AuraSkills', s.log.some(l => /Wranglin' is an AuraSkills skill/.test(l)) && s.log.some(l => /Loaded 12 skills/.test(l))) + const auraFile = name => { const f = path.join(dir, 'plugins/AuraSkills/userdata', uuids[name] + '.yml'); return existsSync(f) ? readFileSync(f, 'utf8') : '' } + // AuraSkills writes its file when a player quits, so the checks read it after a kick + const auraLevel = text => { const m = text.match(/mobsquad\/wranglin:\s*\n\s*level: (\d+)\s*\n\s*xp: ([\d.]+)/) || text.match(/wranglin[^\n]*\n[^\n]*?(\d+)[^\n]*\n[^\n]*?([\d.]+)/); return m ? { level: +m[1], xp: +m[2] } : null } + if (want('coax')) { + // the coaxing section coaxed a chicken as Wrangler: 100 experience, MobSquad level 2 + await s.ask('kick Wrangler', 300); await quit(me); await sleep(2500) + const a = auraLevel(auraFile('Wrangler')) + check('a Wranglin\' level-up from coaxing shows in AuraSkills', a && a.level === 2, auraFile('Wrangler').slice(0, 600)) + } + // a player with a MobSquad level from before AuraSkills sees it there + const offline = name => { const h = createHash('md5').update('OfflinePlayer:' + name).digest(); h[6] = (h[6] & 0x0f) | 0x30; h[8] = (h[8] & 0x3f) | 0x80; const x = h.toString('hex'); return `${x.slice(0, 8)}-${x.slice(8, 12)}-${x.slice(12, 16)}-${x.slice(16, 20)}-${x.slice(20)}` } + mkdirSync(playersDir, { recursive: true }) + writeFileSync(path.join(playersDir, offline('Veteran') + '.txt'), 'wranglin 15000\n') // level 25 + const vet = await bot('Veteran', { physics: PHYSICS }) + await uuidOf('Veteran') + check('the test file is the one the server reads', uuids.Veteran === offline('Veteran'), uuids.Veteran) + await sleep(5000) + const level = async () => { const from = vet.chatLog.length; vet.chat('/mobsquad list'); await waitSaid(vet, /Wranglin' level \d+/, 4000, from); const m = vet.chatLog.slice(from).join(' ').match(/Wranglin' level (\d+)/); return m ? +m[1] : null } + check('MobSquad keeps the level from its own file', await level() === 25) + await s.ask('skills skill setlevel Veteran mobsquad/wranglin 30', 600) + check('MobSquad\'s own level counts, whatever AuraSkills says', await level() === 25) + await s.ask('mobsquad xp Veteran 2250', 400) + check('/mobsquad xp sets the level', await level() === 10) + await s.ask('kick Veteran', 300); await quit(vet); await sleep(2500) + const v = auraLevel(auraFile('Veteran')) + check('/mobsquad xp sets the AuraSkills level too (it was 30 there)', v && v.level === 10, auraFile('Veteran').slice(0, 600)) + check('MobSquad still keeps its own count', file('Veteran').includes('wranglin 2250'), file('Veteran')) + writeFileSync(path.join(playersDir, offline('Oldtimer') + '.txt'), 'wranglin 15000\n') + const old = await bot('Oldtimer', { physics: PHYSICS }) + await uuidOf('Oldtimer'); await sleep(6000) + await s.ask('kick Oldtimer', 300); await quit(old); await sleep(2500) + const o = auraLevel(auraFile('Oldtimer')) + check('a MobSquad level shows in AuraSkills when they join', o && o.level === 25, auraFile('Oldtimer').slice(0, 400)) +} + // ---------- vittles ---------- if (!MENU) skip('vittles') else if (want('vittles')) {