Applied-Energistics-2-tiler.../src/main/java/appeng/items/AEBaseItem.java

124 lines
3.1 KiB
Java
Raw Normal View History

2014-11-13 22:15:06 +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-24 02:26:27 +02:00
package appeng.items;
2014-11-13 22:15:06 +01:00
2014-09-24 02:26:27 +02:00
import java.util.EnumSet;
import java.util.List;
2014-09-24 02:26:27 +02:00
2015-06-16 02:44:59 +02:00
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
2014-09-24 02:26:27 +02:00
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
2015-06-16 02:44:59 +02:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.client.ClientHelper;
import appeng.client.texture.IAESprite;
2014-09-24 02:26:27 +02:00
import appeng.core.features.AEFeature;
import appeng.core.features.FeatureNameExtractor;
2014-09-24 02:26:27 +02:00
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
2014-09-24 02:26:27 +02:00
2015-06-16 02:44:59 +02:00
import com.google.common.base.Optional;
2014-11-13 22:15:06 +01:00
public abstract class AEBaseItem extends Item implements IAEFeature
2014-09-24 02:26:27 +02:00
{
private final String fullName;
private final Optional<String> subName;
private IFeatureHandler feature;
2014-09-24 02:26:27 +02:00
public AEBaseItem()
2014-09-24 02:26:27 +02:00
{
this( Optional.<String>absent() );
this.setNoRepair();
2014-09-24 02:26:27 +02:00
}
public AEBaseItem( Optional<String> subName )
2014-11-13 22:15:06 +01:00
{
this.subName = subName;
this.fullName = new FeatureNameExtractor( this.getClass(), subName ).get();
2014-09-24 02:26:27 +02:00
}
@Override
public String toString()
2014-11-13 22:15:06 +01:00
{
return this.fullName;
2014-09-24 02:26:27 +02:00
}
@Override
public IFeatureHandler handler()
2014-09-24 02:26:27 +02:00
{
return this.feature;
2014-09-24 02:26:27 +02:00
}
@Override
public void postInit()
{
// override!
}
public void setFeature( EnumSet<AEFeature> f )
{
this.feature = new ItemFeatureHandler( f, this, this, this.subName );
}
@Override
@SuppressWarnings( "unchecked" )
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayMoreInfo )
{
this.addCheckedInformation( stack, player, lines, displayMoreInfo );
}
@Override
public boolean isBookEnchantable( ItemStack itemstack1, ItemStack itemstack2 )
{
return false;
}
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addInformation( stack, player, lines, displayMoreInfo );
}
2015-06-16 02:44:59 +02:00
@SideOnly(Side.CLIENT)
protected IAESprite myIcon = null;
@SideOnly(Side.CLIENT)
public void registerIcons(
ClientHelper proxy, String name )
{
proxy.setIcon( this, 0, name );
}
public IAESprite getIcon(
ItemStack is )
{
return myIcon;
}
@SideOnly(Side.CLIENT)
public void registerCustomIcon(
TextureMap map )
{
}
2014-09-24 02:26:27 +02:00
}