2013-10-18 02:53:08 +02:00
|
|
|
package com.pahimar.ee3.item;
|
2013-08-23 16:59:50 +02:00
|
|
|
|
2013-09-06 04:21:55 +02:00
|
|
|
public class EnergyStack implements Comparable<EnergyStack> {
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
public static final String VANILLA_SMELTING_ENERGY_NAME = "vanillaFuelValueUnits";
|
|
|
|
public static final int VANILLA_SMELTING_ENERGY_THRESHOLD = 200;
|
|
|
|
|
|
|
|
public String energyName;
|
|
|
|
public int stackSize;
|
|
|
|
|
|
|
|
public EnergyStack(String energyName, int stackSize) {
|
|
|
|
|
|
|
|
this.energyName = energyName;
|
|
|
|
this.stackSize = stackSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EnergyStack(String energyName) {
|
|
|
|
|
2013-09-24 21:29:11 +02:00
|
|
|
this(energyName, 1);
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
stringBuilder.append(String.format("%dxenergyStack.%s", stackSize, energyName));
|
|
|
|
|
|
|
|
return stringBuilder.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object object) {
|
|
|
|
|
|
|
|
if (!(object instanceof EnergyStack)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnergyStack energyStack = (EnergyStack) object;
|
|
|
|
|
2013-09-06 19:50:17 +02:00
|
|
|
if ((this.energyName != null) && (energyStack.energyName != null)) {
|
|
|
|
return (stackSize == energyStack.stackSize) && energyName.equalsIgnoreCase(energyStack.energyName);
|
|
|
|
}
|
|
|
|
else if ((this.energyName == null) && (energyStack.energyName == null)) {
|
|
|
|
return (stackSize == energyStack.stackSize);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
2013-09-28 21:00:28 +02:00
|
|
|
|
|
|
|
public static boolean compareEnergyNames(EnergyStack energyStack1, EnergyStack energyStack2) {
|
|
|
|
|
|
|
|
if (energyStack1 != null && energyStack2 != null) {
|
|
|
|
if ((energyStack1.energyName != null) && (energyStack2.energyName != null)) {
|
|
|
|
return energyStack1.energyName.equalsIgnoreCase(energyStack2.energyName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
|
2013-09-06 19:50:17 +02:00
|
|
|
@Override
|
|
|
|
public int compareTo(EnergyStack energyStack) {
|
|
|
|
|
|
|
|
if (energyStack != null) {
|
|
|
|
if ((this.energyName != null) && (energyStack.energyName != null)) {
|
|
|
|
if (this.energyName.equalsIgnoreCase(energyStack.energyName)) {
|
|
|
|
return (this.stackSize - energyStack.stackSize);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.energyName.compareToIgnoreCase(energyStack.energyName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((this.energyName != null) && (energyStack.energyName == null)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if ((this.energyName == null) && (energyStack.energyName != null)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return (this.stackSize - energyStack.stackSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|