Applied-Energistics-2-tiler.../src/main/java/appeng/client/texture/FlippableIcon.java

127 lines
2.6 KiB
Java
Raw Normal View History

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-09-20 23:22:45 +02:00
package appeng.client.texture;
2014-09-20 23:22:45 +02:00
import net.minecraft.util.IIcon;
2014-09-20 23:22:45 +02:00
public class FlippableIcon implements IIcon
{
protected IIcon original;
boolean flip_u;
boolean flip_v;
public FlippableIcon( IIcon o )
{
2014-09-20 23:22:45 +02:00
if( o == null )
2014-09-20 23:22:45 +02:00
throw new RuntimeException( "Cannot create a wrapper icon with a null icon." );
2014-12-29 15:13:47 +01:00
this.original = o;
this.flip_u = false;
this.flip_v = false;
2014-09-20 23:22:45 +02:00
}
@Override
public int getIconWidth()
{
2014-12-29 15:13:47 +01:00
return this.original.getIconWidth();
2014-09-20 23:22:45 +02:00
}
@Override
public int getIconHeight()
{
2014-12-29 15:13:47 +01:00
return this.original.getIconHeight();
2014-09-20 23:22:45 +02:00
}
@Override
public float getMinU()
{
if( this.flip_u )
2014-12-29 15:13:47 +01:00
return this.original.getMaxU();
return this.original.getMinU();
2014-09-20 23:22:45 +02:00
}
@Override
public float getMaxU()
{
if( this.flip_u )
2014-12-29 15:13:47 +01:00
return this.original.getMinU();
return this.original.getMaxU();
2014-09-20 23:22:45 +02:00
}
@Override
public float getInterpolatedU( double px )
2014-09-20 23:22:45 +02:00
{
if( this.flip_u )
2014-12-29 15:13:47 +01:00
return this.original.getInterpolatedU( 16 - px );
return this.original.getInterpolatedU( px );
2014-09-20 23:22:45 +02:00
}
@Override
public float getMinV()
{
if( this.flip_v )
2014-12-29 15:13:47 +01:00
return this.original.getMaxV();
return this.original.getMinV();
2014-09-20 23:22:45 +02:00
}
@Override
public float getMaxV()
{
if( this.flip_v )
2014-12-29 15:13:47 +01:00
return this.original.getMinV();
return this.original.getMaxV();
2014-09-20 23:22:45 +02:00
}
@Override
public float getInterpolatedV( double px )
2014-09-20 23:22:45 +02:00
{
if( this.flip_v )
2014-12-29 15:13:47 +01:00
return this.original.getInterpolatedV( 16 - px );
return this.original.getInterpolatedV( px );
2014-09-20 23:22:45 +02:00
}
@Override
public String getIconName()
{
2014-12-29 15:13:47 +01:00
return this.original.getIconName();
2014-09-20 23:22:45 +02:00
}
public IIcon getOriginal()
{
2014-12-29 15:13:47 +01:00
return this.original;
2014-09-20 23:22:45 +02:00
}
public void setFlip( boolean u, boolean v )
2014-09-20 23:22:45 +02:00
{
2014-12-29 15:13:47 +01:00
this.flip_u = u;
this.flip_v = v;
2014-09-20 23:22:45 +02:00
}
public int setFlip( int orientation )
2014-09-20 23:22:45 +02:00
{
this.flip_u = ( orientation & 8 ) == 8;
this.flip_v = ( orientation & 16 ) == 16;
2014-09-20 23:22:45 +02:00
return orientation & 7;
}
}