Furukuwa

Create me a minecraft bedrock addon with these details:

📎 1 file 3,307 chars
📄
pasted-code-1791704320046.txt
txt 27 lines
▶
Project Herobrine AI — Part 4: First Appearance
Create a Minecraft Bedrock add-on for version 1.26.52 using Bridge. The add-on features Herobrine, whom I call Him. The goal is to develop him into a mysterious AI character who can observe players, remember experiences, learn patterns, develop a personality, and make decisions independently.
Part 4: First Appearance
Create Him as a custom entity with a humanoid model, dark texture, and pale eyes. Give him 40 health and make him stationary for this initial test.
When a player enters the world, check whether Him has already appeared. If not, wait approximately 10 seconds, then search for a safe spawning location around five to seven blocks away from the player.
If a suitable location is found, spawn Him there without displaying chat messages, titles, or notifications. Save his first-appearance status only after spawning succeeds. If spawning fails, retry after approximately 10 seconds. Prevent duplicate instances from appearing.
His model, texture, entity definition, scripts, and pack manifests must be compatible with Minecraft Bedrock 1.26.52. Use supported Minecraft APIs and validate all files.
Future AI Features
Observation: Him should eventually observe nearby players and environmental events, including movement, building, mining, exploration, and interactions.
Memory: He should remember important experiences with individual players and events in the world. Player memories and shared world memories must be stored separately and persist after the world is reloaded.
Learning: Him should recognize patterns in his experiences. For example, repeated attacks might make him cautious toward a particular player. Begin with programmed rules and statistics before introducing more advanced learning.
Decision-making: Him should eventually choose whether to observe, approach, investigate, retreat, hide, leave clues, disappear, or do nothing. His decisions should depend on the situation, memories, and personality rather than following a fixed sequence.
Personality: Him may develop calm, mysterious, curious, angry, or mischievous tendencies. Personality should influence his actions, while his relationship with each player remains separate.
Mystery and World Interaction
Him should remain mysterious. He must not announce himself, appear every time a player joins, or constantly attempt to scare players.
Future behaviors could include watching from a distance, appearing between trees, leaving strange signs, creating rare structures, or disappearing when approached. Sometimes, he should remain inactive for long periods.
Protect player builds and designated locations from intentional destruction. Any future AI-generated actions must be validated before execution.
An external AI service may eventually help Him analyze memories and suggest new behaviors. However, the add-on must validate every suggestion and must not execute arbitrary generated code or allow the AI to bypass protected rules.
Testing Requirements
Before developing more features, verify that:
Both Behavior and Resource Packs load correctly.
Him appears near the player after the delay.
His model and texture render properly.
His appearance status persists after reloading the world.
Failed spawning does not crash the game.
Duplicate instances are prevented.
`
Kodari AI
KodariOct 11 at 7:43 am 1
HerobrineFirstAppearance
A Minecraft Bedrock add-on introducing Herobrine, called Him, as a mysterious AI entity. The add-on creates a custom humanoid entity with dark texture and pale eyes, 40 health, and stationary behavior. When a player joins, the system waits 10 seconds, then searches for a safe spawn location 5-7 blocks away. Him spawns silently without notifications, with retry logic on failure and duplicate prevention. First-appearance status persists across world reloads. The architecture supports future AI features including observation, memory storage, pattern learning, decision-making, personality development, and validated world interactions while protecting player builds.
  1. Build Bridge-ready behavior and resource packs with manifests and Him’s stationary 40-health entity.

  2. Add delayed, safe spawning with retries, duplicate detection, and persistent first-appearance state.

  3. Use a built-in humanoid as a temporary visual so the packs work; the custom model and texture need Studio assets.

Created the Bridge-ready behavior and resource packs. Him has 40 health, stays stationary, and is scheduled to appear silently about 10 seconds after a player joins. The script searches for a safe spot 5–7 blocks away, retries after failures, and saves the first-appearance state only after spawning succeeds.

The resource pack currently uses Minecraft’s built-in humanoid model and Steve texture as a placeholder; it does not yet have the requested dark texture or pale eyes. Create Him’s model in Kodari Studio → 3D Models, then bring it into this project through a workspace. Texture generation is disabled for this project; enable it in Settings → Generation, or for all projects at https://kodari.ai/settings?tab=features.

Kodari can make mistakes. Review important code before using.
Files
behavior_packs
resource_packs
Code
5 190
behavior_packs/him_bp/scripts/main.js
import { system, world } from "@minecraft/server";

const HIM_TYPE = "herobrine:him";
const APPEARED_PROPERTY = "herobrine:him_appeared";
const RETRY_TICKS = 200;
const DIMENSIONS = ["overworld", "nether", "the_end"];

let attemptScheduled = false;

function hasAppeared() {
  return world.getDynamicProperty(APPEARED_PROPERTY) === true;
}

function findExistingHim() {
  for (const dimensionId of DIMENSIONS) {
    const entities = world.getDimension(dimensionId).getEntities({ type: HIM_TYPE });
    if (entities.length > 0) {
      world.setDynamicProperty(APPEARED_PROPERTY, true);
      return true;
    }
  }
  return false;
}

function isSafeSpawnBlock(dimension, x, groundY, z) {
  try {
    const ground = dimension.getBlock({ x, y: groundY, z });
    const feet = dimension.getBlock({ x, y: groundY + 1, z });
    const head = dimension.getBlock({ x, y: groundY + 2, z });
    return Boolean(
      ground && ground.isSolid &&
      feet && feet.isAir && !feet.isLiquid &&
      head && head.isAir && !head.isLiquid
    );
  } catch {
    return false;
  }
}

function trySpawnHim() {
  if (hasAppeared() || findExistingHim()) return;

  const players = world.getPlayers();
  if (players.length === 0) return;

  const player = players[Math.floor(Math.random() * players.length)];
  const dimension = player.dimension;
  const location = player.location;
  const baseX = Math.floor(location.x);
  const baseY = Math.floor(location.y);
  const baseZ = Math.floor(location.z);

  for (let attempt = 0; attempt < 48; attempt++) {
    const angle = Math.random() * Math.PI * 2;
    const radius = 5 + Math.random() * 2;
    const x = Math.floor(location.x + Math.cos(angle) * radius);
    const z = Math.floor(location.z + Math.sin(angle) * radius);
    const distance = Math.hypot(x + 0.5 - location.x, z + 0.5 - location.z);
    if (distance < 5 || distance > 7.5) continue;

    const verticalOffset = Math.floor(Math.random() * 7) - 3;
    const groundY = baseY - 1 + verticalOffset;
    if (!isSafeSpawnBlock(dimension, x, groundY, z)) continue;

    dimension.spawnEntity(HIM_TYPE, { x: x + 0.5, y: groundY + 1, z: z + 0.5 });
    world.setDynamicProperty(APPEARED_PROPERTY, true);
    return;
  }
}

function scheduleAttempt() {
  if (attemptScheduled || hasAppeared()) return;
  attemptScheduled = true;
  system.runTimeout(() => {
    attemptScheduled = false;
    try {
      trySpawnHim();
    } catch {
      // A failed spawn or unavailable location is retried without interrupting the script runtime.
    }
    if (!hasAppeared()) scheduleAttempt();
  }, RETRY_TICKS);
}

world.afterEvents.playerSpawn.subscribe((event) => {
  if (!event.initialSpawn || hasAppeared()) return;
  scheduleAttempt();
});