2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
package appeng.block.misc;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
|
|
|
import java.util.Collections;
|
2014-03-02 09:35:11 +01:00
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-11-28 04:36:46 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
2015-05-09 12:18:43 +02:00
|
|
|
import appeng.block.AEBaseTileBlock;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.client.render.blocks.RenderBlockSkyCompass;
|
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
import appeng.helpers.ICustomCollision;
|
|
|
|
import appeng.tile.misc.TileSkyCompass;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2015-05-09 12:18:43 +02:00
|
|
|
public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public BlockSkyCompass()
|
|
|
|
{
|
2015-04-04 00:42:19 +02:00
|
|
|
super( Material.iron );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setTileEntity( TileSkyCompass.class );
|
|
|
|
this.isOpaque = this.isFullSize = false;
|
|
|
|
this.lightOpacity = 0;
|
2015-04-04 01:26:35 +02:00
|
|
|
this.setFeature( EnumSet.of( AEFeature.MeteoriteCompass ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-16 18:03:07 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
|
|
|
protected RenderBlockSkyCompass getRenderer()
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-09-16 18:03:07 +02:00
|
|
|
return new RenderBlockSkyCompass();
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2015-09-25 23:10:56 +02:00
|
|
|
public IIcon getIcon( final int direction, final int metadata )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return Blocks.iron_block.getIcon( direction, metadata );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void registerBlockIcons( final IIconRegister iconRegistry )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
// :P
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public boolean isValidOrientation( final World w, final int x, final int y, final int z, final ForgeDirection forward, final ForgeDirection up )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final TileSkyCompass sc = this.getTileEntity( w, x, y, z );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( sc != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return false;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
return this.canPlaceAt( w, x, y, z, forward.getOpposite() );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
private boolean canPlaceAt( final World w, final int x, final int y, final int z, final ForgeDirection dir )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
|
|
|
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void onNeighborBlockChange( final World w, final int x, final int y, final int z, final Block id )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final TileSkyCompass sc = this.getTileEntity( w, x, y, z );
|
|
|
|
final ForgeDirection up = sc.getForward();
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.dropTorch( w, x, y, z );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
private void dropTorch( final World w, final int x, final int y, final int z )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
|
|
|
w.func_147480_a( x, y, z, true );
|
|
|
|
// w.destroyBlock( x, y, z, true );
|
|
|
|
w.markBlockForUpdate( x, y, z );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public boolean canPlaceBlockAt( final World w, final int x, final int y, final int z )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.canPlaceAt( w, x, y, z, dir ) )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return true;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
return false;
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final int x, final int y, final int z, final Entity e, final boolean isVisual )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final TileSkyCompass tile = this.getTileEntity( w, x, y, z );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( tile != null )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final ForgeDirection forward = tile.getForward();
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
double minX = 0;
|
|
|
|
double minY = 0;
|
|
|
|
double minZ = 0;
|
|
|
|
double maxX = 1;
|
|
|
|
double maxY = 1;
|
|
|
|
double maxZ = 1;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
switch( forward )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
case DOWN:
|
|
|
|
minZ = minX = 5.0 / 16.0;
|
|
|
|
maxZ = maxX = 11.0 / 16.0;
|
|
|
|
maxY = 1.0;
|
|
|
|
minY = 14.0 / 16.0;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
minZ = minY = 5.0 / 16.0;
|
|
|
|
maxZ = maxY = 11.0 / 16.0;
|
|
|
|
maxX = 2.0 / 16.0;
|
|
|
|
minX = 0.0;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
minY = minX = 5.0 / 16.0;
|
|
|
|
maxY = maxX = 11.0 / 16.0;
|
|
|
|
maxZ = 1.0;
|
|
|
|
minZ = 14.0 / 16.0;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
minY = minX = 5.0 / 16.0;
|
|
|
|
maxY = maxX = 11.0 / 16.0;
|
|
|
|
maxZ = 2.0 / 16.0;
|
|
|
|
minZ = 0.0;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
minZ = minX = 5.0 / 16.0;
|
|
|
|
maxZ = maxX = 11.0 / 16.0;
|
|
|
|
maxY = 2.0 / 16.0;
|
|
|
|
minY = 0.0;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
minZ = minY = 5.0 / 16.0;
|
|
|
|
maxZ = maxY = 11.0 / 16.0;
|
|
|
|
maxX = 1.0;
|
|
|
|
minX = 14.0 / 16.0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
2014-11-28 04:36:46 +01:00
|
|
|
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void addCollidingBlockToList( final World w, final int x, final int y, final int z, final AxisAlignedBB bb, final List out, final Entity e )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|