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;
}
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();
}
Aggregations