This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Entity Brain
GamerCoder edited this page Jan 20, 2023
·
1 revision
The Entity Brain is how you can access all of the entity's functionality, from Entity AI to Entity Navigation systems. This will show the primary methods used in the Entity Brain.
A "Restriction Area" is a polar or circular region of area that entities must stay inside.
Fetch existing Restriction Metadata.
import me.gamercoder215.mobchip.EntityBrain;
import me.gamercoder215.mobchip.bukkit.BukkitBrain;
public class MyPlugin extends JavaPlugin {
public static void getRestriction(Mob m) {
EntityBrain brain = BukkitBrain.getBrain(m);
// Fetches the center of the restriction area
Location center = brain.getRestrictionArea();
// Fetches the radius of the circular area for the restriction
int radius = brain.getRestrictionRadius();
// Whether a restriction center and radius was set
if (brain.hasRestriction()) {
// Whether the entity is in the restriction area
if (brain.isInRestriction()) {
System.out.println("Mob has escaped!");
}
}
}
}
How to modify or override an entity's current restriction metadata.
import me.gamercoder215.mobchip.EntityBrain;
import me.gamercoder215.mobchip.bukkit.BukkitBrain;
public class MyPlugin extends JavaPlugin {
public static void setRestriction(Mob m, Location center) {
EntityBrain brain = BukkitBrain.getBrain(m);
// Sets the restriction area with a radius of 5, making the total area roughly 25π in area
brain.setRestrictionArea(center, 5);
}
public static void clearRestriction(Mob m) {
EntityBrain brain = BukkitBrain.getBrain(m);
// Clears all current restriction metadata
brain.clearRestrictionArea();
}
}
Copyright © 2022-Present gmitch215. All Rights Reserved.
Licensed under GNU General Public License v3.0.