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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
package gregtech.api.metatileentity.implementations;
import static gregtech.api.enums.GTValues.GT;
import static gregtech.api.metatileentity.BaseTileEntity.BATTERY_SLOT_TOOLTIP;
import static gregtech.api.metatileentity.BaseTileEntity.BATTERY_SLOT_TOOLTIP_ALT;
import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY;
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import gregtech.api.enums.GTValues;
import gregtech.api.gui.modularui.GTUITextures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.util.GTUtility;
public abstract class MTETieredMachineBlock extends MetaTileEntity {
/**
* Value between [0 - 9] to describe the Tier of this Machine. PLZ [0-15] works - READ! GT_Values class.
*/
public final byte mTier;
/**
* A simple Description.
*/
public final String[] mDescriptionArray;
/**
* Contains all Textures used by this Block.
*/
public final ITexture[][][] mTextures;
public MTETieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount,
String aDescription, ITexture... aTextures) {
super(aID, aName, aNameRegional, aInvSlotCount);
mTier = (byte) Math.max(0, Math.min(aTier, 14));
mDescriptionArray = aDescription == null ? new String[0] : new String[] { aDescription };
// must always be the last call!
if (GT.isClientSide()) mTextures = getTextureSet(aTextures);
else mTextures = null;
}
public MTETieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount,
String[] aDescription, ITexture... aTextures) {
super(aID, aName, aNameRegional, aInvSlotCount);
mTier = (byte) Math.max(0, Math.min(aTier, 15));
mDescriptionArray = aDescription == null ? new String[0] : aDescription;
// must always be the last call!
if (GT.isClientSide()) mTextures = getTextureSet(aTextures);
else mTextures = null;
}
public MTETieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription,
ITexture[][][] aTextures) {
super(aName, aInvSlotCount);
mTier = (byte) aTier;
mDescriptionArray = aDescription == null ? new String[0] : new String[] { aDescription };
mTextures = aTextures;
}
public MTETieredMachineBlock(String aName, int aTier, int aInvSlotCount, String[] aDescription,
ITexture[][][] aTextures) {
super(aName, aInvSlotCount);
mTier = (byte) aTier;
mDescriptionArray = aDescription == null ? new String[0] : aDescription;
mTextures = aTextures;
}
@Override
public byte getTileEntityBaseType() {
return (byte) (Math.min(3, mTier <= 0 ? 0 : 1 + ((mTier - 1) / 4)));
}
@Override
public long getInputTier() {
return mTier;
}
@Override
public long getOutputTier() {
return mTier;
}
@Override
public String[] getDescription() {
return mDescriptionArray;
}
/**
* Used Client Side to get a Texture Set for this Block. Called after setting the Tier and the Description so that
* those two are accessible.
*
* @param aTextures is the optional Array you can give to the Constructor.
*/
public abstract ITexture[][][] getTextureSet(ITexture[] aTextures);
protected SlotWidget createChargerSlot(int x, int y) {
final String batterySlotTooltipKey;
final Object[] batterySlotTooltipArgs;
final String pTier1 = GTUtility.getColoredTierNameFromTier(mTier);
if (mTier == GTValues.VN.length - 1) {
batterySlotTooltipKey = BATTERY_SLOT_TOOLTIP_ALT;
batterySlotTooltipArgs = new String[] { pTier1 };
} else {
batterySlotTooltipKey = BATTERY_SLOT_TOOLTIP;
batterySlotTooltipArgs = new String[] { pTier1, GTUtility.getColoredTierNameFromTier((byte) (mTier + 1)) };
}
return createChargerSlot(x, y, batterySlotTooltipKey, batterySlotTooltipArgs);
}
protected SlotWidget createChargerSlot(int x, int y, String tooltipKey, Object[] tooltipArgs) {
return (SlotWidget) new SlotWidget(inventoryHandler, rechargerSlotStartIndex()).disableShiftInsert()
.setGTTooltip(() -> mTooltipCache.getData(tooltipKey, tooltipArgs))
.setTooltipShowUpDelay(TOOLTIP_DELAY)
.setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_CHARGER)
.setPos(x, y);
}
}
|