Skip to content

Commit

Permalink
Mild decompression adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jan 10, 2024
1 parent 5994ab9 commit 5dea4d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<AEKey, Long> outputs = new HashMap<>();
private final Object2LongMap<AEKey> outputs = new Object2LongOpenHashMap<>();

private int priority = 0;

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -71,15 +71,15 @@ 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)};
}

@Override
public long getMultiplier() {
return multiplier;
return 1;
}

@Override
Expand Down

0 comments on commit 5dea4d0

Please sign in to comment.