SmartBrainLib (Forge/Fabric/Quilt)

SmartBrainLib (Forge/Fabric/Quilt)

24M Downloads

[1.21.1] InteractWithDoor does not work because `BrainUtils.computeMemoryIfAbsent` cannot be used for collections

lcy0x1 opened this issue ยท 0 comments

commented

In InteractWithDoor behavior, it uses

BrainUtils.computeMemoryIfAbsent(entity, 
  MemoryModuleType.DOORS_TO_CLOSE, 
  ObjectOpenHashSet::new
).add(new GlobalPos(level.dimension(), pos));

However, BrainUtils.computeMemoryIfAbsent fails to put the empty set into memory, as minecraft removes empty set from memory, causing the empty set not being added to memory. The fix would involve checking if the memory has a non-empty set, if so, add position into the set, and if not, add a new set containing the new position.