Skip to content

Commit

Permalink
changed more loss references to double
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Nov 15, 2023
1 parent 7e23274 commit a826b9f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ private void transferAroundPipe(GTTransaction transaction, long pos) {
if (!cap.isPresent()) continue;
//Perform insertion, and add to the transaction.
var handler = cap.get();
long voltage = transaction.voltageOut - (long)Math.ceil(cable.getLoss());
long voltage = transaction.voltageOut - Math.round(cable.getLoss());
long ampsToInsert = handler.availableAmpsInput(voltage);
GTTransaction.TransferData data = new GTTransaction.TransferData(transaction,voltage, ampsToInsert);
if (this.callback.modify(data, dir, false, true) || this.callback.modify(data, side, true, true)){
continue;
}
if (data.getAmps(true) < ampsToInsert) ampsToInsert = data.getAmps(true);
if (data.getLoss() > 0) voltage -= (long) Math.ceil(data.getLoss());
if (data.getLoss() > 0) voltage -= Math.round(data.getLoss());
long amps = handler.insertAmps(voltage, ampsToInsert, true);
if (amps > 0){
transaction.addData(amps, cable.getLoss(), t -> {
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/java/tesseract/api/gt/GTConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/
public class GTConsumer extends Consumer<IGTCable, IGTNode> {

private int loss;
private double loss;
private long minVoltage = Integer.MAX_VALUE;
private int minAmperage = Integer.MAX_VALUE;

// Way of the sorting by the loss and the distance to the node
public static final Comparator<GTConsumer> COMPARATOR = (t1, t2) -> (t1.getDistance() == t2.getDistance()) ? compare(t1.getLoss(), t2.getLoss()) : compare(t1.getDistance(), t2.getDistance());
public static final Comparator<GTConsumer> COMPARATOR = (t1, t2) -> (t1.getDistance() == t2.getDistance()) ? Double.compare(t1.getLoss(), t2.getLoss()) : compare(t1.getDistance(), t2.getDistance());

public final LongSet uninsulatedCables = new LongOpenHashSet();

Expand Down Expand Up @@ -51,7 +51,7 @@ public int getPriority() {
/**
* @return Gets the total loss for the given consumer.
*/
public int getLoss() {
public double getLoss() {
return loss;
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/tesseract/api/gt/GTController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private boolean onCheck(IGTNode producer, List<GTConsumer> consumers, Path<IGTCa

if (node != null && node.canInput(dir)) {
GTConsumer consumer = new GTConsumer(node, producer, path);
long voltage = producer.getOutputVoltage() - consumer.getLoss();
long voltage = producer.getOutputVoltage() - Math.round(consumer.getLoss());
if (voltage <= 0) {
return true;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ public void insert(long pipePos, Direction side, GTTransaction stack, ITransacti
if (amperage_in <= 0) {
break;
}
long loss = consumer.getLoss();
long loss = Math.round(consumer.getLoss());
if (loss < 0 || loss > voltage_out) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/tesseract/api/gt/GTTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public TransferData(GTTransaction transaction, long eu) {
}

public long getEnergy(long amps, boolean input) {
return input ? (voltage - (long)(Math.ceil(loss))) * amps : voltage * amps;
return input ? (voltage - Math.round(loss)) * amps : voltage * amps;
}

public long getTotalAmperage() {
Expand Down

0 comments on commit a826b9f

Please sign in to comment.