Fix item slot rendering

This commit is contained in:
Nedelosk committed 2017-07-30 21:01:59 +02:00
1 parent faf2b88ed8
commit 2a451bc72e
2 files changed
+24 -3

No files matched your search

@@ -86,6 +86,11 @@ public class ControlSlot extends ControlSlotBase {
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
boolean highlighted = false;
for (final Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
if (highlight.getKey() == EnumHighlighting.ShiftClick && !ControlSlot.shiftClickActive) {
@@ -100,11 +105,15 @@ public class ControlSlot extends ControlSlotBase {
}
if (!highlighted && this.getTopParent().getMousedOverWidget() == this) {
GuiCraftGUI gui = Window.get(this).getGui();
GlStateManager.disableBlend();
GlStateManager.disableDepth();
if (!gui.getDraggedItem().isEmpty() && !this.slot.isItemValid(gui.getDraggedItem())) {
RenderUtil.drawGradientRect(new Area(1, 1, 16, 16), -1426089575, -1426089575);
} else {
RenderUtil.drawGradientRect(new Area(1, 1, 16, 16), -2130706433, -2130706433);
}
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
}
@@ -1,6 +1,9 @@
package binnie.core.craftgui.minecraft.control;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -61,11 +64,20 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
@Override
@SideOnly(Side.CLIENT)
public void getTooltip(final Tooltip tooltip) {
final ItemStack item = this.getItemStack();
if (item.isEmpty()) {
final ItemStack stack = this.getItemStack();
if (stack.isEmpty()) {
return;
}
tooltip.add(item.getTooltip(((Window) this.getTopParent()).getPlayer(), false));
List<String> list = stack.getTooltip(((Window) this.getTopParent()).getPlayer(), false);
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));
}
}
tooltip.add(list);
}
public abstract ItemStack getItemStack();