Fixed crashing when ic2 is not installed

This commit is contained in:
modmuss50 2015-07-26 15:35:02 +01:00
parent d8e8f45993
commit f433aa706a
9 changed files with 19 additions and 17 deletions

View file

@ -41,7 +41,7 @@ public class ChargeHud
if (mc.inGameHasFocus || (mc.currentScreen != null && mc.gameSettings.showDebugInfo))
{
if (ConfigTechReborn.ShowChargeHud)
if (ConfigTechReborn.ShowChargeHud && ElectricItem.manager != null)
drawChargeHud(event.resolution);
}
}

View file

@ -21,16 +21,18 @@ public class ItemCells extends ItemTR {
public static ItemStack getCellByName(String name, int count)
{
Fluid fluid = FluidRegistry.getFluid("fluid" + name.toLowerCase());
if(fluid != null){
ItemStack stack = IC2Items.getItem("FluidCell").copy();
if(stack != null && stack.getItem() instanceof IFluidContainerItem){
IFluidContainerItem containerItem = (IFluidContainerItem)stack.getItem();
containerItem.fill(stack, new FluidStack(fluid.getID(), 2147483647), true);
stack.stackSize = count;
return stack;
if(IC2Items.getItem("FluidCell") != null){
if(fluid != null){
ItemStack stack = IC2Items.getItem("FluidCell").copy();
if(stack != null && stack.getItem() instanceof IFluidContainerItem){
IFluidContainerItem containerItem = (IFluidContainerItem)stack.getItem();
containerItem.fill(stack, new FluidStack(fluid.getID(), 2147483647), true);
stack.stackSize = count;
return stack;
}
} else {
LogHelper.error("Could not find " + "fluid" + name + " in the fluid registry!");
}
} else {
LogHelper.error("Could not find " + "fluid" + name + " in the fluid registry!");
}
int index = -1;
for (int i = 0; i < types.length; i++) {

View file

@ -38,7 +38,7 @@ public class ItemLapotronicOrb extends Item implements IElectricItem {
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList){
ItemStack itemStack = new ItemStack(this, 1);
if (getChargedItem(itemStack) == this){
if (getChargedItem(itemStack) == this && ElectricItem.manager != null){
ItemStack charged = new ItemStack(this, 1);
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
false);

View file

@ -45,7 +45,7 @@ public class ItemLapotronPack extends ItemArmor implements IElectricItem {
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList){
ItemStack itemStack = new ItemStack(this, 1);
if (getChargedItem(itemStack) == this){
if (getChargedItem(itemStack) == this && ElectricItem.manager != null){
ItemStack charged = new ItemStack(this, 1);
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false);
itemList.add(charged);

View file

@ -45,7 +45,7 @@ public class ItemLithiumBatpack extends ItemArmor implements IElectricItem {
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList){
ItemStack itemStack = new ItemStack(this, 1);
if (getChargedItem(itemStack) == this){
if (getChargedItem(itemStack) == this && ElectricItem.manager != null){
ItemStack charged = new ItemStack(this, 1);
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
false);

View file

@ -48,7 +48,7 @@ public class ItemAdvancedDrill extends ItemPickaxe implements IElectricItem {
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList){
ItemStack itemStack = new ItemStack(this, 1);
if (getChargedItem(itemStack) == this){
if (getChargedItem(itemStack) == this && ElectricItem.manager != null){
ItemStack charged = new ItemStack(this, 1);
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false);
itemList.add(charged);

View file

@ -49,7 +49,7 @@ public class ItemOmniTool extends ItemPickaxe implements IElectricItem {
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList){
ItemStack itemStack = new ItemStack(this, 1);
if (getChargedItem(itemStack) == this){
if (getChargedItem(itemStack) == this && ElectricItem.manager != null){
ItemStack charged = new ItemStack(this, 1);
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
false);

View file

@ -58,7 +58,7 @@ public class ItemRockCutter extends ItemPickaxe implements IElectricItem {
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList){
ItemStack itemStack = new ItemStack(this, 1);
if (getChargedItem(itemStack) == this){
if (getChargedItem(itemStack) == this && ElectricItem.manager != null){
ItemStack charged = new ItemStack(this, 1);
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
false);

View file

@ -156,7 +156,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
return 0;
}
maxReceive *= ConfigTechReborn.euPerRF;
int energyReceived = Math.min(getMaxEnergyStored(ForgeDirection.UNKNOWN) - getEnergyStored(ForgeDirection.UNKNOWN), Math.min((int)this.getMaxInput(), maxReceive));
int energyReceived = Math.min(getMaxEnergyStored(ForgeDirection.UNKNOWN) - getEnergyStored(ForgeDirection.UNKNOWN), Math.min((int)this.getMaxInput() * ConfigTechReborn.euPerRF, maxReceive));
if (!simulate) {
energy += energyReceived;