Add tooltip to grid filter with the filtered items
This commit is contained in:
@@ -28,4 +28,8 @@ public class ItemHandlerGridFilter extends ItemStackHandler {
|
||||
|
||||
TileBase.writeItems(this, 0, stack.getTagCompound());
|
||||
}
|
||||
|
||||
public ItemStack[] getFilteredItems() {
|
||||
return stacks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.tile.TileBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,14 +22,10 @@ public class ItemHandlerGridFilterInGrid extends ItemHandlerBasic {
|
||||
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
ItemHandlerBasic items = new ItemHandlerBasic(9 * 3);
|
||||
|
||||
TileBase.readItems(items, 0, stack.getTagCompound());
|
||||
|
||||
for (int i = 0; i < items.getSlots(); ++i) {
|
||||
ItemStack item = items.getStackInSlot(i);
|
||||
if (stack != null) {
|
||||
ItemHandlerGridFilter items = new ItemHandlerGridFilter(stack);
|
||||
|
||||
for (ItemStack item : items.getFilteredItems()) {
|
||||
if (item != null) {
|
||||
filteredItems.add(item);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ItemBlockController extends ItemBlockBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
if (stack.getMetadata() != EnumControllerType.CREATIVE.getId()) {
|
||||
int energyStored = 0;
|
||||
int energyCapacity = RefinedStorage.INSTANCE.controllerCapacity;
|
||||
@@ -33,7 +33,7 @@ public class ItemBlockController extends ItemBlockBase {
|
||||
}
|
||||
}
|
||||
|
||||
list.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, energyCapacity));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, energyCapacity));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ public class ItemBlockStorage extends ItemBlockBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
EnumStorageType type = EnumStorageType.getById(stack.getMetadata());
|
||||
|
||||
if (type != null && isValid(stack)) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE);
|
||||
|
||||
if (type == EnumStorageType.TYPE_CREATIVE) {
|
||||
list.add(I18n.format("misc.refinedstorage:storage.stored", NBTStorage.getStoredFromNBT(tag)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", NBTStorage.getStoredFromNBT(tag)));
|
||||
} else {
|
||||
list.add(I18n.format("misc.refinedstorage:storage.stored_capacity", NBTStorage.getStoredFromNBT(tag), type.getCapacity()));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", NBTStorage.getStoredFromNBT(tag), type.getCapacity()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.inventory.ItemHandlerGridFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemGridFilter extends ItemBase {
|
||||
public ItemGridFilter() {
|
||||
@@ -31,4 +34,13 @@ public class ItemGridFilter extends ItemBase {
|
||||
|
||||
return new ActionResult(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
|
||||
ItemHandlerGridFilter items = new ItemHandlerGridFilter(stack);
|
||||
|
||||
ItemPattern.combineItems(tooltip, items.getFilteredItems());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ public class ItemPattern extends ItemBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack pattern, EntityPlayer player, List list, boolean b) {
|
||||
public void addInformation(ItemStack pattern, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
if (isValid(pattern)) {
|
||||
if (GuiScreen.isShiftKeyDown() || isProcessing(pattern)) {
|
||||
list.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.inputs") + TextFormatting.RESET);
|
||||
tooltip.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.inputs") + TextFormatting.RESET);
|
||||
|
||||
combineItems(list, getInputs(pattern));
|
||||
combineItems(tooltip, getInputs(pattern));
|
||||
|
||||
list.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.outputs") + TextFormatting.RESET);
|
||||
tooltip.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.outputs") + TextFormatting.RESET);
|
||||
}
|
||||
|
||||
combineItems(list, getOutputs(pattern));
|
||||
combineItems(tooltip, getOutputs(pattern));
|
||||
}
|
||||
}
|
||||
|
||||
private void combineItems(List<String> lines, ItemStack... stacks) {
|
||||
public static void combineItems(List<String> tooltip, ItemStack... stacks) {
|
||||
Set<Integer> combinedIndices = new HashSet<Integer>();
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
if (!combinedIndices.contains(i)) {
|
||||
if (stacks[i] != null && !combinedIndices.contains(i)) {
|
||||
String data = stacks[i].getDisplayName();
|
||||
|
||||
int amount = stacks[i].stackSize;
|
||||
@@ -65,7 +65,7 @@ public class ItemPattern extends ItemBase {
|
||||
data += " (" + amount + "x)";
|
||||
}
|
||||
|
||||
lines.add(data);
|
||||
tooltip.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ public class ItemStorageDisk extends ItemBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack disk, EntityPlayer player, List list, boolean b) {
|
||||
public void addInformation(ItemStack disk, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
if (NBTStorage.isValid(disk)) {
|
||||
int capacity = EnumStorageType.getById(disk.getItemDamage()).getCapacity();
|
||||
|
||||
if (capacity == -1) {
|
||||
list.add(I18n.format("misc.refinedstorage:storage.stored", NBTStorage.getStoredFromNBT(disk.getTagCompound())));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", NBTStorage.getStoredFromNBT(disk.getTagCompound())));
|
||||
} else {
|
||||
list.add(I18n.format("misc.refinedstorage:storage.stored_capacity", NBTStorage.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", NBTStorage.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,15 +106,15 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
if (stack.getItemDamage() != TYPE_CREATIVE) {
|
||||
list.add(I18n.format("misc.refinedstorage:energy_stored", getEnergyStored(stack), getMaxEnergyStored(stack)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:energy_stored", getEnergyStored(stack), getMaxEnergyStored(stack)));
|
||||
}
|
||||
|
||||
if (hasValidNBT(stack)) {
|
||||
list.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip.0", getX(stack)));
|
||||
list.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip.1", getY(stack)));
|
||||
list.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip.2", getZ(stack)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip.0", getX(stack)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip.1", getY(stack)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip.2", getZ(stack)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user