2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei;
|
|
|
|
|
|
2023-09-25 00:34:42 +02:00
|
|
|
import codechicken.nei.api.IHighlightHandler;
|
|
|
|
|
import codechicken.nei.api.ItemInfo;
|
|
|
|
|
import codechicken.nei.guihook.GuiContainerManager;
|
2014-04-29 10:54:20 +10:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
2023-09-25 00:34:42 +02:00
|
|
|
import java.util.List;
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public class DefaultHighlightHandler implements IHighlightHandler {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
2022-06-24 12:32:13 +01:00
|
|
|
public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition mop,
|
|
|
|
|
List<String> currenttip, ItemInfo.Layout layout) {
|
2014-04-29 10:54:20 +10:00
|
|
|
String name = null;
|
2014-09-07 23:32:42 +10:00
|
|
|
try {
|
2014-04-29 10:54:20 +10:00
|
|
|
String s = GuiContainerManager.itemDisplayNameShort(stack);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (s != null && !s.endsWith("Unnamed")) name = s;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (name != null) currenttip.add(name);
|
|
|
|
|
} catch (Exception ignored) {}
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2014-09-07 23:32:42 +10:00
|
|
|
if (name != null && stack.getItem() == Items.redstone) {
|
2014-04-29 10:54:20 +10:00
|
|
|
int md = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
|
2014-09-07 23:32:42 +10:00
|
|
|
String s = "" + md;
|
2022-06-24 12:32:13 +01:00
|
|
|
if (s.length() < 2) s = " " + s;
|
2014-09-07 23:32:42 +10:00
|
|
|
currenttip.set(currenttip.size() - 1, name + " " + s);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2014-09-07 23:32:42 +10:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
return currenttip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-09-07 23:32:42 +10:00
|
|
|
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
2014-04-29 10:54:20 +10:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|