Merge pull request #1127 from thatsIch/b-1118-api-crash
Fixes #1118 Does not crash with invalid ItemStacks anymore
This commit is contained in:
@@ -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 )
|
||||||
|
|||||||
@@ -18,12 +18,15 @@
|
|||||||
|
|
||||||
package appeng.util.item;
|
package appeng.util.item;
|
||||||
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
@@ -40,50 +43,40 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
import appeng.api.config.FuzzyMode;
|
import appeng.api.config.FuzzyMode;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IAEStack;
|
|
||||||
import appeng.api.storage.data.IAETagCompound;
|
import appeng.api.storage.data.IAETagCompound;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack, Comparable<AEItemStack>
|
public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack, Comparable<AEItemStack>
|
||||||
{
|
{
|
||||||
|
|
||||||
AEItemDef def;
|
AEItemDef def;
|
||||||
|
|
||||||
@Override
|
private AEItemStack( AEItemStack is )
|
||||||
public String toString()
|
|
||||||
{
|
{
|
||||||
return this.getItemStack().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(IAEItemStack option)
|
|
||||||
{
|
|
||||||
if ( option == null )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// if ( priority < ((AEItemStack) option).priority )
|
|
||||||
// priority = ((AEItemStack) option).priority;
|
|
||||||
|
|
||||||
this.incStackSize( option.getStackSize() );
|
|
||||||
this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() );
|
|
||||||
this.setCraftable( this.isCraftable() || option.isCraftable() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private AEItemStack(AEItemStack is) {
|
|
||||||
this.def = is.def;
|
this.def = is.def;
|
||||||
this.stackSize = is.stackSize;
|
this.stackSize = is.stackSize;
|
||||||
this.setCraftable( is.isCraftable() );
|
this.setCraftable( is.isCraftable() );
|
||||||
this.setCountRequestable( is.getCountRequestable() );
|
this.setCountRequestable( is.getCountRequestable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private AEItemStack( ItemStack is ) {
|
private AEItemStack( ItemStack is )
|
||||||
if ( is == null )
|
{
|
||||||
throw new RuntimeException( "Invalid Itemstack." );
|
if( is == null )
|
||||||
|
{
|
||||||
|
throw new InvalidParameterException( "null is not a valid ItemStack for AEItemStack." );
|
||||||
|
}
|
||||||
|
|
||||||
this.def = new AEItemDef( is.getItem() );
|
final Item item = is.getItem();
|
||||||
|
if( item == null )
|
||||||
|
{
|
||||||
|
throw new InvalidParameterException( "Contained item is null, thus not a valid ItemStack for AEItemStack." );
|
||||||
|
}
|
||||||
|
|
||||||
if ( this.def.item == null )
|
this.def = new AEItemDef( item );
|
||||||
throw new RuntimeException( "This ItemStack is bad, it has a null item." );
|
|
||||||
|
if( this.def.item == null )
|
||||||
|
throw new InvalidParameterException( "This ItemStack is bad, it has a null item." );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prevent an Item from changing the damage value on me... Either, this or a core mod.
|
* Prevent an Item from changing the damage value on me... Either, this or a core mod.
|
||||||
@@ -103,7 +96,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
this.def.maxDamage = is.getMaxDamage();
|
this.def.maxDamage = is.getMaxDamage();
|
||||||
|
|
||||||
NBTTagCompound tagCompound = is.getTagCompound();
|
NBTTagCompound tagCompound = is.getTagCompound();
|
||||||
if ( tagCompound != null )
|
if( tagCompound != null )
|
||||||
this.def.tagCompound = (AESharedNBT) AESharedNBT.getSharedTagCompound( tagCompound, is );
|
this.def.tagCompound = (AESharedNBT) AESharedNBT.getSharedTagCompound( tagCompound, is );
|
||||||
|
|
||||||
this.stackSize = is.stackSize;
|
this.stackSize = is.stackSize;
|
||||||
@@ -114,74 +107,93 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
this.def.isOre = OreHelper.INSTANCE.isOre( is );
|
this.def.isOre = OreHelper.INSTANCE.isOre( is );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IAEItemStack loadItemStackFromNBT( NBTTagCompound i )
|
||||||
|
{
|
||||||
|
if( i == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ItemStack itemstack = ItemStack.loadItemStackFromNBT( i );
|
||||||
|
if( itemstack == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
AEItemStack item = AEItemStack.create( itemstack );
|
||||||
|
// item.priority = i.getInteger( "Priority" );
|
||||||
|
item.stackSize = i.getLong( "Cnt" );
|
||||||
|
item.setCountRequestable( i.getLong( "Req" ) );
|
||||||
|
item.setCraftable( i.getBoolean( "Craft" ) );
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static AEItemStack create( ItemStack stack )
|
public static AEItemStack create( ItemStack stack )
|
||||||
{
|
{
|
||||||
|
if( stack == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new AEItemStack( stack );
|
return new AEItemStack( stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IAEStack<IAEItemStack> create( IAEStack<IAEItemStack> stack )
|
public static IAEItemStack loadItemStackFromPacket( ByteBuf data ) throws IOException
|
||||||
{
|
{
|
||||||
return stack.copy();
|
byte mask = data.readByte();
|
||||||
}
|
// byte PriorityType = (byte) (mask & 0x03);
|
||||||
|
byte StackType = (byte) ( ( mask & 0x0C ) >> 2 );
|
||||||
|
byte CountReqType = (byte) ( ( mask & 0x30 ) >> 4 );
|
||||||
|
boolean isCraftable = ( mask & 0x40 ) > 0;
|
||||||
|
boolean hasTagCompound = ( mask & 0x80 ) > 0;
|
||||||
|
|
||||||
@Override
|
// don't send this...
|
||||||
public Item getItem()
|
NBTTagCompound d = new NBTTagCompound();
|
||||||
{
|
|
||||||
return this.def.item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
d.setShort( "id", data.readShort() );
|
||||||
public boolean equals(Object ia)
|
d.setShort( "Damage", data.readShort() );
|
||||||
{
|
d.setByte( "Count", (byte) 0 );
|
||||||
if ( ia instanceof AEItemStack )
|
|
||||||
|
if( hasTagCompound )
|
||||||
{
|
{
|
||||||
return ((AEItemStack) ia).def.equals( this.def );// && def.tagCompound == ((AEItemStack) ia).def.tagCompound;
|
int len = data.readInt();
|
||||||
|
|
||||||
|
byte[] bd = new byte[len];
|
||||||
|
data.readBytes( bd );
|
||||||
|
|
||||||
|
ByteArrayInputStream di = new ByteArrayInputStream( bd );
|
||||||
|
d.setTag( "tag", CompressedStreamTools.read( new DataInputStream( di ) ) );
|
||||||
}
|
}
|
||||||
else if ( ia instanceof ItemStack )
|
|
||||||
{
|
|
||||||
ItemStack is = (ItemStack) ia;
|
|
||||||
|
|
||||||
if ( is.getItem() == this.def.item && is.getItemDamage() == this.def.damageValue )
|
// long priority = getPacketValue( PriorityType, data );
|
||||||
{
|
long stackSize = getPacketValue( StackType, data );
|
||||||
NBTTagCompound ta = this.def.tagCompound;
|
long countRequestable = getPacketValue( CountReqType, data );
|
||||||
NBTTagCompound tb = is.getTagCompound();
|
|
||||||
if ( ta == tb )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if ( (ta == null && tb == null) || (ta != null && ta.hasNoTags() && tb == null) || (tb != null && tb.hasNoTags() && ta == null)
|
ItemStack itemstack = ItemStack.loadItemStackFromNBT( d );
|
||||||
|| (ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags()) )
|
if( itemstack == null )
|
||||||
return true;
|
return null;
|
||||||
|
|
||||||
if ( (ta == null && tb != null) || (ta != null && tb == null) )
|
AEItemStack item = AEItemStack.create( itemstack );
|
||||||
return false;
|
// item.priority = (int) priority;
|
||||||
|
item.stackSize = stackSize;
|
||||||
if ( AESharedNBT.isShared( tb ) )
|
item.setCountRequestable( countRequestable );
|
||||||
return ta == tb;
|
item.setCraftable( isCraftable );
|
||||||
|
return item;
|
||||||
return Platform.NBTEqualityTest( ta, tb );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack()
|
public void add( IAEItemStack option )
|
||||||
{
|
{
|
||||||
ItemStack is = new ItemStack( this.def.item, (int) Math.min( Integer.MAX_VALUE, this.stackSize ), this.def.damageValue );
|
if( option == null )
|
||||||
if ( this.def.tagCompound != null )
|
return;
|
||||||
is.setTagCompound( this.def.tagCompound.getNBTTagCompoundCopy() );
|
|
||||||
|
|
||||||
return is;
|
// if ( priority < ((AEItemStack) option).priority )
|
||||||
|
// priority = ((AEItemStack) option).priority;
|
||||||
|
|
||||||
|
this.incStackSize( option.getStackSize() );
|
||||||
|
this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() );
|
||||||
|
this.setCraftable( this.isCraftable() || option.isCraftable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAEItemStack copy()
|
public void writeToNBT( NBTTagCompound i )
|
||||||
{
|
|
||||||
return new AEItemStack( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound i)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Mojang Fucked this over ; GC Optimization - Ugly Yes, but it saves a lot in the memory department.
|
* Mojang Fucked this over ; GC Optimization - Ugly Yes, but it saves a lot in the memory department.
|
||||||
@@ -224,247 +236,63 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
*/
|
*/
|
||||||
i.setShort( "Damage", (short) this.def.damageValue );
|
i.setShort( "Damage", (short) this.def.damageValue );
|
||||||
|
|
||||||
if ( this.def.tagCompound != null )
|
if( this.def.tagCompound != null )
|
||||||
i.setTag( "tag", this.def.tagCompound );
|
i.setTag( "tag", this.def.tagCompound );
|
||||||
else
|
else
|
||||||
i.removeTag( "tag" );
|
i.removeTag( "tag" );
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IAEItemStack loadItemStackFromNBT(NBTTagCompound i)
|
|
||||||
{
|
|
||||||
if ( i == null )
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack itemstack = ItemStack.loadItemStackFromNBT( i );
|
|
||||||
if ( itemstack == null )
|
|
||||||
return null;
|
|
||||||
|
|
||||||
AEItemStack item = AEItemStack.create( itemstack );
|
|
||||||
// item.priority = i.getInteger( "Priority" );
|
|
||||||
item.stackSize = i.getLong( "Cnt" );
|
|
||||||
item.setCountRequestable( i.getLong( "Req" ) );
|
|
||||||
item.setCraftable( i.getBoolean( "Craft" ) );
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTagCompound()
|
public boolean fuzzyComparison( Object st, FuzzyMode Mode )
|
||||||
{
|
{
|
||||||
return this.def.tagCompound != null;
|
if( st instanceof IAEItemStack )
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return this.def.myHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(AEItemStack b)
|
|
||||||
{
|
|
||||||
int id = this.def.itemID - b.def.itemID;
|
|
||||||
if (id != 0)
|
|
||||||
return id;
|
|
||||||
|
|
||||||
int damageValue = this.def.damageValue - b.def.damageValue ;
|
|
||||||
if (damageValue != 0)
|
|
||||||
return damageValue;
|
|
||||||
|
|
||||||
int displayDamage = this.def.displayDamage - b.def.displayDamage;
|
|
||||||
if (displayDamage != 0)
|
|
||||||
return displayDamage;
|
|
||||||
|
|
||||||
return (this.def.tagCompound == b.def.tagCompound) ? 0 : this.compareNBT( b.def );
|
|
||||||
}
|
|
||||||
|
|
||||||
private int compareNBT(AEItemDef b)
|
|
||||||
{
|
|
||||||
int nbt = this.compare( (this.def.tagCompound == null ? 0 : this.def.tagCompound.getHash()), (b.tagCompound == null ? 0 : b.tagCompound.getHash()) );
|
|
||||||
if ( nbt == 0 )
|
|
||||||
return this.compare( System.identityHashCode( this.def.tagCompound ), System.identityHashCode( b.tagCompound ) );
|
|
||||||
return nbt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int compare(int l, int m)
|
|
||||||
{
|
|
||||||
return l < m ? -1 : (l > m ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public List getToolTip()
|
|
||||||
{
|
|
||||||
if ( this.def.tooltip != null )
|
|
||||||
return this.def.tooltip;
|
|
||||||
|
|
||||||
return this.def.tooltip = Platform.getTooltip( this.getItemStack() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public String getDisplayName()
|
|
||||||
{
|
|
||||||
if ( this.def.displayName != null )
|
|
||||||
return this.def.displayName;
|
|
||||||
|
|
||||||
return this.def.displayName = Platform.getItemDisplayName( this.getItemStack() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public String getModID()
|
|
||||||
{
|
|
||||||
if ( this.def.uniqueID != null )
|
|
||||||
return this.getModName( this.def.uniqueID );
|
|
||||||
|
|
||||||
return this.getModName( this.def.uniqueID = GameRegistry.findUniqueIdentifierFor( this.def.item ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getModName(UniqueIdentifier uniqueIdentifier)
|
|
||||||
{
|
|
||||||
if ( uniqueIdentifier == null )
|
|
||||||
return "** Null";
|
|
||||||
|
|
||||||
return uniqueIdentifier.modId == null ? "** Null" : uniqueIdentifier.modId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IAEItemStack empty()
|
|
||||||
{
|
|
||||||
IAEItemStack dup = this.copy();
|
|
||||||
dup.reset();
|
|
||||||
return dup;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemDamage()
|
|
||||||
{
|
|
||||||
return this.def.damageValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void writeIdentity(ByteBuf i) throws IOException
|
|
||||||
{
|
|
||||||
i.writeShort( Item.itemRegistry.getIDForObject( this.def.item ) );
|
|
||||||
i.writeShort( this.getItemDamage() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void readNBT(ByteBuf i) throws IOException
|
|
||||||
{
|
|
||||||
if ( this.hasTagCompound() )
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream data = new DataOutputStream( bytes );
|
|
||||||
|
|
||||||
CompressedStreamTools.write( (NBTTagCompound) this.getTagCompound(), data );
|
|
||||||
|
|
||||||
byte[] tagBytes = bytes.toByteArray();
|
|
||||||
int size = tagBytes.length;
|
|
||||||
|
|
||||||
i.writeInt( size );
|
|
||||||
i.writeBytes( tagBytes );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IAEItemStack loadItemStackFromPacket(ByteBuf data) throws IOException
|
|
||||||
{
|
|
||||||
byte mask = data.readByte();
|
|
||||||
// byte PriorityType = (byte) (mask & 0x03);
|
|
||||||
byte StackType = (byte) ((mask & 0x0C) >> 2);
|
|
||||||
byte CountReqType = (byte) ((mask & 0x30) >> 4);
|
|
||||||
boolean isCraftable = (mask & 0x40) > 0;
|
|
||||||
boolean hasTagCompound = (mask & 0x80) > 0;
|
|
||||||
|
|
||||||
// don't send this...
|
|
||||||
NBTTagCompound d = new NBTTagCompound();
|
|
||||||
|
|
||||||
d.setShort( "id", data.readShort() );
|
|
||||||
d.setShort( "Damage", data.readShort() );
|
|
||||||
d.setByte( "Count", (byte) 0 );
|
|
||||||
|
|
||||||
if ( hasTagCompound )
|
|
||||||
{
|
|
||||||
int len = data.readInt();
|
|
||||||
|
|
||||||
byte[] bd = new byte[len];
|
|
||||||
data.readBytes( bd );
|
|
||||||
|
|
||||||
ByteArrayInputStream di = new ByteArrayInputStream( bd );
|
|
||||||
d.setTag( "tag", CompressedStreamTools.read( new DataInputStream( di ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// long priority = getPacketValue( PriorityType, data );
|
|
||||||
long stackSize = getPacketValue( StackType, data );
|
|
||||||
long countRequestable = getPacketValue( CountReqType, data );
|
|
||||||
|
|
||||||
ItemStack itemstack = ItemStack.loadItemStackFromNBT( d );
|
|
||||||
if ( itemstack == null )
|
|
||||||
return null;
|
|
||||||
|
|
||||||
AEItemStack item = AEItemStack.create( itemstack );
|
|
||||||
// item.priority = (int) priority;
|
|
||||||
item.stackSize = stackSize;
|
|
||||||
item.setCountRequestable( countRequestable );
|
|
||||||
item.setCraftable( isCraftable );
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean sameOre(IAEItemStack is)
|
|
||||||
{
|
|
||||||
return OreHelper.INSTANCE.sameOre( this, is );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean fuzzyComparison(Object st, FuzzyMode Mode)
|
|
||||||
{
|
|
||||||
if ( st instanceof IAEItemStack )
|
|
||||||
{
|
{
|
||||||
IAEItemStack o = (IAEItemStack) st;
|
IAEItemStack o = (IAEItemStack) st;
|
||||||
|
|
||||||
if ( this.sameOre( o ) )
|
if( this.sameOre( o ) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( o.getItem() == this.getItem() )
|
if( o.getItem() == this.getItem() )
|
||||||
{
|
{
|
||||||
if ( this.def.item.isDamageable() )
|
if( this.def.item.isDamageable() )
|
||||||
{
|
{
|
||||||
ItemStack a = this.getItemStack();
|
ItemStack a = this.getItemStack();
|
||||||
ItemStack b = o.getItemStack();
|
ItemStack b = o.getItemStack();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( Mode == FuzzyMode.IGNORE_ALL )
|
if( Mode == FuzzyMode.IGNORE_ALL )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( Mode == FuzzyMode.PERCENT_99 )
|
else if( Mode == FuzzyMode.PERCENT_99 )
|
||||||
{
|
{
|
||||||
return (a.getItemDamageForDisplay() > 1) == (b.getItemDamageForDisplay() > 1);
|
return ( a.getItemDamageForDisplay() > 1 ) == ( b.getItemDamageForDisplay() > 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float APercentDamaged = 1.0f - (float) a.getItemDamageForDisplay() / (float) a.getMaxDamage();
|
float APercentDamaged = 1.0f - (float) a.getItemDamageForDisplay() / (float) a.getMaxDamage();
|
||||||
float BPercentDamaged = 1.0f - (float) b.getItemDamageForDisplay() / (float) b.getMaxDamage();
|
float BPercentDamaged = 1.0f - (float) b.getItemDamageForDisplay() / (float) b.getMaxDamage();
|
||||||
|
|
||||||
return (APercentDamaged > Mode.breakPoint) == (BPercentDamaged > Mode.breakPoint);
|
return ( APercentDamaged > Mode.breakPoint ) == ( BPercentDamaged > Mode.breakPoint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch( Throwable e )
|
||||||
{
|
{
|
||||||
if ( Mode == FuzzyMode.IGNORE_ALL )
|
if( Mode == FuzzyMode.IGNORE_ALL )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( Mode == FuzzyMode.PERCENT_99 )
|
else if( Mode == FuzzyMode.PERCENT_99 )
|
||||||
{
|
{
|
||||||
return (a.getItemDamage() > 1) == (b.getItemDamage() > 1);
|
return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float APercentDamaged = (float) a.getItemDamage() / (float) a.getMaxDamage();
|
float APercentDamaged = (float) a.getItemDamage() / (float) a.getMaxDamage();
|
||||||
float BPercentDamaged = (float) b.getItemDamage() / (float) b.getMaxDamage();
|
float BPercentDamaged = (float) b.getItemDamage() / (float) b.getMaxDamage();
|
||||||
|
|
||||||
return (APercentDamaged > Mode.breakPoint) == (BPercentDamaged > Mode.breakPoint);
|
return ( APercentDamaged > Mode.breakPoint ) == ( BPercentDamaged > Mode.breakPoint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -473,52 +301,52 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( st instanceof ItemStack )
|
if( st instanceof ItemStack )
|
||||||
{
|
{
|
||||||
ItemStack o = (ItemStack) st;
|
ItemStack o = (ItemStack) st;
|
||||||
|
|
||||||
OreHelper.INSTANCE.sameOre( this, o );
|
OreHelper.INSTANCE.sameOre( this, o );
|
||||||
|
|
||||||
if ( o.getItem() == this.getItem() )
|
if( o.getItem() == this.getItem() )
|
||||||
{
|
{
|
||||||
if ( this.def.item.isDamageable() )
|
if( this.def.item.isDamageable() )
|
||||||
{
|
{
|
||||||
ItemStack a = this.getItemStack();
|
ItemStack a = this.getItemStack();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( Mode == FuzzyMode.IGNORE_ALL )
|
if( Mode == FuzzyMode.IGNORE_ALL )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( Mode == FuzzyMode.PERCENT_99 )
|
else if( Mode == FuzzyMode.PERCENT_99 )
|
||||||
{
|
{
|
||||||
return (a.getItemDamageForDisplay() > 1) == (o.getItemDamageForDisplay() > 1);
|
return ( a.getItemDamageForDisplay() > 1 ) == ( o.getItemDamageForDisplay() > 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float APercentDamaged = 1.0f - (float) a.getItemDamageForDisplay() / (float) a.getMaxDamage();
|
float APercentDamaged = 1.0f - (float) a.getItemDamageForDisplay() / (float) a.getMaxDamage();
|
||||||
float BPercentDamaged = 1.0f - (float) o.getItemDamageForDisplay() / (float) o.getMaxDamage();
|
float BPercentDamaged = 1.0f - (float) o.getItemDamageForDisplay() / (float) o.getMaxDamage();
|
||||||
|
|
||||||
return (APercentDamaged > Mode.breakPoint) == (BPercentDamaged > Mode.breakPoint);
|
return ( APercentDamaged > Mode.breakPoint ) == ( BPercentDamaged > Mode.breakPoint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch( Throwable e )
|
||||||
{
|
{
|
||||||
if ( Mode == FuzzyMode.IGNORE_ALL )
|
if( Mode == FuzzyMode.IGNORE_ALL )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( Mode == FuzzyMode.PERCENT_99 )
|
else if( Mode == FuzzyMode.PERCENT_99 )
|
||||||
{
|
{
|
||||||
return (a.getItemDamage() > 1) == (o.getItemDamage() > 1);
|
return ( a.getItemDamage() > 1 ) == ( o.getItemDamage() > 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float APercentDamaged = (float) a.getItemDamage() / (float) a.getMaxDamage();
|
float APercentDamaged = (float) a.getItemDamage() / (float) a.getMaxDamage();
|
||||||
float BPercentDamaged = (float) o.getItemDamage() / (float) o.getMaxDamage();
|
float BPercentDamaged = (float) o.getItemDamage() / (float) o.getMaxDamage();
|
||||||
|
|
||||||
return (APercentDamaged > Mode.breakPoint) == (BPercentDamaged > Mode.breakPoint);
|
return ( APercentDamaged > Mode.breakPoint ) == ( BPercentDamaged > Mode.breakPoint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -530,83 +358,18 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAEItemStack getLow(FuzzyMode fuzzy, boolean ignoreMeta)
|
@Override
|
||||||
|
public IAEItemStack copy()
|
||||||
{
|
{
|
||||||
AEItemStack bottom = new AEItemStack( this );
|
return new AEItemStack( this );
|
||||||
AEItemDef newDef = bottom.def = bottom.def.copy();
|
|
||||||
|
|
||||||
if ( ignoreMeta )
|
|
||||||
{
|
|
||||||
newDef.displayDamage = newDef.damageValue = 0;
|
|
||||||
newDef.reHash();
|
|
||||||
return bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( newDef.item.isDamageable() )
|
|
||||||
{
|
|
||||||
if ( fuzzy == FuzzyMode.IGNORE_ALL )
|
|
||||||
{
|
|
||||||
newDef.displayDamage = 0;
|
|
||||||
}
|
|
||||||
else if ( fuzzy == FuzzyMode.PERCENT_99 )
|
|
||||||
{
|
|
||||||
if ( this.def.damageValue == 0 )
|
|
||||||
newDef.displayDamage = 0;
|
|
||||||
else
|
|
||||||
newDef.displayDamage = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int breakpoint = fuzzy.calculateBreakPoint( this.def.maxDamage );
|
|
||||||
newDef.displayDamage = breakpoint <= this.def.displayDamage ? breakpoint : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
newDef.damageValue = newDef.displayDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
newDef.tagCompound = AEItemDef.LOW_TAG;
|
|
||||||
newDef.reHash();
|
|
||||||
return bottom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAEItemStack getHigh(FuzzyMode fuzzy, boolean ignoreMeta)
|
@Override
|
||||||
|
public IAEItemStack empty()
|
||||||
{
|
{
|
||||||
AEItemStack top = new AEItemStack( this );
|
IAEItemStack dup = this.copy();
|
||||||
AEItemDef newDef = top.def = top.def.copy();
|
dup.reset();
|
||||||
|
return dup;
|
||||||
if ( ignoreMeta )
|
|
||||||
{
|
|
||||||
newDef.displayDamage = newDef.damageValue = Integer.MAX_VALUE;
|
|
||||||
newDef.reHash();
|
|
||||||
return top;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( newDef.item.isDamageable() )
|
|
||||||
{
|
|
||||||
if ( fuzzy == FuzzyMode.IGNORE_ALL )
|
|
||||||
{
|
|
||||||
newDef.displayDamage = this.def.maxDamage + 1;
|
|
||||||
}
|
|
||||||
else if ( fuzzy == FuzzyMode.PERCENT_99 )
|
|
||||||
{
|
|
||||||
if ( this.def.damageValue == 0 )
|
|
||||||
newDef.displayDamage = 0;
|
|
||||||
else
|
|
||||||
newDef.displayDamage = this.def.maxDamage + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int breakpoint = fuzzy.calculateBreakPoint( this.def.maxDamage );
|
|
||||||
newDef.displayDamage = this.def.displayDamage < breakpoint ? breakpoint - 1 : this.def.maxDamage + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
newDef.damageValue = newDef.displayDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
newDef.tagCompound = AEItemDef.HIGH_TAG;
|
|
||||||
newDef.reHash();
|
|
||||||
return top;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -615,24 +378,6 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
return this.def.tagCompound;
|
return this.def.tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSameType(IAEItemStack otherStack)
|
|
||||||
{
|
|
||||||
if ( otherStack == null )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return this.def.equals( ((AEItemStack) otherStack).def );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSameType(ItemStack otherStack)
|
|
||||||
{
|
|
||||||
if ( otherStack == null )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return this.def.isItem( otherStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItem()
|
public boolean isItem()
|
||||||
{
|
{
|
||||||
@@ -651,9 +396,274 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||||||
return StorageChannel.ITEMS;
|
return StorageChannel.ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.def.myHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals( Object ia )
|
||||||
|
{
|
||||||
|
if( ia instanceof AEItemStack )
|
||||||
|
{
|
||||||
|
return ( (AEItemStack) ia ).def.equals( this.def );// && def.tagCompound == ((AEItemStack) ia).def.tagCompound;
|
||||||
|
}
|
||||||
|
else if( ia instanceof ItemStack )
|
||||||
|
{
|
||||||
|
ItemStack is = (ItemStack) ia;
|
||||||
|
|
||||||
|
if( is.getItem() == this.def.item && is.getItemDamage() == this.def.damageValue )
|
||||||
|
{
|
||||||
|
NBTTagCompound ta = this.def.tagCompound;
|
||||||
|
NBTTagCompound tb = is.getTagCompound();
|
||||||
|
if( ta == tb )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( ( ta == null && tb != null ) || ( ta != null && tb == null ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( AESharedNBT.isShared( tb ) )
|
||||||
|
return ta == tb;
|
||||||
|
|
||||||
|
return Platform.NBTEqualityTest( ta, tb );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.getItemStack().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemStack()
|
||||||
|
{
|
||||||
|
ItemStack is = new ItemStack( this.def.item, (int) Math.min( Integer.MAX_VALUE, this.stackSize ), this.def.damageValue );
|
||||||
|
if( this.def.tagCompound != null )
|
||||||
|
is.setTagCompound( this.def.tagCompound.getNBTTagCompoundCopy() );
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item getItem()
|
||||||
|
{
|
||||||
|
return this.def.item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemDamage()
|
||||||
|
{
|
||||||
|
return this.def.damageValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sameOre( IAEItemStack is )
|
||||||
|
{
|
||||||
|
return OreHelper.INSTANCE.sameOre( this, is );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSameType( IAEItemStack otherStack )
|
||||||
|
{
|
||||||
|
if( otherStack == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return this.def.equals( ( (AEItemStack) otherStack ).def );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSameType( ItemStack otherStack )
|
||||||
|
{
|
||||||
|
if( otherStack == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return this.def.isItem( otherStack );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo( AEItemStack b )
|
||||||
|
{
|
||||||
|
int id = this.def.itemID - b.def.itemID;
|
||||||
|
if( id != 0 )
|
||||||
|
return id;
|
||||||
|
|
||||||
|
int damageValue = this.def.damageValue - b.def.damageValue;
|
||||||
|
if( damageValue != 0 )
|
||||||
|
return damageValue;
|
||||||
|
|
||||||
|
int displayDamage = this.def.displayDamage - b.def.displayDamage;
|
||||||
|
if( displayDamage != 0 )
|
||||||
|
return displayDamage;
|
||||||
|
|
||||||
|
return ( this.def.tagCompound == b.def.tagCompound ) ? 0 : this.compareNBT( b.def );
|
||||||
|
}
|
||||||
|
|
||||||
|
private int compareNBT( AEItemDef b )
|
||||||
|
{
|
||||||
|
int nbt = this.compare( ( this.def.tagCompound == null ? 0 : this.def.tagCompound.getHash() ), ( b.tagCompound == null ? 0 : b.tagCompound.getHash() ) );
|
||||||
|
if( nbt == 0 )
|
||||||
|
return this.compare( System.identityHashCode( this.def.tagCompound ), System.identityHashCode( b.tagCompound ) );
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int compare( int l, int m )
|
||||||
|
{
|
||||||
|
return l < m ? -1 : ( l > m ? 1 : 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly( Side.CLIENT )
|
||||||
|
public List getToolTip()
|
||||||
|
{
|
||||||
|
if( this.def.tooltip != null )
|
||||||
|
return this.def.tooltip;
|
||||||
|
|
||||||
|
return this.def.tooltip = Platform.getTooltip( this.getItemStack() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly( Side.CLIENT )
|
||||||
|
public String getDisplayName()
|
||||||
|
{
|
||||||
|
if( this.def.displayName != null )
|
||||||
|
return this.def.displayName;
|
||||||
|
|
||||||
|
return this.def.displayName = Platform.getItemDisplayName( this.getItemStack() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly( Side.CLIENT )
|
||||||
|
public String getModID()
|
||||||
|
{
|
||||||
|
if( this.def.uniqueID != null )
|
||||||
|
return this.getModName( this.def.uniqueID );
|
||||||
|
|
||||||
|
return this.getModName( this.def.uniqueID = GameRegistry.findUniqueIdentifierFor( this.def.item ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getModName( UniqueIdentifier uniqueIdentifier )
|
||||||
|
{
|
||||||
|
if( uniqueIdentifier == null )
|
||||||
|
return "** Null";
|
||||||
|
|
||||||
|
return uniqueIdentifier.modId == null ? "** Null" : uniqueIdentifier.modId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void writeIdentity( ByteBuf i ) throws IOException
|
||||||
|
{
|
||||||
|
i.writeShort( Item.itemRegistry.getIDForObject( this.def.item ) );
|
||||||
|
i.writeShort( this.getItemDamage() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void readNBT( ByteBuf i ) throws IOException
|
||||||
|
{
|
||||||
|
if( this.hasTagCompound() )
|
||||||
|
{
|
||||||
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream data = new DataOutputStream( bytes );
|
||||||
|
|
||||||
|
CompressedStreamTools.write( (NBTTagCompound) this.getTagCompound(), data );
|
||||||
|
|
||||||
|
byte[] tagBytes = bytes.toByteArray();
|
||||||
|
int size = tagBytes.length;
|
||||||
|
|
||||||
|
i.writeInt( size );
|
||||||
|
i.writeBytes( tagBytes );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTagCompound()
|
||||||
|
{
|
||||||
|
return this.def.tagCompound != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAEItemStack getLow( FuzzyMode fuzzy, boolean ignoreMeta )
|
||||||
|
{
|
||||||
|
AEItemStack bottom = new AEItemStack( this );
|
||||||
|
AEItemDef newDef = bottom.def = bottom.def.copy();
|
||||||
|
|
||||||
|
if( ignoreMeta )
|
||||||
|
{
|
||||||
|
newDef.displayDamage = newDef.damageValue = 0;
|
||||||
|
newDef.reHash();
|
||||||
|
return bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( newDef.item.isDamageable() )
|
||||||
|
{
|
||||||
|
if( fuzzy == FuzzyMode.IGNORE_ALL )
|
||||||
|
{
|
||||||
|
newDef.displayDamage = 0;
|
||||||
|
}
|
||||||
|
else if( fuzzy == FuzzyMode.PERCENT_99 )
|
||||||
|
{
|
||||||
|
if( this.def.damageValue == 0 )
|
||||||
|
newDef.displayDamage = 0;
|
||||||
|
else
|
||||||
|
newDef.displayDamage = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int breakpoint = fuzzy.calculateBreakPoint( this.def.maxDamage );
|
||||||
|
newDef.displayDamage = breakpoint <= this.def.displayDamage ? breakpoint : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
newDef.damageValue = newDef.displayDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
newDef.tagCompound = AEItemDef.LOW_TAG;
|
||||||
|
newDef.reHash();
|
||||||
|
return bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAEItemStack getHigh( FuzzyMode fuzzy, boolean ignoreMeta )
|
||||||
|
{
|
||||||
|
AEItemStack top = new AEItemStack( this );
|
||||||
|
AEItemDef newDef = top.def = top.def.copy();
|
||||||
|
|
||||||
|
if( ignoreMeta )
|
||||||
|
{
|
||||||
|
newDef.displayDamage = newDef.damageValue = Integer.MAX_VALUE;
|
||||||
|
newDef.reHash();
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( newDef.item.isDamageable() )
|
||||||
|
{
|
||||||
|
if( fuzzy == FuzzyMode.IGNORE_ALL )
|
||||||
|
{
|
||||||
|
newDef.displayDamage = this.def.maxDamage + 1;
|
||||||
|
}
|
||||||
|
else if( fuzzy == FuzzyMode.PERCENT_99 )
|
||||||
|
{
|
||||||
|
if( this.def.damageValue == 0 )
|
||||||
|
newDef.displayDamage = 0;
|
||||||
|
else
|
||||||
|
newDef.displayDamage = this.def.maxDamage + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int breakpoint = fuzzy.calculateBreakPoint( this.def.maxDamage );
|
||||||
|
newDef.displayDamage = this.def.displayDamage < breakpoint ? breakpoint - 1 : this.def.maxDamage + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
newDef.damageValue = newDef.displayDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
newDef.tagCompound = AEItemDef.HIGH_TAG;
|
||||||
|
newDef.reHash();
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOre()
|
public boolean isOre()
|
||||||
{
|
{
|
||||||
return this.def.isOre != null;
|
return this.def.isOre != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user