I run a small Minecraft server for friends. We had a problem: every time we'd go exploring, mobs would wreck our base. The obvious solution? Guard dogs. Minecraft has wolves, they can be tamed, but tamed wolves are useless as guards. They either sit there doing nothing or follow you around like lost puppies.
I wanted wolves that would stay at a location, patrol a radius, and attack hostile mobs. Basically guard dogs. Minecraft doesn't have that.
The language I'd never seen
The way to script custom behavior in Minecraft (without writing a full Java plugin) is DenizenScript. It's a YAML-like scripting language specific to Minecraft servers. It has its own syntax, its own commands, its own way of handling entities, events, and flags.
I'd never written a line of it. My day job is TypeScript. DenizenScript looks like this:
- if <[wolf].location.distance[<[guard_center]>]> > 15:
- walk <[wolf]> <[safe_center]> speed:0.3
- flag <[wolf]> return_attempts:++
That's not YAML. That's not any language I know. The angle brackets, the dot-chained methods, the flag system. It's its own thing entirely.
Learning DenizenScript properly for one project didn't make sense. I'd use it once and forget it. So I described what I wanted in plain English and let AI translate it into DenizenScript.
What I asked for
The concept was simple:
- Right-click a tamed wolf with a stick to toggle guard mode
- Guard wolf stays at that location and patrols a 15-block radius
- It attacks hostile mobs but never players, never creepers (explosions near the base = bad), and never passive animals
- If it gets stuck or wanders too far, teleport it back
- When the owner comes back, right-click with a stick to get your wolf back
Simple on paper. 463 lines of DenizenScript in practice.
The easy part
AI handled the basic structure well. The event handlers, the combat scanning, the flag system for tracking guard state. Within an hour I had a script that could toggle guard mode and make wolves attack nearby zombies.
The owner removal trick was clever: when a wolf enters guard mode, you remove the owner (so it stops following you and won't teleport to you), but save the original owner in a flag. When you disable guard mode, restore the owner. AI figured that out without me asking.
# Enter guard mode
- flag <[wolf]> original_owner:<player>
- adjust <[wolf]> owner:!
- flag <[wolf]> guard_mode
# Exit guard mode
- adjust <[wolf]> owner:<[wolf].flag[original_owner]>
- flag <[wolf]> guard_mode:!
The hard part
Then reality hit. The script worked in theory. In practice, wolves are dumb.
Pathfinding failures. Wolves would try to walk back to their guard point and get stuck on a fence. Or a half-slab. Or literally nothing visible. The AI-generated "walk back" command wasn't enough. I needed stuck detection: if a wolf hasn't moved in 60 seconds despite being told to walk, teleport it home.
- if <[time_stuck]> > 60:
- teleport <[wolf]> <[guard_center]>
- flag <[wolf]> invulnerable_until:<util.time_now.add[3s]>
Teleport safety. Teleporting a wolf sounds simple. But if you teleport it into a block, it suffocates. If you teleport it mid-air, fall damage. If you teleport it while a mob is hitting it, it dies during the invulnerability gap. Every teleport needed a 3-second invulnerability window with protection from multiple damage types.
The creeper problem. First version: wolves attacked everything hostile. I realized pretty quickly that creepers would be a disaster. Wolf attacks creeper, creeper explodes, half your base is gone. Worse than no guard wolf at all. Had to explicitly exclude creepers from the target list.
Server restarts. Guard wolves need to survive server restarts. Their guard points, health, and state all stored in Denizen flags. But on restart, max health resets to vanilla values. Needed a startup script that re-discovers all guard wolves and restores their stats.
Health management. Tamed wolves in Minecraft can be healed by feeding them meat. But guard wolves have their owner removed (that's how they stay put). Without an owner, the healing mechanic doesn't work the same way. I had to add a warning message: "Disable guard mode first, then heal, then re-enable."
Each of these took multiple deploy-test-fix cycles. Change the script, reload on the server, spawn some zombies, watch the wolf, see what breaks, repeat.
What the result looks like
After all the iteration, the plugin is actually solid:
- Wolves patrol a 15-block radius and return to their post
- They attack zombies, skeletons, spiders, and other hostiles on sight
- They ignore creepers, players, and passive mobs
- They survive server restarts with all their stats intact
- Stuck wolves teleport home with invulnerability
- You get death notifications when a guard wolf dies
- A
/gw lscommand shows all your wolves with health, location, and armor status
========== Your Wolves (5) ==========
• Fang (Pale) ❤ 32/40 GUARDING at -487,78,-18,world
• Rex (Ashen) ❤ 20/20 Following at 123,65,456,world
• Scout (Woods) ❤ 8/8 Sitting at -200,70,300,world
The unexpected payoff
Once the guard wolves script was solid, something clicked. I had 463 lines of working DenizenScript that covered events, flags, entity management, combat, persistence. It was basically a reference implementation.
When I wanted other scripts afterward, like keeping dolphins alive (they drown when you wander too far from them), I could point AI at the guard wolves script and say "make something like this but for dolphins." It already understood the patterns: how Denizen handles entities, how flags work, how to hook into server events.
The first script took a day. The dolphin script took maybe 20 minutes. Having a working example in the same language made AI dramatically better at generating new scripts. It's like giving it a style guide instead of asking it to figure everything out from scratch.
The honest breakdown
AI got me maybe 60-70% of the way there. The basic structure, the event system, the flag management. Things that are well-documented and pattern-based.
The remaining 30-40% was all edge cases that only surface when you actually run the thing. Pathfinding quirks, teleport safety, combat targeting rules, persistence across restarts. AI can't predict that wolves get stuck on half-slabs or that creepers near your base are a disaster. That knowledge comes from testing.
Total time: about a day. Without AI, I probably wouldn't have built it at all. DenizenScript is too niche to justify learning for one project. With AI, I could focus on what I wanted instead of how DenizenScript works.
The plugin is open source if you want to use it or build on it: guard-wolves on GitHub.
Anyone else building weird Minecraft plugins? I'd love to see what people are doing with DenizenScript.
Top comments (0)