Add checks to prevent crash on item inseration into generators

This commit is contained in:
Blood-Asp 2017-02-03 22:46:39 +01:00
parent 023609842c
commit 9afffee2a6
2 changed files with 3 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenera
import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_DieselGenerator public class GT_MetaTileEntity_DieselGenerator
@ -54,6 +55,7 @@ public class GT_MetaTileEntity_DieselGenerator
} }
public int getFuelValue(ItemStack aStack) { public int getFuelValue(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0;
int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack));
if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) {
rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3);

View file

@ -56,6 +56,7 @@ public class GT_MetaTileEntity_SteamTurbine extends GT_MetaTileEntity_BasicGener
} }
public int getFuelValue(FluidStack aLiquid) { public int getFuelValue(FluidStack aLiquid) {
if(aLiquid==null)return 0;
String fluidName = aLiquid.getFluid().getUnlocalizedName(aLiquid); String fluidName = aLiquid.getFluid().getUnlocalizedName(aLiquid);
return GT_ModHandler.isSteam(aLiquid) || fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name") ? 3 : 0; return GT_ModHandler.isSteam(aLiquid) || fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name") ? 3 : 0;
} }