GT5-Unofficial/main/java/gregtech/api/objects/GT_FluidStack.java

55 lines
1.7 KiB
Java
Raw Normal View History

2015-04-23 16:14:22 +00:00
package gregtech.api.objects;
import gregtech.api.GregTech_API;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import net.minecraftforge.common.ForgeVersion;
2015-04-23 16:14:22 +00:00
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
/**
* 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);
private Fluid mFluid;
private static boolean lock=false;
2015-04-23 16:14:22 +00:00
public GT_FluidStack(Fluid aFluid, int aAmount) {
super(aFluid, aAmount);
mFluid = aFluid;
sAllFluidStacks.add(this);
}
public GT_FluidStack(FluidStack aFluid) {
this(aFluid.getFluid(), aFluid.amount);
}
public static void fixAllThoseFuckingFluidIDs() {
if(ForgeVersion.getBuildVersion()<1355){
while(lock){try {Thread.sleep(1);} catch (InterruptedException e) {}}
lock=true;
2015-04-24 21:47:25 +00:00
for (GT_FluidStack tFluid : sAllFluidStacks) tFluid.fixFluidIDForFucksSake();
for (Map<Fluid, ?> tMap : GregTech_API.sFluidMappings) try {GT_Utility.reMap(tMap);} catch(Throwable e) {e.printStackTrace(GT_Log.err);}
lock=false;}
2015-04-23 16:14:22 +00:00
}
public void fixFluidIDForFucksSake() {
if(ForgeVersion.getBuildVersion()<1355){
int fluidID;
try {fluidID = this.getFluid().getID();} catch(Throwable e){System.err.println(e);}
try {fluidID = mFluid.getID();} catch(Throwable e) {fluidID = -1;}}
2015-04-23 16:14:22 +00:00
}
@Override
public FluidStack copy() {
if(ForgeVersion.getBuildVersion()<1355){
fixFluidIDForFucksSake();}
2015-04-23 16:14:22 +00:00
return new GT_FluidStack(this);
}
}