From 5dea4d0a659f522b652b7f7bb76f5cf0ebc7ed89 Mon Sep 17 00:00:00 2001 From: 90 Date: Wed, 10 Jan 2024 22:47:57 +0000 Subject: [PATCH] Mild decompression adjustment --- .../item/part/DecompressionModulePart.java | 13 +++++++------ .../_90/megacells/misc/DecompressionPattern.java | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java b/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java index 366ac697..6436ad60 100644 --- a/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java +++ b/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java @@ -1,8 +1,9 @@ package gripe._90.megacells.item.part; -import java.util.HashMap; import java.util.List; -import java.util.Map; + +import it.unimi.dsi.fastutil.objects.Object2LongMap; +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; @@ -43,7 +44,7 @@ public class DecompressionModulePart extends AEBasePart implements ICraftingProv @PartModels public static final IPartModel MODEL = new PartModel(MEGACells.makeId("part/decompression_module")); - private final Map outputs = new HashMap<>(); + private final Object2LongMap outputs = new Object2LongOpenHashMap<>(); private int priority = 0; @@ -117,13 +118,13 @@ public TickingRequest getTickingRequest(IGridNode node) { public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { var storage = node.getGrid().getStorageService().getInventory(); - for (var output : new HashMap<>(outputs).entrySet()) { + for (var output : new Object2LongOpenHashMap<>(outputs).object2LongEntrySet()) { var what = output.getKey(); - var amount = output.getValue(); + var amount = output.getLongValue(); var inserted = storage.insert(what, amount, Actionable.MODULATE, IActionSource.ofMachine(this)); if (inserted >= amount) { - outputs.remove(what); + outputs.removeLong(what); } else if (inserted > 0) { outputs.put(what, amount - inserted); } diff --git a/common/src/main/java/gripe/_90/megacells/misc/DecompressionPattern.java b/common/src/main/java/gripe/_90/megacells/misc/DecompressionPattern.java index 4426578a..a7fd3e6c 100644 --- a/common/src/main/java/gripe/_90/megacells/misc/DecompressionPattern.java +++ b/common/src/main/java/gripe/_90/megacells/misc/DecompressionPattern.java @@ -51,7 +51,7 @@ public AEItemKey getDefinition() { @Override public IInput[] getInputs() { - return new IInput[] {new Input(variant, 1)}; + return new IInput[] {new Input(variant)}; } @Override @@ -71,7 +71,7 @@ public int hashCode() { return definition.hashCode(); } - private record Input(AEItemKey input, long multiplier) implements IInput { + private record Input(AEItemKey input) implements IInput { @Override public GenericStack[] getPossibleInputs() { return new GenericStack[] {new GenericStack(input, 1)}; @@ -79,7 +79,7 @@ public GenericStack[] getPossibleInputs() { @Override public long getMultiplier() { - return multiplier; + return 1; } @Override