Ghost slots can now be used to paint grayed out items everywhere

e.g. as background images for real slots
This commit is contained in:
HenryLoenwind committed 2015-11-09 03:28:55 +01:00
1 parent cf9cf9825f
commit 4db03c998c
4 files changed
+79 -5

No files matched your search

@@ -198,7 +198,7 @@ public class GhostSlotHandler {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, slot.getGrayOutLevel());
String guiTexture = gui.getGuiTexture();
if (guiTexture == null) {
NEUTRAL_SLOT_BACKGROUND.getMap().render(NEUTRAL_SLOT_BACKGROUND, gui.getGuiLeft() + slot.x, gui.getGuiTop() + slot.y, gui.getZlevel(), true);
@@ -390,8 +390,8 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
}
protected void drawFakeItemsStart() {
zLevel = 100.0F;
itemRender.zLevel = 100.0F;
zLevel = 0.0F;
itemRender.zLevel = -25.0F;
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
@@ -0,0 +1,66 @@
package com.enderio.core.client.gui.widget;
import net.minecraft.block.Block;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class GhostBackgroundItemSlot extends GhostSlot {
private final ItemStack stack;
private final Slot parent;
public GhostBackgroundItemSlot(ItemStack stack, int x, int y) {
this.stack = stack;
this.parent = null;
this.x = x;
this.y = y;
this.grayOut = true;
this.grayOutLevel = .75f;
}
public GhostBackgroundItemSlot(ItemStack stack, Slot parent) {
this.stack = stack;
this.parent = parent;
this.x = parent.xDisplayPosition;
this.y = parent.yDisplayPosition;
this.grayOut = true;
this.grayOutLevel = .75f;
}
public GhostBackgroundItemSlot(Item item, int x, int y) {
this(new ItemStack(item), x, y);
}
public GhostBackgroundItemSlot(Block block, int x, int y) {
this(new ItemStack(block), x, y);
}
public GhostBackgroundItemSlot(Item item, Slot parent) {
this(new ItemStack(item), parent);
}
public GhostBackgroundItemSlot(Block block, Slot parent) {
this(new ItemStack(block), parent);
}
@Override
public boolean isMouseOver(int mx, int my) {
return false;
}
@Override
public ItemStack getStack() {
return stack;
}
@Override
public void putStack(ItemStack stack) {
}
@Override
public boolean isVisible() {
return parent != null ? parent.xDisplayPosition >= 0 && parent.yDisplayPosition >= 0 : super.isVisible();
}
}
@@ -1,11 +1,11 @@
package com.enderio.core.client.gui.widget;
import net.minecraft.item.ItemStack;
import com.enderio.core.common.TileEntityEnder;
import com.enderio.core.common.network.EnderPacketHandler;
import com.enderio.core.common.network.PacketGhostSlot;
import net.minecraft.item.ItemStack;
public abstract class GhostSlot {
public TileEntityEnder te = null;
@@ -15,6 +15,7 @@ public abstract class GhostSlot {
public boolean visible = true;
public boolean grayOut = true;
public float grayOutLevel = 0.5f;
public boolean displayStdOverlay = false;
public int stackSizeLimit = 1;
@@ -44,6 +45,13 @@ public abstract class GhostSlot {
return grayOut;
}
/**
* If it should be grayed out, how far? (1=no graying, 0=fully invisible)
*/
public float getGrayOutLevel() {
return grayOutLevel;
}
/**
* Should the items in the slot have their standard overlay (stacksize)?
*/