Search in sources :

Example 1 with RedstoneChannels

use of mcjty.rftools.blocks.logic.wireless.RedstoneChannels in project RFTools by McJty.

the class ButtonScreenModule method mouseClick.

@Override
public void mouseClick(World world, int x, int y, boolean clicked, EntityPlayer player) {
    int xoffset;
    if (!line.isEmpty()) {
        xoffset = 80;
    } else {
        xoffset = 5;
    }
    if (x >= xoffset) {
        if (channel != -1) {
            if (toggle) {
                if (clicked) {
                    RedstoneChannels channels = RedstoneChannels.getChannels(world);
                    RedstoneChannels.RedstoneChannel ch = channels.getOrCreateChannel(channel);
                    ch.setValue((ch.getValue() == 0) ? 15 : 0);
                    channels.save(world);
                }
            } else {
                RedstoneChannels channels = RedstoneChannels.getChannels(world);
                RedstoneChannels.RedstoneChannel ch = channels.getOrCreateChannel(channel);
                ch.setValue(clicked ? 15 : 0);
                channels.save(world);
            }
        } else {
            if (player != null) {
                player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Module is not linked to redstone channel!"), false);
            }
        }
    }
}
Also used : RedstoneChannels(mcjty.rftools.blocks.logic.wireless.RedstoneChannels) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with RedstoneChannels

use of mcjty.rftools.blocks.logic.wireless.RedstoneChannels in project RFTools by McJty.

the class ButtonScreenModule method getData.

@Override
public IModuleDataBoolean getData(IScreenDataHelper helper, World worldObj, long millis) {
    if (channel != -1 && toggle) {
        RedstoneChannels channels = RedstoneChannels.getChannels(worldObj);
        RedstoneChannels.RedstoneChannel ch = channels.getOrCreateChannel(channel);
        return helper.createBoolean(ch.getValue() > 0);
    }
    return null;
}
Also used : RedstoneChannels(mcjty.rftools.blocks.logic.wireless.RedstoneChannels)

Example 3 with RedstoneChannels

use of mcjty.rftools.blocks.logic.wireless.RedstoneChannels in project RFTools by McJty.

the class RedstoneScreenModule method getData.

@Override
public IModuleDataInteger getData(IScreenDataHelper helper, World worldObj, long millis) {
    if (channel == -1) {
        // If we are monitoring some block then we can use that.
        if (!BlockPosTools.INVALID.equals(coordinate)) {
            World world = DimensionManager.getWorld(dim);
            if (world != null) {
                // int powerTo = world.isBlockProvidingPowerTo(coordinate.getX(), coordinate.getY(), coordinate.getZ(), side);
                int powerTo = world.getRedstonePower(coordinate.offset(side), side.getOpposite());
                return helper.createInteger(powerTo);
            }
        }
        return null;
    }
    RedstoneChannels channels = RedstoneChannels.getChannels();
    if (channels == null) {
        return null;
    }
    RedstoneChannels.RedstoneChannel ch = channels.getChannel(channel);
    if (ch == null) {
        return null;
    }
    return helper.createInteger(ch.getValue());
}
Also used : RedstoneChannels(mcjty.rftools.blocks.logic.wireless.RedstoneChannels) World(net.minecraft.world.World)

Aggregations

RedstoneChannels (mcjty.rftools.blocks.logic.wireless.RedstoneChannels)3 TextComponentString (net.minecraft.util.text.TextComponentString)1 World (net.minecraft.world.World)1