LandOfSignals (Railroad Signal Mod)

LandOfSignals (Railroad Signal Mod)

45.9k Downloads

Make blocks transmit redstone signal from buttons and levers

Danielxs01 opened this issue ยท 0 comments

commented

Make blocks transmit redstone signal

Current behaviour:
Currently blocks are unable to pass redstone.

Wanted behaviour:
Blocks pass redstone signal provided by buttons, levers or redstone wires.

Code example:

public class Tile??? extends BlockEntity implements IRedstoneProvider {
    
    @TagField
    private int redstonePass = 0;

    @Override
    public void onNeighborChange(Vec3i neighbor) {
        redstonePass = 0;
        int newRedstonePass = getWorld().getRedstone(getPos());
        if(this.redstonePass != newRedstonePass){
            this.redstonePass = newRedstonePass;
            getWorld().notifyNeighborsOfStateChange(getPos(), LOSBlocks.BLOCK_???, true);
        }
    }

    @Override
    public int getStrongPower(Facing from) {
        return redstonePass;
    }

    @Override
    public int getWeakPower(Facing from) {
        return redstonePass;
    }

}