Skip to content

Commit

Permalink
Merge branch 'fix/cache_barrels' into feature/crafting
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/io/github/sefiraat/networks/network/NetworkRoot.java
  • Loading branch information
Sefiraat committed Jan 14, 2022
2 parents 1fb058d + 100c6fe commit b57045c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/io/github/sefiraat/networks/network/NetworkRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class NetworkRoot extends NetworkNode {
protected final Set<Location> networkPurgers = new HashSet<>();
protected final Set<Location> networkPowerNodes = new HashSet<>();
protected final Set<Location> networkCrafters = new HashSet<>();
protected Set<BarrelIdentity> barrels = null;

private long totalPower = 0;

Expand Down Expand Up @@ -180,8 +181,13 @@ public Map<ItemStack, Integer> getAllNetworkItems() {

@Nonnull
public Set<BarrelIdentity> getBarrels() {

if (this.barrels != null) {
return this.barrels;
}

final Set<Location> addedLocations = new HashSet<>();
final Set<BarrelIdentity> barrelItemMap = new HashSet<>();
final Set<BarrelIdentity> barrelSet = new HashSet<>();

for (Location cellLocation : networkMonitors) {
final BlockFace face = NetworkDirectional.getSelectedFace(cellLocation);
Expand All @@ -206,7 +212,7 @@ public Set<BarrelIdentity> getBarrels() {
BlockMenu menu = BlockStorage.getInventory(testLocation);
InfinityBarrel infinityBarrel = getInfinityBarrel(menu, unit);
if (infinityBarrel != null) {
barrelItemMap.add(infinityBarrel);
barrelSet.add(infinityBarrel);
}
continue;
}
Expand All @@ -215,13 +221,14 @@ public Set<BarrelIdentity> getBarrels() {
BlockMenu menu = BlockStorage.getInventory(testLocation);
NetworkShell shell = getShell(menu);
if (shell != null) {
barrelItemMap.add(shell);
barrelSet.add(shell);
}
}

}

return barrelItemMap;
this.barrels = barrelSet;
return barrelSet;
}

@Nullable
Expand Down

0 comments on commit b57045c

Please sign in to comment.