Skip to content

Commit

Permalink
Fixing crash with FrypanLogic
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander committed Apr 4, 2014
1 parent b6ba870 commit cf6b286
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
5 changes: 5 additions & 0 deletions src/main/java/tconstruct/blocks/GravelOre.java
Expand Up @@ -3,6 +3,8 @@
import java.util.List;
import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tconstruct.common.TRepo;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.BlockSand;
Expand All @@ -27,6 +29,7 @@ public GravelOre()
this.setStepSound(soundTypeGravel);
}

@Override
public void registerBlockIcons (IIconRegister iconRegister)
{
this.icons = new IIcon[textureNames.length];
Expand All @@ -38,6 +41,7 @@ public void registerBlockIcons (IIconRegister iconRegister)
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
return icons[meta];
Expand All @@ -60,6 +64,7 @@ public int damageDropped (int meta)
return meta;
}

@Override
public Item getItemDropped (int par1, Random par2Random, int par3)
{
/*if (par1 == 1)
Expand Down
40 changes: 19 additions & 21 deletions src/main/java/tconstruct/blocks/logic/FrypanLogic.java
@@ -1,5 +1,6 @@
package tconstruct.blocks.logic;

import tconstruct.inventory.FrypanContainer;
import mantle.blocks.BlockUtils;
import mantle.blocks.iface.IActiveLogic;
import net.minecraft.block.Block;
Expand All @@ -18,7 +19,6 @@
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import tconstruct.inventory.FrypanContainer;
import cpw.mods.fml.common.registry.GameRegistry;

/* Slots
Expand Down Expand Up @@ -89,7 +89,7 @@ public void updateEntity ()
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5);
if (fuel > 0)
{
if (inventory[1].getItem().hasContainerItem()) // Fuel slot
if (inventory[1].getItem().hasContainerItem()) //Fuel slot
{
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public void cookItems ()
if (!canCook())
return;

for (int id = 2; id < 10; id++) // Check every slot
for (int id = 2; id < 10; id++) //Check every slot
{
if (canCook())
{
Expand All @@ -147,7 +147,7 @@ public void cookItems ()
{
int ids = 2;
boolean placed = false;
while (ids < 10 && !placed) // Try to merge stacks first
while (ids < 10 && !placed) //Try to merge stacks first
{
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
{
Expand All @@ -167,7 +167,7 @@ public void cookItems ()
}

ids = 2;
while (!placed && ids < 10) // Place remaining in slot
while (!placed && ids < 10) //Place remaining in slot
{
if (inventory[ids] == null)
{
Expand All @@ -188,11 +188,11 @@ public boolean canCook ()
{
for (int id = 2; id < 10; id++)
{
if (inventory[id] == null) // Nothing here!
if (inventory[id] == null) //Nothing here!
continue;

ItemStack result = getResultFor(inventory[id]);
if (result == null) // Doesn't cook into anything
if (result == null) //Doesn't cook into anything
continue;

for (int slotid = 2; slotid < 10; slotid++)
Expand All @@ -214,13 +214,18 @@ public boolean isBurning ()

public ItemStack getResultFor (ItemStack stack)
{
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
if (result != null && result.getItem() instanceof ItemFood) // Only
// valid for
// food
return result.copy();
if (stack == null)
{
return null;
}
else
{
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
return result.copy();

return null;
return null;
}
}

public static int getItemBurnTime (ItemStack stack)
Expand Down Expand Up @@ -273,7 +278,6 @@ public static int getItemBurnTime (ItemStack stack)
}

/* NBT */
@Override
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
Expand All @@ -282,7 +286,6 @@ public void readFromNBT (NBTTagCompound tags)
fuelGague = tags.getInteger("FuelGague");
}

@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
Expand All @@ -309,11 +312,6 @@ public boolean hasCustomInventoryName ()
return true;
}

/*
* @Override public boolean canDropInventorySlot(int slot) { if (slot == 0)
* return false; else return true; }
*/

@Override
public void openInventory ()
{
Expand All @@ -323,4 +321,4 @@ public void openInventory ()
public void closeInventory ()
{
}
}
}

0 comments on commit cf6b286

Please sign in to comment.