Search in sources :

Example 1 with IGateConnection

use of com.bluepowermod.api.gate.IGateConnection in project BluePower by Qmunity.

the class GateBase method onActivated.

// Interaction
@Override
public boolean onActivated(EntityPlayer player, QMovingObjectPosition mop, ItemStack item) {
    if (getLayout() == null && !getWorld().isRemote)
        loadLayout();
    if (item != null && item.getItem() instanceof IScrewdriver) {
        if (player.isSneaking()) {
            if (logic().changeMode()) {
                if (!getWorld().isRemote) {
                    ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
                    getRedstoneConnectionCache().recalculateConnections();
                    getBundledConnectionCache().recalculateConnections();
                    for (IGateConnection c : getConnections()) if (c != null)
                        c.notifyUpdate();
                    sendUpdateIfNeeded();
                }
                return true;
            }
            return false;
        } else {
            setRotation((getRotation() + 1) % 4);
            ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
            getRedstoneConnectionCache().recalculateConnections();
            getBundledConnectionCache().recalculateConnections();
            for (GateConnectionBase c : getConnections()) if (c != null)
                c.notifyUpdate();
            sendUpdateIfNeeded();
        }
        return true;
    } else if (hasGUI()) {
        if (getWorld().isRemote) {
            FMLCommonHandler.instance().showGuiScreen(getGui(player));
        } else {
            handleGUIServer(player);
        }
        return true;
    }
    return false;
}
Also used : IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) GateConnectionBase(com.bluepowermod.part.gate.connection.GateConnectionBase) IGateConnection(com.bluepowermod.api.gate.IGateConnection)

Aggregations

IGateConnection (com.bluepowermod.api.gate.IGateConnection)1 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)1 GateConnectionBase (com.bluepowermod.part.gate.connection.GateConnectionBase)1