Pattern slots now report the output qty as well as the item type, at all times ( not just when shift is held )

This commit is contained in:
AlgorithmX2 2014-04-23 00:30:29 -05:00
parent 94951b4209
commit 589e2d60d2
3 changed files with 41 additions and 45 deletions

View file

@ -4,14 +4,12 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import appeng.util.Platform;
import appeng.items.misc.ItemEncodedPattern;
public class ItemEncodedPatternRenderer implements IItemRenderer
{
@ -26,42 +24,14 @@ public class ItemEncodedPatternRenderer implements IItemRenderer
if ( resursive == false && type == IItemRenderer.ItemRenderType.INVENTORY && isShiftHeld )
{
if ( readOutput( item ) != null )
ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
if ( iep.getOutput( item ) != null )
return true;
}
return false;
}
private ItemStack readOutput(ItemStack item)
{
NBTTagCompound encodedValue = item.getTagCompound();
if ( encodedValue == null )
return null;
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
if ( outTag.tagCount() == 0 )
return null;
ItemStack out = null;
for (int x = 0; x < outTag.tagCount(); x++)
{
ItemStack readItem = ItemStack.loadItemStackFromNBT( outTag.getCompoundTagAt( x ) );
if ( readItem != null )
{
if ( out == null )
out = readItem;
else if ( out != null && Platform.isSameItemPrecise( readItem, out ) )
out.stackSize += readItem.stackSize;
}
}
return out;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
@ -73,7 +43,9 @@ public class ItemEncodedPatternRenderer implements IItemRenderer
{
resursive = true;
ItemStack is = readOutput( item );
ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
ItemStack is = iep.getOutput( item );
Minecraft mc = Minecraft.getMinecraft();
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );

View file

@ -18,7 +18,7 @@ import appeng.api.implementations.items.ISpatialStorageCell;
import appeng.api.implementations.items.IStorageComponent;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.data.IAEItemStack;
import appeng.items.misc.ItemEncodedPattern;
import appeng.recipes.handlers.Inscribe;
import appeng.util.Platform;
@ -91,19 +91,14 @@ public class SlotRestrictedInput extends AppEngSlot
@Override
public ItemStack getDisplayStack()
{
if ( Platform.isClient() && (which == PlaceableItemType.VALID_ENCODED_PATTERN_W_OUPUT || which == PlaceableItemType.ENCODED_PATTERN_W_OUTPUT) )
if ( Platform.isClient() && (which == PlaceableItemType.ENCODED_PATTERN) )
{
ItemStack is = super.getStack();
if ( is != null && is.getItem() instanceof ICraftingPatternItem )
if ( is != null && is.getItem() instanceof ItemEncodedPattern )
{
ICraftingPatternItem it = (ICraftingPatternItem) is.getItem();
ICraftingPatternDetails details = it.getPatternForItem( is );
if ( details != null )
{
IAEItemStack list[] = details.getOutputs();
if ( list.length > 0 )
return list[0].getItemStack();
}
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
ItemStack out = iep.getOutput( is );
return out;
}
}
return super.getStack();

View file

@ -74,6 +74,35 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
}
}
public ItemStack getOutput(ItemStack item)
{
NBTTagCompound encodedValue = item.getTagCompound();
if ( encodedValue == null )
return null;
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
if ( outTag.tagCount() == 0 )
return null;
ItemStack out = null;
for (int x = 0; x < outTag.tagCount(); x++)
{
ItemStack readItem = ItemStack.loadItemStackFromNBT( outTag.getCompoundTagAt( x ) );
if ( readItem != null )
{
if ( out == null )
out = readItem;
else if ( out != null && Platform.isSameItemPrecise( readItem, out ) )
out.stackSize += readItem.stackSize;
}
}
return out;
}
private void readItems(ItemStack[] itemList, NBTTagList tagSrc)
{
for (int x = 0; x < itemList.length; x++)