diff --git a/client/render/BusRenderer.java b/client/render/BusRenderer.java index 0426f7aa..25cf5598 100644 --- a/client/render/BusRenderer.java +++ b/client/render/BusRenderer.java @@ -32,7 +32,8 @@ public class BusRenderer implements IItemRenderer if ( part == null ) { part = c.createPartFromItemStack( is ); - renderPart.put( id, part ); + if ( part != null ) + renderPart.put( id, part ); } return part; @@ -53,6 +54,9 @@ public class BusRenderer implements IItemRenderer @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + if ( item == null ) + return; + GL11.glPushMatrix(); if ( type == ItemRenderType.ENTITY ) GL11.glTranslatef( -0.5f, -0.5f, -0.5f ); @@ -83,7 +87,11 @@ public class BusRenderer implements IItemRenderer fp.renderInventory( BusRenderHelper.instance, renderer ); } else - getRenderer( item, (IPartItem) item.getItem() ).renderInventory( BusRenderHelper.instance, renderer ); + { + IPart ip = getRenderer( item, (IPartItem) item.getItem() ); + if ( ip != null ) + ip.renderInventory( BusRenderHelper.instance, renderer ); + } GL11.glPopMatrix(); } diff --git a/core/CreativeTab.java b/core/CreativeTab.java index f0c5b859..659d38d0 100644 --- a/core/CreativeTab.java +++ b/core/CreativeTab.java @@ -1,8 +1,10 @@ package appeng.core; +import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.util.AEItemDefinition; import appeng.util.Platform; public final class CreativeTab extends CreativeTabs @@ -19,7 +21,21 @@ public final class CreativeTab extends CreativeTabs @Override public ItemStack getIconItemStack() { - return AEApi.instance().items().itemWirelessTerminal.stack( 1 ); + return findFirst( AEApi.instance().blocks().blockController, AEApi.instance().blocks().blockChest, AEApi.instance().blocks().blockCellWorkbench, + AEApi.instance().blocks().blockFluix, AEApi.instance().items().itemCell1k, AEApi.instance().items().itemNetworkTool, + AEApi.instance().materials().materialFluixCrystal, AEApi.instance().materials().materialCertusQuartzCrystal ); + } + + private ItemStack findFirst(AEItemDefinition... choices) + { + for (AEItemDefinition a : choices) + { + ItemStack is = a.stack( 1 ); + if ( is != null ) + return is; + } + + return new ItemStack( Block.chest ); } public static void init() diff --git a/helpers/TickHandler.java b/helpers/TickHandler.java index e0b2f197..80019467 100644 --- a/helpers/TickHandler.java +++ b/helpers/TickHandler.java @@ -83,15 +83,19 @@ public class TickHandler implements ITickHandler { if ( Platform.isServer() ) { - while (!getRepo().networks.isEmpty()) + LinkedList toDestroy = new LinkedList(); + + for (Grid g : getRepo().networks) { - Grid g = getRepo().networks.poll(); for (IGridNode n : g.getNodes()) { if ( n.getWorld() == ev.world ) - n.destroy(); + toDestroy.add( n ); } } + + for (IGridNode n : toDestroy) + n.destroy(); } } diff --git a/items/parts/ItemPart.java b/items/parts/ItemPart.java index 297999f1..d7826c57 100644 --- a/items/parts/ItemPart.java +++ b/items/parts/ItemPart.java @@ -51,8 +51,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup try { ItemStack is = new ItemStack( this ); - PartType t = getTypeByStack( is ); - t.getPart().getConstructor( ItemStack.class ).newInstance( is ); + mat.getPart().getConstructor( ItemStack.class ).newInstance( is ); } catch (Throwable e) { @@ -92,7 +91,14 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup public PartType getTypeByStack(ItemStack is) { - return dmgToPart.get( is.getItemDamage() ).part; + if ( is == null ) + return null; + + PartTypeIst pt = dmgToPart.get( is.getItemDamage() ); + if ( pt != null ) + return pt.part; + + return null; } @Override @@ -123,7 +129,11 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup @Override public String getItemDisplayName(ItemStack is) { - Enum[] varients = getTypeByStack( is ).getVarients(); + PartType pt = getTypeByStack( is ); + if ( pt == null ) + return "Unnamed"; + + Enum[] varients = pt.getVarients(); if ( varients != null ) return super.getItemDisplayName( is ) + " - " + varients[dmgToPart.get( is.getItemDamage() ).varient].toString(); @@ -153,13 +163,15 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup try { PartType t = getTypeByStack( is ); - return t.getPart().getConstructor( ItemStack.class ).newInstance( is ); + if ( t != null ) + return t.getPart().getConstructor( ItemStack.class ).newInstance( is ); } catch (Throwable e) { throw new RuntimeException( "Unable to construct IBusPart from IBusItem : " + getTypeByStack( is ).getPart().getName() + " ; Possibly didn't have correct constructor( ItemStack )", e ); } + return null; } @Override