Skip to content

Commit

Permalink
keep track of whether a pull side has been configured
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Aug 31, 2024
1 parent 1d44f2b commit 75e22ed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public PipeTier getTier() {

@Override
public void pullFromAcceptors() {
if (getAvailablePull() <= 0) {
if (!hasPullSide || getAvailablePull() <= 0) {
return;
}
AcceptorCache<IFluidHandler> acceptorCache = getAcceptorCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public TubeTier getTier() {

@Override
public void pullFromAcceptors() {
if (getAvailablePull() <= 0) {
if (!hasPullSide || getAvailablePull() <= 0) {
return;
}
AcceptorCache<IChemicalHandler> acceptorCache = getAcceptorCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private static boolean isConnectionType(Direction side, byte allConnections, byt
ConnectionType.NORMAL};
private final AbstractAcceptorCache<ACCEPTOR, ?> acceptorCache;
public byte currentTransmitterConnections = 0x00;
protected boolean hasPullSide = false;

private final TileEntityTransmitter transmitterTile;
private final Set<TransmissionType> supportedTransmissionTypes;
Expand Down Expand Up @@ -117,6 +118,16 @@ public void setConnectionTypesRaw(@NotNull ConnectionType[] connectionTypes) {
throw new IllegalArgumentException("Mismatched connection types length");
}
this.connectionTypes = connectionTypes;
this.hasPullSide = recalculateHasPull(connectionTypes);
}

private boolean recalculateHasPull(@NotNull ConnectionType @NotNull [] connectionTypes) {
for (@NotNull ConnectionType connectionType : connectionTypes) {
if (connectionType == ConnectionType.PULL) {
return true;
}
}
return false;
}

public ConnectionType getConnectionTypeRaw(@NotNull Direction side) {
Expand All @@ -128,6 +139,11 @@ public void setConnectionTypeRaw(@NotNull Direction side, @NotNull ConnectionTyp
ConnectionType old = connectionTypes[index];
if (old != type) {
connectionTypes[index] = type;
if (type == ConnectionType.PULL) {
hasPullSide = true;
} else if (hasPullSide) {
this.hasPullSide = recalculateHasPull(connectionTypes);
}
getTransmitterTile().sideChanged(side, old, type);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public CableTier getTier() {

@Override
public void pullFromAcceptors() {
if (getAvailablePull() <= 0) {
if (!hasPullSide || getAvailablePull() <= 0) {
return;
}
EnergyAcceptorCache acceptorCache = getAcceptorCache();
Expand Down

0 comments on commit 75e22ed

Please sign in to comment.