Setting expirable memory repeatedly causes it to tick multiple times every tick
ByteLaw5 opened this issue ยท 1 comments
When you set an expirable memory while there's an existing value, the SmartBrain does not check for duplicate entries and adds another instance of it, causing it to tick down multiple times every tick
Caused by SmartBrain.setMemoryInternal:
@Override
public <U> void setMemoryInternal(MemoryModuleType<U> memoryType, Optional<? extends ExpirableValue<?>> memory) {
if (memory.isPresent() && memory.get().getValue()instanceof Collection<?> collection && collection.isEmpty())
memory = Optional.empty();
this.memories.put(memoryType, memory);
if (memory.isPresent() && memory.get().canExpire()) //This does not check if the memory already exists in expirableMemories
this.expirableMemories.add(memoryType);
}