Adds improved tooltip to invalid encodedPattern (#2992)
* Adds improved tooltip to invalid encodedPattern This also fixes that encodedPattern might be shown as valid, even though one or more input or output item is missing.
This commit is contained in:
@@ -43,6 +43,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.InvalidPatternHelper;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
@@ -108,10 +109,49 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
|
||||
if( details == null )
|
||||
{
|
||||
lines.add( TextFormatting.RED + GuiText.InvalidPattern.getLocal() );
|
||||
if( !stack.hasTagCompound() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
stack.setStackDisplayName( TextFormatting.RED + GuiText.InvalidPattern.getLocal() );
|
||||
|
||||
InvalidPatternHelper invalid = new InvalidPatternHelper( stack );
|
||||
|
||||
final String label = ( invalid.isCraftable() ? GuiText.Crafts.getLocal() : GuiText.Creates.getLocal() ) + ": ";
|
||||
final String and = ' ' + GuiText.And.getLocal() + ' ';
|
||||
final String with = GuiText.With.getLocal() + ": ";
|
||||
|
||||
boolean first = true;
|
||||
for( final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs() )
|
||||
{
|
||||
lines.add( ( first ? label : and ) + output.getFormattedToolTip() );
|
||||
first = false;
|
||||
}
|
||||
|
||||
first = true;
|
||||
for( final InvalidPatternHelper.PatternIngredient input : invalid.getInputs() )
|
||||
{
|
||||
lines.add( ( first ? with : and ) + input.getFormattedToolTip() );
|
||||
first = false;
|
||||
}
|
||||
|
||||
if( invalid.isCraftable() )
|
||||
{
|
||||
final String substitutionLabel = GuiText.Substitute.getLocal() + " ";
|
||||
final String canSubstitute = invalid.canSubstitute() ? GuiText.Yes.getLocal() : GuiText.No.getLocal();
|
||||
|
||||
lines.add( substitutionLabel + canSubstitute );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( stack.hasDisplayName() )
|
||||
{
|
||||
stack.removeSubCompound( "display" );
|
||||
}
|
||||
|
||||
final boolean isCrafting = details.isCraftable();
|
||||
final boolean substitute = details.canSubstitute();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user