Code cleanup

This commit is contained in:
LemADEC 2016-07-16 15:29:35 +02:00
parent 954976a547
commit a92cd9ed08

View file

@ -29,8 +29,8 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2API") @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2API")
}) })
public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfaced implements IEnergyHandler, IEnergySink, IEnergySource { public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfaced implements IEnergyHandler, IEnergySink, IEnergySource {
protected boolean addedToEnergyNet = false; private boolean addedToEnergyNet = false;
protected int energyStored_internal = 0; private int energyStored_internal = 0;
private static final double EU_PER_INTERNAL = 1.0D; private static final double EU_PER_INTERNAL = 1.0D;
private static final double RF_PER_INTERNAL = 1800.0D / 437.5D; private static final double RF_PER_INTERNAL = 1800.0D / 437.5D;
protected int IC2_sinkTier = 3; protected int IC2_sinkTier = 3;
@ -41,7 +41,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
private Object[] cofhEnergyReceivers; private Object[] cofhEnergyReceivers;
@Deprecated @Deprecated
protected final HashMap<UpgradeType,Integer> deprecated_upgrades = new HashMap<>(); protected final HashMap<UpgradeType, Integer> deprecated_upgrades = new HashMap<>();
public TileEntityAbstractEnergy() { public TileEntityAbstractEnergy() {
super(); super();
@ -52,13 +52,11 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
} }
@Deprecated @Deprecated
public Object[] getUpgrades_deprecated() public Object[] getUpgrades_deprecated() {
{
Object[] retVal = new Object[UpgradeType.values().length]; Object[] retVal = new Object[UpgradeType.values().length];
for(UpgradeType type : UpgradeType.values()) for (UpgradeType type : UpgradeType.values()) {
{
int am = 0; int am = 0;
if(deprecated_upgrades.containsKey(type)) if (deprecated_upgrades.containsKey(type))
am = deprecated_upgrades.get(type); am = deprecated_upgrades.get(type);
retVal[type.ordinal()] = type + ":" + am; retVal[type.ordinal()] = type + ":" + am;
} }
@ -67,11 +65,11 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
// WarpDrive methods // WarpDrive methods
protected static int convertInternalToRF(int energy) { protected static int convertInternalToRF(int energy) {
return (int)Math.round(energy * RF_PER_INTERNAL); return (int) Math.round(energy * RF_PER_INTERNAL);
} }
protected static int convertRFtoInternal(int energy) { protected static int convertRFtoInternal(int energy) {
return (int)Math.round(energy / RF_PER_INTERNAL); return (int) Math.round(energy / RF_PER_INTERNAL);
} }
protected static double convertInternalToEU(int energy) { protected static double convertInternalToEU(int energy) {
@ -79,7 +77,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
} }
protected static int convertEUtoInternal(double amount) { protected static int convertEUtoInternal(double amount) {
return (int)Math.round(amount / EU_PER_INTERNAL); return (int) Math.round(amount / EU_PER_INTERNAL);
} }
public int getEnergyStored() { public int getEnergyStored() {
@ -87,6 +85,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
} }
// Methods to override // Methods to override
/** /**
* Should return the maximum amount of energy that can be stored (measured in internal energy units). * Should return the maximum amount of energy that can be stored (measured in internal energy units).
*/ */
@ -112,6 +111,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
/** /**
* Should return true if that direction can receive energy. * Should return true if that direction can receive energy.
*/ */
@SuppressWarnings("UnusedParameters")
public boolean canInputEnergy(ForgeDirection from) { public boolean canInputEnergy(ForgeDirection from) {
return false; return false;
} }
@ -119,6 +119,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
/** /**
* Should return true if that direction can output energy. * Should return true if that direction can output energy.
*/ */
@SuppressWarnings("UnusedParameters")
public boolean canOutputEnergy(ForgeDirection to) { public boolean canOutputEnergy(ForgeDirection to) {
return false; return false;
} }
@ -174,7 +175,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
} }
return StatCollector.translateToLocalFormatted("warpdrive.energy.statusLine", return StatCollector.translateToLocalFormatted("warpdrive.energy.statusLine",
BigDecimal.valueOf(convertInternalToEU(getEnergyStored())).toPlainString(), BigDecimal.valueOf(convertInternalToEU(getEnergyStored())).toPlainString(),
BigDecimal.valueOf(convertInternalToEU(getMaxEnergyStored())).toPlainString() ); BigDecimal.valueOf(convertInternalToEU(getMaxEnergyStored())).toPlainString());
} }
public String getStatus() { public String getStatus() {
@ -397,7 +398,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
@Optional.Method(modid = "CoFHCore") @Optional.Method(modid = "CoFHCore")
private void outputEnergy() { private void outputEnergy() {
for(ForgeDirection from: ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection from : ForgeDirection.VALID_DIRECTIONS) {
if (cofhEnergyReceivers[from.ordinal()] != null) { if (cofhEnergyReceivers[from.ordinal()] != null) {
outputEnergy(from, (IEnergyReceiver) cofhEnergyReceivers[from.ordinal()]); outputEnergy(from, (IEnergyReceiver) cofhEnergyReceivers[from.ordinal()]);
} }
@ -452,12 +453,12 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
@Optional.Method(modid = "CoFHCore") @Optional.Method(modid = "CoFHCore")
private void scanForEnergyHandlers() { private void scanForEnergyHandlers() {
for(ForgeDirection from : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection from : ForgeDirection.VALID_DIRECTIONS) {
boolean energyReceiverFound = false; boolean energyReceiverFound = false;
if (canConnectEnergy(from)) { if (canConnectEnergy(from)) {
TileEntity tileEntity = worldObj.getTileEntity(xCoord + from.offsetX, yCoord + from.offsetY, zCoord + from.offsetZ); TileEntity tileEntity = worldObj.getTileEntity(xCoord + from.offsetX, yCoord + from.offsetY, zCoord + from.offsetZ);
if (tileEntity != null && tileEntity instanceof IEnergyReceiver) { if (tileEntity != null && tileEntity instanceof IEnergyReceiver) {
IEnergyReceiver energyReceiver = (IEnergyReceiver)tileEntity; IEnergyReceiver energyReceiver = (IEnergyReceiver) tileEntity;
if (energyReceiver.canConnectEnergy(from.getOpposite())) { if (energyReceiver.canConnectEnergy(from.getOpposite())) {
energyReceiverFound = true; energyReceiverFound = true;
cofhEnergyReceivers[from.ordinal()] = energyReceiver; cofhEnergyReceivers[from.ordinal()] = energyReceiver;