Fixed World Unload Crash.

Fixed render crashes for items that are not available.
Parts now load properly.
This commit is contained in:
AlgorithmX2 2014-01-28 16:30:14 -06:00
parent 24ad83356c
commit 699e82a889
4 changed files with 51 additions and 11 deletions

View file

@ -32,6 +32,7 @@ public class BusRenderer implements IItemRenderer
if ( part == null ) if ( part == null )
{ {
part = c.createPartFromItemStack( is ); part = c.createPartFromItemStack( is );
if ( part != null )
renderPart.put( id, part ); renderPart.put( id, part );
} }
@ -53,6 +54,9 @@ public class BusRenderer implements IItemRenderer
@Override @Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{ {
if ( item == null )
return;
GL11.glPushMatrix(); GL11.glPushMatrix();
if ( type == ItemRenderType.ENTITY ) if ( type == ItemRenderType.ENTITY )
GL11.glTranslatef( -0.5f, -0.5f, -0.5f ); GL11.glTranslatef( -0.5f, -0.5f, -0.5f );
@ -83,7 +87,11 @@ public class BusRenderer implements IItemRenderer
fp.renderInventory( BusRenderHelper.instance, renderer ); fp.renderInventory( BusRenderHelper.instance, renderer );
} }
else 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(); GL11.glPopMatrix();
} }

View file

@ -1,8 +1,10 @@
package appeng.core; package appeng.core;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.util.AEItemDefinition;
import appeng.util.Platform; import appeng.util.Platform;
public final class CreativeTab extends CreativeTabs public final class CreativeTab extends CreativeTabs
@ -19,7 +21,21 @@ public final class CreativeTab extends CreativeTabs
@Override @Override
public ItemStack getIconItemStack() 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() public static void init()

View file

@ -83,17 +83,21 @@ public class TickHandler implements ITickHandler
{ {
if ( Platform.isServer() ) if ( Platform.isServer() )
{ {
while (!getRepo().networks.isEmpty()) LinkedList<IGridNode> toDestroy = new LinkedList();
for (Grid g : getRepo().networks)
{ {
Grid g = getRepo().networks.poll();
for (IGridNode n : g.getNodes()) for (IGridNode n : g.getNodes())
{ {
if ( n.getWorld() == ev.world ) if ( n.getWorld() == ev.world )
toDestroy.add( n );
}
}
for (IGridNode n : toDestroy)
n.destroy(); n.destroy();
} }
} }
}
}
@Override @Override
public void tickStart(EnumSet<TickType> type, Object... tickData) public void tickStart(EnumSet<TickType> type, Object... tickData)

View file

@ -51,8 +51,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
try try
{ {
ItemStack is = new ItemStack( this ); ItemStack is = new ItemStack( this );
PartType t = getTypeByStack( is ); mat.getPart().getConstructor( ItemStack.class ).newInstance( is );
t.getPart().getConstructor( ItemStack.class ).newInstance( is );
} }
catch (Throwable e) catch (Throwable e)
{ {
@ -92,7 +91,14 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
public PartType getTypeByStack(ItemStack is) 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 @Override
@ -123,7 +129,11 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
@Override @Override
public String getItemDisplayName(ItemStack is) 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 ) if ( varients != null )
return super.getItemDisplayName( is ) + " - " + varients[dmgToPart.get( is.getItemDamage() ).varient].toString(); return super.getItemDisplayName( is ) + " - " + varients[dmgToPart.get( is.getItemDamage() ).varient].toString();
@ -153,6 +163,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
try try
{ {
PartType t = getTypeByStack( is ); PartType t = getTypeByStack( is );
if ( t != null )
return t.getPart().getConstructor( ItemStack.class ).newInstance( is ); return t.getPart().getConstructor( ItemStack.class ).newInstance( is );
} }
catch (Throwable e) catch (Throwable e)
@ -160,6 +171,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
throw new RuntimeException( "Unable to construct IBusPart from IBusItem : " + getTypeByStack( is ).getPart().getName() throw new RuntimeException( "Unable to construct IBusPart from IBusItem : " + getTypeByStack( is ).getPart().getName()
+ " ; Possibly didn't have correct constructor( ItemStack )", e ); + " ; Possibly didn't have correct constructor( ItemStack )", e );
} }
return null;
} }
@Override @Override