Skip to content

Commit

Permalink
Recalculate transmutation patterns on player knowledge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Apr 28, 2024
1 parent 393db73 commit 16aeaec
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import moze_intel.projecte.api.ItemInfo;
import moze_intel.projecte.api.capabilities.IKnowledgeProvider;
import moze_intel.projecte.api.event.PlayerKnowledgeChangeEvent;
import moze_intel.projecte.api.proxy.ITransmutationProxy;

public class CompositeKnowledgeProvider implements IKnowledgeProvider {
Expand All @@ -42,7 +43,7 @@ public class CompositeKnowledgeProvider implements IKnowledgeProvider {
private final Set<IGridNode> moduleNodes = new ObjectLinkedOpenHashSet<>();
private final List<IPatternDetails> patterns = new ObjectArrayList<>();

public CompositeKnowledgeProvider() {
CompositeKnowledgeProvider() {
MinecraftForge.EVENT_BUS.addListener((PlayerEvent event) -> {
if (event instanceof PlayerEvent.PlayerLoggedInEvent || event instanceof PlayerEvent.PlayerLoggedOutEvent) {
cachedProviders.clear();
Expand All @@ -56,6 +57,12 @@ public CompositeKnowledgeProvider() {
}
}
});

MinecraftForge.EVENT_BUS.addListener((PlayerKnowledgeChangeEvent event) -> {
if (cachedProviders.get(event.getPlayerUUID()) != null) {
recalculatePatterns();
}
});
}

Set<IKnowledgeProvider> getProviders() {
Expand Down

0 comments on commit 16aeaec

Please sign in to comment.