Add in some protection for itemstacks that do not have a valid icon for the meta value on the itemstack. Also add in page numbers for the Alchemical Tome and some help text (to be localized later) for when a player knows no transmutations
This commit is contained in:
parent
c0cc0c4154
commit
6fb6bd98a1
|
@ -63,6 +63,23 @@ public class GuiAlchemicalTome extends GuiBase
|
|||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
super.drawGuiContainerForegroundLayer(x, y);
|
||||
int pageOffset = ((ContainerAlchemicalTome) this.inventorySlots).getPageOffset();
|
||||
|
||||
if (this.inventorySlots.getSlot(0).getHasStack())
|
||||
{
|
||||
fontRendererObj.drawString((pageOffset * 2 + 1) + "", 64, 178, new GuiColor(50, 50, 50).getColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO Localize this
|
||||
fontRendererObj.drawSplitString("You don't know how to transmute anything yet!", 142, 20, 100, new GuiColor(50, 50, 50).getColor());
|
||||
fontRendererObj.drawSplitString("Use a Research Station to teach yourself how to transmute items", 142, 60, 100, new GuiColor(50, 50, 50).getColor());
|
||||
}
|
||||
|
||||
if (this.inventorySlots.getSlot(40).getHasStack())
|
||||
{
|
||||
fontRendererObj.drawString((pageOffset * 2 + 2) + "", 186, 178, new GuiColor(50, 50, 50).getColor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ContainerAlchemicalTome extends ContainerEE
|
|||
|
||||
inventoryTransmutationKnowledge = new InventoryTransmutationKnowledge(knownTransmutations);
|
||||
pageOffset = 0;
|
||||
maxPageOffset = knownTransmutations.size() % 80;
|
||||
maxPageOffset = knownTransmutations.size() / 80;
|
||||
|
||||
int i = 0;
|
||||
for (int rowIndex = 0; rowIndex < MAX_ROW_INDEX; ++rowIndex)
|
||||
|
@ -165,6 +165,7 @@ public class ContainerAlchemicalTome extends ContainerEE
|
|||
boolean shouldUpdateInventory = false;
|
||||
ItemStack[] newInventory = new ItemStack[80];
|
||||
List<ItemStack> filteredList = new ArrayList(ItemHelper.filterByNameContains(inventoryTransmutationKnowledge.getKnownTransmutations(), searchTerm));
|
||||
ItemHelper.filterOutItemsWithInvalidIcons(filteredList);
|
||||
|
||||
maxPageOffset = filteredList.size() / 80;
|
||||
if (pageOffset > maxPageOffset)
|
||||
|
|
|
@ -6,10 +6,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemHelper
|
||||
{
|
||||
|
@ -337,4 +334,23 @@ public class ItemHelper
|
|||
{
|
||||
NBTHelper.setString(itemStack, Names.NBT.OWNER, entityPlayer.getDisplayName());
|
||||
}
|
||||
|
||||
public static void filterOutItemsWithInvalidIcons(List<ItemStack> unfilteredCollection)
|
||||
{
|
||||
List<ItemStack> itemsToRemove = new ArrayList<ItemStack>();
|
||||
|
||||
for (ItemStack itemStack : unfilteredCollection)
|
||||
{
|
||||
try
|
||||
{
|
||||
itemStack.getItem().getIconIndex(itemStack);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
itemsToRemove.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
unfilteredCollection.removeAll(itemsToRemove);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue