aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/covers/redstone/CoverAdvancedRedstoneReceiverInternal.java
blob: f22a81bdba5be172a35ea6aaaf5d9796ac20a3cb (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
package gregtech.common.covers.redstone;

import net.minecraftforge.common.util.ForgeDirection;

import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.IMachineProgress;

public class CoverAdvancedRedstoneReceiverInternal extends CoverAdvancedRedstoneReceiverBase {

    public CoverAdvancedRedstoneReceiverInternal(ITexture coverTexture) {
        super(coverTexture);
    }

    @Override
    public ReceiverData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID,
        ReceiverData aCoverVariable, ICoverable aTileEntity, long aTimer) {
        if (aTileEntity instanceof IMachineProgress machine) {
            if (getRedstoneInput(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity) > 0) {
                machine.enableWorking();
            } else {
                machine.disableWorking();
            }

            machine.setWorkDataValue(aInputRedstone);
        }

        return aCoverVariable;
    }

    @Override
    protected byte getRedstoneInputImpl(ForgeDirection side, byte aInputRedstone, int aCoverID,
        ReceiverData aCoverVariable, ICoverable aTileEntity) {
        return getSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), aCoverVariable.getGateMode());
    }

    @Override
    protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ReceiverData aCoverVariable,
        ICoverable aTileEntity, long aTimer) {
        return true;
    }
}