aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/gui/GT_Slot_Holo.java
blob: 9b7b75f0b24d20e5cc7ef538ceebc7ead419d61d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package gregtech.api.gui;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class GT_Slot_Holo extends Slot {

    public final int mSlotIndex;
    public boolean mEnabled = true;
    public boolean mCanInsertItem, mCanStackItem;
    public int mMaxStacksize = 127;

    public GT_Slot_Holo(IInventory inventory, int slotIndex, int xPos, int yPos, boolean aCanInsertItem,
        boolean aCanStackItem, int aMaxStacksize) {
        super(inventory, slotIndex, xPos, yPos);
        mCanInsertItem = aCanInsertItem;
        mCanStackItem = aCanStackItem;
        mMaxStacksize = aMaxStacksize;
        mSlotIndex = slotIndex;
    }

    @Override
    public boolean isItemValid(ItemStack itemStack) {
        return mCanInsertItem;
    }

    @Override
    public int getSlotStackLimit() {
        return mMaxStacksize;
    }

    @Override
    public boolean getHasStack() {
        return false;
    }

    @Override
    public ItemStack decrStackSize(int amount) {
        if (!mCanStackItem) return null;
        return super.decrStackSize(amount);
    }

    @Override
    public boolean canTakeStack(EntityPlayer player) {
        return false;
    }

    /**
     * Sets if this slot should be ignored in event-processing. For example, highlight the slot on mouseOver.
     *
     * @param enabled if the slot should be enabled
     */
    public void setEnabled(boolean enabled) {
        mEnabled = enabled;
    }

    /**
     * Use this value to determine whether to ignore this slot in event processing
     */
    public boolean isEnabled() {
        return mEnabled;
    }

    /**
     * This function controls whether to highlight the slot on mouseOver.
     */
    @Override
    @SideOnly(Side.CLIENT)
    public boolean func_111238_b() {
        return isEnabled();
    }
}