LandOfRails / LandOfSignals

Minecraft railroad signal mod for Minecraft written by the LandOfRails Management.
https://discord.gg/ykAqHKYjVM
13 stars 1 forks source link

Make blocks transmit redstone signal from buttons and levers #157

Open Danielxs01 opened 7 months ago

Danielxs01 commented 7 months ago

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;
    }

}