2013-12-27 23:59:59 +01:00
|
|
|
package appeng.block.networking;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2014-01-29 04:10:23 +01:00
|
|
|
import net.minecraft.block.Block;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.Entity;
|
2013-12-28 21:54:05 +01:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.item.Item;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.util.IIcon;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.api.parts.PartItemStack;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.SelectedPart;
|
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.BaseBlockRender;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.client.render.BusRenderHelper;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.render.blocks.RendererCableBus;
|
2014-02-09 02:34:52 +01:00
|
|
|
import appeng.client.texture.ExtraTextures;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.core.AEConfig;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.Api;
|
|
|
|
import appeng.core.AppEng;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.core.CommonHelper;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
import appeng.integration.abstraction.IFMP;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.parts.ICableBusContainer;
|
|
|
|
import appeng.parts.NullCableBusContainer;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.tile.AEBaseTile;
|
|
|
|
import appeng.tile.networking.TileCableBus;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.tile.networking.TileCableBusTESR;
|
2014-01-28 20:27:22 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class BlockCableBus extends AEBaseBlock
|
|
|
|
{
|
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
static private ICableBusContainer nullCB = new NullCableBusContainer();
|
2014-05-05 02:51:05 +02:00
|
|
|
static public Class<? extends TileEntity> noTesrTile;
|
|
|
|
static public Class<? extends TileEntity> tesrTile;
|
|
|
|
|
|
|
|
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.isInstance( te ) )
|
|
|
|
return (T) te;
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2014-01-20 17:41:37 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public BlockCableBus() {
|
|
|
|
super( BlockCableBus.class, Material.glass );
|
|
|
|
setfeature( EnumSet.of( AEFeature.Core ) );
|
|
|
|
setLightOpacity( 0 );
|
|
|
|
isFullSize = isOpaque = false;
|
|
|
|
}
|
|
|
|
|
2014-05-05 02:51:05 +02:00
|
|
|
@Override
|
|
|
|
public int getRenderBlockPass()
|
|
|
|
{
|
|
|
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canRenderInPass(int pass)
|
|
|
|
{
|
|
|
|
BusRenderHelper.instance.setPass( pass );
|
|
|
|
|
|
|
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return pass == 0;
|
|
|
|
}
|
|
|
|
|
2013-12-28 21:54:05 +01:00
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
|
2013-12-28 21:54:05 +01:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return cb( world, x, y, z ).isLadder( entity );
|
2013-12-28 21:54:05 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
2014-03-27 04:27:14 +01:00
|
|
|
{
|
|
|
|
return 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)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-03-27 04:27:14 +01:00
|
|
|
return cb( world, x, y, z ).recolourBlock( side, colour, who );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
Block block = world.getBlock( x, y, z );
|
2014-01-29 04:10:23 +01:00
|
|
|
if ( block != null && block != this )
|
|
|
|
{
|
|
|
|
return block.getLightValue( world, x, y, z );
|
|
|
|
}
|
|
|
|
if ( block == null )
|
|
|
|
return 0;
|
2014-01-20 17:41:37 +01:00
|
|
|
return cb( world, x, y, z ).getLightValue();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
|
|
|
|
SelectedPart sp = cb( world, x, y, z ).selectPart( v3 );
|
2014-01-20 17:41:37 +01:00
|
|
|
|
|
|
|
if ( sp.part != null )
|
2014-02-23 23:50:53 +01:00
|
|
|
return sp.part.getItemStack( PartItemStack.Pick );
|
2014-01-20 17:41:37 +01:00
|
|
|
else if ( sp.facade != null )
|
|
|
|
return sp.facade.getItemStack();
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return cb( world, x, y, z ).isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
if ( player.capabilities.isCreativeMode )
|
|
|
|
{
|
|
|
|
AEBaseTile tile = getTileEntity( world, x, y, z );
|
|
|
|
if ( tile != null )
|
|
|
|
tile.dropItems = false;
|
|
|
|
// maybe ray trace?
|
|
|
|
}
|
2014-02-09 02:34:52 +01:00
|
|
|
return super.removedByPlayer( world, player, x, y, z );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return getIcon( s, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public IIcon getIcon(int direction, int metadata)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
IIcon i = super.getIcon( direction, metadata );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( i != null )
|
|
|
|
return i;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
return ExtraTextures.BlockQuartzGlassB.getIcon();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Class<? extends BaseBlockRender> getRenderer()
|
|
|
|
{
|
|
|
|
return RendererCableBus.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void registerBlockIcons(IIconRegister iconRegistry)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canProvidePower()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public boolean isSideSolid(IBlockAccess w, int x, int y, int z, ForgeDirection side)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return cb( w, x, y, z ).isSolidOnSide( side );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void onNeighborBlockChange(World w, int x, int y, int z, Block meh)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
cb( w, x, y, z ).onNeighborChanged();
|
|
|
|
}
|
|
|
|
|
2014-01-01 07:30:52 +01:00
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public Item getItemDropped(int i, Random r, int k)
|
2014-01-01 07:30:52 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
return null;
|
2014-01-01 07:30:52 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
|
|
|
{
|
|
|
|
return cb( w, x, y, z ).activate( player, w.getWorldVec3Pool().getVecFromPool( hitX, hitY, hitZ ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity e)
|
|
|
|
{
|
|
|
|
cb( w, x, y, z ).onEntityCollision( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canConnectRedstone(IBlockAccess w, int x, int y, int z, int side)
|
|
|
|
{
|
2014-01-06 07:54:51 +01:00
|
|
|
switch (side)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
case 4:
|
|
|
|
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
|
|
|
|
case 0:
|
|
|
|
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
|
|
|
|
case 1:
|
|
|
|
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
|
|
|
|
case 2:
|
|
|
|
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
|
|
|
|
case 3:
|
|
|
|
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
|
|
|
|
}
|
|
|
|
return false;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
|
|
|
|
{
|
2014-01-06 07:54:51 +01:00
|
|
|
return cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
|
|
|
|
{
|
2014-01-06 07:54:51 +01:00
|
|
|
return cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setupTile()
|
|
|
|
{
|
2014-05-05 02:51:05 +02:00
|
|
|
setTileEntiy( noTesrTile = Api.instance.partHelper.getCombinedInstance( TileCableBus.class.getName() ) );
|
2014-01-28 20:27:22 +01:00
|
|
|
if ( Platform.isClient() )
|
2014-05-05 02:51:05 +02:00
|
|
|
{
|
|
|
|
tesrTile = Api.instance.partHelper.getCombinedInstance( TileCableBusTESR.class.getName() );
|
|
|
|
CommonHelper.proxy.bindTileEntitySpecialRenderer( tesrTile, this );
|
|
|
|
}
|
2014-01-20 17:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private ICableBusContainer cb(IBlockAccess w, int x, int y, int z)
|
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
TileEntity te = w.getTileEntity( x, y, z );
|
2014-01-20 17:41:37 +01:00
|
|
|
if ( te instanceof TileCableBus )
|
|
|
|
return ((TileCableBus) te).cb;
|
|
|
|
|
|
|
|
if ( AppEng.instance.isIntegrationEnabled( "FMP" ) )
|
|
|
|
return ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te );
|
|
|
|
|
|
|
|
return nullCB;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-03-22 22:51:37 +01:00
|
|
|
/**
|
|
|
|
* Immibis MB Support.
|
|
|
|
*/
|
|
|
|
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|