aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMetaTileEntity.java
blob: f8bea768dacc57183fb1d56341fc6806d45b18e0 (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
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base;

import static gregtech.api.enums.GTValues.GT;

import gregtech.api.interfaces.ITexture;
import gregtech.api.metatileentity.MetaTileEntity;

public abstract class GTPPMetaTileEntity extends MetaTileEntity {

    /**
     * Value between [0 - 9] to describe the Tier of this Machine.
     */
    protected byte mTier;

    /**
     * A simple Description.
     */
    protected final String mDescription;

    /**
     * Contains all Textures used by this Block.
     */
    public final ITexture[][][] mTextures;

    public GTPPMetaTileEntity(final int aID, final String aName, final String aNameRegional, final int aTier,
        final int aInvSlotCount, final String aDescription, final ITexture... aTextures) {
        super(aID, aName, aNameRegional, aInvSlotCount);
        this.mTier = (byte) Math.max(0, Math.min(aTier, 9));
        this.mDescription = aDescription;

        // must always be the last call!
        if (GT.isClientSide()) {
            this.mTextures = this.getTextureSet(aTextures);
        } else {
            this.mTextures = null;
        }
    }

    public GTPPMetaTileEntity(final String aName, final int aTier, final int aInvSlotCount, final String aDescription,
        final ITexture[][][] aTextures) {
        super(aName, aInvSlotCount);
        this.mTier = (byte) aTier;
        this.mDescription = aDescription;
        this.mTextures = aTextures;
    }

    @Override
    public byte getTileEntityBaseType() {
        return (byte) (Math.min(3, this.mTier <= 0 ? 0 : 1 + ((this.mTier - 1) / 4)));
    }

    @Override
    public long getInputTier() {
        return this.mTier;
    }

    @Override
    public long getOutputTier() {
        return this.mTier;
    }

    @Override
    public String[] getDescription() {
        return new String[] { this.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);
}