2013-12-27 23:59:59 +01:00
|
|
|
package appeng.block.networking;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.entity.Entity;
|
2014-02-04 05:23:14 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.util.IIcon;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.world.World;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.BaseBlockRender;
|
|
|
|
import appeng.client.render.blocks.RenderBlockWireless;
|
|
|
|
import appeng.core.features.AEFeature;
|
2014-02-04 05:23:14 +01:00
|
|
|
import appeng.core.sync.GuiBridge;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.helpers.ICustomCollision;
|
|
|
|
import appeng.tile.networking.TileWireless;
|
2014-02-04 05:23:14 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class BlockWireless extends AEBaseBlock implements ICustomCollision
|
|
|
|
{
|
|
|
|
|
|
|
|
public BlockWireless() {
|
|
|
|
super( BlockWireless.class, Material.glass );
|
|
|
|
setfeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
|
|
|
|
setTileEntiy( TileWireless.class );
|
|
|
|
setLightOpacity( 0 );
|
|
|
|
isFullSize = false;
|
|
|
|
isOpaque = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Class<? extends BaseBlockRender> getRenderer()
|
|
|
|
{
|
|
|
|
return RenderBlockWireless.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public IIcon getIcon(int direction, int metadata)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return super.getIcon( direction, metadata );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-31 18:11:50 +01:00
|
|
|
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
TileWireless tile = getTileEntity( w, x, y, z );
|
|
|
|
if ( tile != null )
|
|
|
|
{
|
|
|
|
ForgeDirection forward = tile.getForward();
|
|
|
|
|
|
|
|
double minX = 0;
|
|
|
|
double minY = 0;
|
|
|
|
double minZ = 0;
|
|
|
|
double maxX = 1;
|
|
|
|
double maxY = 1;
|
|
|
|
double maxZ = 1;
|
|
|
|
|
|
|
|
switch (forward)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
minZ = minX = 3.0 / 16.0;
|
|
|
|
maxZ = maxX = 13.0 / 16.0;
|
|
|
|
maxY = 1.0;
|
|
|
|
minY = 5.0 / 16.0;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
minZ = minY = 3.0 / 16.0;
|
|
|
|
maxZ = maxY = 13.0 / 16.0;
|
|
|
|
maxX = 11.0 / 16.0;
|
|
|
|
minX = 0.0;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
minY = minX = 3.0 / 16.0;
|
|
|
|
maxY = maxX = 13.0 / 16.0;
|
|
|
|
maxZ = 1.0;
|
|
|
|
minZ = 5.0 / 16.0;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
minY = minX = 3.0 / 16.0;
|
|
|
|
maxY = maxX = 13.0 / 16.0;
|
|
|
|
maxZ = 11.0 / 16.0;
|
|
|
|
minZ = 0.0;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
minZ = minX = 3.0 / 16.0;
|
|
|
|
maxZ = maxX = 13.0 / 16.0;
|
|
|
|
maxY = 11.0 / 16.0;
|
|
|
|
minY = 0.0;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
minZ = minY = 3.0 / 16.0;
|
|
|
|
maxZ = maxY = 13.0 / 16.0;
|
|
|
|
maxX = 1.0;
|
|
|
|
minX = 5.0 / 16.0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) } );
|
|
|
|
}
|
|
|
|
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
|
|
|
{
|
|
|
|
TileWireless tile = getTileEntity( w, x, y, z );
|
|
|
|
if ( tile != null )
|
|
|
|
{
|
|
|
|
ForgeDirection forward = tile.getForward();
|
|
|
|
|
|
|
|
double minX = 0;
|
|
|
|
double minY = 0;
|
|
|
|
double minZ = 0;
|
|
|
|
double maxX = 1;
|
|
|
|
double maxY = 1;
|
|
|
|
double maxZ = 1;
|
|
|
|
|
|
|
|
switch (forward)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
minZ = minX = 3.0 / 16.0;
|
|
|
|
maxZ = maxX = 13.0 / 16.0;
|
|
|
|
maxY = 1.0;
|
|
|
|
minY = 5.0 / 16.0;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
minZ = minY = 3.0 / 16.0;
|
|
|
|
maxZ = maxY = 13.0 / 16.0;
|
|
|
|
maxX = 11.0 / 16.0;
|
|
|
|
minX = 0.0;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
minY = minX = 3.0 / 16.0;
|
|
|
|
maxY = maxX = 13.0 / 16.0;
|
|
|
|
maxZ = 1.0;
|
|
|
|
minZ = 5.0 / 16.0;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
minY = minX = 3.0 / 16.0;
|
|
|
|
maxY = maxX = 13.0 / 16.0;
|
|
|
|
maxZ = 11.0 / 16.0;
|
|
|
|
minZ = 0.0;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
minZ = minX = 3.0 / 16.0;
|
|
|
|
maxZ = maxX = 13.0 / 16.0;
|
|
|
|
maxY = 11.0 / 16.0;
|
|
|
|
minY = 0.0;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
minZ = minY = 3.0 / 16.0;
|
|
|
|
maxZ = maxY = 13.0 / 16.0;
|
|
|
|
maxX = 1.0;
|
|
|
|
minX = 5.0 / 16.0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-05 05:59:56 +02:00
|
|
|
out.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
2014-06-05 05:59:56 +02:00
|
|
|
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-02-04 05:23:14 +01:00
|
|
|
@Override
|
|
|
|
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
|
|
|
{
|
|
|
|
if ( p.isSneaking() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
TileWireless tg = getTileEntity( w, x, y, z );
|
|
|
|
if ( tg != null )
|
|
|
|
{
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|