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

Entity Brain | Memories | Unit Memories

GamerCoder edited this page Feb 14, 2023 · 1 revision

Unit Memories are special kind of memories that use their expiry cooldowns as their value, as opposed to a set value in the Entity's Brain.

The reason behind this is so that memories pertaining to cooldowns can automatically update every tick. Instead of manually changing the memory to go down 1 every 1/20 of a second, they use the built-in expiry system to account for their value.

Unit memories are usually used in the following:

  • Action Delays
  • Action Cooldowns
  • true/false type values (present = true, not present = false)

Examples

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

public class MyPlugin extends JavaPlugin {

    public static void setMemories(Warden m) {
         EntityBrian brain = BukkitBrain.getBrain(m);
         
         brain.setMemory(EntityMemory.VIBRATION_COOLDOWN, Unit.INSTANCE, 3000); // Sets the warden's vibration cooldown to 3000 ticks
    }
}