mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 19:59:58 +00:00
Finished double conversion.
This commit is contained in:
1 parent
d4ab76990b
commit
fc64bf76ea
7 files changed
+29
-29
No files matched your search
@@ -411,7 +411,7 @@ public class NetworkPowerManager {
|
||||
|
||||
}
|
||||
|
||||
private float minAbs(float amount, float limit) {
|
||||
private double minAbs(double amount, double limit) {
|
||||
if(amount < 0) {
|
||||
return Math.max(amount, -limit);
|
||||
} else {
|
||||
@@ -462,14 +462,14 @@ public class NetworkPowerManager {
|
||||
maxToBalance += cb.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
float canGet = 0;
|
||||
double canGet = 0;
|
||||
|
||||
if(cb.isOutputEnabled(rec.direction.getOpposite())) {
|
||||
canGet = Math.min(cb.getEnergyStored(), cb.getMaxOutput());
|
||||
canGet = Math.min(canGet, rec.emmiter.getMaxEnergyRecieved(rec.direction));
|
||||
canExtract += canGet;
|
||||
}
|
||||
float canFill = 0;
|
||||
double canFill = 0;
|
||||
if(cb.isInputEnabled(rec.direction.getOpposite())) {
|
||||
canFill = Math.min(cb.getMaxEnergyStored() - cb.getEnergyStored(), cb.getMaxInput());
|
||||
canFill = Math.min(canFill, rec.emmiter.getMaxEnergyExtracted(rec.direction));
|
||||
@@ -509,16 +509,16 @@ public class NetworkPowerManager {
|
||||
CapBankSupplyEntry from = enteries.get(i);
|
||||
if(from.emmiter.getConectionMode(from.direction) == ConnectionMode.IN_OUT) {
|
||||
|
||||
float amount = from.toBalance;
|
||||
double amount = from.toBalance;
|
||||
amount = minAbs(amount, toalTransferAmount);
|
||||
from.capBank.addEnergy(amount);
|
||||
toalTransferAmount -= Math.abs(amount);
|
||||
float toTranfser = Math.abs(amount);
|
||||
double toTranfser = Math.abs(amount);
|
||||
|
||||
for (int j = i + 1; j < enteries.size() && toTranfser > 0; j++) {
|
||||
CapBankSupplyEntry to = enteries.get(j);
|
||||
if(Math.signum(amount) != Math.signum(to.toBalance)) {
|
||||
float toAmount = Math.min(toTranfser, Math.abs(to.toBalance));
|
||||
double toAmount = Math.min(toTranfser, Math.abs(to.toBalance));
|
||||
to.capBank.addEnergy(toAmount * Math.signum(to.toBalance));
|
||||
toTranfser -= toAmount;
|
||||
}
|
||||
@@ -571,13 +571,13 @@ public class NetworkPowerManager {
|
||||
private static class CapBankSupplyEntry {
|
||||
|
||||
final TileCapacitorBank capBank;
|
||||
final float canExtract;
|
||||
final float canFill;
|
||||
float toBalance;
|
||||
final double canExtract;
|
||||
final double canFill;
|
||||
double toBalance;
|
||||
IPowerConduit emmiter;
|
||||
ForgeDirection direction;
|
||||
|
||||
private CapBankSupplyEntry(TileCapacitorBank capBank, float available, float canFill, IPowerConduit emmiter, ForgeDirection direction) {
|
||||
private CapBankSupplyEntry(TileCapacitorBank capBank, double available, double canFill, IPowerConduit emmiter, ForgeDirection direction) {
|
||||
this.capBank = capBank;
|
||||
this.canExtract = available;
|
||||
this.canFill = canFill;
|
||||
|
||||
@@ -13,7 +13,7 @@ import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class BlockItemCapacitorBank extends ItemBlock {
|
||||
|
||||
public static ItemStack createItemStackWithPower(float storedEnergy) {
|
||||
public static ItemStack createItemStackWithPower(double storedEnergy) {
|
||||
ItemStack res = new ItemStack(EnderIO.blockCapacitorBank);
|
||||
PowerHandlerUtil.setStoredEnergyForItem(res, storedEnergy);
|
||||
return res;
|
||||
|
||||
@@ -172,7 +172,7 @@ public class CapBankRenderer2 implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFillBarOnFace(GaugeBounds gb, IIcon icon, float filledRatio, List<Vertex> vertices, double x, double y, double z) {
|
||||
private void renderFillBarOnFace(GaugeBounds gb, IIcon icon, double filledRatio, List<Vertex> vertices, double x, double y, double z) {
|
||||
|
||||
int totalPixels;
|
||||
if(gb.vInfo.verticalHeight == 1) {
|
||||
@@ -181,7 +181,7 @@ public class CapBankRenderer2 implements ISimpleBlockRenderingHandler {
|
||||
totalPixels = VPos.BOTTOM.numFillPixels + VPos.TOP.numFillPixels + (VPos.MIDDLE.numFillPixels * (gb.vInfo.verticalHeight - 2));
|
||||
}
|
||||
|
||||
int targetPixelCount = Math.max(0, Math.round(totalPixels * filledRatio));
|
||||
int targetPixelCount = (int)Math.max(0, Math.round(totalPixels * filledRatio));
|
||||
int pixelsBellowFace;
|
||||
if(gb.vInfo.index < 2) {
|
||||
// either none or a bottom section
|
||||
|
||||
@@ -69,7 +69,7 @@ public class CapacitorBankRenderer extends TileEntitySpecialRenderer implements
|
||||
|
||||
}
|
||||
|
||||
private void renderBlock(TileCapacitorBank te, float filledRatio, int meta) {
|
||||
private void renderBlock(TileCapacitorBank te, double filledRatio, int meta) {
|
||||
RenderUtil.bindBlockTexture();
|
||||
Tessellator tes = Tessellator.instance;
|
||||
|
||||
@@ -181,7 +181,7 @@ public class CapacitorBankRenderer extends TileEntitySpecialRenderer implements
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFillBarOnFace(GaugeBounds gb, IIcon icon, float filledRatio) {
|
||||
private void renderFillBarOnFace(GaugeBounds gb, IIcon icon, double filledRatio) {
|
||||
|
||||
int totalPixels;
|
||||
if(gb.vInfo.verticalHeight == 1) {
|
||||
@@ -190,7 +190,7 @@ public class CapacitorBankRenderer extends TileEntitySpecialRenderer implements
|
||||
totalPixels = VPos.BOTTOM.numFillPixels + VPos.TOP.numFillPixels + (VPos.MIDDLE.numFillPixels * (gb.vInfo.verticalHeight - 2));
|
||||
}
|
||||
|
||||
int targetPixelCount = Math.max(0, Math.round(totalPixels * filledRatio));
|
||||
int targetPixelCount = (int)Math.max(0, Math.round(totalPixels * filledRatio));
|
||||
int pixelsBellowFace;
|
||||
if(gb.vInfo.index < 2) {
|
||||
// either none or a bottom section
|
||||
|
||||
@@ -18,7 +18,7 @@ public class PacketPowerStorage implements IMessage, IMessageHandler<PacketPower
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private float storedEnergy;
|
||||
private double storedEnergy;
|
||||
|
||||
public PacketPowerStorage() {
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class PacketPowerStorage implements IMessage, IMessageHandler<PacketPower
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeFloat(storedEnergy);
|
||||
buf.writeDouble(storedEnergy);
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PacketPowerStorage implements IMessage, IMessageHandler<PacketPower
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
storedEnergy = buf.readFloat();
|
||||
storedEnergy = buf.readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +55,7 @@ public class PacketPowerStorage implements IMessage, IMessageHandler<PacketPower
|
||||
TileCapacitorBank me = (TileCapacitorBank) te;
|
||||
me.storedEnergy = message.storedEnergy;
|
||||
|
||||
float dif = Math.abs(me.lastRenderStoredRatio - me.getEnergyStoredRatio());
|
||||
double dif = Math.abs(me.lastRenderStoredRatio - me.getEnergyStoredRatio());
|
||||
if(dif > 0.025) { //update rendering at a 2.5% diff
|
||||
if(!me.isMultiblock()) {
|
||||
player.worldObj.markBlockForUpdate(message.x, message.y, message.z);
|
||||
|
||||
@@ -93,11 +93,11 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
|
||||
private boolean notifyNeighbours = false;
|
||||
|
||||
float energyAtLastRender = -1;
|
||||
double energyAtLastRender = -1;
|
||||
|
||||
private boolean isCreative = false;
|
||||
|
||||
float lastRenderStoredRatio;
|
||||
double lastRenderStoredRatio;
|
||||
|
||||
// private boolean registered = false;
|
||||
|
||||
@@ -575,7 +575,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
|
||||
// end rf power
|
||||
|
||||
public void addEnergy(float add) {
|
||||
public void addEnergy(double add) {
|
||||
getController().doAddEnergy(add);
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
return storedEnergy / maxStoredEnergy;
|
||||
}
|
||||
|
||||
void doAddEnergy(float add) {
|
||||
void doAddEnergy(double add) {
|
||||
storedEnergy = Math.max(0, Math.min(maxStoredEnergy, storedEnergy + add));
|
||||
}
|
||||
|
||||
@@ -1052,7 +1052,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
|
||||
double oldEnergy = storedEnergy;
|
||||
if(nbtRoot.hasKey("")) {
|
||||
if(nbtRoot.hasKey("storedEnergy")) {
|
||||
storedEnergy = nbtRoot.getFloat("storedEnergy");
|
||||
} else {
|
||||
storedEnergy = nbtRoot.getDouble("storedEnergyD");
|
||||
|
||||
@@ -41,20 +41,20 @@ public class PowerHandlerUtil {
|
||||
|
||||
}
|
||||
|
||||
public static float getStoredEnergyForItem(ItemStack item) {
|
||||
public static double getStoredEnergyForItem(ItemStack item) {
|
||||
NBTTagCompound tag = item.getTagCompound();
|
||||
if(tag == null) {
|
||||
return 0;
|
||||
}
|
||||
return tag.getFloat("storedEnergy");
|
||||
return tag.getDouble("storedEnergy");
|
||||
}
|
||||
|
||||
public static void setStoredEnergyForItem(ItemStack item, float storedEnergy) {
|
||||
public static void setStoredEnergyForItem(ItemStack item, double storedEnergy) {
|
||||
NBTTagCompound tag = item.getTagCompound();
|
||||
if(tag == null) {
|
||||
tag = new NBTTagCompound();
|
||||
}
|
||||
tag.setFloat("storedEnergy", storedEnergy);
|
||||
tag.setDouble("storedEnergy", storedEnergy);
|
||||
item.setTagCompound(tag);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user