Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
@@ -74,29 +75,22 @@ import appeng.transformer.annotations.Integration.Interface;
import appeng.transformer.annotations.Integration.Method;
import appeng.util.Platform;
@Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR")
@Interface( iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR" )
public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
{
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
static public Class<? extends TileEntity> noTesrTile;
static public Class<? extends TileEntity> tesrTile;
/**
* Immibis MB Support.
*/
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
int myColorMultiplier = 0xffffff;
@Override
public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
public BlockCableBus()
{
TileEntity te = w.getTileEntity( x, y, z );
if ( noTesrTile.isInstance( te ) )
return (T) te;
if ( tesrTile != null && tesrTile.isInstance( te ) )
return (T) te;
return null;
}
public BlockCableBus() {
super( BlockCableBus.class, AEGlassMaterial.INSTANCE );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setLightOpacity( 0 );
@@ -104,240 +98,41 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
}
@Override
public int getRenderBlockPass()
{
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return 1;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
{
Object object = this.cb( world, target.blockX, target.blockY, target.blockZ );
if ( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = this.getIcon( p );
if ( ico == null )
continue;
byte b0 = (byte) (Platform.getRandomInt() % 2 == 0 ? 1 : 0);
for (int i1 = 0; i1 < b0; ++i1)
{
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
double d0 = target.blockX + (i1 + 0.5D) / b0;
double d1 = target.blockY + (j1 + 0.5D) / b0;
double d2 = target.blockZ + (k1 + 0.5D) / b0;
double dd0 = target.hitVec.xCoord;
double dd1 = target.hitVec.yCoord;
double dd2 = target.hitVec.zCoord;
EntityDiggingFX fx = (new EntityDiggingFX( world, dd0, dd1, dd2, d0 - target.blockX - 0.5D, d1 - target.blockY
- 0.5D, d2 - target.blockZ - 0.5D, this, 0 )).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
{
Object object = this.cb( world, x, y, z );
if ( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = this.getIcon( p );
if ( ico == null )
continue;
byte b0 = 3;
for (int i1 = 0; i1 < b0; ++i1)
{
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
double d0 = x + (i1 + 0.5D) / b0;
double d1 = y + (j1 + 0.5D) / b0;
double d2 = z + (k1 + 0.5D) / b0;
EntityDiggingFX fx = (new EntityDiggingFX( world, d0, d1, d2, d0 - x - 0.5D, d1 - y - 0.5D, d2 - z
- 0.5D, this, meta )).applyColourMultiplier( x, y, z );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
private IIcon getIcon(IPart p)
{
if ( p == null )
return null;
try
{
IIcon ico = p.getBreakingTexture();
if ( ico != null )
return ico;
}
catch (Throwable t)
{
// nothing.
}
ItemStack is = p.getItemStack( PartItemStack.Network );
if ( is == null || is.getItem() == null )
return null;
return is.getItem().getIcon( is, 0 );
}
@Override
public boolean canRenderInPass(int pass)
{
BusRenderHelper.INSTANCE.setPass( pass );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return true;
return pass == 0;
}
@Override
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return this.cb( world, x, y, z ).isLadder( entity );
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
return this.recolourBlock( world, x, y, z, side, colour, null );
}
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who)
{
try
{
return this.cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
}
catch (Throwable ignored)
{
}
return false;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random r)
public void randomDisplayTick( World world, int x, int y, int z, Random r )
{
this.cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
public void onNeighborBlockChange( World w, int x, int y, int z, Block meh )
{
Block block = world.getBlock( x, y, z );
if ( block != null && block != this )
{
return block.getLightValue( world, x, y, z );
}
if ( block == null )
return 0;
return this.cb( world, x, y, z ).getLightValue();
this.cb( w, x, y, z ).onNeighborChanged();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
public Item getItemDropped( int i, Random r, int k )
{
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
SelectedPart sp = this.cb( world, x, y, z ).selectPart( v3 );
if ( sp.part != null )
return sp.part.getItemStack( PartItemStack.Pick );
else if ( sp.facade != null )
return sp.facade.getItemStack();
return null;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
public int getRenderBlockPass()
{
return this.cb( world, x, y, z ).isEmpty();
}
@SuppressWarnings("deprecation")
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
if ( player.capabilities.isCreativeMode )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
if ( tile != null )
tile.disableDrops();
// maybe ray trace?
}
return super.removedByPlayer( world, player, x, y, z );
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return 1;
return 0;
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
public int colorMultiplier( IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_ )
{
return this.getIcon( s, 0 );
return this.myColorMultiplier;
}
@Override
public IIcon getIcon(int direction, int metadata)
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
{
IIcon i = super.getIcon( direction, metadata );
if ( i != null )
return i;
return ExtraBlockTextures.BlockQuartzGlassB.getIcon();
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererCableBus.class;
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
return this.cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
@@ -347,85 +142,316 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
}
@Override
public boolean isSideSolid(IBlockAccess w, int x, int y, int z, ForgeDirection side)
{
return this.cb( w, x, y, z ).isSolidOnSide( side );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block meh)
{
this.cb( w, x, y, z ).onNeighborChanged();
}
@Override
public void onNeighborChange(IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ)
{
if ( Platform.isServer() )
this.cb( w, x, y, z ).onNeighborChanged();
}
@Override
public Item getItemDropped(int i, Random r, int k)
{
return null;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
return this.cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
}
@Override
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity e)
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity e )
{
this.cb( w, x, y, z ).onEntityCollision( e );
}
@Override
public boolean canConnectRedstone(IBlockAccess w, int x, int y, int z, int side)
{
switch (side)
{
case -1:
case 4:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
case 0:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
case 1:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
case 2:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
case 3:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
}
return false;
}
@Override
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
{
return this.cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
public int isProvidingStrongPower( IBlockAccess w, int x, int y, int z, int side )
{
return this.cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
public int getLightValue( IBlockAccess world, int x, int y, int z )
{
Block block = world.getBlock( x, y, z );
if( block != null && block != this )
{
return block.getLightValue( world, x, y, z );
}
if( block == null )
return 0;
return this.cb( world, x, y, z ).getLightValue();
}
@Override
public boolean isLadder( IBlockAccess world, int x, int y, int z, EntityLivingBase entity )
{
return this.cb( world, x, y, z ).isLadder( entity );
}
@Override
public boolean isSideSolid( IBlockAccess w, int x, int y, int z, ForgeDirection side )
{
return this.cb( w, x, y, z ).isSolidOnSide( side );
}
@Override
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
{
return this.cb( world, x, y, z ).isEmpty();
}
@SuppressWarnings( "deprecation" )
@Override
public boolean removedByPlayer( World world, EntityPlayer player, int x, int y, int z )
{
if( player.capabilities.isCreativeMode )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
if( tile != null )
tile.disableDrops();
// maybe ray trace?
}
return super.removedByPlayer( world, player, x, y, z );
}
@Override
public boolean canConnectRedstone( IBlockAccess w, int x, int y, int z, int side )
{
switch( side )
{
case -1:
case 4:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
case 0:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
case 1:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
case 2:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
case 3:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
}
return false;
}
@Override
public boolean canRenderInPass( int pass )
{
BusRenderHelper.INSTANCE.setPass( pass );
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return true;
return pass == 0;
}
@Override
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z )
{
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
SelectedPart sp = this.cb( world, x, y, z ).selectPart( v3 );
if( sp.part != null )
return sp.part.getItemStack( PartItemStack.Pick );
else if( sp.facade != null )
return sp.facade.getItemStack();
return null;
}
@Override
@SideOnly( Side.CLIENT )
public boolean addHitEffects( World world, MovingObjectPosition target, EffectRenderer effectRenderer )
{
Object object = this.cb( world, target.blockX, target.blockY, target.blockZ );
if( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for( ForgeDirection side : ForgeDirection.values() )
{
IPart p = host.getPart( side );
IIcon ico = this.getIcon( p );
if( ico == null )
continue;
byte b0 = (byte) ( Platform.getRandomInt() % 2 == 0 ? 1 : 0 );
for( int i1 = 0; i1 < b0; ++i1 )
{
for( int j1 = 0; j1 < b0; ++j1 )
{
for( int k1 = 0; k1 < b0; ++k1 )
{
double d0 = target.blockX + ( i1 + 0.5D ) / b0;
double d1 = target.blockY + ( j1 + 0.5D ) / b0;
double d2 = target.blockZ + ( k1 + 0.5D ) / b0;
double dd0 = target.hitVec.xCoord;
double dd1 = target.hitVec.yCoord;
double dd2 = target.hitVec.zCoord;
EntityDiggingFX fx = ( new EntityDiggingFX( world, dd0, dd1, dd2, d0 - target.blockX - 0.5D, d1 - target.blockY - 0.5D, d2 - target.blockZ - 0.5D, this, 0 ) ).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@Override
@SideOnly( Side.CLIENT )
public boolean addDestroyEffects( World world, int x, int y, int z, int meta, EffectRenderer effectRenderer )
{
Object object = this.cb( world, x, y, z );
if( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for( ForgeDirection side : ForgeDirection.values() )
{
IPart p = host.getPart( side );
IIcon ico = this.getIcon( p );
if( ico == null )
continue;
byte b0 = 3;
for( int i1 = 0; i1 < b0; ++i1 )
{
for( int j1 = 0; j1 < b0; ++j1 )
{
for( int k1 = 0; k1 < b0; ++k1 )
{
double d0 = x + ( i1 + 0.5D ) / b0;
double d1 = y + ( j1 + 0.5D ) / b0;
double d2 = z + ( k1 + 0.5D ) / b0;
EntityDiggingFX fx = ( new EntityDiggingFX( world, d0, d1, d2, d0 - x - 0.5D, d1 - y - 0.5D, d2 - z - 0.5D, this, meta ) ).applyColourMultiplier( x, y, z );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@Override
public void onNeighborChange( IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ )
{
if( Platform.isServer() )
this.cb( w, x, y, z ).onNeighborChanged();
}
private IIcon getIcon( IPart p )
{
if( p == null )
return null;
try
{
IIcon ico = p.getBreakingTexture();
if( ico != null )
return ico;
}
catch( Throwable t )
{
// nothing.
}
ItemStack is = p.getItemStack( PartItemStack.Network );
if( is == null || is.getItem() == null )
return null;
return is.getItem().getIcon( is, 0 );
}
private ICableBusContainer cb( IBlockAccess w, int x, int y, int z )
{
TileEntity te = w.getTileEntity( x, y, z );
ICableBusContainer out = null;
if( te instanceof TileCableBus )
out = ( (TileCableBus) te ).cb;
else if( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
out = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getCableContainer( te );
return out == null ? NULL_CABLE_BUS : out;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererCableBus.class;
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
{
return this.getIcon( s, 0 );
}
@Override
public IIcon getIcon( int direction, int metadata )
{
IIcon i = super.getIcon( direction, metadata );
if( i != null )
return i;
return ExtraBlockTextures.BlockQuartzGlassB.getIcon();
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{
return this.cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
}
@Override
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
{
return this.recolourBlock( world, x, y, z, side, colour, null );
}
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who )
{
try
{
return this.cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
}
catch( Throwable ignored )
{
}
return false;
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
// do nothing
}
@Override
public <T extends TileEntity> T getTileEntity( IBlockAccess w, int x, int y, int z )
{
TileEntity te = w.getTileEntity( x, y, z );
if( noTesrTile.isInstance( te ) )
return (T) te;
if( tesrTile != null && tesrTile.isInstance( te ) )
return (T) te;
return null;
}
public void setupTile()
{
this.setTileEntity( noTesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBus.class.getName() ) );
if ( Platform.isClient() )
if( Platform.isClient() )
{
tesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBusTESR.class.getName() );
GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" );
@@ -433,43 +459,15 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
}
}
private ICableBusContainer cb(IBlockAccess w, int x, int y, int z)
{
TileEntity te = w.getTileEntity( x, y, z );
ICableBusContainer out = null;
if ( te instanceof TileCableBus )
out = ((TileCableBus) te).cb;
else if ( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
out = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getCableContainer( te );
return out == null ? NULL_CABLE_BUS : out;
}
/**
* Immibis MB Support.
*/
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
@Override
@Method(iname = "MFR")
public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side)
@Method( iname = "MFR" )
public RedNetConnectionType getConnectionType( World world, int x, int y, int z, ForgeDirection side )
{
return this.cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( ForgeDirection.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
}
int myColorMultiplier = 0xffffff;
public void setRenderColor(int color)
public void setRenderColor( int color )
{
this.myColorMultiplier = color;
}
@Override
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
{
return this.myColorMultiplier;
}
}