Better pattern tooltip
This commit is contained in:
@@ -21,6 +21,10 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
import refinedstorage.api.storage.CompareFlags;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public final class RefinedStorageUtils {
|
||||
public static final String NBT_INVENTORY = "Inventory_%d";
|
||||
public static final String NBT_SLOT = "Slot";
|
||||
@@ -265,4 +269,30 @@ public final class RefinedStorageUtils {
|
||||
|
||||
return (int) multiplier;
|
||||
}
|
||||
|
||||
public static void combineMultipleItemsInTooltip(List<String> lines, ItemStack... stacks) {
|
||||
Set<Integer> combinedIndices = new HashSet<Integer>();
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
if (!combinedIndices.contains(i)) {
|
||||
String data = stacks[i].getDisplayName();
|
||||
|
||||
int amount = stacks[i].stackSize;
|
||||
|
||||
for (int j = i + 1; j < stacks.length; ++j) {
|
||||
if (RefinedStorageUtils.compareStack(stacks[i], stacks[j])) {
|
||||
amount += stacks[j].stackSize;
|
||||
|
||||
combinedIndices.add(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (amount != 1) {
|
||||
data += " (" + amount + "x)";
|
||||
}
|
||||
|
||||
lines.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,19 +25,15 @@ public class ItemPattern extends ItemBase {
|
||||
@Override
|
||||
public void addInformation(ItemStack pattern, EntityPlayer player, List list, boolean b) {
|
||||
if (isValid(pattern)) {
|
||||
if (!isProcessing(pattern)) {
|
||||
for (ItemStack output : getOutputs(pattern)) {
|
||||
list.add(output.getDisplayName());
|
||||
}
|
||||
} else {
|
||||
for (ItemStack input : getInputs(pattern)) {
|
||||
list.add(input.getDisplayName());
|
||||
}
|
||||
if (GuiScreen.isShiftKeyDown() || isProcessing(pattern)) {
|
||||
list.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.inputs") + TextFormatting.RESET);
|
||||
|
||||
for (ItemStack output : getOutputs(pattern)) {
|
||||
list.add("-> " + output.getDisplayName());
|
||||
}
|
||||
RefinedStorageUtils.combineMultipleItemsInTooltip(list, getInputs(pattern));
|
||||
|
||||
list.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.outputs") + TextFormatting.RESET);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.combineMultipleItemsInTooltip(list, getOutputs(pattern));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ misc.refinedstorage:wireless_grid.tooltip.2=Z: %d
|
||||
misc.refinedstorage:wireless_grid.out_of_range=Controller out of range.
|
||||
misc.refinedstorage:wireless_grid.not_found=Controller not found.
|
||||
|
||||
misc.refinedstorage:pattern.inputs=Inputs
|
||||
misc.refinedstorage:pattern.outputs=Outputs
|
||||
|
||||
misc.refinedstorage:start=Start
|
||||
misc.refinedstorage:clear=Clear
|
||||
misc.refinedstorage:cancel_all=Cancel All
|
||||
|
||||
Reference in New Issue
Block a user