Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Entity Brain | Memories

GamerCoder edited this page Jan 20, 2023 · 1 revision

Memories are small bits of information stored in the Entity's Brain. They are used to store things like angry at, nearest items, and more.

Getting & Setting Memories

Here's an example on how to get and set memories:

import me.gamercoder215.mobchip.bukkit.BukkitBrain;
import me.gamercoder215.mobchip.EntityBrain;
import me.gamercoder215.mobchip.ai.memories.EntityMemory;

// Bukkit imports...

public class MyPlugin extends JavaPlugin {

    public void setMemories(Mob m) {
        EntityBrain brain = BukkitBrain.getBrain(m);

        // Fetch Memory Value of "HOME"
        Location home = brain.getMemory(EntityMemory.HOME); // EntityMemory types are paramaterized

        // Set Memory value of "HOME"
        brain.setMemory(EntityMemory.HOME, m.getLocation());

        // Set temporary memory value of "HOME" with expiration in ticks
        brain.setMemory(EntityMemory.HOME, m.getLocation(), 20 * 60 * 20); // Will expire in 20 minutes
    }

}