aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java
blob: daffadecfe38708415241856942d4ab4c5ba5aa9 (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
package gregtech.api.metatileentity.implementations;

import static gregtech.api.enums.GT_Values.GT;
import gregtech.api.interfaces.ITexture;
import gregtech.api.metatileentity.MetaTileEntity;

public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntity {
	/**
	 * Value between [0 - 9] to describe the Tier of this Machine.
	 */
	public final byte mTier;
	
	/**
	 * A simple Description.
	 */
	public final String mDescription;
	
	/**
	 * Contains all Textures used by this Block.
	 */
	public final ITexture[][][] mTextures;
	
	public GT_MetaTileEntity_TieredMachineBlock(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, 9));
		mDescription = aDescription;
		
		// must always be the last call!
		if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null;
	}
	
	public GT_MetaTileEntity_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
		super(aName, aInvSlotCount);
		mTier = (byte)aTier;
		mDescription = 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 new String[] {mDescription};
	}
	
	/**
	 * 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);
}