blob: 4e2d144aa7e53e6fae17c8bdc1751ca217fbd345 (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package gregtech.api.gui.widgets;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.apache.commons.lang3.NotImplementedException;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.ImmutableList;
import com.gtnewhorizons.modularui.api.ModularUITextures;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
import com.gtnewhorizons.modularui.api.drawable.Text;
import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable;
import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot;
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import gregtech.api.gui.modularui.GT_UITextures;
import gregtech.api.interfaces.metatileentity.IItemLockable;
/**
* Creates a phantom item in a GUI. Useful for filtering.
*/
public class GT_PhantomItemButton extends SlotWidget {
public static final IDrawable[] FILTER_BACKGROUND = { ModularUITextures.ITEM_SLOT,
GT_UITextures.OVERLAY_SLOT_FILTER };
public GT_PhantomItemButton(final IItemLockable delegate) {
super(BaseSlot.phantom(new PhantomItemDelegate(delegate), 0));
controlsAmount = false;
}
@Override
public List<Text> getTooltip() {
return ImmutableList.of(new Text(StatCollector.translateToLocal("GT5U.bus.filterTooltip.empty")));
}
@Override
public List<String> getExtraTooltip() {
return ImmutableList.of(StatCollector.translateToLocal("GT5U.bus.filterTooltip.full"));
}
@Override
public boolean onMouseScroll(int direction) {
return false;
}
@SuppressWarnings("ClassCanBeRecord")
private static class PhantomItemDelegate implements IItemHandlerModifiable {
private final IItemLockable delegate;
public PhantomItemDelegate(final IItemLockable delegate) {
this.delegate = delegate;
}
@Override
public void setStackInSlot(int slot, ItemStack itemStack) {
delegate.setLockedItem(itemStack);
}
@Override
public int getSlots() {
return 1;
}
@Override
public ItemStack getStackInSlot(int slot) {
return delegate.getLockedItem();
}
@Nullable
@Override
public ItemStack insertItem(int slot, ItemStack itemStack, boolean simulate) {
delegate.setLockedItem(itemStack);
return null;
}
@Nullable
@Override
public ItemStack extractItem(int var1, int var2, boolean var3) {
throw new NotImplementedException("Extract item is disabled for GhostItemButtons.");
}
@Override
public int getSlotLimit(int slot) {
return 1;
}
}
}
|