aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorbasdxz <tudurap.com@gmail.com>2020-07-18 09:38:35 +0100
committerbasdxz <tudurap.com@gmail.com>2020-07-18 09:38:35 +0100
commitd895a4f85ae7edad8884c5ded8c29ff47bbb8de9 (patch)
tree2100bda47070e4edb907de9523c6caccb2767ef6 /src/main/java/com
parent792d54ffa2fde437a3af9925c7c41399821b2d83 (diff)
downloadGT5-Unofficial-d895a4f85ae7edad8884c5ded8c29ff47bbb8de9.tar.gz
GT5-Unofficial-d895a4f85ae7edad8884c5ded8c29ff47bbb8de9.tar.bz2
GT5-Unofficial-d895a4f85ae7edad8884c5ded8c29ff47bbb8de9.zip
Lots of Tesla Tower work
Reworked power loss Fixed Tesla Tower exploding when already powered off Added and reworded some comments Added plasma consumption values to config
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/technus/tectech/loader/TecTechConfig.java65
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java119
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java64
3 files changed, 119 insertions, 129 deletions
diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java
index 2cc52e8513..030be65f3b 100644
--- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java
+++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java
@@ -21,14 +21,17 @@ public class TecTechConfig extends ConfigManager {
public boolean DISABLE_BLOCK_HARDNESS_NERF;
public float TURRET_DAMAGE_FACTOR;
public float TURRET_EXPLOSION_FACTOR;
- public float TESLA_MULTI_MIN_EFFICIENCY;
- public float TESLA_MULTI_MAX_EFFICIENCY;
- public float TESLA_MULTI_OVERDRIVE_LOSS;
- public int TESLA_MULTI_SCAN_RANGE;
- public boolean TESLA_MULTI_MOLTEN_OUTPUT;
- public float TESLA_SINGLE_MIN_EFFICIENCY;
- public float TESLA_SINGLE_MAX_EFFICIENCY;
- public float TESLA_SINGLE_OVERDRIVE_LOSS;
+ public int TESLA_MULTI_HELIUM_PLASMA_PER_SECOND;
+ public int TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND;
+ public int TESLA_MULTI_RADON_PLASMA_PER_SECOND;
+ public int TESLA_MULTI_LOSS_PER_BLOCK_T0;
+ public int TESLA_MULTI_LOSS_PER_BLOCK_T1;
+ public int TESLA_MULTI_LOSS_PER_BLOCK_T2;
+ public float TESLA_MULTI_OVERDRIVE_LOSS_FACTOR;
+ public int TESLA_MULTI_SCAN_RANGE;//TODO delete
+ public boolean TESLA_MULTI_GAS_OUTPUT;
+ public int TESLA_SINGLE_LOSS_PER_BLOCK;
+ public float TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;
/**
* This loading phases do not correspond to mod loading phases!
@@ -44,17 +47,19 @@ public class TecTechConfig extends ConfigManager {
DISABLE_MATERIAL_LOADING_FFS = false;
TURRET_DAMAGE_FACTOR = 10;
TURRET_EXPLOSION_FACTOR = 1;
- TESLA_MULTI_MIN_EFFICIENCY = 0.955F;
- TESLA_MULTI_MAX_EFFICIENCY = 0.98F;
- TESLA_MULTI_OVERDRIVE_LOSS = 0.005F;
+ TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = 100;
+ TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = 50;
+ TESLA_MULTI_RADON_PLASMA_PER_SECOND = 50;
+ TESLA_MULTI_LOSS_PER_BLOCK_T0 = 1;
+ TESLA_MULTI_LOSS_PER_BLOCK_T1 = 1;
+ TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1;
+ TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = 0.25F;
TESLA_MULTI_SCAN_RANGE = 40;
- TESLA_MULTI_MOLTEN_OUTPUT = false;
- TESLA_SINGLE_MIN_EFFICIENCY = 0.91F;
- TESLA_SINGLE_MAX_EFFICIENCY = 0.95F;
- TESLA_SINGLE_OVERDRIVE_LOSS = 0.010F;
+ TESLA_MULTI_GAS_OUTPUT = false;
+ TESLA_SINGLE_LOSS_PER_BLOCK = 1;
+ TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = 0.25F;
}
-
/**
* This loading phases do not correspond to mod loading phases!
*/
@@ -80,22 +85,18 @@ public class TecTechConfig extends ConfigManager {
"Set to true to disable the block hardness nerf");
DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "Debug", DISABLE_MATERIAL_LOADING_FFS,
"Set to true to disable gregtech material processing");
- TESLA_MULTI_MIN_EFFICIENCY = _mainConfig.getFloat("TeslaMultiMinEfficency", "Features", TESLA_MULTI_MIN_EFFICIENCY, 0, 1,
- "Worst possible power loss per block for the multi block tesla");
- TESLA_MULTI_MAX_EFFICIENCY = _mainConfig.getFloat("TeslaMultiMaxEfficency", "Features", TESLA_MULTI_MAX_EFFICIENCY, 0, 1,
- "Best possible power loss per block for the multi block tesla");
- TESLA_MULTI_OVERDRIVE_LOSS = _mainConfig.getFloat("TeslaMultiOverdriveLoss", "Features", TESLA_MULTI_OVERDRIVE_LOSS, 0, 1,
- "Additional losses for overdrive use on the multi block tesla");
- TESLA_MULTI_SCAN_RANGE = _mainConfig.getInt("TeslaMultiScanRange", "Features", TESLA_MULTI_SCAN_RANGE, 4, 256,
- "Determines the scan range constant for multi block tesla");
- TESLA_MULTI_MOLTEN_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Features", TESLA_MULTI_MOLTEN_OUTPUT,
- "Set to true to get molten outputs when boosting the multi block tesla with plasmas");
- TESLA_SINGLE_MIN_EFFICIENCY = _mainConfig.getFloat("TeslaSingleMinEfficency", "Features", TESLA_SINGLE_MIN_EFFICIENCY, 0, 1,
- "Worst possible power loss per block for the single block tesla");
- TESLA_SINGLE_MAX_EFFICIENCY = _mainConfig.getFloat("TeslaSingleMaxEfficency", "Features", TESLA_SINGLE_MAX_EFFICIENCY, 0, 1,
- "Best possible power loss per block for the single block tesla");
- TESLA_SINGLE_OVERDRIVE_LOSS = _mainConfig.getFloat("TeslaSingleOverdriveLoss", "Features", TESLA_SINGLE_OVERDRIVE_LOSS, 0, 1,
- "Additional losses for overdrive use on the single block tesla");
+
+ TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiHeliumPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_HELIUM_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower helium plasma consumed each second the tesla tower is active");
+ TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiNitrogenPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower nitrogen plasma consumed each second the tesla tower is active");
+ TESLA_MULTI_RADON_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiRadonPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_RADON_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower radon plasma consumed each second the tesla tower is active");
+ TESLA_MULTI_LOSS_PER_BLOCK_T0 = _mainConfig.getInt("TeslaMultiLossPerBlockT0", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T0, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using no plasmas");
+ TESLA_MULTI_LOSS_PER_BLOCK_T1 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T1, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using helium or nitrogen plasma");
+ TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T2, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using radon plasma");
+ TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaMultiOverdriveLossFactor", "Balance Tweaks", TESLA_MULTI_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Tower power loss per amp as a factor of the tier voltage");
+ TESLA_MULTI_SCAN_RANGE = _mainConfig.getInt("TeslaMultiScanRange", "Balance Tweaks", TESLA_MULTI_SCAN_RANGE, 4, 256, "The horizontal radius scanned by the Tesla Tower");
+ TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Balance Tweaks", TESLA_MULTI_GAS_OUTPUT, "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio");
+ TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt("TeslaSingleLossPerBlock", "Balance Tweaks", TESLA_SINGLE_LOSS_PER_BLOCK, 0, Integer.MAX_VALUE, "Tesla Transceiver power transmission loss per block per amp");
+ TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaSingleOverdriveLossFactor", "Balance Tweaks", TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage");
}
/**
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java
index 58ea6d322b..09f6d597ad 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java
@@ -55,42 +55,44 @@ import static net.minecraft.util.StatCollector.translateToLocal;
public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable {
//region variables
- private final static HashSet<ThaumSpark> sparkList = new HashSet<>();
-
+ private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_HELIUM_PLASMA_PER_SECOND;//Default is 100
+ private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND;//Default is 50
+ private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_RADON_PLASMA_PER_SECOND;//Default is 50
+ //Default is {1, 1, 1}
+ private static final int[] plasmaTierLoss = new int[]{TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0,
+ TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2};
+ private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F;
+ private static final int scanRangeXZ = TecTech.configTecTech.TESLA_MULTI_SCAN_RANGE;//Default is 40
+ private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; //Default is false
+
+ //Face icons
private static Textures.BlockIcons.CustomIcon ScreenOFF;
private static Textures.BlockIcons.CustomIcon ScreenON;
- //TODO Make the setting abstractions static, if they aren't changed at tick time
- private int mTier = 0; //Determines max voltage and efficiency (MV to LuV)
- private int maxTier = 7; //Max tier for efficiency calcuation
- private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon
- private boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_MOLTEN_OUTPUT; //Default is false
- private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs for one second
- private float energyEfficiency = 1;
- private float overdriveEfficiency = 1;
- private float minEfficiency = TecTech.configTecTech.TESLA_MULTI_MIN_EFFICIENCY;//Default is 0.955F
- private float maxEfficiency = TecTech.configTecTech.TESLA_MULTI_MAX_EFFICIENCY;//Default is 0.98F
- private float overdriveEfficiencyExtra = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS;//Default is 0.005F
+ private int mTier = 0; //Determines max voltage (LV to ZPM)
+ private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon (Does not match actual plasma tiers)
+
+ private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs, so the tesla takes a second to 'cool' any plasma it would output as a gas
- private Map<IGregTechTileEntity, Integer> eTeslaMap = new HashMap<>(); //Used to store targets for power transmission
- private final ArrayList<GT_MetaTileEntity_Hatch_Capacitor> eCapacitorHatches = new ArrayList<>(); //Used to determine count and tier of capacitors present
+ private final HashSet<ThaumSpark> sparkList = new HashSet<>(); //Thaumcraft lighting coordinate pairs, so we can send them in bursts and save on lag
+ private final Map<IGregTechTileEntity, Integer> eTeslaMap = new HashMap<>(); //Targets for power transmission //TODO Make this fill more efficently and globally
+ private final ArrayList<GT_MetaTileEntity_Hatch_Capacitor> eCapacitorHatches = new ArrayList<>(); //Capacitor hatches which determine the max voltage tier and count of amps
- private int scanTime = 0; //Scan timer used for tesla search intervals
- private int scanRangeXZ = TecTech.configTecTech.TESLA_MULTI_SCAN_RANGE;//Default is 40
+ private int scanTime = 0; //Scan timer used for tesla search intervals //TODO Replace with something that fetches from a global map
private long energyCapacity = 0; //Total energy storage limited by capacitors
private long outputVoltageMax = 0; //Tesla voltage output limited by capacitors
private int vTier = -1; //Tesla voltage tier limited by capacitors
private long outputCurrentMax = 0; //Tesla current output limited by capacitors
- //Prevents unnecessary offset calculation
+ //Prevents unnecessary offset calculation, saving on lag
private byte oldRotation = -1;
private byte oldOrientation = -1;
//Coordinate Arrays
private final Vec3Impl[] scanPosOffsets = new Vec3Impl[10];
- private Vec3Impl posZap = Vec3Impl.NULL_VECTOR;//Power Transfer Origin
- public Vec3Impl posTop = Vec3Impl.NULL_VECTOR;//Lightning Origin
+ private Vec3Impl posZap = Vec3Impl.NULL_VECTOR;//Location of the bottom middle of the tower, used as the power transfer origin
+ public Vec3Impl posTop = Vec3Impl.NULL_VECTOR;//Location of the center of the sphere on top of the tower, used as theThaumcraft lightning origin
//endregion
//region structure
@@ -252,24 +254,22 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
super(aName);
}
- private long getEnergyEfficiency(long voltage, int distance, boolean overDriveToggle) {
- //Helium and Nitrogen Plasmas will half the effective distance
- //Radon will half it again
- int effectiveDistance = distance;
- switch (plasmaTier) {
- case 2:
- effectiveDistance = distance / 4;
- break;
- case 1:
- effectiveDistance = distance / 2;
- break;
- }
+ private int getPerBlockLoss(){
+ return plasmaTierLoss[plasmaTier];
+ }
+
+ private long[] getOutputVoltage(long outputVoltage, int distance, boolean overDriveToggle) {
+ long outputVoltageInjectable;
+ long outputVoltageConsumption;
if (overDriveToggle) {
- return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, effectiveDistance)));
+ outputVoltageInjectable = outputVoltage;
+ outputVoltageConsumption = outputVoltage + (distance * getPerBlockLoss()) + (long) Math.round(overDriveLoss * outputVoltage);
} else {
- return (long) (voltage * Math.pow(energyEfficiency, effectiveDistance));
+ outputVoltageInjectable = outputVoltage - (distance * getPerBlockLoss());
+ outputVoltageConsumption = outputVoltage;
}
+ return new long[]{outputVoltageInjectable, outputVoltageConsumption};
}
private float getRangeMulti(int mTier, int vTier) {
@@ -345,24 +345,24 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
for (GT_MetaTileEntity_Hatch_Input fluidHatch : mInputHatches) {
if (fluidHatch.mFluid != null) {
- if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) && fluidHatch.mFluid.amount >= 100) {
- fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 100;
+ if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) && fluidHatch.mFluid.amount >= heliumUse) {
+ fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - heliumUse;
if (doFluidOutput) {
- mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(100)};
+ mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(heliumUse)};
}
plasmaTier = 1;
return;
- } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) {
- fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50;
+ } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && fluidHatch.mFluid.amount >= nitrogenUse) {
+ fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - nitrogenUse;
if (doFluidOutput) {
- mOutputFluidsQueue = new FluidStack[]{Materials.Nitrogen.getGas(50)};
+ mOutputFluidsQueue = new FluidStack[]{Materials.Nitrogen.getGas(nitrogenUse)};
}
plasmaTier = 1;
return;
- } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) {
- fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50;
+ } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) && fluidHatch.mFluid.amount >= radonUse) {
+ fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - radonUse;
if (doFluidOutput) {
- mOutputFluidsQueue = new FluidStack[]{Materials.Radon.getGas(50)};
+ mOutputFluidsQueue = new FluidStack[]{Materials.Radon.getGas(radonUse)};
}
plasmaTier = 2;
return;
@@ -390,9 +390,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 1));
mTier = iGregTechTileEntity.getMetaIDOffset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2());
- if (mTier == 9){
- mTier = 6;
- }
+ if (mTier == 9){mTier = 6;}//Hacky remap because the ZPM coils were added later
if (structureCheck_EM(shape, blockType, blockMetas[mTier], addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 3, 16, 0) && eCapacitorHatches.size() > 0) {
for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) {
@@ -461,11 +459,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
}
}
- //Calculate Efficiency values
- energyEfficiency = map(mTier + 1, 1, maxTier, minEfficiency, maxEfficiency);
- //OD Eff calc
- overdriveEfficiency = energyEfficiency - overdriveEfficiencyExtra;
-
energyCapacity = 0;
outputCurrentMax = 0;
@@ -608,6 +601,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
cap.getBaseMetaTileEntity().setActive(false);
}
+ ePowerPass = false;
setEUVar(0);
energyStoredDisplay.set(0);
energyFractionDisplay.set(0);
@@ -618,12 +612,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
IGregTechTileEntity mte = getBaseMetaTileEntity();
//Hysteresis based ePowerPass setting
- long energyMax = maxEUStore() / 2;
long energyStored = getEUVar();
+ float energyFrac = (float) energyStored / energyCapacity;
- float energyFrac = (float) energyStored / energyMax;
-
- energyCapacityDisplay.set(energyMax);
+ energyCapacityDisplay.set(energyCapacity);
energyStoredDisplay.set(energyStored);
energyFractionDisplay.set(energyFrac);
@@ -793,15 +785,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
IGregTechTileEntity node = Rx.getKey();
IMetaTileEntity nodeInside = node.getMetaTileEntity();
- long outputVoltageInjectable;
- long outputVoltageConsumption;
- if (overdriveToggle) {
- outputVoltageInjectable = outputVoltage;
- outputVoltageConsumption = getEnergyEfficiency(outputVoltage, Rx.getValue(), true);
- } else {
- outputVoltageInjectable = getEnergyEfficiency(outputVoltage, Rx.getValue(), false);
- outputVoltageConsumption = outputVoltage;
- }
+ long[] outputVoltageNow = getOutputVoltage(outputVoltage, Rx.getValue(), overdriveToggle);
+ long outputVoltageInjectable = outputVoltageNow[0];
+ long outputVoltageConsumption = outputVoltageNow[1];
if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) {
GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside;
@@ -865,6 +851,11 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock
return energyCapacity * 2;
}
+ @Override
+ public long getEUVar() {
+ return getBaseMetaTileEntity().isActive() ? super.getEUVar() : 0;
+ }
+
private boolean addCapacitorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) {
return false;
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java
index ed36dec7cb..0f73750d48 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java
@@ -36,37 +36,32 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted;
public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer {
+ private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1
+ private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F
+
+ public Map<IGregTechTileEntity, Integer> eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois!
private final static HashSet<ThaumSpark> sparkList = new HashSet<>();
private byte sparkCount = 0;
- private int maxTier = 4; //Max tier of transceiver
- private int minTier = 0; //Min tier of transceiver
-
- public Map<IGregTechTileEntity, Integer> eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois!
+ private final static int maxTier = 4; //Max tier of transceiver
+ private final static int minTier = 0; //Min tier of transceiver
- private int transferRadiusMax = 20;
- private int transferRadiusMin = 4;
- private int transferRadiusLimitTop = (int) map(mTier + 1, minTier + 1, maxTier + 1, transferRadiusMin, transferRadiusMax);
- private int transferRadiusLimitBottom = 1; //Minimum user configurable
+ private final static int transferRadiusMax = 20;
+ private final static int transferRadiusMin = 4;
+ private final int transferRadiusLimitTop = (int) map(mTier + 1, minTier + 1, maxTier + 1, transferRadiusMin, transferRadiusMax);
+ private final static int transferRadiusLimitBottom = 1; //Minimum user configurable
private int transferRadius = transferRadiusLimitTop; //Default transferRadius setting
- private int transferRadiusTower = 0; //Radius for transceiver to tower transfers
- private int transferRadiusCover = 0; //Radius for transceiver to cover transfers
public boolean powerPassToggle = false; //Power Pass for public viewing
- private int histSteps = 20; //Hysteresis Resolution
+ private final static int histSteps = 20; //Hysteresis Resolution
private int histSettingLow = 3; //Hysteresis Low Limit
private int histSettingHigh = 15; //Hysteresis High Limit
- private int histLowLimit = 1; //How low can you configure it?
- private int histHighLimit = 19; //How high can you configure it?
+ private final static int histLowLimit = 1; //How low can you configure it?
+ private final static int histHighLimit = 19; //How high can you configure it?
private float histLow = (float) histSettingLow / histSteps; //Power pass is disabled if power is under this fraction
private float histHigh = (float) histSettingHigh / histSteps; //Power pass is enabled if power is over this fraction
- private long outputVoltage = V[mTier];
- private float minEfficiency = TecTech.configTecTech.TESLA_SINGLE_MIN_EFFICIENCY;//Default is 0.91F
- private float maxEfficiency = TecTech.configTecTech.TESLA_SINGLE_MAX_EFFICIENCY;//Default is 0.95F
- private float overdriveEfficiencyExtra = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS;//Default is 0.010F
- private float energyEfficiency = map(mTier + 1, minTier + 1, maxTier + 1, minEfficiency, maxEfficiency);
- private float overdriveEfficiency = energyEfficiency - overdriveEfficiencyExtra;
+ private final long outputVoltage = V[mTier];
private boolean overdriveToggle = false;
private String clientLocale = "en_US";
@@ -220,12 +215,18 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB
sparkList.add(new ThaumSpark(x, y, z, xR, yR, zR, wID));
}
- private long getEnergyEfficiency(long voltage, int distance, boolean overDriveToggle) {
+ private long[] getOutputVoltage(long outputVoltage, int distance, boolean overDriveToggle) {
+ long outputVoltageInjectable;
+ long outputVoltageConsumption;
+
if (overDriveToggle) {
- return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, distance)));
+ outputVoltageInjectable = outputVoltage;
+ outputVoltageConsumption = outputVoltage + (distance * perBlockLoss) + (long) Math.round(overDriveLoss * outputVoltage);
} else {
- return (long) (voltage * Math.pow(energyEfficiency, distance));
+ outputVoltageInjectable = outputVoltage - (distance * perBlockLoss);
+ outputVoltageConsumption = outputVoltage;
}
+ return new long[]{outputVoltageInjectable, outputVoltageConsumption};
}
@Override
@@ -251,8 +252,10 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB
if (powerPassToggle) {
float rangeFrac = (float) ((-0.5 * Math.pow(energyFrac, 2)) + (1.5 * energyFrac));
long outputCurrent = mBatteryCount;
- transferRadiusTower = (int) (transferRadius * rangeFrac);
- transferRadiusCover = (int) (transferRadiusTower / 1.25);
+ //Radius for transceiver to tower transfers
+ int transferRadiusTower = (int) (transferRadius * rangeFrac);
+ //Radius for transceiver to cover transfers
+ int transferRadiusCover = (int) (transferRadiusTower / 1.25);
//Clean the eTeslaMap
for (Map.Entry<IGregTechTileEntity, Integer> Rx : eTeslaMap.entrySet()) {
@@ -282,15 +285,10 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB
IGregTechTileEntity node = Rx.getKey();
IMetaTileEntity nodeInside = node.getMetaTileEntity();
- long outputVoltageInjectable;
- long outputVoltageConsumption;
- if (overdriveToggle) {
- outputVoltageInjectable = outputVoltage;
- outputVoltageConsumption = getEnergyEfficiency(outputVoltage, Rx.getValue(), true);
- } else {
- outputVoltageInjectable = getEnergyEfficiency(outputVoltage, Rx.getValue(), false);
- outputVoltageConsumption = outputVoltage;
- }
+ long[] outputVoltageNow = getOutputVoltage(outputVoltage, Rx.getValue(), overdriveToggle);
+ long outputVoltageInjectable = outputVoltageNow[0];
+ long outputVoltageConsumption = outputVoltageNow[1];
+
if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) {
GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside;
if (!nodeTesla.ePowerPass) {