Prevent null Items?

This commit is contained in:
AlgorithmX2 2014-08-13 00:25:21 -05:00
parent a3091741ff
commit 2d12ffc304
2 changed files with 9 additions and 9 deletions

View file

@ -7,6 +7,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui; import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox; import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton; import appeng.client.gui.widgets.GuiTabButton;
@ -109,7 +110,7 @@ public class GuiCraftAmount extends AEBaseGui
try try
{ {
if ( btn == originalGuiBtn ) if ( btn == originalGuiBtn )
{ {
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) ); NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
@ -117,12 +118,13 @@ public class GuiCraftAmount extends AEBaseGui
if ( btn == next ) if ( btn == next )
{ {
NetworkHandler.instance.sendToServer( new PacketCraftRequest( inventorySlots.getSlot( 0 ).getStack(), Integer.parseInt( this.amountToCraft IAEItemStack what = AEApi.instance().storage().createItemStack( inventorySlots.getSlot( 0 ).getStack() );
.getText() ), isShiftKeyDown() ) ); if ( what != null )
NetworkHandler.instance.sendToServer( new PacketCraftRequest( what, Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
} }
} }
catch(NumberFormatException e ) catch (NumberFormatException e)
{ {
// nope.. // nope..
amountToCraft.setText( "1" ); amountToCraft.setText( "1" );
@ -166,7 +168,7 @@ public class GuiCraftAmount extends AEBaseGui
result += i; result += i;
if ( result < 1 ) if ( result < 1 )
result = 1; result = 1;
Out = Long.toString( result ); Out = Long.toString( result );
Integer.parseInt( Out ); Integer.parseInt( Out );
amountToCraft.setText( Out ); amountToCraft.setText( Out );

View file

@ -7,10 +7,8 @@ import java.io.IOException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@ -90,8 +88,8 @@ public class PacketCraftRequest extends AppEngPacket
} }
} }
public PacketCraftRequest(ItemStack stack, int parseInt, boolean shift) throws IOException { public PacketCraftRequest(IAEItemStack stack, int parseInt, boolean shift) throws IOException {
this.slotItem = AEApi.instance().storage().createItemStack( stack ); this.slotItem = stack;
this.slotItem.setStackSize( parseInt ); this.slotItem.setStackSize( parseInt );
this.heldShift = shift; this.heldShift = shift;