SmartBrainLib (Forge/Fabric/Quilt)

SmartBrainLib (Forge/Fabric/Quilt)

24M Downloads

Suggestion: Override BehaviorControl#debugString in GroupBehavior to return a bit more information

Thelnfamous1 opened this issue ยท 1 comments

commented

I use Flemmli97's DebugUtils, which re-enables the vanilla debug renderers, to help with in-game debugging of Brains. When reading which behaviors are currently running, any instance of GroupBehavior does not provide any more information beyond the name of the GroupBehavior sub-class.

If you override BehaviorControl#debugString in GroupBehavior, you can format the debug string to not only provide the name of the GroupBehavior sub-class, but the debug strings of the currently running behaviors. This can help diagnose which of the sub-behaviors of a GroupBehavior are currently running when the vanilla debug renderer is re-enabled.

Example:
@Override public String debugString() { Set<String> runningBehaviors = this.behaviours.stream() .filter((behaviour) -> behaviour.getStatus() == Behavior.Status.RUNNING) .map(BehaviorControl::debugString) .collect(Collectors.toSet()); String name = this.getClass().getSimpleName(); return "(" + name + "): " + String.join(",", runningBehaviors); }

commented

I'm gonna stick with vanilla's expected behaviour of keeping debugString as the class name, and instead override toString
This is what vanilla does in GateBehavior, so I'm gonna follow that standard

Done in 1.12.1