2016-06-21 16:50:29 +00:00
|
|
|
package gregtech.api.objects;
|
|
|
|
|
|
|
|
import gregtech.api.GregTech_API;
|
|
|
|
import gregtech.api.util.GT_Log;
|
|
|
|
import gregtech.api.util.GT_Utility;
|
|
|
|
import net.minecraftforge.common.ForgeVersion;
|
|
|
|
import net.minecraftforge.fluids.Fluid;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Because Forge fucked this one up royally.
|
|
|
|
*/
|
|
|
|
public class GT_FluidStack extends FluidStack {
|
|
|
|
private static final Collection<GT_FluidStack> sAllFluidStacks = new ArrayList<GT_FluidStack>(5000);
|
2016-06-21 19:07:14 +00:00
|
|
|
private static volatile boolean lock = false;
|
2016-06-21 16:50:29 +00:00
|
|
|
private Fluid mFluid;
|
|
|
|
|
|
|
|
public GT_FluidStack(Fluid aFluid, int aAmount) {
|
|
|
|
super(aFluid, aAmount);
|
|
|
|
mFluid = aFluid;
|
|
|
|
if(!GregTech_API.mServerStarted){sAllFluidStacks.add(this);}
|
|
|
|
}
|
|
|
|
|
|
|
|
public GT_FluidStack(FluidStack aFluid) {
|
|
|
|
this(aFluid.getFluid(), aFluid.amount);
|
|
|
|
}
|
|
|
|
|
2016-08-13 07:28:24 +00:00
|
|
|
public static final synchronized void fixAllThoseFuckingFluidIDs() {
|
2016-08-13 09:10:11 +00:00
|
|
|
if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) {
|
|
|
|
try {
|
|
|
|
while (lock) {
|
2016-06-21 16:50:29 +00:00
|
|
|
Thread.sleep(1);
|
2016-08-13 09:10:11 +00:00
|
|
|
}} catch (InterruptedException e) {}
|
2016-06-21 16:50:29 +00:00
|
|
|
lock = true;
|
|
|
|
for (GT_FluidStack tFluid : sAllFluidStacks) tFluid.fixFluidIDForFucksSake();
|
2016-08-13 09:10:11 +00:00
|
|
|
try {
|
|
|
|
for (Map<Fluid, ?> tMap : GregTech_API.sFluidMappings)
|
2016-06-21 16:50:29 +00:00
|
|
|
GT_Utility.reMap(tMap);
|
2016-08-13 09:10:11 +00:00
|
|
|
} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
|
2016-06-21 16:50:29 +00:00
|
|
|
lock = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-13 07:28:24 +00:00
|
|
|
public final void fixFluidIDForFucksSake() {
|
2016-08-13 09:10:11 +00:00
|
|
|
if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) {
|
2016-06-21 16:50:29 +00:00
|
|
|
int fluidID;
|
|
|
|
try {
|
|
|
|
fluidID = this.getFluid().getID();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
System.err.println(e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
fluidID = mFluid.getID();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
fluidID = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack copy() {
|
2016-08-13 09:10:11 +00:00
|
|
|
if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) {
|
2016-06-21 16:50:29 +00:00
|
|
|
fixFluidIDForFucksSake();
|
|
|
|
}
|
|
|
|
return new GT_FluidStack(this);
|
|
|
|
}
|
|
|
|
}
|