Skip to content

Commit

Permalink
Fix machines and cables input/output energy to the wrong side of bloc…
Browse files Browse the repository at this point in the history
…ks adjacent (#467)
  • Loading branch information
AlexNijjar committed Feb 18, 2024
1 parent 7dbf334 commit a07b6c6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ See https://modrinth.com/mod/ad-astra/version/1.15.7 for the full changelog.
- Fixed The Ti-69s red and green lights being swapped from the item texture (#479).
- Added painting translations (#485).
- The Nasa workbench now works with recipes with less than 14 ingredients (#483).
- Prevent configured pipes from resetting on neighbor update (#484).
- Prevent configured pipes from resetting on neighbor update (#484).
- Fixed machines and cables input/output energy to the wrong side of blocks adjacent (#467).
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void addNode(@NotNull BlockEntity entity, PipeProperty pipeProperty, Dire
public void moveContents(long transferRate, @NotNull BlockEntity source, @NotNull BlockEntity consumer, Direction direction) {
var sourceContainer = EnergyContainer.of(source, direction);
if (sourceContainer == null) return;
var consumerContainer = EnergyContainer.of(consumer, direction);
var consumerContainer = EnergyContainer.of(consumer, direction.getOpposite());
if (consumerContainer == null) return;
EnergyApi.moveEnergy(sourceContainer, consumerContainer, Math.min(transferRate, sourceContainer.getStoredEnergy()), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void moveContents(long transferRate, @NotNull BlockEntity source, @NotNul
var sourceContainer = FluidContainer.of(source, direction);
if (sourceContainer == null) return;
if (!(FluidContainer.holdsFluid(consumer, direction))) return;
var consumerContainer = FluidContainer.of(consumer, direction);
var consumerContainer = FluidContainer.of(consumer, direction.getOpposite());
if (consumerContainer == null) return;
for (var fluid : sourceContainer.getFluids()) {
if (fluid.isEmpty()) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void pushEnergyNearby(ContainerMachineBlockEntity machine, BlockPo
if (!filter.test(direction)) continue;
BlockEntity nearbyEntity = machine.level().getBlockEntity(pos.relative(direction));
if (nearbyEntity == null) continue;
EnergyContainer nearbyContainer = EnergyContainer.of(nearbyEntity, direction);
EnergyContainer nearbyContainer = EnergyContainer.of(nearbyEntity, direction.getOpposite());
if (nearbyContainer == null) continue;
EnergyApi.moveEnergy(container, nearbyContainer, amount, false);
}
Expand All @@ -48,7 +48,7 @@ public static void pullEnergyNearby(ContainerMachineBlockEntity machine, BlockPo
if (!filter.test(direction)) continue;
BlockEntity nearbyEntity = machine.level().getBlockEntity(pos.relative(direction));
if (nearbyEntity == null) continue;
EnergyContainer nearbyContainer = EnergyContainer.of(nearbyEntity, direction);
EnergyContainer nearbyContainer = EnergyContainer.of(nearbyEntity, direction.getOpposite());
if (nearbyContainer == null) continue;
EnergyApi.moveEnergy(nearbyContainer, container, amount, false);
}
Expand All @@ -65,7 +65,7 @@ public static void pushFluidNearby(ContainerMachineBlockEntity machine, BlockPos
BlockEntity nearbyEntity = machine.level().getBlockEntity(pos.relative(direction));
if (nearbyEntity == null) continue;
if (!FluidContainer.holdsFluid(nearbyEntity, direction)) continue;
FluidContainer nearbyContainer = FluidContainer.of(nearbyEntity, direction);
FluidContainer nearbyContainer = FluidContainer.of(nearbyEntity, direction.getOpposite());
if (nearbyContainer == null) continue;
FluidHolder holder = container.getFluids().get(tank);
if (holder.isEmpty()) continue;
Expand All @@ -84,7 +84,7 @@ public static void pullFluidNearby(ContainerMachineBlockEntity machine, BlockPos
BlockEntity nearbyEntity = machine.level().getBlockEntity(pos.relative(direction));
if (nearbyEntity == null) continue;
if (!FluidContainer.holdsFluid(nearbyEntity, direction)) continue;
FluidContainer nearbyContainer = FluidContainer.of(nearbyEntity, direction);
FluidContainer nearbyContainer = FluidContainer.of(nearbyEntity, direction.getOpposite());
if (nearbyContainer == null) continue;
FluidHolder holder = nearbyContainer.getFluids().get(tank);
if (holder.isEmpty()) continue;
Expand Down

0 comments on commit a07b6c6

Please sign in to comment.