Fixed World Unload Crash.
Fixed render crashes for items that are not available. Parts now load properly.
This commit is contained in:
parent
24ad83356c
commit
699e82a889
4 changed files with 51 additions and 11 deletions
|
@ -32,6 +32,7 @@ public class BusRenderer implements IItemRenderer
|
|||
if ( part == null )
|
||||
{
|
||||
part = c.createPartFromItemStack( is );
|
||||
if ( part != null )
|
||||
renderPart.put( id, 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();
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -83,17 +83,21 @@ public class TickHandler implements ITickHandler
|
|||
{
|
||||
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())
|
||||
{
|
||||
if ( n.getWorld() == ev.world )
|
||||
toDestroy.add( n );
|
||||
}
|
||||
}
|
||||
|
||||
for (IGridNode n : toDestroy)
|
||||
n.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
|
|
|
@ -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,6 +163,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
|
|||
try
|
||||
{
|
||||
PartType t = getTypeByStack( is );
|
||||
if ( t != null )
|
||||
return t.getPart().getConstructor( ItemStack.class ).newInstance( is );
|
||||
}
|
||||
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()
|
||||
+ " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue