Skip to content

Commit 6cfc4bb

Browse files
authored
Fix #19 by caching IHashedItems to AEItemKeys (#23)
* Upgrade dependencies for new Mekanism API
1 parent 9c5d258 commit 6cfc4bb

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
minecraft_version=1.19.2
2-
forge_version=43.1.65
3-
ae2_version=12.8.6
4-
mekanism_version=10.3.5.474
2+
forge_version=43.2.4
3+
ae2_version=12.9.2
4+
mekanism_version=10.3.7.476
55
jei_version=11.4.0.287
66
jade_id=4096513
77

src/main/java/me/ramidzkh/mekae2/qio/QioStorageAdapter.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.ramidzkh.mekae2.qio;
22

3+
import java.util.Map;
4+
import java.util.WeakHashMap;
5+
36
import org.jetbrains.annotations.Nullable;
47

58
import net.minecraft.core.Direction;
@@ -10,6 +13,7 @@
1013
import me.ramidzkh.mekae2.AMText;
1114
import mekanism.api.Action;
1215
import mekanism.api.MekanismAPI;
16+
import mekanism.api.inventory.IHashedItem;
1317
import mekanism.api.inventory.qio.IQIOComponent;
1418
import mekanism.api.inventory.qio.IQIOFrequency;
1519
import mekanism.api.security.SecurityMode;
@@ -28,6 +32,7 @@
2832
* block entity class.
2933
*/
3034
public class QioStorageAdapter<DASHBOARD extends BlockEntity & IQIOComponent> implements MEStorage {
35+
private static final Map<IHashedItem, AEItemKey> CACHE = new WeakHashMap<>();
3136
private final DASHBOARD dashboard;
3237
@Nullable
3338
private final Direction queriedSide;
@@ -99,8 +104,12 @@ public void getAvailableStacks(KeyCounter out) {
99104
if (freq == null) {
100105
return;
101106
}
102-
// noinspection ConstantConditions
103-
freq.forAllStored((stack, value) -> out.add(AEItemKey.of(stack), value));
107+
108+
// Fixes #19
109+
freq.forAllHashedStored((type, count) -> {
110+
// noinspection ConstantConditions
111+
out.add(CACHE.computeIfAbsent(type, it -> AEItemKey.of(it.getInternalStack())), count);
112+
});
104113
}
105114

106115
@Override

src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ side = "BOTH"
3232
[[dependencies.appmek]]
3333
modId = "mekanism"
3434
mandatory = true
35-
versionRange = "[10.3.0,11.0.0)"
35+
versionRange = "[10.3.7,11.0.0)"
3636
ordering = "AFTER"
3737
side = "BOTH"

0 commit comments

Comments
 (0)