Search in sources :

Example 6 with GateConnectionBase

use of com.bluepowermod.part.gate.connection.GateConnectionBase 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)

Example 7 with GateConnectionBase

use of com.bluepowermod.part.gate.connection.GateConnectionBase in project BluePower by Qmunity.

the class GateBase method onUpdate.

@Override
public void onUpdate() {
    if (getLayout() == null && !getWorld().isRemote)
        loadLayout();
    if (RedstoneApi.getInstance().shouldWiresHandleUpdates()) {
        getRedstoneConnectionCache().recalculateConnections();
        getBundledConnectionCache().recalculateConnections();
        for (GateConnectionBase c : getConnections()) if (c != null)
            c.refresh();
        for (GateConnectionBase c : getConnections()) if (c != null)
            if (getRedstoneConnectionCache().getConnectionOnSide(c.getForgeDirection()) != null)
                RedstoneApi.getInstance().getRedstonePropagator(this, c.getForgeDirection()).propagate();
    }
    logic().doLogic();
    sendUpdateIfNeeded();
}
Also used : GateConnectionBase(com.bluepowermod.part.gate.connection.GateConnectionBase)

Aggregations

GateConnectionBase (com.bluepowermod.part.gate.connection.GateConnectionBase)7 IGateComponent (com.bluepowermod.api.gate.IGateComponent)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IGateConnection (com.bluepowermod.api.gate.IGateConnection)1 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)1