2015-08-18 20:40:55 -04:00
package team.chisel.client.render ;
2015-04-22 21:04:40 -04:00
2015-08-18 20:40:55 -04:00
import team.chisel.Chisel ;
2015-08-25 22:06:38 -04:00
import team.chisel.ctmlib.CTM ;
import team.chisel.ctmlib.TextureSubmap ;
2015-08-18 20:40:55 -04:00
import team.chisel.init.ChiselBlocks ;
2015-04-22 21:04:40 -04:00
import net.minecraft.block.Block ;
import net.minecraft.client.renderer.texture.IIconRegister ;
import net.minecraft.util.IIcon ;
import net.minecraft.world.IBlockAccess ;
2015-07-15 00:35:00 -04:00
import com.google.common.base.Optional ;
2015-06-03 17:43:03 -04:00
2015-08-25 22:06:38 -04:00
import static team.chisel.ctmlib.Dir.* ;
2015-04-26 21:46:18 -04:00
import cpw.mods.fml.relauncher.Side ;
import cpw.mods.fml.relauncher.SideOnly ;
2015-08-06 00:00:22 -04:00
2015-05-13 13:19:24 -04:00
public class SubmapManagerFakeController extends SubmapManagerBase {
2015-04-22 21:04:40 -04:00
private TextureSubmap map ;
private CTM ctm = CTM . getInstance ();
2015-06-21 22:28:46 -04:00
private int meta ;
2015-08-06 00:00:22 -04:00
private String texturePath ;
2015-06-30 02:14:36 -07:00
2015-08-06 00:00:22 -04:00
public SubmapManagerFakeController ( int meta , String texture ) {
ctm . disableObscuredFaceCheck = Optional . of ( true );
this . meta = meta ;
texturePath = texture ;
}
2015-04-22 21:04:40 -04:00
2015-06-21 22:28:46 -04:00
public SubmapManagerFakeController ( int meta ) {
2015-07-15 00:35:00 -04:00
ctm . disableObscuredFaceCheck = Optional . of ( true );
2015-06-21 22:28:46 -04:00
this . meta = meta ;
2015-04-22 21:04:40 -04:00
}
@Override
public IIcon getIcon ( int side , int meta ) {
2015-04-23 17:31:25 -04:00
return map . getSubIcon ( 0 , 0 );
2015-04-22 21:04:40 -04:00
}
@Override
2015-08-06 00:00:22 -04:00
public IIcon getIcon ( IBlockAccess world , int x , int y , int z , int side ) {
2015-06-21 22:28:46 -04:00
ctm . buildConnectionMap ( world , x , y , z , side , ChiselBlocks . futura , meta );
2015-06-30 01:53:28 -07:00
if ( ctm . connectedAnd ( TOP , TOP_RIGHT , RIGHT , BOTTOM_RIGHT , BOTTOM , BOTTOM_LEFT , LEFT , TOP_LEFT )) {
2015-04-23 17:31:25 -04:00
return map . getSubIcon ( 1 , 1 );
2015-04-22 21:04:40 -04:00
} else if ( ctm . connectedAnd ( TOP , BOTTOM )) {
2015-04-23 17:31:25 -04:00
return map . getSubIcon ( 0 , 1 );
2015-04-22 21:04:40 -04:00
} else if ( ctm . connectedAnd ( LEFT , RIGHT )) {
2015-04-23 17:31:25 -04:00
return map . getSubIcon ( 1 , 0 );
2015-04-22 21:04:40 -04:00
} else {
2015-04-23 17:31:25 -04:00
return map . getSubIcon ( 0 , 0 );
2015-04-22 21:04:40 -04:00
}
}
@Override
2015-04-26 21:46:18 -04:00
@SideOnly ( Side . CLIENT )
2015-04-22 21:04:40 -04:00
public void registerIcons ( String modName , Block block , IIconRegister register ) {
2015-06-30 01:53:28 -07:00
2015-08-06 00:00:22 -04:00
if ( texturePath != null ) {
map = new TextureSubmap ( register . registerIcon ( modName + ":" + texturePath ), 2 , 2 );
} else {
Chisel . logger . info ( "SubmapManagerFakeController was called on block " + block . getUnlocalizedName () + " without declaring texture, using a default texture instead." );
map = new TextureSubmap ( register . registerIcon ( modName + ":futura/WIP/controller" ), 2 , 2 );
}
2015-04-22 21:04:40 -04:00
}
}