Properly convert IC2 energy
This commit is contained in:
@@ -298,6 +298,16 @@ public final class RefinedStorageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep this on par with the Forestry generators
|
||||||
|
// 1 EU is worth 4 RF
|
||||||
|
public static int convertIC2ToRF(double amount) {
|
||||||
|
return (int) amount * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double convertRFToIC2(int amount) {
|
||||||
|
return amount / 4;
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack extractItem(INetworkMaster network, ItemStack stack, int size) {
|
public static ItemStack extractItem(INetworkMaster network, ItemStack stack, int size) {
|
||||||
return network.extractItem(stack, size, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
|
return network.extractItem(stack, size, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ import refinedstorage.tile.grid.TileGrid;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static refinedstorage.RefinedStorageUtils.convertIC2ToRF;
|
||||||
|
import static refinedstorage.RefinedStorageUtils.convertRFToIC2;
|
||||||
|
|
||||||
public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialElectricItem, IElectricItemManager {
|
public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialElectricItem, IElectricItemManager {
|
||||||
public static final int TYPE_NORMAL = 0;
|
public static final int TYPE_NORMAL = 0;
|
||||||
public static final int TYPE_CREATIVE = 1;
|
public static final int TYPE_CREATIVE = 1;
|
||||||
@@ -229,22 +232,22 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
|
public double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
|
||||||
return receiveEnergy(stack, (int) amount, simulate);
|
return convertRFToIC2(receiveEnergy(stack, convertIC2ToRF(amount), simulate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) {
|
public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) {
|
||||||
return extractEnergy(stack, (int) amount, simulate);
|
return convertRFToIC2(extractEnergy(stack, convertIC2ToRF(amount), simulate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getCharge(ItemStack stack) {
|
public double getCharge(ItemStack stack) {
|
||||||
return getEnergyStored(stack);
|
return convertRFToIC2(getEnergyStored(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxCharge(ItemStack stack) {
|
public double getMaxCharge(ItemStack stack) {
|
||||||
return getMaxEnergyStored(stack);
|
return convertRFToIC2(getMaxEnergyStored(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ import refinedstorage.tile.config.RedstoneMode;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static refinedstorage.RefinedStorageUtils.convertIC2ToRF;
|
||||||
|
import static refinedstorage.RefinedStorageUtils.convertRFToIC2;
|
||||||
|
|
||||||
public class TileController extends TileBase implements INetworkMaster, IEnergyReceiver, ITeslaHolder, ITeslaConsumer, ISynchronizedContainer, IRedstoneModeConfig {
|
public class TileController extends TileBase implements INetworkMaster, IEnergyReceiver, ITeslaHolder, ITeslaConsumer, ISynchronizedContainer, IRedstoneModeConfig {
|
||||||
public static final String NBT_ENERGY = "Energy";
|
public static final String NBT_ENERGY = "Energy";
|
||||||
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
||||||
@@ -98,15 +101,15 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<ICraftingTask>();
|
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<ICraftingTask>();
|
||||||
|
|
||||||
private EnergyStorage energy = new EnergyStorage(RefinedStorage.INSTANCE.controller);
|
private EnergyStorage energy = new EnergyStorage(RefinedStorage.INSTANCE.controller);
|
||||||
private BasicSink ic2Energy = new BasicSink(this, energy.getMaxEnergyStored(), Integer.MAX_VALUE) {
|
private BasicSink IC2Energy = new BasicSink(this, energy.getMaxEnergyStored(), Integer.MAX_VALUE) {
|
||||||
@Override
|
@Override
|
||||||
public double getDemandedEnergy() {
|
public double getDemandedEnergy() {
|
||||||
return Math.max(0.0D, (double) energy.getMaxEnergyStored() - (double) energy.getEnergyStored());
|
return Math.max(0.0D, convertRFToIC2(energy.getMaxEnergyStored()) - convertRFToIC2(energy.getEnergyStored()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||||
energy.setEnergyStored(energy.getEnergyStored() + (int) amount);
|
energy.setEnergyStored(energy.getEnergyStored() + convertIC2ToRF(amount));
|
||||||
|
|
||||||
return 0.0D;
|
return 0.0D;
|
||||||
}
|
}
|
||||||
@@ -142,7 +145,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!worldObj.isRemote) {
|
if (!worldObj.isRemote) {
|
||||||
ic2Energy.update();
|
IC2Energy.update();
|
||||||
|
|
||||||
for (INetworkNode node : nodesToAdd) {
|
for (INetworkNode node : nodesToAdd) {
|
||||||
nodes.add(node);
|
nodes.add(node);
|
||||||
@@ -242,7 +245,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
|
||||||
ic2Energy.invalidate();
|
IC2Energy.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,7 +289,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
public void onChunkUnload() {
|
public void onChunkUnload() {
|
||||||
disconnectNodes();
|
disconnectNodes();
|
||||||
|
|
||||||
ic2Energy.invalidate();
|
IC2Energy.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGroupedStorage getStorage() {
|
public IGroupedStorage getStorage() {
|
||||||
|
|||||||
Reference in New Issue
Block a user