Search in sources :

Example 6 with ISensorSetting

use of pneumaticCraft.api.universalSensor.ISensorSetting in project PneumaticCraft by MineMaarten.

the class TileEntityUniversalSensor method onEvent.

public void onEvent(Event event) {
    ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(sensorSetting);
    if (sensor != null && sensor instanceof IEventSensorSetting && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
        int newRedstoneStrength = ((IEventSensorSetting) sensor).emitRedstoneOnEvent(event, this, getRange(), sensorGuiText);
        if (newRedstoneStrength != 0)
            eventTimer = ((IEventSensorSetting) sensor).getRedstonePulseLength();
        if (invertedRedstone)
            newRedstoneStrength = 15 - newRedstoneStrength;
        if (eventTimer > 0 && ThirdPartyManager.computerCraftLoaded) {
            if (event instanceof PlayerInteractEvent) {
                PlayerInteractEvent e = (PlayerInteractEvent) event;
                notifyComputers(newRedstoneStrength, e.x, e.y, e.z);
            } else {
                notifyComputers(newRedstoneStrength);
            }
        }
        if (newRedstoneStrength != redstoneStrength) {
            redstoneStrength = newRedstoneStrength;
            updateNeighbours();
        }
    }
}
Also used : IEventSensorSetting(pneumaticCraft.api.universalSensor.IEventSensorSetting) ISensorSetting(pneumaticCraft.api.universalSensor.ISensorSetting) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent)

Aggregations

ISensorSetting (pneumaticCraft.api.universalSensor.ISensorSetting)6 ItemStack (net.minecraft.item.ItemStack)2 IEventSensorSetting (pneumaticCraft.api.universalSensor.IEventSensorSetting)2 IPollSensorSetting (pneumaticCraft.api.universalSensor.IPollSensorSetting)2 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ChunkPosition (net.minecraft.world.ChunkPosition)1 PlayerInteractEvent (net.minecraftforge.event.entity.player.PlayerInteractEvent)1 LuaConstant (pneumaticCraft.common.thirdparty.computercraft.LuaConstant)1 LuaMethod (pneumaticCraft.common.thirdparty.computercraft.LuaMethod)1