Merge pull request #1127 from thatsIch/b-1118-api-crash

Fixes #1118 Does not crash with invalid ItemStacks anymore
This commit is contained in:
thatsIch
2015-03-30 11:54:28 +02:00
10 changed files with 1077 additions and 1068 deletions
+144 -132
View File
@@ -22,9 +22,7 @@ package appeng.block;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
@@ -56,6 +54,9 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages; import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile; import appeng.api.implementations.tiles.IColorableTile;
@@ -97,11 +98,13 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
BlockRenderInfo renderInfo; BlockRenderInfo renderInfo;
private IFeatureHandler handler; private IFeatureHandler handler;
@Nullable
private Class<? extends TileEntity> tileEntityType = null; private Class<? extends TileEntity> tileEntityType = null;
protected AEBaseBlock( Class<? extends AEBaseBlock> c, Material mat ) protected AEBaseBlock( Class<? extends AEBaseBlock> c, Material mat )
{ {
this( c, mat, Optional.<String> absent() ); this( c, mat, Optional.<String>absent() );
this.setLightOpacity( 255 ); this.setLightOpacity( 255 );
this.setLightLevel( 0 ); this.setLightLevel( 0 );
this.setHardness( 2.2F ); this.setHardness( 2.2F );
@@ -113,11 +116,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
super( mat ); super( mat );
if ( mat == AEGlassMaterial.INSTANCE || mat == Material.glass ) if( mat == AEGlassMaterial.INSTANCE || mat == Material.glass )
this.setStepSound( Block.soundTypeGlass ); this.setStepSound( Block.soundTypeGlass );
else if ( mat == Material.rock ) else if( mat == Material.rock )
this.setStepSound( Block.soundTypeStone ); this.setStepSound( Block.soundTypeStone );
else if ( mat == Material.wood ) else if( mat == Material.wood )
this.setStepSound( Block.soundTypeWood ); this.setStepSound( Block.soundTypeWood );
else else
this.setStepSound( Block.soundTypeMetal ); this.setStepSound( Block.soundTypeMetal );
@@ -126,6 +129,12 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
this.featureSubName = subName; this.featureSubName = subName;
} }
// update Block value.
private void setTileProvider( boolean b )
{
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" );
}
@Override @Override
public String toString() public String toString()
{ {
@@ -139,6 +148,28 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
info.updateIcons( i, i, i, i, i, i ); info.updateIcons( i, i, i, i, i, i );
} }
@SideOnly( Side.CLIENT )
public BlockRenderInfo getRendererInstance()
{
if( this.renderInfo != null )
return this.renderInfo;
try
{
return this.renderInfo = new BlockRenderInfo( this.getRenderer().newInstance() );
}
catch( Throwable t )
{
throw new RuntimeException( t );
}
}
@SideOnly( Side.CLIENT )
protected Class<? extends BaseBlockRender> getRenderer()
{
return BaseBlockRender.class;
}
public IIcon unmappedGetIcon( IBlockAccess w, int x, int y, int z, int s ) public IIcon unmappedGetIcon( IBlockAccess w, int x, int y, int z, int s )
{ {
return super.getIcon( w, x, y, z, s ); return super.getIcon( w, x, y, z, s );
@@ -146,16 +177,17 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
protected void setTileEntity( Class<? extends TileEntity> c ) protected void setTileEntity( Class<? extends TileEntity> c )
{ {
this.tileEntityType = c;
AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) ); AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) );
GameRegistry.registerTileEntity( this.tileEntityType = c, this.featureFullName ); GameRegistry.registerTileEntity( this.tileEntityType, this.featureFullName );
this.isInventory = IInventory.class.isAssignableFrom( c ); this.isInventory = IInventory.class.isAssignableFrom( c );
this.setTileProvider( this.hasBlockTileEntity() ); this.setTileProvider( this.hasBlockTileEntity() );
} }
// update Block value. public boolean hasBlockTileEntity()
private void setTileProvider( boolean b )
{ {
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" ); return this.tileEntityType != null;
} }
protected void setFeature( EnumSet<AEFeature> f ) protected void setFeature( EnumSet<AEFeature> f )
@@ -203,7 +235,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata ) public IIcon getIcon( int direction, int metadata )
{ {
if ( this.renderIcon != null ) if( this.renderIcon != null )
return this.renderIcon; return this.renderIcon;
return this.getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) ); return this.getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
@@ -216,20 +248,20 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
ICustomCollision collisionHandler = null; ICustomCollision collisionHandler = null;
if ( this instanceof ICustomCollision ) if( this instanceof ICustomCollision )
collisionHandler = ( ICustomCollision ) this; collisionHandler = (ICustomCollision) this;
else else
{ {
AEBaseTile te = this.getTileEntity( w, x, y, z ); AEBaseTile te = this.getTileEntity( w, x, y, z );
if ( te instanceof ICustomCollision ) if( te instanceof ICustomCollision )
collisionHandler = ( ICustomCollision ) te; collisionHandler = (ICustomCollision) te;
} }
if ( collisionHandler != null && bb != null ) if( collisionHandler != null && bb != null )
{ {
List<AxisAlignedBB> tmp = new ArrayList<AxisAlignedBB>(); List<AxisAlignedBB> tmp = new ArrayList<AxisAlignedBB>();
collisionHandler.addCollidingBlockToList( w, x, y, z, bb, tmp, e ); collisionHandler.addCollidingBlockToList( w, x, y, z, bb, tmp, e );
for ( AxisAlignedBB b : tmp ) for( AxisAlignedBB b : tmp )
{ {
b.minX += x; b.minX += x;
b.minY += y; b.minY += y;
@@ -237,7 +269,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
b.maxX += x; b.maxX += x;
b.maxY += y; b.maxY += y;
b.maxZ += z; b.maxZ += z;
if ( bb.intersectsWith( b ) ) if( bb.intersectsWith( b ) )
out.add( b ); out.add( b );
} }
} }
@@ -252,18 +284,18 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
ICustomCollision collisionHandler = null; ICustomCollision collisionHandler = null;
AxisAlignedBB b = null; AxisAlignedBB b = null;
if ( this instanceof ICustomCollision ) if( this instanceof ICustomCollision )
collisionHandler = ( ICustomCollision ) this; collisionHandler = (ICustomCollision) this;
else else
{ {
AEBaseTile te = this.getTileEntity( w, x, y, z ); AEBaseTile te = this.getTileEntity( w, x, y, z );
if ( te instanceof ICustomCollision ) if( te instanceof ICustomCollision )
collisionHandler = ( ICustomCollision ) te; collisionHandler = (ICustomCollision) te;
} }
if ( collisionHandler != null ) if( collisionHandler != null )
{ {
if ( Platform.isClient() ) if( Platform.isClient() )
{ {
EntityPlayer player = Minecraft.getMinecraft().thePlayer; EntityPlayer player = Minecraft.getMinecraft().thePlayer;
LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) ); LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
@@ -273,22 +305,22 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
double lastDist = 0; double lastDist = 0;
for ( AxisAlignedBB bb : bbs ) for( AxisAlignedBB bb : bbs )
{ {
this.setBlockBounds( ( float ) bb.minX, ( float ) bb.minY, ( float ) bb.minZ, ( float ) bb.maxX, ( float ) bb.maxY, ( float ) bb.maxZ ); this.setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, ld.a, ld.b ); MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, ld.a, ld.b );
this.setBlockBounds( 0, 0, 0, 1, 1, 1 ); this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
if ( r != null ) if( r != null )
{ {
double xLen = ( ld.a.xCoord - r.hitVec.xCoord ); double xLen = ( ld.a.xCoord - r.hitVec.xCoord );
double yLen = ( ld.a.yCoord - r.hitVec.yCoord ); double yLen = ( ld.a.yCoord - r.hitVec.yCoord );
double zLen = ( ld.a.zCoord - r.hitVec.zCoord ); double zLen = ( ld.a.zCoord - r.hitVec.zCoord );
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen; double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
if ( br == null || lastDist > thisDist ) if( br == null || lastDist > thisDist )
{ {
lastDist = thisDist; lastDist = thisDist;
br = bb; br = bb;
@@ -296,16 +328,16 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
} }
} }
if ( br != null ) if( br != null )
{ {
br.setBounds( br.minX + x, br.minY + y, br.minZ + z, br.maxX + x, br.maxY + y, br.maxZ + z ); br.setBounds( br.minX + x, br.minY + y, br.minZ + z, br.maxX + x, br.maxY + y, br.maxZ + z );
return br; return br;
} }
} }
for ( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ) ) for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ) )
{ {
if ( b == null ) if( b == null )
b = bx; b = bx;
else else
{ {
@@ -338,38 +370,38 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
ICustomCollision collisionHandler = null; ICustomCollision collisionHandler = null;
if ( this instanceof ICustomCollision ) if( this instanceof ICustomCollision )
collisionHandler = ( ICustomCollision ) this; collisionHandler = (ICustomCollision) this;
else else
{ {
AEBaseTile te = this.getTileEntity( w, x, y, z ); AEBaseTile te = this.getTileEntity( w, x, y, z );
if ( te instanceof ICustomCollision ) if( te instanceof ICustomCollision )
collisionHandler = ( ICustomCollision ) te; collisionHandler = (ICustomCollision) te;
} }
if ( collisionHandler != null ) if( collisionHandler != null )
{ {
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true ); Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
MovingObjectPosition br = null; MovingObjectPosition br = null;
double lastDist = 0; double lastDist = 0;
for ( AxisAlignedBB bb : bbs ) for( AxisAlignedBB bb : bbs )
{ {
this.setBlockBounds( ( float ) bb.minX, ( float ) bb.minY, ( float ) bb.minZ, ( float ) bb.maxX, ( float ) bb.maxY, ( float ) bb.maxZ ); this.setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, a, b ); MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, a, b );
this.setBlockBounds( 0, 0, 0, 1, 1, 1 ); this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
if ( r != null ) if( r != null )
{ {
double xLen = ( a.xCoord - r.hitVec.xCoord ); double xLen = ( a.xCoord - r.hitVec.xCoord );
double yLen = ( a.yCoord - r.hitVec.yCoord ); double yLen = ( a.yCoord - r.hitVec.yCoord );
double zLen = ( a.zCoord - r.hitVec.zCoord ); double zLen = ( a.zCoord - r.hitVec.zCoord );
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen; double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
if ( br == null || lastDist > thisDist ) if( br == null || lastDist > thisDist )
{ {
lastDist = thisDist; lastDist = thisDist;
br = r; br = r;
@@ -377,7 +409,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
} }
} }
if ( br != null ) if( br != null )
{ {
return br; return br;
} }
@@ -391,37 +423,37 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
@Override @Override
final public boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ ) final public boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{ {
if ( player != null ) if( player != null )
{ {
ItemStack is = player.inventory.getCurrentItem(); ItemStack is = player.inventory.getCurrentItem();
if ( is != null ) if( is != null )
{ {
if ( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() ) if( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() )
{ {
Block id = w.getBlock( x, y, z ); Block id = w.getBlock( x, y, z );
if ( id != null ) if( id != null )
{ {
AEBaseTile tile = this.getTileEntity( w, x, y, z ); AEBaseTile tile = this.getTileEntity( w, x, y, z );
ItemStack[] drops = Platform.getBlockDrops( w, x, y, z ); ItemStack[] drops = Platform.getBlockDrops( w, x, y, z );
if ( tile == null ) if( tile == null )
return false; return false;
if ( tile instanceof TileCableBus || tile instanceof TileSkyChest ) if( tile instanceof TileCableBus || tile instanceof TileSkyChest )
return false; return false;
ItemStack op = new ItemStack( this ); ItemStack op = new ItemStack( this );
for ( ItemStack ol : drops ) for( ItemStack ol : drops )
{ {
if ( Platform.isSameItemType( ol, op ) ) if( Platform.isSameItemType( ol, op ) )
{ {
NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM ); NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM );
if ( tag != null ) if( tag != null )
ol.setTagCompound( tag ); ol.setTagCompound( tag );
} }
} }
if ( id.removedByPlayer( w, player, x, y, z, false ) ) if( id.removedByPlayer( w, player, x, y, z, false ) )
{ {
List<ItemStack> l = Lists.newArrayList( drops ); List<ItemStack> l = Lists.newArrayList( drops );
Platform.spawnDrops( w, x, y, z, l ); Platform.spawnDrops( w, x, y, z, l );
@@ -431,17 +463,17 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
return false; return false;
} }
if ( is.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus ) ) if( is.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus ) )
{ {
IMemoryCard memoryCard = ( IMemoryCard ) is.getItem(); IMemoryCard memoryCard = (IMemoryCard) is.getItem();
if ( player.isSneaking() ) if( player.isSneaking() )
{ {
AEBaseTile t = this.getTileEntity( w, x, y, z ); AEBaseTile t = this.getTileEntity( w, x, y, z );
if ( t != null ) if( t != null )
{ {
String name = this.getUnlocalizedName(); String name = this.getUnlocalizedName();
NBTTagCompound data = t.downloadSettings( SettingsFrom.MEMORY_CARD ); NBTTagCompound data = t.downloadSettings( SettingsFrom.MEMORY_CARD );
if ( data != null ) if( data != null )
{ {
memoryCard.setMemoryCardContents( is, name, data ); memoryCard.setMemoryCardContents( is, name, data );
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
@@ -453,7 +485,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
String name = memoryCard.getSettingsName( is ); String name = memoryCard.getSettingsName( is );
NBTTagCompound data = memoryCard.getData( is ); NBTTagCompound data = memoryCard.getData( is );
if ( this.getUnlocalizedName().equals( name ) ) if( this.getUnlocalizedName().equals( name ) )
{ {
AEBaseTile t = this.getTileEntity( w, x, y, z ); AEBaseTile t = this.getTileEntity( w, x, y, z );
t.uploadSettings( SettingsFrom.MEMORY_CARD, data ); t.uploadSettings( SettingsFrom.MEMORY_CARD, data );
@@ -478,11 +510,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
@Override @Override
public void onBlockPlacedBy( World w, int x, int y, int z, EntityLivingBase player, ItemStack is ) public void onBlockPlacedBy( World w, int x, int y, int z, EntityLivingBase player, ItemStack is )
{ {
if ( is.hasDisplayName() ) if( is.hasDisplayName() )
{ {
TileEntity te = this.getTileEntity( w, x, y, z ); TileEntity te = this.getTileEntity( w, x, y, z );
if ( te instanceof AEBaseTile ) if( te instanceof AEBaseTile )
( ( AEBaseTile ) w.getTileEntity( x, y, z ) ).setName( is.getDisplayName() ); ( (AEBaseTile) w.getTileEntity( x, y, z ) ).setName( is.getDisplayName() );
} }
} }
@@ -504,8 +536,8 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
public int getComparatorInputOverride( World w, int x, int y, int z, int s ) public int getComparatorInputOverride( World w, int x, int y, int z, int s )
{ {
TileEntity te = this.getTileEntity( w, x, y, z ); TileEntity te = this.getTileEntity( w, x, y, z );
if ( te instanceof IInventory ) if( te instanceof IInventory )
return Container.calcRedstoneFromInventory( ( IInventory ) te ); return Container.calcRedstoneFromInventory( (IInventory) te );
return 0; return 0;
} }
@@ -544,18 +576,18 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
IOrientable rotatable = null; IOrientable rotatable = null;
if ( this.hasBlockTileEntity() ) if( this.hasBlockTileEntity() )
{ {
rotatable = ( AEBaseTile ) this.getTileEntity( w, x, y, z ); rotatable = (AEBaseTile) this.getTileEntity( w, x, y, z );
} }
else if ( this instanceof IOrientableBlock ) else if( this instanceof IOrientableBlock )
{ {
rotatable = ( ( IOrientableBlock ) this ).getOrientable( w, x, y, z ); rotatable = ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
} }
if ( rotatable != null && rotatable.canBeRotated() ) if( rotatable != null && rotatable.canBeRotated() )
{ {
if ( this.hasCustomRotation() ) if( this.hasCustomRotation() )
{ {
this.customRotateBlock( rotatable, axis ); this.customRotateBlock( rotatable, axis );
return true; return true;
@@ -565,12 +597,12 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
ForgeDirection forward = rotatable.getForward(); ForgeDirection forward = rotatable.getForward();
ForgeDirection up = rotatable.getUp(); ForgeDirection up = rotatable.getUp();
for ( int rs = 0; rs < 4; rs++ ) for( int rs = 0; rs < 4; rs++ )
{ {
forward = Platform.rotateAround( forward, axis ); forward = Platform.rotateAround( forward, axis );
up = Platform.rotateAround( up, axis ); up = Platform.rotateAround( up, axis );
if ( this.isValidOrientation( w, x, y, z, forward, up ) ) if( this.isValidOrientation( w, x, y, z, forward, up ) )
{ {
rotatable.setOrientation( forward, up ); rotatable.setOrientation( forward, up );
return true; return true;
@@ -600,10 +632,10 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
@Override @Override
final public ForgeDirection[] getValidRotations( World w, int x, int y, int z ) final public ForgeDirection[] getValidRotations( World w, int x, int y, int z )
{ {
if ( this.hasBlockTileEntity() ) if( this.hasBlockTileEntity() )
{ {
AEBaseTile obj = this.getTileEntity( w, x, y, z ); AEBaseTile obj = this.getTileEntity( w, x, y, z );
if ( obj != null && obj.canBeRotated() ) if( obj != null && obj.canBeRotated() )
{ {
return ForgeDirection.VALID_DIRECTIONS; return ForgeDirection.VALID_DIRECTIONS;
} }
@@ -617,13 +649,13 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
TileEntity te = this.getTileEntity( world, x, y, z ); TileEntity te = this.getTileEntity( world, x, y, z );
if ( te instanceof IColorableTile ) if( te instanceof IColorableTile )
{ {
IColorableTile ct = ( IColorableTile ) te; IColorableTile ct = (IColorableTile) te;
AEColor c = ct.getColor(); AEColor c = ct.getColor();
AEColor newColor = AEColor.values()[colour]; AEColor newColor = AEColor.values()[colour];
if ( c != newColor ) if( c != newColor )
{ {
ct.recolourBlock( side, newColor, null ); ct.recolourBlock( side, newColor, null );
return true; return true;
@@ -634,42 +666,25 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
return super.recolourBlock( world, x, y, z, side, colour ); return super.recolourBlock( world, x, y, z, side, colour );
} }
@SideOnly( Side.CLIENT )
public BlockRenderInfo getRendererInstance()
{
if ( this.renderInfo != null )
return this.renderInfo;
try
{
return this.renderInfo = new BlockRenderInfo( this.getRenderer().newInstance() );
}
catch ( Throwable t )
{
throw new RuntimeException( t );
}
}
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
private FlippableIcon optionalIcon( IIconRegister ir, String Name, IIcon substitute ) private FlippableIcon optionalIcon( IIconRegister ir, String Name, IIcon substitute )
{ {
// if the input is an flippable IIcon find the original. // if the input is an flippable IIcon find the original.
while ( substitute instanceof FlippableIcon ) while( substitute instanceof FlippableIcon )
substitute = ( ( FlippableIcon ) substitute ).getOriginal(); substitute = ( (FlippableIcon) substitute ).getOriginal();
if ( substitute != null ) if( substitute != null )
{ {
try try
{ {
ResourceLocation resLoc = new ResourceLocation( Name ); ResourceLocation resLoc = new ResourceLocation( Name );
resLoc = new ResourceLocation( resLoc.getResourceDomain(), String.format( "%s/%s%s", "textures/blocks", resLoc = new ResourceLocation( resLoc.getResourceDomain(), String.format( "%s/%s%s", "textures/blocks", resLoc.getResourcePath(), ".png" ) );
resLoc.getResourcePath(), ".png" ) );
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc ); IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
if ( res != null ) if( res != null )
return new FlippableIcon( ir.registerIcon( Name ) ); return new FlippableIcon( ir.registerIcon( Name ) );
} }
catch ( Throwable e ) catch( Throwable e )
{ {
return new FlippableIcon( substitute ); return new FlippableIcon( substitute );
} }
@@ -678,12 +693,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
return new FlippableIcon( ir.registerIcon( Name ) ); return new FlippableIcon( ir.registerIcon( Name ) );
} }
@SideOnly( Side.CLIENT )
protected Class<? extends BaseBlockRender> getRenderer()
{
return BaseBlockRender.class;
}
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks ) public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{ {
@@ -694,16 +703,16 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
IOrientable ori = null; IOrientable ori = null;
if ( this.hasBlockTileEntity() ) if( this.hasBlockTileEntity() )
{ {
ori = ( AEBaseTile ) this.getTileEntity( w, x, y, z ); ori = (AEBaseTile) this.getTileEntity( w, x, y, z );
} }
else if ( this instanceof IOrientableBlock ) else if( this instanceof IOrientableBlock )
{ {
ori = ( ( IOrientableBlock ) this ).getOrientable( w, x, y, z ); ori = ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
} }
if ( ori != null && ori.canBeRotated() ) if( ori != null && ori.canBeRotated() )
{ {
return this.mapRotation( ori, ForgeDirection.getOrientation( s ) ).ordinal(); return this.mapRotation( ori, ForgeDirection.getOrientation( s ) ).ordinal();
} }
@@ -711,19 +720,15 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
return s; return s;
} }
public boolean hasBlockTileEntity() @Nullable
{
return this.tileEntityType != null;
}
public <T extends TileEntity> T getTileEntity( IBlockAccess w, int x, int y, int z ) public <T extends TileEntity> T getTileEntity( IBlockAccess w, int x, int y, int z )
{ {
if ( !this.hasBlockTileEntity() ) if( !this.hasBlockTileEntity() )
return null; return null;
TileEntity te = w.getTileEntity( x, y, z ); TileEntity te = w.getTileEntity( x, y, z );
if ( this.tileEntityType.isInstance( te ) ) if( this.tileEntityType.isInstance( te ) )
return ( T ) te; return (T) te;
return null; return null;
} }
@@ -741,30 +746,30 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
ForgeDirection up = ori.getUp(); ForgeDirection up = ori.getUp();
ForgeDirection west = ForgeDirection.UNKNOWN; ForgeDirection west = ForgeDirection.UNKNOWN;
if ( forward == null || up == null ) if( forward == null || up == null )
return dir; return dir;
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY; int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ; int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX; int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
for ( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS ) for( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS )
if ( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z ) if( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
west = dx; west = dx;
if ( dir == forward ) if( dir == forward )
return ForgeDirection.SOUTH; return ForgeDirection.SOUTH;
if ( dir == forward.getOpposite() ) if( dir == forward.getOpposite() )
return ForgeDirection.NORTH; return ForgeDirection.NORTH;
if ( dir == up ) if( dir == up )
return ForgeDirection.UP; return ForgeDirection.UP;
if ( dir == up.getOpposite() ) if( dir == up.getOpposite() )
return ForgeDirection.DOWN; return ForgeDirection.DOWN;
if ( dir == west ) if( dir == west )
return ForgeDirection.WEST; return ForgeDirection.WEST;
if ( dir == west.getOpposite() ) if( dir == west.getOpposite() )
return ForgeDirection.EAST; return ForgeDirection.EAST;
return ForgeDirection.UNKNOWN; return ForgeDirection.UNKNOWN;
@@ -784,17 +789,24 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
@Override @Override
final public TileEntity createNewTileEntity( World var1, int var2 ) final public TileEntity createNewTileEntity( World var1, int var2 )
{ {
if ( this.hasBlockTileEntity() ) if( this.hasBlockTileEntity() )
{ {
try try
{ {
return this.tileEntityType.newInstance(); return this.tileEntityType.newInstance();
} }
catch ( Throwable e ) catch( InstantiationException e )
{ {
e.printStackTrace();
throw new RuntimeException( e );
}
catch( IllegalAccessException e )
{
e.printStackTrace();
throw new RuntimeException( e ); throw new RuntimeException( e );
} }
} }
return null; return null;
} }
@@ -802,10 +814,10 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
public void breakBlock( World w, int x, int y, int z, Block a, int b ) public void breakBlock( World w, int x, int y, int z, Block a, int b )
{ {
AEBaseTile te = this.getTileEntity( w, x, y, z ); AEBaseTile te = this.getTileEntity( w, x, y, z );
if ( te != null ) if( te != null )
{ {
ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
if ( te.dropItems() ) if( te.dropItems() )
te.getDrops( w, x, y, z, drops ); te.getDrops( w, x, y, z, drops );
else else
te.getNoDrops( w, x, y, z, drops ); te.getNoDrops( w, x, y, z, drops );
@@ -815,7 +827,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
} }
super.breakBlock( w, x, y, z, a, b ); super.breakBlock( w, x, y, z, a, b );
if ( te != null ) if( te != null )
w.setTileEntity( x, y, z, null ); w.setTileEntity( x, y, z, null );
} }
File diff suppressed because it is too large Load Diff
@@ -57,8 +57,8 @@ public class AppEngRenderItem extends RenderItem
{ {
if ( is != null ) if ( is != null )
{ {
float ScaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f; float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
float RScaleFactor = 1.0f / ScaleFactor; float inverseScaleFactor = 1.0f / scaleFactor;
int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1; int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;
boolean unicodeFlag = par1FontRenderer.getUnicodeFlag(); boolean unicodeFlag = par1FontRenderer.getUnicodeFlag();
@@ -93,9 +93,9 @@ public class AppEngRenderItem extends RenderItem
GL11.glDisable( GL11.GL_LIGHTING ); GL11.glDisable( GL11.GL_LIGHTING );
GL11.glDisable( GL11.GL_DEPTH_TEST ); GL11.glDisable( GL11.GL_DEPTH_TEST );
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glScaled( ScaleFactor, ScaleFactor, ScaleFactor ); GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
int X = (int) (((float) par4 + offset + 16.0f - par1FontRenderer.getStringWidth( var6 ) * ScaleFactor) * RScaleFactor); int X = (int) (((float) par4 + offset + 16.0f - par1FontRenderer.getStringWidth( var6 ) * scaleFactor) * inverseScaleFactor);
int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * ScaleFactor) * RScaleFactor); int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
par1FontRenderer.drawStringWithShadow( var6, X, Y, 16777215 ); par1FontRenderer.drawStringWithShadow( var6, X, Y, 16777215 );
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glEnable( GL11.GL_LIGHTING ); GL11.glEnable( GL11.GL_LIGHTING );
@@ -103,8 +103,7 @@ public class AppEngRenderItem extends RenderItem
} }
long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize; long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize;
if ( amount > 999999999999L ) amount = Math.max( amount, 999999999999L );
amount = 999999999999L;
if ( amount != 0 ) if ( amount != 0 )
{ {
@@ -156,9 +155,9 @@ public class AppEngRenderItem extends RenderItem
GL11.glDisable( GL11.GL_LIGHTING ); GL11.glDisable( GL11.GL_LIGHTING );
GL11.glDisable( GL11.GL_DEPTH_TEST ); GL11.glDisable( GL11.GL_DEPTH_TEST );
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glScaled( ScaleFactor, ScaleFactor, ScaleFactor ); GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
int X = (int) (((float) par4 + offset + 16.0f - par1FontRenderer.getStringWidth( var6 ) * ScaleFactor) * RScaleFactor); int X = (int) (((float) par4 + offset + 16.0f - par1FontRenderer.getStringWidth( var6 ) * scaleFactor) * inverseScaleFactor);
int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * ScaleFactor) * RScaleFactor); int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
par1FontRenderer.drawStringWithShadow( var6, X, Y, 16777215 ); par1FontRenderer.drawStringWithShadow( var6, X, Y, 16777215 );
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glEnable( GL11.GL_LIGHTING ); GL11.glEnable( GL11.GL_LIGHTING );
@@ -22,6 +22,8 @@ package appeng.client.render;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.EnumSet; import java.util.EnumSet;
import javax.annotation.Nullable;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -432,6 +434,7 @@ public class BaseBlockRender
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
} }
@Nullable
public IOrientable getOrientable( AEBaseBlock block, IBlockAccess w, int x, int y, int z ) public IOrientable getOrientable( AEBaseBlock block, IBlockAccess w, int x, int y, int z )
{ {
if ( block.hasBlockTileEntity() ) if ( block.hasBlockTileEntity() )
@@ -102,6 +102,7 @@ public class RenderBlockInscriber extends BaseBlockRender
BlockInscriber blk = (BlockInscriber) block; BlockInscriber blk = (BlockInscriber) block;
IOrientable te = this.getOrientable( block, world, x, y, z ); IOrientable te = this.getOrientable( block, world, x, y, z );
if ( te == null ) return false;
ForgeDirection fdy = te.getUp(); ForgeDirection fdy = te.getUp();
ForgeDirection fdz = te.getForward(); ForgeDirection fdz = te.getForward();
@@ -40,10 +40,9 @@ public class RenderBlockInterface extends BaseBlockRender
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer) public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
{ {
TileInterface ti = block.getTileEntity( world, x, y, z ); TileInterface ti = block.getTileEntity( world, x, y, z );
BlockRenderInfo info = block.getRendererInstance(); BlockRenderInfo info = block.getRendererInstance();
if ( ti.getForward() != ForgeDirection.UNKNOWN ) if ( ti != null && ti.getForward() != ForgeDirection.UNKNOWN )
{ {
IIcon side = ExtraBlockTextures.BlockInterfaceAlternateArrow.getIcon(); IIcon side = ExtraBlockTextures.BlockInterfaceAlternateArrow.getIcon();
info.setTemporaryRenderIcons( ExtraBlockTextures.BlockInterfaceAlternate.getIcon(), block.getIcon( 0, 0 ), side, side, side, side ); info.setTemporaryRenderIcons( ExtraBlockTextures.BlockInterfaceAlternate.getIcon(), block.getIcon( 0, 0 ), side, side, side, side );
@@ -67,6 +67,8 @@ public class RenderMEChest extends BaseBlockRender
TileChest sp = imb.getTileEntity( world, x, y, z ); TileChest sp = imb.getTileEntity( world, x, y, z );
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 ); renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
if ( sp == null ) return false;
ForgeDirection up = sp.getUp(); ForgeDirection up = sp.getUp();
ForgeDirection forward = sp.getForward(); ForgeDirection forward = sp.getForward();
ForgeDirection west = Platform.crossProduct( forward, up ); ForgeDirection west = Platform.crossProduct( forward, up );
@@ -18,6 +18,7 @@
package appeng.client.render.blocks; package appeng.client.render.blocks;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -32,15 +33,17 @@ import appeng.client.render.BlockRenderInfo;
import appeng.client.texture.ExtraBlockTextures; import appeng.client.texture.ExtraBlockTextures;
import appeng.tile.spatial.TileSpatialPylon; import appeng.tile.spatial.TileSpatialPylon;
public class RenderSpatialPylon extends BaseBlockRender public class RenderSpatialPylon extends BaseBlockRender
{ {
public RenderSpatialPylon() { public RenderSpatialPylon()
{
super( false, 0 ); super( false, 0 );
} }
@Override @Override
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) public void renderInventory( AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj )
{ {
renderer.overrideBlockTexture = ExtraBlockTextures.BlockSpatialPylon_dim.getIcon(); renderer.overrideBlockTexture = ExtraBlockTextures.BlockSpatialPylon_dim.getIcon();
super.renderInventory( block, is, renderer, type, obj ); super.renderInventory( block, is, renderer, type, obj );
@@ -49,28 +52,28 @@ public class RenderSpatialPylon extends BaseBlockRender
} }
@Override @Override
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer) public boolean renderInWorld( AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer )
{ {
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 ); renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
TileSpatialPylon sp = imb.getTileEntity( world, x, y, z ); TileSpatialPylon sp = imb.getTileEntity( world, x, y, z );
int displayBits = sp.getDisplayBits(); int displayBits = ( sp == null ) ? 0 : sp.getDisplayBits();
ForgeDirection ori = ForgeDirection.UNKNOWN; ForgeDirection ori = ForgeDirection.UNKNOWN;
if ( displayBits != 0 ) if( displayBits != 0 )
{ {
if ( (displayBits & sp.DISPLAY_Z) == sp.DISPLAY_X ) if( ( displayBits & sp.DISPLAY_Z ) == sp.DISPLAY_X )
{ {
ori = ForgeDirection.EAST; ori = ForgeDirection.EAST;
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MAX ) if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX )
{ {
renderer.uvRotateEast = 1; renderer.uvRotateEast = 1;
renderer.uvRotateWest = 2; renderer.uvRotateWest = 2;
renderer.uvRotateTop = 2; renderer.uvRotateTop = 2;
renderer.uvRotateBottom = 1; renderer.uvRotateBottom = 1;
} }
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MIN ) else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MIN )
{ {
renderer.uvRotateEast = 2; renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1; renderer.uvRotateWest = 1;
@@ -86,10 +89,10 @@ public class RenderSpatialPylon extends BaseBlockRender
} }
} }
else if ( (displayBits & sp.DISPLAY_Z) == sp.DISPLAY_Y ) else if( ( displayBits & sp.DISPLAY_Z ) == sp.DISPLAY_Y )
{ {
ori = ForgeDirection.UP; ori = ForgeDirection.UP;
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MAX ) if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX )
{ {
renderer.uvRotateNorth = 3; renderer.uvRotateNorth = 3;
renderer.uvRotateSouth = 3; renderer.uvRotateSouth = 3;
@@ -98,15 +101,15 @@ public class RenderSpatialPylon extends BaseBlockRender
} }
} }
else if ( (displayBits & sp.DISPLAY_Z) == sp.DISPLAY_Z ) else if( ( displayBits & sp.DISPLAY_Z ) == sp.DISPLAY_Z )
{ {
ori = ForgeDirection.NORTH; ori = ForgeDirection.NORTH;
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MAX ) if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX )
{ {
renderer.uvRotateSouth = 1; renderer.uvRotateSouth = 1;
renderer.uvRotateNorth = 2; renderer.uvRotateNorth = 2;
} }
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MIN ) else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MIN )
{ {
renderer.uvRotateNorth = 1; renderer.uvRotateNorth = 1;
renderer.uvRotateSouth = 2; renderer.uvRotateSouth = 2;
@@ -122,33 +125,23 @@ public class RenderSpatialPylon extends BaseBlockRender
BlockRenderInfo bri = imb.getRendererInstance(); BlockRenderInfo bri = imb.getRendererInstance();
bri.setTemporaryRenderIcon( null ); bri.setTemporaryRenderIcon( null );
bri.setTemporaryRenderIcons( this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.UP ), bri.setTemporaryRenderIcons( this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.UP ), this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.DOWN ), this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.SOUTH ), this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.NORTH ), this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.EAST ), this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.WEST ) );
this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.DOWN ),
this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.SOUTH ),
this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.NORTH ),
this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.EAST ),
this.getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.WEST ) );
boolean r = renderer.renderStandardBlock( imb, x, y, z ); boolean r = renderer.renderStandardBlock( imb, x, y, z );
if ( (displayBits & sp.DISPLAY_POWERED_ENABLED) == sp.DISPLAY_POWERED_ENABLED ) if( ( displayBits & sp.DISPLAY_POWERED_ENABLED ) == sp.DISPLAY_POWERED_ENABLED )
{ {
int bn = 15; int bn = 15;
Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
Tessellator.instance.setColorOpaque_I( 0xffffff ); Tessellator.instance.setColorOpaque_I( 0xffffff );
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
this.renderFace( x, y, z, imb, this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, d ), renderer, d ); this.renderFace( x, y, z, imb, this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, d ), renderer, d );
} }
else else
{ {
bri.setTemporaryRenderIcon( null ); bri.setTemporaryRenderIcon( null );
bri.setTemporaryRenderIcons( this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.UP ), bri.setTemporaryRenderIcons( this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.UP ), this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.DOWN ), this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.SOUTH ), this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.NORTH ), this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.EAST ), this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.WEST ) );
this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.DOWN ),
this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.SOUTH ),
this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.NORTH ),
this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.EAST ),
this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.WEST ) );
renderer.renderStandardBlock( imb, x, y, z ); renderer.renderStandardBlock( imb, x, y, z );
} }
@@ -169,38 +162,38 @@ public class RenderSpatialPylon extends BaseBlockRender
return result; return result;
} }
private IIcon getBlockTextureFromSideOutside(AEBaseBlock blk, TileSpatialPylon sp, int displayBits, ForgeDirection ori, ForgeDirection dir) private IIcon getBlockTextureFromSideOutside( AEBaseBlock blk, TileSpatialPylon sp, int displayBits, ForgeDirection ori, ForgeDirection dir )
{ {
if ( ori == dir || ori.getOpposite() == dir ) if( ori == dir || ori.getOpposite() == dir )
return blk.getRendererInstance().getTexture( dir ); return blk.getRendererInstance().getTexture( dir );
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_MIDDLE ) if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_MIDDLE )
return ExtraBlockTextures.BlockSpatialPylonC.getIcon(); return ExtraBlockTextures.BlockSpatialPylonC.getIcon();
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MIN ) else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MIN )
return ExtraBlockTextures.BlockSpatialPylonE.getIcon(); return ExtraBlockTextures.BlockSpatialPylonE.getIcon();
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MAX ) else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX )
return ExtraBlockTextures.BlockSpatialPylonE.getIcon(); return ExtraBlockTextures.BlockSpatialPylonE.getIcon();
return blk.getIcon( 0, 0 ); return blk.getIcon( 0, 0 );
} }
private IIcon getBlockTextureFromSideInside(AEBaseBlock blk, TileSpatialPylon sp, int displayBits, ForgeDirection ori, ForgeDirection dir) private IIcon getBlockTextureFromSideInside( AEBaseBlock blk, TileSpatialPylon sp, int displayBits, ForgeDirection ori, ForgeDirection dir )
{ {
boolean good = (displayBits & sp.DISPLAY_ENABLED) == sp.DISPLAY_ENABLED; boolean good = ( displayBits & sp.DISPLAY_ENABLED ) == sp.DISPLAY_ENABLED;
if ( ori == dir || ori.getOpposite() == dir ) if( ori == dir || ori.getOpposite() == dir )
return good ? ExtraBlockTextures.BlockSpatialPylon_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylon_red.getIcon(); return good ? ExtraBlockTextures.BlockSpatialPylon_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylon_red.getIcon();
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_MIDDLE ) if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_MIDDLE )
return good ? ExtraBlockTextures.BlockSpatialPylonC_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonC_red.getIcon(); return good ? ExtraBlockTextures.BlockSpatialPylonC_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonC_red.getIcon();
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MIN ) else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MIN )
return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon(); return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon();
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_END_MAX ) else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX )
return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon(); return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon();
return blk.getIcon( 0, 0 ); return blk.getIcon( 0, 0 );
@@ -21,6 +21,7 @@ package appeng.tile.storage;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -114,7 +115,8 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
this.mySrc = new MachineSource( this ); this.mySrc = new MachineSource( this );
this.lastRedstoneState = YesNo.UNDECIDED; this.lastRedstoneState = YesNo.UNDECIDED;
this.upgrades = new BlockUpgradeInventory( this.getBlockType(), this, 3 ); final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get();
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, 3 );
} }
@TileEvent( TileEventType.WORLD_NBT_WRITE ) @TileEvent( TileEventType.WORLD_NBT_WRITE )
File diff suppressed because it is too large Load Diff