Fixed not rendering some tooltips correctly, fixes #1106
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
- Fire playerCrafting event when shift clicking in the grid (way2muchnoise)
|
||||
- Fixed controller model warning during launch (raoulvdberge)
|
||||
- Improved memory usage of some models (raoulvdberge)
|
||||
- Fixed not rendering some tooltips correctly (raoulvdberge)
|
||||
|
||||
### 1.4.1
|
||||
- Added Storage Monitor (raoulvdberge)
|
||||
|
@@ -20,6 +20,7 @@ import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -293,14 +294,22 @@ public abstract class GuiBase extends GuiContainer {
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
|
||||
public void drawTooltip(int x, int y, String message) {
|
||||
drawTooltip(x, y, Arrays.asList(message.split("\n")));
|
||||
public void drawTooltip(@Nonnull ItemStack stack, int x, int y, String lines) {
|
||||
drawTooltip(stack, x, y, Arrays.asList(lines.split("\n")));
|
||||
}
|
||||
|
||||
public void drawTooltip(int x, int y, String lines) {
|
||||
drawTooltip(ItemStack.EMPTY, x, y, lines);
|
||||
}
|
||||
|
||||
public void drawTooltip(@Nonnull ItemStack stack, int x, int y, List<String> lines) {
|
||||
GlStateManager.disableLighting();
|
||||
GuiUtils.drawHoveringText(stack, lines, x, y, width - guiLeft, height, -1, fontRendererObj);
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
|
||||
public void drawTooltip(int x, int y, List<String> lines) {
|
||||
GlStateManager.disableLighting();
|
||||
GuiUtils.drawHoveringText(null, lines, x, y, width - guiLeft, height, -1, fontRendererObj);
|
||||
GlStateManager.enableLighting();
|
||||
drawTooltip(ItemStack.EMPTY, x, y, lines);
|
||||
}
|
||||
|
||||
public void drawTexture(int x, int y, int textureX, int textureY, int width, int height) {
|
||||
|
@@ -145,7 +145,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
}
|
||||
|
||||
if (hoveringStack != null) {
|
||||
drawTooltip(mouseX, mouseY, hoveringStack.getTooltip(Minecraft.getMinecraft().player, false));
|
||||
drawTooltip(hoveringStack, mouseX, mouseY, hoveringStack.getTooltip(Minecraft.getMinecraft().player, false));
|
||||
} else if (hoveringFluid != null) {
|
||||
drawTooltip(mouseX, mouseY, hoveringFluid.getLocalizedName());
|
||||
}
|
||||
|
@@ -284,7 +284,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOverSlotWithItem() {
|
||||
private boolean isOverSlotWithStack() {
|
||||
return grid.isActive() && isOverSlot() && slotNumber < STACKS.size();
|
||||
}
|
||||
|
||||
@@ -470,8 +470,10 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
if (isOverSlotWithItem()) {
|
||||
drawTooltip(mouseX, mouseY, STACKS.get(slotNumber).getTooltip());
|
||||
if (isOverSlotWithStack()) {
|
||||
IGridStack stack = STACKS.get(slotNumber);
|
||||
|
||||
drawTooltip(stack instanceof GridStackItem ? ((GridStackItem) stack).getStack() : ItemStack.EMPTY, mouseX, mouseY, stack.getTooltip());
|
||||
}
|
||||
|
||||
if (isOverClear(mouseX, mouseY)) {
|
||||
@@ -533,7 +535,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
||||
RS.INSTANCE.network.sendToServer(grid.getType() == GridType.FLUID ? new MessageGridFluidInsertHeld() : new MessageGridItemInsertHeld(clickedButton == 1));
|
||||
}
|
||||
|
||||
if (isOverSlotWithItem()) {
|
||||
if (isOverSlotWithStack()) {
|
||||
if (grid.getType() != GridType.FLUID && (held.isEmpty() || (!held.isEmpty() && clickedButton == 2))) {
|
||||
GridStackItem stack = (GridStackItem) STACKS.get(slotNumber);
|
||||
|
||||
|
Reference in New Issue
Block a user