Use type safe base method to add information to the tooltip
This commit is contained in:
parent
8c144b22cc
commit
4e1b93b842
|
@ -1,7 +1,10 @@
|
|||
package appeng.items;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
@ -53,4 +56,16 @@ public class AEBaseItem extends Item implements IAEFeature
|
|||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
this.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
}
|
||||
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( stack, player, lines, displayAdditionalInformation );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,21 +92,21 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List details, boolean displayAdditionalInformation)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( is, player, details, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
MaterialType mt = getTypeByStack( is );
|
||||
MaterialType mt = getTypeByStack( stack );
|
||||
if ( mt == null )
|
||||
return;
|
||||
|
||||
if ( mt == MaterialType.NamePress )
|
||||
{
|
||||
NBTTagCompound c = Platform.openNbtData( is );
|
||||
details.add( c.getString( "InscribeName" ) );
|
||||
NBTTagCompound c = Platform.openNbtData( stack );
|
||||
lines.add( c.getString( "InscribeName" ) );
|
||||
}
|
||||
|
||||
Upgrades u = getType( is );
|
||||
Upgrades u = getType( stack );
|
||||
if ( u != null )
|
||||
{
|
||||
List<String> textList = new LinkedList<String>();
|
||||
|
@ -134,7 +134,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
|||
Pattern p = Pattern.compile( "(\\d+)[^\\d]" );
|
||||
SlightlyBetterSort s = new SlightlyBetterSort( p );
|
||||
Collections.sort( textList, s );
|
||||
details.addAll( textList );
|
||||
lines.addAll( textList );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,12 +123,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer p, List l, boolean b)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
l.add( ButtonToolTips.DoesntDespawn.getLocal() );
|
||||
lines.add( ButtonToolTips.DoesntDespawn.getLocal() );
|
||||
int progress = getProgress( stack ) % SINGLE_OFFSET;
|
||||
l.add( Math.floor( (float) progress / (float) (SINGLE_OFFSET / 100) ) + "%" );
|
||||
super.addInformation( stack, p, l, b );
|
||||
lines.add( Math.floor( (float) progress / (float) (SINGLE_OFFSET / 100) ) + "%" );
|
||||
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,13 +69,13 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean more)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
ICraftingPatternDetails details = getPatternForItem( is, p.worldObj );
|
||||
ICraftingPatternDetails details = getPatternForItem( stack, player.worldObj );
|
||||
|
||||
if ( details == null )
|
||||
{
|
||||
l.add( EnumChatFormatting.RED + GuiText.InvalidPattern.getLocal() );
|
||||
lines.add( EnumChatFormatting.RED + GuiText.InvalidPattern.getLocal() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||
continue;
|
||||
}
|
||||
|
||||
l.add( (first ? label : and) + anOut.getStackSize() + " " + Platform.getItemDisplayName( anOut ) );
|
||||
lines.add( (first ? label : and) + anOut.getStackSize() + " " + Platform.getItemDisplayName( anOut ) );
|
||||
first = false;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||
continue;
|
||||
}
|
||||
|
||||
l.add( (first ? with : and) + anIn.getStackSize() + " " + Platform.getItemDisplayName( anIn ) );
|
||||
lines.add( (first ? with : and) + anIn.getStackSize() + " " + Platform.getItemDisplayName( anIn ) );
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,9 +72,9 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
IMEInventory<IAEItemStack> inventory = AEApi.instance().registries().cell().getCellInventory( i, null, StorageChannel.ITEMS );
|
||||
IMEInventory<IAEItemStack> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
if ( inventory instanceof ICellInventoryHandler )
|
||||
{
|
||||
|
@ -83,11 +83,11 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
|||
|
||||
if (cellInventory != null)
|
||||
{
|
||||
l.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + " "
|
||||
lines.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + " "
|
||||
+ cellInventory.getTotalBytes() + " "
|
||||
+ GuiText.BytesUsed.getLocal());
|
||||
|
||||
l.add(cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal()
|
||||
lines.add(cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal()
|
||||
+ " " + cellInventory.getTotalItemTypes() + " "
|
||||
+ GuiText.Types.getLocal());
|
||||
|
||||
|
@ -97,9 +97,9 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
|||
: GuiText.Excluded ).getLocal();
|
||||
|
||||
if ( handler.isFuzzy() )
|
||||
l.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Fuzzy.getLocal() );
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Fuzzy.getLocal() );
|
||||
else
|
||||
l.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Precise.getLocal() );
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Precise.getLocal() );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List list, boolean adv)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
WorldCoord wc = getStoredSize( is );
|
||||
WorldCoord wc = getStoredSize( stack );
|
||||
if ( wc.x > 0 )
|
||||
list.add( GuiText.StoredSize.getLocal() + ": " + wc.x + " x " + wc.y + " x " + wc.z );
|
||||
lines.add( GuiText.StoredSize.getLocal() + ": " + wc.x + " x " + wc.y + " x " + wc.z );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,11 +78,11 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean b)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = getPermissions( is );
|
||||
EnumSet<SecurityPermissions> perms = getPermissions( stack );
|
||||
if ( perms.isEmpty() )
|
||||
l.add( GuiText.NoPermissions.getLocal() );
|
||||
lines.add( GuiText.NoPermissions.getLocal() );
|
||||
else
|
||||
{
|
||||
String msg = null;
|
||||
|
@ -94,7 +94,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||
else
|
||||
msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
}
|
||||
l.add( msg );
|
||||
lines.add( msg );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
l.add( getLocalizedName( getSettingsName( i ) + ".name", getSettingsName( i ) ) );
|
||||
lines.add( getLocalizedName( getSettingsName( stack ) + ".name", getSettingsName( stack ) ) );
|
||||
|
||||
NBTTagCompound data = getData( i );
|
||||
NBTTagCompound data = getData( stack );
|
||||
if ( data.hasKey( "tooltip" ) )
|
||||
l.add( StatCollector.translateToLocal( getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
|
||||
lines.add( StatCollector.translateToLocal( getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -367,11 +367,11 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( is, player, lines, advancedItemTooltips );
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
|
|
|
@ -72,11 +72,11 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( is, player, lines, advancedItemTooltips );
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
|
|
|
@ -56,11 +56,11 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( is, player, lines, advancedItemTooltips );
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
|
|
|
@ -48,25 +48,25 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( i, p, l, b );
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
if ( i.hasTagCompound() )
|
||||
if ( stack.hasTagCompound() )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( i );
|
||||
NBTTagCompound tag = Platform.openNbtData( stack );
|
||||
if ( tag != null )
|
||||
{
|
||||
String encKey = tag.getString( "encryptionKey" );
|
||||
|
||||
if ( encKey == null || encKey.equals( "" ) )
|
||||
l.add( GuiText.Unlinked.getLocal() );
|
||||
lines.add( GuiText.Unlinked.getLocal() );
|
||||
else
|
||||
l.add( GuiText.Linked.getLocal() );
|
||||
lines.add( GuiText.Linked.getLocal() );
|
||||
}
|
||||
}
|
||||
else
|
||||
l.add( StatCollector.translateToLocal( "AppEng.GuiITooltip.Unlinked" ) );
|
||||
lines.add( StatCollector.translateToLocal( "AppEng.GuiITooltip.Unlinked" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,11 +32,11 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
NBTTagCompound tag = is.getTagCompound();
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
double internalCurrentPower = 0;
|
||||
double internalMaxPower = getAEMaxPower( is );
|
||||
double internalMaxPower = getAEMaxPower( stack );
|
||||
|
||||
if ( tag != null )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue