aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.properties2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java69
3 files changed, 38 insertions, 37 deletions
diff --git a/build.properties b/build.properties
index 02c2b83517..0143910a75 100644
--- a/build.properties
+++ b/build.properties
@@ -6,7 +6,7 @@ ic2.version=2.2.790-experimental
codechickenlib.version=1.1.3.140
codechickencore.version=1.0.7.47
nei.version=1.0.5.120
-gregtech.jenkinsbuild=736
+gregtech.jenkinsbuild=745
gregtech.version=5.09.33.55
#cofhcore.version=[1.7.10]3.1.4-329-dev
cofh_core_version=2388751
diff --git a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java
index 58caed7951..4004a8d826 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java
@@ -31,7 +31,7 @@ public class RendererMessage implements IMessage {
ObjectInputStream ois = new ObjectInputStream(is);
Object data = ois.readObject();
sparkList = (HashSet<ThaumSpark>) data;
- } catch (IOException | ClassNotFoundException ex) {
+ } catch (IOException | ClassNotFoundException ignored) {
}
}
@@ -44,7 +44,7 @@ public class RendererMessage implements IMessage {
oos.flush();
InputStream is = new ByteArrayInputStream(baos.toByteArray());
pBuffer.writeBytes(is, baos.toByteArray().length);
- } catch (IOException ex) {
+ } catch (IOException ignore) {
}
}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java
index 74aa4b8463..d5f215053f 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java
@@ -87,56 +87,57 @@ public interface ITeslaConnectable extends ITeslaConnectableSimple {
}
public static long powerTeslaNodeMap(ITeslaConnectable origin) {
- //Teslas can only send OR receive
- if (origin.isTeslaReadyToReceive()) {
- return 0L;//TODO Negative values to indicate charging?
- }
long remainingAmperes = origin.getTeslaOutputCurrent();
- while (remainingAmperes > 0) {
- long startingAmperes = remainingAmperes;
- for (Map.Entry<Integer, ITeslaConnectableSimple> Rx : origin.getTeslaNodeMap().entries()) {
- if (origin.getTeslaStoredEnergy() < (origin.isOverdriveEnabled() ? origin.getTeslaOutputVoltage() * 2 : origin.getTeslaOutputVoltage())) {
- //Return and end the tick if we're out of energy to send
- return origin.getTeslaOutputCurrent() - remainingAmperes;
- }
+ boolean canSendPower = !origin.isTeslaReadyToReceive() && remainingAmperes > 0;
+ if (canSendPower) {
+ for (Map.Entry<Integer, ITeslaConnectableSimple> Rx : origin.getTeslaNodeMap().entries()) {
+ //Do we still have power left to send kind of check
+ if (origin.getTeslaStoredEnergy() < (origin.isOverdriveEnabled() ? origin.getTeslaOutputVoltage() *
+ 2 : origin.getTeslaOutputVoltage())) break;
+ //Explicit words for the important fields
ITeslaConnectableSimple target = Rx.getValue();
-
- //Continue if the target can't receive
- if(!target.isTeslaReadyToReceive()) continue;
-
int distance = Rx.getKey();
+ //Can our target receive energy?
+ if(!target.isTeslaReadyToReceive()) continue;
//Calculate the voltage output
long outputVoltageInjectable;
long outputVoltageConsumption;
-
if (origin.isOverdriveEnabled()) {
outputVoltageInjectable = origin.getTeslaOutputVoltage();
- outputVoltageConsumption = origin.getTeslaOutputVoltage() + (distance * origin.getTeslaEnergyLossPerBlock()) +
- (long) Math.round(origin.getTeslaOutputVoltage() * origin.getTeslaOverdriveLossCoefficient());
+ outputVoltageConsumption = origin.getTeslaOutputVoltage() +
+ (distance * origin.getTeslaEnergyLossPerBlock()) +
+ (long) Math.round(origin.getTeslaOutputVoltage() *
+ origin.getTeslaOverdriveLossCoefficient());
} else {
- outputVoltageInjectable = origin.getTeslaOutputVoltage() - (distance * origin.getTeslaEnergyLossPerBlock());
+ outputVoltageInjectable = origin.getTeslaOutputVoltage() - (distance *
+ origin.getTeslaEnergyLossPerBlock());
outputVoltageConsumption = origin.getTeslaOutputVoltage();
}
- //Skip the target if the cost is too high
- if (origin.getTeslaStoredEnergy() < outputVoltageConsumption) {
- continue;
+ //Break out of the loop if the cost is too high
+ //Since the next target will have an even higher cost, just quit now.
+ if (origin.getTeslaStoredEnergy() < outputVoltageConsumption) break;
+
+ //Now shove in as many packets as will fit~
+ while(canSendPower){
+ if (target.teslaInjectEnergy(outputVoltageInjectable)) {
+ origin.teslaDrainEnergy(outputVoltageConsumption);
+ origin.getSparkList().add(new ThaumSpark(origin.getTeslaPosition(),
+ target.getTeslaPosition(), origin.getTeslaDimension()));
+ remainingAmperes--;
+ //Update the can send power flag each time we send power
+ canSendPower = (origin.getTeslaStoredEnergy() < outputVoltageConsumption ||
+ remainingAmperes == 0);
+ } else {
+ //Breaks out when I can't send anymore power
+ break;
+ }
}
- if (target.teslaInjectEnergy(outputVoltageInjectable)) {
- origin.teslaDrainEnergy(outputVoltageConsumption);
- origin.getSparkList().add(new ThaumSpark(origin.getTeslaPosition(), target.getTeslaPosition(), origin.getTeslaDimension()));
- remainingAmperes--;
- }
- if (remainingAmperes == 0) {
- return origin.getTeslaOutputCurrent();
- }
- }
- //End the tick after one iteration with no transmissions
- if (remainingAmperes == startingAmperes) {
- return origin.getTeslaOutputCurrent() - remainingAmperes;
+ //Break out if we can't send power anymore
+ if (canSendPower)break;
}
}
return origin.getTeslaOutputCurrent() - remainingAmperes;