Skip to content

Commit

Permalink
Fix import/export buses not working with cable part inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed May 22, 2024
1 parent f1017ab commit 244e000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/main/java/gripe/_90/appliede/part/EMCExportBusPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ public void writeToNBT(CompoundTag extra) {
extra.putInt("nextSlot", nextSlot);
}

@SuppressWarnings("DuplicatedCode")
@Override
protected boolean doBusWork(IGrid grid) {
var adjacentPos = getHost().getBlockEntity().getBlockPos().relative(getSide());
var facing = getSide().getOpposite();
var blockEntity = getLevel().getBlockEntity(adjacentPos);

if (blockEntity == null) {
Expand All @@ -80,20 +82,19 @@ protected boolean doBusWork(IGrid grid) {

var doneWork = new AtomicBoolean(false);

blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(itemHandler -> {
blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, facing).ifPresent(itemHandler -> {
var emcStorage = grid.getService(KnowledgeService.class).getStorage();
var schedulingMode = getConfigManager().getSetting(Settings.SCHEDULING_MODE);
var remaining = getOperationsPerTick();
var slot = 0;

for (slot = 0; slot < availableSlots() && remaining > 0; slot++) {
// spotless:off
var startingSlot = switch (schedulingMode) {
case RANDOM -> getLevel().getRandom().nextInt(availableSlots());
case ROUNDROBIN -> (nextSlot + slot) % availableSlots();
default -> slot;
};
// spotless:on
var startingSlot =
switch (schedulingMode) {
case RANDOM -> getLevel().getRandom().nextInt(availableSlots());
case ROUNDROBIN -> (nextSlot + slot) % availableSlots();
default -> slot;
};
var what = getConfig().getKey(startingSlot);

if (!(what instanceof AEItemKey item)) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/gripe/_90/appliede/part/EMCImportBusPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ protected MenuType<?> getMenuType() {
return MENU;
}

@SuppressWarnings("DuplicatedCode")
@Override
protected boolean doBusWork(IGrid grid) {
var adjacentPos = getHost().getBlockEntity().getBlockPos().relative(getSide());
var facing = getSide().getOpposite();
var blockEntity = getLevel().getBlockEntity(adjacentPos);

if (blockEntity == null) {
Expand All @@ -63,7 +65,7 @@ protected boolean doBusWork(IGrid grid) {

var doneWork = new AtomicBoolean(false);

blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(itemHandler -> {
blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, facing).ifPresent(itemHandler -> {
var emcStorage = grid.getService(KnowledgeService.class).getStorage();
var adjacentStorage = ExternalStorageFacade.of(itemHandler);
var remaining = getOperationsPerTick();
Expand Down

0 comments on commit 244e000

Please sign in to comment.