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>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.client.texture;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.util.IIcon;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
public class OffsetIcon implements IIcon
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private final float offsetX;
|
|
|
|
private final float offsetY;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-01 21:19:50 +01:00
|
|
|
private final IIcon p;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public OffsetIcon( final IIcon o, final float x, final float y )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
|
|
|
if( o == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-03-23 10:14:35 +01:00
|
|
|
throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-02-03 12:04:13 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.p = o;
|
|
|
|
this.offsetX = x;
|
|
|
|
this.offsetY = y;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public int getIconWidth()
|
|
|
|
{
|
|
|
|
return this.p.getIconWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getIconHeight()
|
|
|
|
{
|
|
|
|
return this.p.getIconHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly( Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
public float getMinU()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.u( 0 - this.offsetX );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
public float getMaxU()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.u( 16 - this.offsetX );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2015-09-25 23:10:56 +02:00
|
|
|
public float getInterpolatedU( final double d0 )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.u( d0 - this.offsetX );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
public float getMinV()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.v( 0 - this.offsetY );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
public float getMaxV()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.v( 16 - this.offsetY );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2015-09-25 23:10:56 +02:00
|
|
|
public float getInterpolatedV( final double d0 )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.v( d0 - this.offsetY );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
public String getIconName()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.p.getIconName();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
private float v( final double d )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return this.p.getInterpolatedV( Math.min( 16.0, Math.max( 0.0, d ) ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
private float u( final double d )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return this.p.getInterpolatedU( Math.min( 16.0, Math.max( 0.0, d ) ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|