use of net.minecraft.client.util.ITooltipFlag in project Tropicraft by Tropicraft.
the class GuiTropicalBook method checkMouseHover.
/**
* Draw the name of an item when it's hovered over in game
* @param itemstack ItemStack being hovered over
* @param x x coord
* @param y y coord
* @param size size...of something idk what :D
*/
private void checkMouseHover(ItemStack itemstack, int x, int y, int mx, int my, int size) {
boolean checkHover = (mx >= x && my >= y && mx < x + size && my < y + size);
float z = this.zLevel;
this.zLevel = 500;
if (!itemstack.isEmpty() && checkHover) {
ITooltipFlag flag = mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
ItemTooltipEvent evt = new ItemTooltipEvent(itemstack, mc.player, itemstack.getTooltip(mc.player, flag), flag);
if (!MinecraftForge.EVENT_BUS.post(evt)) {
ttLines = evt.getToolTip();
} else {
ttLines = null;
}
}
this.zLevel = z;
}
use of net.minecraft.client.util.ITooltipFlag in project RFToolsControl by McJty.
the class GuiCraftingStation method updateRecipeList.
private void updateRecipeList() {
String filterText = searchField.getText().toLowerCase().trim();
fromServer_craftables.sort((r1, r2) -> {
return r1.getDisplayName().compareTo(r2.getDisplayName());
});
recipeList.removeChildren();
Panel panel = null;
int index = 0;
for (ItemStack stack : fromServer_craftables) {
String displayName = stack.getDisplayName();
if ((!filterText.isEmpty()) && !displayName.toLowerCase().contains(filterText)) {
continue;
}
if (panel == null || panel.getChildCount() >= 6) {
panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(3).setHorizontalMargin(1)).setDesiredHeight(16);
recipeList.addChild(panel);
}
BlockRender blockRender = new BlockRender(mc, this) {
@Override
public List<String> getTooltips() {
ITooltipFlag flag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> list = stack.getTooltip(this.mc.player, flag);
for (int i = 0; i < list.size(); ++i) {
if (i == 0) {
list.set(i, stack.getRarity().rarityColor + list.get(i));
} else {
list.set(i, TextFormatting.GRAY + list.get(i));
}
}
List<String> newlist = new ArrayList<>();
newlist.add(TextFormatting.GREEN + "Click: " + TextFormatting.WHITE + "craft single");
newlist.add(TextFormatting.GREEN + "Shift + click: " + TextFormatting.WHITE + "craft amount");
newlist.add("");
newlist.addAll(list);
return newlist;
}
}.setRenderItem(stack).setHilightOnHover(true).setOffsetX(-1).setOffsetY(-1).setUserObject(index);
index++;
blockRender.addSelectionEvent(new BlockRenderEvent() {
@Override
public void select(Widget widget) {
BlockRender br = (BlockRender) widget;
Object item = br.getRenderItem();
if (item != null) {
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
Object index = br.getUserObject();
if (shift) {
askAmountToCraft(stack);
} else {
requestItem(stack, 1);
}
}
}
@Override
public void doubleClick(Widget widget) {
}
});
panel.addChild(blockRender);
}
}
use of net.minecraft.client.util.ITooltipFlag in project Binnie by ForestryMC.
the class GuiCraftGUI method drawScreen.
@Override
public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
this.window.setMousePosition(mouseX - this.window.getPosition().xPos(), mouseY - this.window.getPosition().yPos());
this.drawDefaultBackground();
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
this.zLevel = 10.0f;
// GuiScreen.itemRender.zLevel = this.zLevel;
this.window.render(this.width, this.height);
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
final InventoryPlayer playerInventory = this.mc.player.inventory;
this.draggedItem = playerInventory.getItemStack();
if (!this.draggedItem.isEmpty()) {
GlStateManager.translate(0, 0, 200);
RenderUtil.drawItem(new Point(mouseX - 8, mouseY - 8), this.draggedItem, false);
}
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
if (draggedItem.isEmpty()) {
ITooltipFlag tooltipFlag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
final MinecraftTooltip tooltip = new MinecraftTooltip();
boolean helpMode = this.isHelpMode();
if (helpMode || this.showBasicHelpTooltips()) {
tooltip.setType(Tooltip.Type.HELP);
ITooltipFlag helpTooltipFlag = helpMode ? ITooltipFlag.TooltipFlags.ADVANCED : tooltipFlag;
if (!this.window.getHelpTooltip(tooltip, helpTooltipFlag)) {
// fallback if there is no help tooltip
this.window.getTooltip(tooltip, tooltipFlag);
}
} else {
tooltip.setType(Tooltip.Type.STANDARD);
this.window.getTooltip(tooltip, tooltipFlag);
}
if (tooltip.exists()) {
this.renderTooltip(new Point(mouseX, mouseY), tooltip);
}
}
this.zLevel = 0.0f;
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
use of net.minecraft.client.util.ITooltipFlag in project RFToolsControl by McJty.
the class GuiCraftingStation method updateRequestList.
private void updateRequestList() {
requestList.removeChildren();
for (CraftingRequest request : fromServer_requests) {
final ItemStack stack = request.getStack();
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(16);
requestList.addChild(panel);
BlockRender blockRender = new BlockRender(mc, this) {
@Override
public List<String> getTooltips() {
ITooltipFlag flag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> list = stack.getTooltip(this.mc.player, flag);
for (int i = 0; i < list.size(); ++i) {
if (i == 0) {
list.set(i, stack.getRarity().rarityColor + list.get(i));
} else {
list.set(i, TextFormatting.GRAY + list.get(i));
}
}
return list;
}
}.setRenderItem(stack).setOffsetX(-1).setOffsetY(-1);
panel.addChild(blockRender);
boolean failed = request.getFailed() != -1;
boolean ok = request.getOk() != -1;
panel.addChild(new Label(mc, this).setColor(failed ? 0xffff3030 : (ok ? 0xff30ff30 : StyleConfig.colorTextNormal)).setText(failed ? "Failed!" : (ok ? "Ok" : "Wait (" + request.getTodo() + ")")));
}
}
Aggregations