Inspiration
We were inspired by the desire for more lifelike and engaging interactions within Minecraft. Standard villagers, while useful, often feel static and predictable. We wanted to leverage modern AI to create NPCs that genuinely react to player behavior, making every trade and conversation feel unique and impactful.
What it does
Our "Smart Villagers" mod transforms standard Minecraft villagers into AI-powered entities. When a player interacts with a villager, a chat interface opens alongside the traditional trading UI. The villager greets the player, and all subsequent chat messages are analyzed by the Gemini API for politeness. This politeness score, combined with a rolling "familiarity" value, dynamically adjusts the villager's trade prices, offering discounts for sustained kindness and increasing costs for rudeness over time.
How we built it
The mod was developed using Java, integrated with CurseForge and Gradle for the Minecraft modding environment. We created a client-side mod that detects player interaction with villagers and opens the chat interface. A server-side component (a Forge/Fabric mod or Spigot/Paper plugin) intercepts player chat messages. These messages are sent to an external backend service (not directly detailed here, but implied as the Gemini API intermediary) which then communicates with the Gemini API. The Gemini API provides both the AI villager's chat response and a politeness score (-1.0 to 1.0). This score updates a politeness Value variable. This politeness Value is then multiplied by a familiarity trait, which increments with each interaction, influencing the final trade cost adjustments.
Challenges we ran into
Integrating real-time AI API calls with game mechanics presented challenges, particularly managing potential latency and API rate limits to ensure a smooth player experience. A significant hurdle was reworking core Minecraft UI mechanics; specifically, enabling access to the chat bar while the villager trading menu was open, a functionality not natively available without exiting the trade screen first. Maintaining a consistent AI villager persona across varying player inputs was also a complex task, requiring careful prompt engineering. Balancing the dynamic price changes to feel impactful but fair, without being exploitative or overly punitive, required iterative testing. Securely handling and storing API keys was another critical consideration.
Accomplishments that we're proud of
We are particularly proud of successfully integrating a sophisticated AI model like Gemini into a Minecraft mod, creating genuinely dynamic and personalized NPC interactions. We've enhanced player immersion by making villagers truly responsive to their words. Achieving stable performance while relying on external API calls was a significant technical accomplishment.
What we learned
This project provided invaluable experience in Minecraft modding architecture, especially understanding game events and NBT data for custom entity properties. We gained practical knowledge in applying large language models for in-game AI, including the nuances of prompt engineering for character consistency. The importance of designing robust backend services for external API communication was underscored. We also learned how to balance AI capabilities with traditional game mechanics to create cohesive and engaging gameplay.
What's next for Smart Villager
Future plans for "Smart Villager" include expanding the range of AI-powered villager types (e.g., specific professions with unique conversational styles), implementing more complex emotional states that influence behaviors beyond just trading, and potentially allowing villagers to initiate conversations or quests based on player interaction history. We also aim to optimize performance further and explore cross-server compatibility.
Log in or sign up for Devpost to join the conversation.