Skip to content

[WIP] Implement SURVIVAL and LOGISTICS activities for HumanoidNPC - #17

Draft
DizzyMii with Copilot wants to merge 1 commit into
mainfrom
copilot/phase-2-implement-survival-logistics-again
Draft

[WIP] Implement SURVIVAL and LOGISTICS activities for HumanoidNPC#17
DizzyMii with Copilot wants to merge 1 commit into
mainfrom
copilot/phase-2-implement-survival-logistics-again

Conversation

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Objective: Phase 2 - Implement the SURVIVAL and LOGISTICS activities for the HumanoidNPC using SmartBrainLib in NeoForge 1.21.1.

Context: Building on the previous foundational entity and memory setup, this NPC must prioritize self-preservation above all other tasks. It needs to monitor its health and hunger, consume food when necessary, retreat from overwhelming odds, and manage its inventory to prevent filling up on useless items.

Please implement the following components, integrating them into the existing HumanoidNPC and ModMemoryTypes architecture:

Step 1: Memory and Sensor Expansion

Update the memory registry to include LAST_KNOWN_DANGER (Type: BlockPos).

Create a new sensor SelfPreservationSensor extending ExtendedSensor. This sensor should evaluate the NPC's current health percentage, food level, and the presence of hostile entities within a 15-block radius. It should write to a new memory module NEEDS_HEALING (Type: Boolean) if health drops below 40%.

Step 2: Survival Behaviors (Highest Priority)
Create the following behaviors for a new SURVIVAL activity:

ConsumeFoodBehavior: Extends ExtendedBehaviour. If NEEDS_HEALING is true or hunger is low, this behavior searches the inventory for edible items, moves the best food item to the main hand, and simulates the item use duration to consume it.

StrategicRetreatBehavior: Extends ExtendedBehaviour. If outmatched (e.g., low health and hostile mobs are closing in), this behavior calculates a path away from the threat or toward BASE_LOCATION and sprints.

Step 3: Logistics Behaviors
Create the following behavior for a new LOGISTICS activity:

InventoryManagementBehavior: Extends ExtendedBehaviour. This behavior triggers when the NPC's inventory is over 80% full. It should identify low-value blocks (e.g., dirt, cobblestone, gravel) and throw them on the ground to free up space for high-value targets (like ores or logs).

Step 4: Update the Entity Brain
Modify the brainProvider() in HumanoidNPC:

Register the new SelfPreservationSensor.

Add the SURVIVAL activity with the highest priority weighting. This must override CORE and ACQUISITION.

Add the LOGISTICS activity, set to trigger only when the NPC is in a safe location (no immediate threats) and not currently engaged in SURVIVAL.

Constraints:
Ensure seamless integration with Phase 1. The SURVIVAL state must immediately interrupt any block-breaking or tool-swapping logic handled in ACQUISITION. Provide the complete Java code for the new sensors and behaviors, and show the exact modifications needed in the HumanoidNPC class.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI requested a review from DizzyMii March 26, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants