parent
3b0a047570
commit
6c73c1a070
15 changed files with 96 additions and 100 deletions
|
@ -28,7 +28,7 @@ public interface ILaserTarget {
|
||||||
*
|
*
|
||||||
* @param energy
|
* @param energy
|
||||||
*/
|
*/
|
||||||
void receiveLaserEnergy(float energy);
|
void receiveLaserEnergy(double energy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the Tile Entity object is no longer a valid target. For
|
* Return true if the Tile Entity object is no longer a valid target. For
|
||||||
|
|
|
@ -65,7 +65,7 @@ public final class PowerHandler {
|
||||||
|
|
||||||
public static final float DEFAULT_POWERLOSS = 1F;
|
public static final float DEFAULT_POWERLOSS = 1F;
|
||||||
public static final float MIN_POWERLOSS = 0.01F;
|
public static final float MIN_POWERLOSS = 0.01F;
|
||||||
private final float powerLoss;
|
private final double powerLoss;
|
||||||
|
|
||||||
public PerditionCalculator() {
|
public PerditionCalculator() {
|
||||||
powerLoss = DEFAULT_POWERLOSS;
|
powerLoss = DEFAULT_POWERLOSS;
|
||||||
|
@ -76,7 +76,7 @@ public final class PowerHandler {
|
||||||
*
|
*
|
||||||
* @param powerLoss power loss per tick
|
* @param powerLoss power loss per tick
|
||||||
*/
|
*/
|
||||||
public PerditionCalculator(float powerLoss) {
|
public PerditionCalculator(double powerLoss) {
|
||||||
if (powerLoss < MIN_POWERLOSS) {
|
if (powerLoss < MIN_POWERLOSS) {
|
||||||
powerLoss = MIN_POWERLOSS;
|
powerLoss = MIN_POWERLOSS;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public final class PowerHandler {
|
||||||
* @param ticksPassed ticks since the last time this function was called
|
* @param ticksPassed ticks since the last time this function was called
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
|
public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) {
|
||||||
// float prev = current;
|
// float prev = current;
|
||||||
current -= powerLoss * ticksPassed;
|
current -= powerLoss * ticksPassed;
|
||||||
if (current < 0) {
|
if (current < 0) {
|
||||||
|
@ -110,16 +110,16 @@ public final class PowerHandler {
|
||||||
*
|
*
|
||||||
* @return percent of input to tax
|
* @return percent of input to tax
|
||||||
*/
|
*/
|
||||||
public float getTaxPercent() {
|
public double getTaxPercent() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
|
public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
|
||||||
private float minEnergyReceived;
|
private double minEnergyReceived;
|
||||||
private float maxEnergyReceived;
|
private double maxEnergyReceived;
|
||||||
private float maxEnergyStored;
|
private double maxEnergyStored;
|
||||||
private float activationEnergy;
|
private double activationEnergy;
|
||||||
private float energyStored = 0;
|
private double energyStored = 0;
|
||||||
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
|
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
|
||||||
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
|
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
|
||||||
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
|
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
|
||||||
|
@ -145,23 +145,23 @@ public final class PowerHandler {
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMinEnergyReceived() {
|
public double getMinEnergyReceived() {
|
||||||
return minEnergyReceived;
|
return minEnergyReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxEnergyReceived() {
|
public double getMaxEnergyReceived() {
|
||||||
return maxEnergyReceived;
|
return maxEnergyReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxEnergyStored() {
|
public double getMaxEnergyStored() {
|
||||||
return maxEnergyStored;
|
return maxEnergyStored;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getActivationEnergy() {
|
public double getActivationEnergy() {
|
||||||
return activationEnergy;
|
return activationEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getEnergyStored() {
|
public double getEnergyStored() {
|
||||||
return energyStored;
|
return energyStored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public final class PowerHandler {
|
||||||
* store. Values tend to range between 100 and 5000. With 1000 and 1500
|
* store. Values tend to range between 100 and 5000. With 1000 and 1500
|
||||||
* being common.
|
* being common.
|
||||||
*/
|
*/
|
||||||
public void configure(float minEnergyReceived, float maxEnergyReceived, float activationEnergy, float maxStoredEnergy) {
|
public void configure(double minEnergyReceived, double maxEnergyReceived, double activationEnergy, double maxStoredEnergy) {
|
||||||
if (minEnergyReceived > maxEnergyReceived) {
|
if (minEnergyReceived > maxEnergyReceived) {
|
||||||
maxEnergyReceived = minEnergyReceived;
|
maxEnergyReceived = minEnergyReceived;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ public final class PowerHandler {
|
||||||
|
|
||||||
private void applyPerdition() {
|
private void applyPerdition() {
|
||||||
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
|
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
|
||||||
float newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
double newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||||
if (newEnergy == 0 || newEnergy < energyStored)
|
if (newEnergy == 0 || newEnergy < energyStored)
|
||||||
energyStored = newEnergy;
|
energyStored = newEnergy;
|
||||||
else
|
else
|
||||||
|
@ -296,10 +296,10 @@ public final class PowerHandler {
|
||||||
* @param doUse
|
* @param doUse
|
||||||
* @return amount used
|
* @return amount used
|
||||||
*/
|
*/
|
||||||
public float useEnergy(float min, float max, boolean doUse) {
|
public double useEnergy(double min, double max, boolean doUse) {
|
||||||
applyPerdition();
|
applyPerdition();
|
||||||
|
|
||||||
float result = 0;
|
double result = 0;
|
||||||
|
|
||||||
if (energyStored >= min) {
|
if (energyStored >= min) {
|
||||||
if (energyStored <= max) {
|
if (energyStored <= max) {
|
||||||
|
@ -329,7 +329,7 @@ public final class PowerHandler {
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound data, String tag) {
|
public void readFromNBT(NBTTagCompound data, String tag) {
|
||||||
NBTTagCompound nbt = data.getCompoundTag(tag);
|
NBTTagCompound nbt = data.getCompoundTag(tag);
|
||||||
energyStored = nbt.getFloat("storedEnergy");
|
energyStored = nbt.getDouble("energyStored");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound data) {
|
public void writeToNBT(NBTTagCompound data) {
|
||||||
|
@ -338,7 +338,7 @@ public final class PowerHandler {
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound data, String tag) {
|
public void writeToNBT(NBTTagCompound data, String tag) {
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
nbt.setFloat("storedEnergy", energyStored);
|
nbt.setDouble("energyStored", energyStored);
|
||||||
data.setCompoundTag(tag, nbt);
|
data.setCompoundTag(tag, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,23 +347,23 @@ public final class PowerHandler {
|
||||||
private PowerReceiver() {
|
private PowerReceiver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMinEnergyReceived() {
|
public double getMinEnergyReceived() {
|
||||||
return minEnergyReceived;
|
return minEnergyReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxEnergyReceived() {
|
public double getMaxEnergyReceived() {
|
||||||
return maxEnergyReceived;
|
return maxEnergyReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxEnergyStored() {
|
public double getMaxEnergyStored() {
|
||||||
return maxEnergyStored;
|
return maxEnergyStored;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getActivationEnergy() {
|
public double getActivationEnergy() {
|
||||||
return activationEnergy;
|
return activationEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getEnergyStored() {
|
public double getEnergyStored() {
|
||||||
return energyStored;
|
return energyStored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ public final class PowerHandler {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public float powerRequest() {
|
public double powerRequest() {
|
||||||
update();
|
update();
|
||||||
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
|
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
|
||||||
}
|
}
|
||||||
|
@ -394,8 +394,8 @@ public final class PowerHandler {
|
||||||
* @param from
|
* @param from
|
||||||
* @return the amount of power used
|
* @return the amount of power used
|
||||||
*/
|
*/
|
||||||
public float receiveEnergy(Type source, final float quantity, ForgeDirection from) {
|
public double receiveEnergy(Type source, final double quantity, ForgeDirection from) {
|
||||||
float used = quantity;
|
double used = quantity;
|
||||||
if (source == Type.ENGINE) {
|
if (source == Type.ENGINE) {
|
||||||
if (used < minEnergyReceived) {
|
if (used < minEnergyReceived) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -426,7 +426,7 @@ public final class PowerHandler {
|
||||||
*
|
*
|
||||||
* @return the amount the power changed by
|
* @return the amount the power changed by
|
||||||
*/
|
*/
|
||||||
public float addEnergy(float quantity) {
|
public double addEnergy(double quantity) {
|
||||||
energyStored += quantity;
|
energyStored += quantity;
|
||||||
|
|
||||||
if (energyStored > maxEnergyStored) {
|
if (energyStored > maxEnergyStored) {
|
||||||
|
@ -442,7 +442,7 @@ public final class PowerHandler {
|
||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(float quantity) {
|
public void setEnergy(double quantity) {
|
||||||
this.energyStored = quantity;
|
this.energyStored = quantity;
|
||||||
validateEnergy();
|
validateEnergy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ public class EntityEnergyLaser extends EntityLaser {
|
||||||
|
|
||||||
public static final short POWER_AVERAGING = 100;
|
public static final short POWER_AVERAGING = 100;
|
||||||
public int displayStage = 0;
|
public int displayStage = 0;
|
||||||
private final float power[] = new float[POWER_AVERAGING];
|
private final double power[] = new double[POWER_AVERAGING];
|
||||||
private int powerIndex = 0;
|
private int powerIndex = 0;
|
||||||
private float powerAverage = 0;
|
private double powerAverage = 0;
|
||||||
|
|
||||||
public EntityEnergyLaser(World world) {
|
public EntityEnergyLaser(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
|
@ -28,7 +28,7 @@ public class EntityEnergyLaser extends EntityLaser {
|
||||||
super(world, head, tail);
|
super(world, head, tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushPower(float received) {
|
public void pushPower(double received) {
|
||||||
|
|
||||||
powerAverage -= power[powerIndex];
|
powerAverage -= power[powerIndex];
|
||||||
powerAverage += received;
|
powerAverage += received;
|
||||||
|
@ -40,7 +40,7 @@ public class EntityEnergyLaser extends EntityLaser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPowerAverage() {
|
public double getPowerAverage() {
|
||||||
return powerAverage / POWER_AVERAGING;
|
return powerAverage / POWER_AVERAGING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,7 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.ICrafting;
|
import net.minecraft.inventory.ICrafting;
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagFloat;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
@ -52,12 +50,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
protected int progressPart = 0;
|
protected int progressPart = 0;
|
||||||
protected boolean lastPower = false;
|
protected boolean lastPower = false;
|
||||||
protected PowerHandler powerHandler;
|
protected PowerHandler powerHandler;
|
||||||
public float currentOutput = 0;
|
public double currentOutput = 0;
|
||||||
public boolean isRedstonePowered = false;
|
public boolean isRedstonePowered = false;
|
||||||
private boolean checkOrienation = false;
|
private boolean checkOrienation = false;
|
||||||
private TileBuffer[] tileCache;
|
private TileBuffer[] tileCache;
|
||||||
public float progress;
|
public float progress;
|
||||||
public float energy;
|
public double energy;
|
||||||
public float heat = MIN_HEAT;
|
public float heat = MIN_HEAT;
|
||||||
//
|
//
|
||||||
public @TileNetworkData
|
public @TileNetworkData
|
||||||
|
@ -86,7 +84,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getEnergyLevel() {
|
public double getEnergyLevel() {
|
||||||
return energy / getMaxEnergy();
|
return energy / getMaxEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +118,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHeatLevel() {
|
public void updateHeatLevel() {
|
||||||
heat = ((MAX_HEAT - MIN_HEAT) * getEnergyLevel()) + MIN_HEAT;
|
heat = (float) ((MAX_HEAT - MIN_HEAT) * getEnergyLevel()) + MIN_HEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHeatLevel() {
|
public float getHeatLevel() {
|
||||||
|
@ -216,7 +214,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
burn();
|
burn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getPowerToExtract() {
|
private double getPowerToExtract() {
|
||||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||||
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
|
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
|
||||||
return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); // Comment out for constant power
|
return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); // Comment out for constant power
|
||||||
|
@ -228,9 +226,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
if (isPoweredTile(tile, orientation)) {
|
if (isPoweredTile(tile, orientation)) {
|
||||||
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
|
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
|
||||||
|
|
||||||
float extracted = getPowerToExtract();
|
double extracted = getPowerToExtract();
|
||||||
if (extracted > 0) {
|
if (extracted > 0) {
|
||||||
float needed = receptor.receiveEnergy(PowerHandler.Type.ENGINE, extracted, orientation.getOpposite());
|
double needed = receptor.receiveEnergy(PowerHandler.Type.ENGINE, extracted, orientation.getOpposite());
|
||||||
extractEnergy(receptor.getMinEnergyReceived(), needed, true); // Comment out for constant power
|
extractEnergy(receptor.getMinEnergyReceived(), needed, true); // Comment out for constant power
|
||||||
// currentOutput = extractEnergy(0, needed, true); // Uncomment for constant power
|
// currentOutput = extractEnergy(0, needed, true); // Uncomment for constant power
|
||||||
}
|
}
|
||||||
|
@ -318,10 +316,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
super.readFromNBT(data);
|
super.readFromNBT(data);
|
||||||
orientation = ForgeDirection.getOrientation(data.getInteger("orientation"));
|
orientation = ForgeDirection.getOrientation(data.getInteger("orientation"));
|
||||||
progress = data.getFloat("progress");
|
progress = data.getFloat("progress");
|
||||||
energy = data.getFloat("energyF");
|
energy = data.getDouble("energy");
|
||||||
NBTBase tag = data.getTag("heat");
|
heat = data.getFloat("heat");
|
||||||
if (tag instanceof NBTTagFloat)
|
|
||||||
heat = data.getFloat("heat");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -329,19 +325,19 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
super.writeToNBT(data);
|
super.writeToNBT(data);
|
||||||
data.setInteger("orientation", orientation.ordinal());
|
data.setInteger("orientation", orientation.ordinal());
|
||||||
data.setFloat("progress", progress);
|
data.setFloat("progress", progress);
|
||||||
data.setFloat("energyF", energy);
|
data.setDouble("energy", energy);
|
||||||
data.setFloat("heat", heat);
|
data.setFloat("heat", heat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getGUINetworkData(int id, int value) {
|
public void getGUINetworkData(int id, int value) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
int iEnergy = Math.round(energy * 10);
|
int iEnergy = (int) Math.round(energy * 10);
|
||||||
iEnergy = (iEnergy & 0xffff0000) | (value & 0xffff);
|
iEnergy = (iEnergy & 0xffff0000) | (value & 0xffff);
|
||||||
energy = iEnergy / 10;
|
energy = iEnergy / 10;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
iEnergy = Math.round(energy * 10);
|
iEnergy = (int) Math.round(energy * 10);
|
||||||
iEnergy = (iEnergy & 0xffff) | ((value & 0xffff) << 16);
|
iEnergy = (iEnergy & 0xffff) | ((value & 0xffff) << 16);
|
||||||
energy = iEnergy / 10;
|
energy = iEnergy / 10;
|
||||||
break;
|
break;
|
||||||
|
@ -355,9 +351,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) {
|
public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) {
|
||||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, Math.round(energy * 10) & 0xffff);
|
iCrafting.sendProgressBarUpdate(containerEngine, 0, (int) Math.round(energy * 10) & 0xffff);
|
||||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, (Math.round(energy * 10) & 0xffff0000) >> 16);
|
iCrafting.sendProgressBarUpdate(containerEngine, 1, (int) (Math.round(energy * 10) & 0xffff0000) >> 16);
|
||||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, Math.round(currentOutput * 10));
|
iCrafting.sendProgressBarUpdate(containerEngine, 2, (int) Math.round(currentOutput * 10));
|
||||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, Math.round(heat * 100));
|
iCrafting.sendProgressBarUpdate(containerEngine, 3, Math.round(heat * 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +375,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
addEnergy(powerHandler.useEnergy(1, maxEnergyReceived(), true) * 0.95F);
|
addEnergy(powerHandler.useEnergy(1, maxEnergyReceived(), true) * 0.95F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEnergy(float addition) {
|
public void addEnergy(double addition) {
|
||||||
energy += addition;
|
energy += addition;
|
||||||
|
|
||||||
if (getEnergyStage() == EnergyStage.OVERHEAT) {
|
if (getEnergyStage() == EnergyStage.OVERHEAT) {
|
||||||
|
@ -391,11 +387,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
energy = getMaxEnergy();
|
energy = getMaxEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float extractEnergy(float min, float max, boolean doExtract) {
|
public double extractEnergy(double min, double max, boolean doExtract) {
|
||||||
if (energy < min)
|
if (energy < min)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
float actualMax;
|
double actualMax;
|
||||||
|
|
||||||
if (max > maxEnergyExtracted())
|
if (max > maxEnergyExtracted())
|
||||||
actualMax = maxEnergyExtracted();
|
actualMax = maxEnergyExtracted();
|
||||||
|
@ -405,7 +401,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
if (actualMax < min)
|
if (actualMax < min)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
float extracted;
|
double extracted;
|
||||||
|
|
||||||
if (energy >= actualMax) {
|
if (energy >= actualMax) {
|
||||||
extracted = actualMax;
|
extracted = actualMax;
|
||||||
|
@ -427,23 +423,23 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract float getMaxEnergy();
|
public abstract double getMaxEnergy();
|
||||||
|
|
||||||
public float minEnergyReceived() {
|
public double minEnergyReceived() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract float maxEnergyReceived();
|
public abstract double maxEnergyReceived();
|
||||||
|
|
||||||
public abstract float maxEnergyExtracted();
|
public abstract double maxEnergyExtracted();
|
||||||
|
|
||||||
public abstract float explosionRange();
|
public abstract float explosionRange();
|
||||||
|
|
||||||
public float getEnergyStored() {
|
public double getEnergyStored() {
|
||||||
return energy;
|
return energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract float getCurrentOutput();
|
public abstract double getCurrentOutput();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ITrigger> getTriggers() {
|
public LinkedList<ITrigger> getTriggers() {
|
||||||
|
|
|
@ -396,22 +396,22 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyReceived() {
|
public double maxEnergyReceived() {
|
||||||
return 2000;
|
return 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyExtracted() {
|
public double maxEnergyExtracted() {
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxEnergy() {
|
public double getMaxEnergy() {
|
||||||
return 10000;
|
return 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getCurrentOutput() {
|
public double getCurrentOutput() {
|
||||||
if (currentFuel == null) {
|
if (currentFuel == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,12 @@ public class TileEngineLegacy extends TileEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxEnergy() {
|
public double getMaxEnergy() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyReceived() {
|
public double maxEnergyReceived() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ public class TileEngineLegacy extends TileEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getCurrentOutput() {
|
public double getCurrentOutput() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyExtracted() {
|
public double maxEnergyExtracted() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import buildcraft.api.gates.ITrigger;
|
||||||
import buildcraft.core.GuiIds;
|
import buildcraft.core.GuiIds;
|
||||||
import buildcraft.core.inventory.InvUtils;
|
import buildcraft.core.inventory.InvUtils;
|
||||||
import buildcraft.core.proxy.CoreProxy;
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.MathUtils;
|
||||||
import buildcraft.energy.gui.ContainerEngine;
|
import buildcraft.energy.gui.ContainerEngine;
|
||||||
|
|
||||||
public class TileEngineStone extends TileEngineWithInventory {
|
public class TileEngineStone extends TileEngineWithInventory {
|
||||||
|
@ -32,10 +32,10 @@ public class TileEngineStone extends TileEngineWithInventory {
|
||||||
final float TARGET_OUTPUT = 0.375f;
|
final float TARGET_OUTPUT = 0.375f;
|
||||||
final float kp = 1f;
|
final float kp = 1f;
|
||||||
final float ki = 0.05f;
|
final float ki = 0.05f;
|
||||||
final float eLimit = (MAX_OUTPUT - MIN_OUTPUT) / ki;
|
final double eLimit = (MAX_OUTPUT - MIN_OUTPUT) / ki;
|
||||||
int burnTime = 0;
|
int burnTime = 0;
|
||||||
int totalBurnTime = 0;
|
int totalBurnTime = 0;
|
||||||
float esum = 0;
|
double esum = 0;
|
||||||
|
|
||||||
public TileEngineStone() {
|
public TileEngineStone() {
|
||||||
super(1);
|
super(1);
|
||||||
|
@ -69,7 +69,7 @@ public class TileEngineStone extends TileEngineWithInventory {
|
||||||
if (burnTime > 0) {
|
if (burnTime > 0) {
|
||||||
burnTime--;
|
burnTime--;
|
||||||
|
|
||||||
float output = getCurrentOutput();
|
double output = getCurrentOutput();
|
||||||
currentOutput = output; // Comment out for constant power
|
currentOutput = output; // Comment out for constant power
|
||||||
addEnergy(output);
|
addEnergy(output);
|
||||||
}
|
}
|
||||||
|
@ -131,25 +131,25 @@ public class TileEngineStone extends TileEngineWithInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyReceived() {
|
public double maxEnergyReceived() {
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyExtracted() {
|
public double maxEnergyExtracted() {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxEnergy() {
|
public double getMaxEnergy() {
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getCurrentOutput() {
|
public double getCurrentOutput() {
|
||||||
float e = TARGET_OUTPUT * getMaxEnergy() - energy;
|
double e = TARGET_OUTPUT * getMaxEnergy() - energy;
|
||||||
esum = Math.min(Math.max(esum + e, -eLimit), eLimit);
|
esum = MathUtils.clamp(esum + e, -eLimit, eLimit);
|
||||||
return Math.min(Math.max(e * kp + esum * ki, MIN_OUTPUT), MAX_OUTPUT);
|
return MathUtils.clamp(e * kp + esum * ki, MIN_OUTPUT, MAX_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,18 +28,18 @@ public class TileEngineWood extends TileEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float minEnergyReceived() {
|
public double minEnergyReceived() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyReceived() {
|
public double maxEnergyReceived() {
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EnergyStage computeEnergyStage() {
|
protected EnergyStage computeEnergyStage() {
|
||||||
float energyLevel = getEnergyLevel();
|
double energyLevel = getEnergyLevel();
|
||||||
if (energyLevel < 0.25f)
|
if (energyLevel < 0.25f)
|
||||||
return EnergyStage.BLUE;
|
return EnergyStage.BLUE;
|
||||||
else if (energyLevel < 0.5f)
|
else if (energyLevel < 0.5f)
|
||||||
|
@ -91,17 +91,17 @@ public class TileEngineWood extends TileEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxEnergy() {
|
public double getMaxEnergy() {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getCurrentOutput() {
|
public double getCurrentOutput() {
|
||||||
return OUTPUT;
|
return OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxEnergyExtracted() {
|
public double maxEnergyExtracted() {
|
||||||
return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS;
|
return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,9 +150,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
||||||
}
|
}
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if (inProcess) {
|
if (inProcess) {
|
||||||
float energyToUse = 2 + powerHandler.getEnergyStored() / 500;
|
double energyToUse = 2 + powerHandler.getEnergyStored() / 500;
|
||||||
|
|
||||||
float energy = powerHandler.useEnergy(energyToUse, energyToUse, true);
|
double energy = powerHandler.useEnergy(energyToUse, energyToUse, true);
|
||||||
|
|
||||||
if (energy > 0) {
|
if (energy > 0) {
|
||||||
moveHead(0.1 + energy / 200F);
|
moveHead(0.1 + energy / 200F);
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe
|
||||||
if (!time.markTimeIfDelay(worldObj, currentRecipe.timeRequired))
|
if (!time.markTimeIfDelay(worldObj, currentRecipe.timeRequired))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float energyUsed = powerHandler.useEnergy(currentRecipe.energyCost, currentRecipe.energyCost, true);
|
double energyUsed = powerHandler.useEnergy(currentRecipe.energyCost, currentRecipe.energyCost, true);
|
||||||
|
|
||||||
if (energyUsed != 0) {
|
if (energyUsed != 0) {
|
||||||
if (consumeInput(currentRecipe.ingredient1) && consumeInput(currentRecipe.ingredient2)) {
|
if (consumeInput(currentRecipe.ingredient1) && consumeInput(currentRecipe.ingredient2)) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consume power and transfer it to the table.
|
// Consume power and transfer it to the table.
|
||||||
float power = powerHandler.useEnergy(0, getMaxPowerSent(), true);
|
double power = powerHandler.useEnergy(0, getMaxPowerSent(), true);
|
||||||
laserTarget.receiveLaserEnergy(power);
|
laserTarget.receiveLaserEnergy(power);
|
||||||
|
|
||||||
if (laser != null) {
|
if (laser != null) {
|
||||||
|
@ -113,7 +113,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPowerSent(float power) {
|
protected void onPowerSent(double power) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canFindTable() {
|
protected boolean canFindTable() {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveLaserEnergy(float energy) {
|
public void receiveLaserEnergy(double energy) {
|
||||||
this.energy += energy;
|
this.energy += energy;
|
||||||
recentEnergy[tick] += energy;
|
recentEnergy[tick] += energy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[j]);
|
PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[j]);
|
||||||
if (prov != null && prov.powerRequest() > 0) {
|
if (prov != null && prov.powerRequest() > 0) {
|
||||||
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
|
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
|
||||||
watts = prov.receiveEnergy(Type.PIPE, watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
watts = (float) prov.receiveEnergy(Type.PIPE, watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||||
internalPower[i] -= watts;
|
internalPower[i] -= watts;
|
||||||
} else if (tiles[j] instanceof TileGenericPipe) {
|
} else if (tiles[j] instanceof TileGenericPipe) {
|
||||||
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
|
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
|
||||||
|
@ -202,7 +202,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[i]);
|
PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[i]);
|
||||||
if (prov != null) {
|
if (prov != null) {
|
||||||
float request = prov.powerRequest();
|
float request = (float) prov.powerRequest();
|
||||||
|
|
||||||
if (request > 0) {
|
if (request > 0) {
|
||||||
requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request);
|
requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request);
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IPowe
|
||||||
|
|
||||||
CoreProxy.proxy.obsidianPipePickup(container.worldObj, item, this.container);
|
CoreProxy.proxy.obsidianPipePickup(container.worldObj, item, this.container);
|
||||||
|
|
||||||
float energyUsed = powerHandler.useEnergy(distance, contained.stackSize * distance, true);
|
double energyUsed = powerHandler.useEnergy(distance, contained.stackSize * distance, true);
|
||||||
|
|
||||||
if (distance == 0 || energyUsed / distance == contained.stackSize) {
|
if (distance == 0 || energyUsed / distance == contained.stackSize) {
|
||||||
stack = contained;
|
stack = contained;
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float energyToRemove;
|
double energyToRemove;
|
||||||
|
|
||||||
if (powerHandler.getEnergyStored() > 40) {
|
if (powerHandler.getEnergyStored() > 40) {
|
||||||
energyToRemove = powerHandler.getEnergyStored() / 40 + 4;
|
energyToRemove = powerHandler.getEnergyStored() / 40 + 4;
|
||||||
|
@ -107,7 +107,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
if (!powerSources[o.ordinal()])
|
if (!powerSources[o.ordinal()])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float energyUsable = powerHandler.useEnergy(0, energyToRemove, false);
|
float energyUsable = (float) powerHandler.useEnergy(0, energyToRemove, false);
|
||||||
|
|
||||||
float energySent = transport.receiveEnergy(o, energyUsable);
|
float energySent = transport.receiveEnergy(o, energyUsable);
|
||||||
if (energySent > 0) {
|
if (energySent > 0) {
|
||||||
|
|
Loading…
Reference in a new issue